FreeBSD程序安装及管理

pkg_replace
常用参数:
-P 使用二进制安装包升级,二进制包自动从 PACKAGEROOT 环境变量定义的存储服务器中获取
-f 强制更新程序包(当有其他程序依赖于该程序包时,需要使用该参数,否则无法更新)
-F 下载更新包,不安装更新


全部参数:
-a       Do with all the installed packages.
-b       Keep backup packages of the old versions.  By default, the created backup package will be deleted after installation.
-B       Do not backup old packages.
-c       Do ``make clean'' before each build.
-C       Do ``make clean'' after each installation.  This is the default.
-f       Force to replace packages.
-F       Fetch distfiles or packages, do not replace.
-i       Turn on interactive mode. 
-l FILE  Save the results to FILE.  By default, pkg_replace does not save results.
-L PREFIX
        Save the logs in the files that begins with PREFIX.
-m ARGS  Specify arguments to append to each make(1) command.
-n       Do not actually replace any packages.
-N       Install new packages, do not replace.
-p       Do ``make package''.
-P       Use binary packages instead of installing from source.
        pkg_replace finds them from the directory specified by
        PKGREPOSITORY, and the remote site specified by PACKAGEROOT.
-q       Do not read the configuration file.
-r       In addition to the specified packages, replace all packages that
        depend on those packages as well.
-R       In addition to the specified packages, replace all packages that
        required by those packages as well.
-u       Do not preserve old shared libraries.  By default, pkg_replace preserves old shared libraries in PKGCOMPATDIR.
-v       Turn on verbose output.
-V       List the installed packages that need updating.
-w       Do not ``make clean'' before each build.  This is the default.
-W       Do not ``make clean'' after each installation.
-x GLOB  Do not replace packages matching the specified glob pattern.



ports 中的 make 有用的参数


常用参数
fetch 下载二进制安装包
fetch-recursive 下载安装包及所需的依赖包
fetch-required-list 列出需要的依赖包


package 编译并安装源代码,完成安装后将已经安装的该程序打包为二进制的安装包,放入$package 目录中(usr/ports/packages/ALL)
package-recursive 编译并安装源代码,完成安装后将已经安装的该程序及其依赖包全部打包为二进制的安装包,放入$package 目录中


reinstall 重新安装(忽略 "already installed" flag. )
run-depends-list 显示运行依赖包列表


make extract 只解开软件包
make patch 解开软件包并补上官方的patch
distclean 全部删除,包括/usr/ports/distfiles下的源码包
deinstall-depends 连同依赖一起删除


all-depends-list 显示所有相关的依赖
pretty-print-build-depends-list 显示编译期间所需要的依赖
pretty-print-run-depends-list 显示执行时需要的依赖


PREFIX=/usr/local/XXX 指定一个安装路径
fetchindex 下载 index /usr/ports


全部参数
fetch - Retrieves ${DISTFILES} (and ${PATCHFILES} if defined) into ${DISTDIR} as necessary. 
fetch-list - Show list of files that would be retrieved by fetch. 
fetch-recursive - Retrieves ${DISTFILES} (and ${PATCHFILES} if defined), for port and dependencies into ${DISTDIR} as necessary. 
fetch-recursive-list - Show list of files that would be retrieved by fetch-recursive. 
fetch-required-list - Show list of files that would be retrieved by fetch-required. 
fetch-required - Retrieves ${DISTFILES} (and ${PATCHFILES} if defined), for port and dependencies that are not already installed into ${DISTDIR}. 
all-depends-list - Show all directories which are dependencies for this port. 
build-depends-list - Show all directories which are build-dependencies for this port. 
package-depends-list - Show all directories which are package-dependencies for this port. 
run-depends-list - Show all directories which are run-dependencies for this port. extract - Unpacks ${DISTFILES} into ${WRKDIR}. 
patch - Apply any provided patches to the source. 
configure - Runs either GNU configure, one or more local configure scripts or nothing, depending on what's available. 
build - Actually compile the sources. 
install - Install the results of a build. 
reinstall - Install the results of a build, ignoring "already installed" flag. 
deinstall - Remove the installation. 
deinstall-all - Remove all installations with the same PKGORIGIN. package - Create a package from an _installed_ port.
package-recursive - Create a package for a port and _all_ of its dependancies. 
describe - Try to generate a one-line description for each port for use in INDEX files and the like. 
checkpatch - Do a "patch -C" instead of a "patch". Note that it may give incorrect results if multiple patches deal with the same file. 
checksum - Use distinfo to ensure that your distfiles are valid. 
checksum-recursive - Run checksum in this port and all dependencies. 
makesum - Generate distinfo (only do this for your own ports!). 
clean - Remove ${WRKDIR} and other temporary files used for building. 
clean-depends - Do a "make clean" for all dependencies. 
config - Configure options for this port (using ${DIALOG}). Automatically run prior to extract, patch, configure, build, install, and package. 
showconfig - Display options config for this port 
rmconfig - Remove the options config for this port






