长久以来FreeBSD的包管理非常落后。pkg 解决这个问题,可以想linux 里面的yum / apt-get 一样安装软件了。
2.4. PKGNG - Pkgng is the Next Generation package management tool for FreeBSD.
https://mebsd.com/make-build-your-freebsd-word/pkgng-first-look-at-freebsds-new-package-manager.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pkgng-intro.html
https://wiki.freebsd.org/pkgng
方法一:
# /usr/sbin/pkg The package management tool is not yet installed on your system. Do you want to fetch and install it now? [y/N]: y Bootstrapping pkg please wait Installing pkg-1.0.11... done If you are upgrading from the old package format, first run: # pkg2ng usage: pkg [-v] [-d] [-j <jail name or id>|-c <chroot path>] <command> [<args>] Global options supported: -d Increment debug level -j Execute pkg(1) inside a jail(8) -c Execute pkg(1) inside a chroot(8) -v Display pkg(1) version Commands supported: add Registers a package and installs it on the system audit Reports vulnerable packages autoremove Removes orphan packages backup Backs-up and restores the local package database check Checks for missing dependencies and database consistency clean Cleans old packages from the cache create Creates software package distributions delete Deletes packages from the database and the system fetch Fetches packages from a remote repository help Displays help information info Displays information about installed packages install Installs packages from remote package repositories query Queries information about installed packages register Registers a package into the local database remove Deletes packages from the database and the system repo Creates a package repository catalogue rquery Queries information in repository catalogues search Performs a search of package repository catalogues set Modifies information about packages in the local database shell Opens a debug shell shlib Displays which packages link against a specific shared library stats Displays package database statistics update Updates package repository catalogues updating Displays UPDATING information for a package upgrade Performs upgrades of packaged software distributions version Displays the versions of installed packages which Displays which package installed a specific file For more information on the different commands see 'pkg help <command>'.
方法二:
# portsnap fetch update # cd /usr/ports/ports-mgmt/pkg # make # make install clean
方法三
# pkg_add -r pkg
显示所有包信息
pkg info
显示包之间的依赖关系
# pkg info -d subversion subversion-1.7.7 depends on: expat-2.0.1_2 pkgconf-0.8.9 sqlite3-3.7.14.1 gdbm-1.9.1 db42-4.2.52_5 libiconv-1.14 gettext-0.18.1.1
显示包中的文件
# pkg info -l subversion subversion-1.7.7 owns the following files: /usr/local/bin/svn /usr/local/bin/svnadmin /usr/local/bin/svndumpfilter /usr/local/bin/svnlook /usr/local/bin/svnrdump /usr/local/bin/svnserve /usr/local/bin/svnsync /usr/local/bin/svnversion /usr/local/etc/rc.d/svnserve
# pkg query "Package name = %n, Version = %v, Size = %sh" libxml2 Package name = libxml2, Version = 2.7.8_5, Size = 4 MB # pkg query -a "Package name = %n, Version = %v, Size = %sh"
# pkg query "\ package[%n]\n\ version[%v]\n\ origin[%o]\n\ prefix[%p]\n\ maintainer[%m]\n\ comment[%c]\n\ www[%w]\n\ licenselogic[%l]\n\ flatsize[%sh]\n\ flatsizebytes[%sb]\n\ orphan[%a]\n\ message[%M]\n\ " libxml2 typescript package[libxml2] typescript version[2.7.8_5] typescript origin[textproc/libxml2] typescript prefix[/usr/local] typescript maintainer[gnome@FreeBSD.org] typescript comment[XML parser library for GNOME] typescript www[http://xmlsoft.org/] typescript licenselogic[single] typescript flatsize[4 MB] typescript flatsizebytes[4258960] typescript orphan[0] typescript message[]
2.5.1. Shared object "libarchive.so.5" not found, required by "pkg"
问题出现在从FreeBSD 9.2 升级到 FreeBSD 10.0,升级pkg可以解决
# pkg-static upgrade
编辑下面的文件
# cat /usr/local/etc/pkg.conf [0] #packagesite: http://pkg.FreeBSD.org/freebsd:9:x86:64/latest PACKAGESITE : http://pkg.freebsd.org/${ABI}/latest
到 http://pkg.freebsd.org/ 查找适合你版本的URL
# cat /usr/local/etc/pkg.conf [0] #packagesite: http://pkg.FreeBSD.org/freebsd:9:x86:64/latest #PACKAGESITE : http://pkg.freebsd.org/${ABI}/latest PACKAGESITE : http://pkg.freebsd.org/freebsd:10:x86:64/latest
更新pkg
pkg update