FreeBSD Package Management
FreeBSD provides two complementary technologies for installing third-party software on your system:
Ports - for installing from source
Packages - for installing from pre-built binaries
Either method may be used to install the newest version of your favorite applications from local media or straight off the network.
Ports Setup
vi /etc/make.conf
or
make config-recursive
Upgrade Packages
Update Ports:
pkg_add -r csup
vi /usr/share/example/cvsup/ports-supfile (change CHANGE_THIS.FreeBSD.org to cvsup.tw.freebsd.org)
csup /usr/share/example/cvsup/ports-supfile
Upgrade Ports:
pkg_add -r portupgrade
portupgrade -ai
pkg_add -r freebsd-update
cp /usr/local/etc/freebsd-update.conf.sample /usr/local/etc/freebsd-update.conf
freebsd-update fetch
freebsd-update install
Install a Package
Package:
pkg_add -r xxx
pkg_add xxx.tgz
Ports:
cd /usr/ports/xxx/xxx
make
make install
make clean
Deleting a Package
pkg_delete xxx
delete all depends:
pkg_deinstall -R xxx (from portupgrade)
Query Packages and Files
Finding ports
cd /usr/ports
make search name=xxx
Lists and describes the installed packages:
pkg_info
installed file list:
cat /var/db/pkg/xxx/+CONTENTS
which package contains the installed file:
Way 1:
pkg_add -r portupgrade
pkg_which xxx
Way 2:
cd /var/db/pkg
grep xxx . -r
query depends:
make pretty-print-build-denpends-list
make pretty-print-run-depends-list
System Clean
clean up the temporary work directories:
portsclean -C
delete all the distfiles that are no longer referenced by any ports:
portsclean -D