pkg_cutleaves 批量管理软件包
pkg_cutleaves -lc 生成所有的叶子结点
pkg_cutleaves -lxg 通过删除 /usr/local/etc/pkg_leaves.exclude中的对应的行来卸载我们不需要的叶子结点

/usr/local/etc/pkg_leaves.exclude 这个文件记录了所有叶子结点的文件名,不包含版本信息。
我们可以编辑修改这个文件,去掉我们不需要的叶子结点。接着,我们可以放心地清除我们不需要的build依存包,一个简单的命令就搞定: 

pkg_cutleaves -Rxg
系统会交互地询问我们是否删除某某某,保证文件/usr/local/etc/pkg_leaves.exclude所记录的就是软件依存图的所有叶子结点。
概括而言,pkg_cutleaves清除软件包安装过程中产生的冗余的包,为我们的系统瘦身。

其他管理工具
Package是一套将以经整理好的软体安装进FreeBSD的系统里的软体,主要下列功能∶


pkg_add 安装一个pkg套件 
pkg_create 创造一个pkg套件 
pkg_info 查询一个pkg套件资料 
pkg_update 升级一个pkg套件 
pkg_check 检查一个pkg套件的加密签章(cryptographic signature) 
pkg_delete 删除一个pkg套件 
pkg_sign 插入加密签章(cryptographic signature)至一个pkg套件 
pkg_version 创造一个pkg套件 


pkg_version -v -L= 查看系统中的安装包是否有可升级的新版本
portupgrade -arf 升级系统所有可升级的port安装包
portupgrade -P -f -o shells/bash bash 升级制定的安装包




pkg_info
pkg_info |grep zh-fcitx (查软件版本)
#ls /var/db/pkg也可以查软件版本
pkg_info -L zh-fcitx-3.4 (查看软件安装目录和安装的文件)
pkg_info -xL zh-fcitx (加x了不需要加软件版本号)
pkg_info -r zh-fcitx-3.4 (查看软件依赖情况)
pkg_info -W fcitx (查看fcitx属于哪个软件)



打包已安裝的軟體
不管是 packages 安裝的,或是用 ports 安裝的, FreeBSD 都會留安裝記錄到 /var/db/pkg 中, 利用裡面的資料檔即可將檔案包裝成 package 。


在 /var/db/pkg 的每個目錄中會有一些以加號+ 開頭大寫檔名的檔案 
+COMMENT package的簡訊 用參數 -c 
+CONTENTS package的內容:檔案清單,目錄架構... 用參數 -f 
+DESC package的說明 用參數 -d 
+INSTALL 安裝時需執行的命令(script) 用參數 -i 
+DEINSTALL 移除時需執行的命令(script) 用參數 -k 


例如:要包裝 zh-joe-2.8 ,我們可以執行
cd /var/db/pkg/zh-joe-2.8 
pkg_create -c +COMMENT -d +DESC -f +CONTENTS zh-joe-2.8 
pkg_create -c +COMMENT -d +DESC -f +CONTENTS /tmp/zh-joe-2.8 


最簡單的方式是利用 -b 的參數:(如果確認 packages 的名稱為 zj-joe-2.8)
pkg_create -b zh-joe-2.8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值