FreeBSD 10.0とpkg時代の到来


長い間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
2.4.1.pkgngのインストール
方法1:
			
# /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>'.
			
			

方法2:
# portsnap fetch update
# cd /usr/ports/ports-mgmt/pkg
# make
# make install clean
			

方法3
# pkg_add -r pkg
			

2.4.2.データベースの変換
pkg 2 ngコマンドの実行
# pkg2ng
			

makeを設定します.confファイル
			
cat >> /etc/make.conf <<EOF

WITH_PKGNG=yes
EOF
			
			

2.4.3. install
パッケージのインストール
# pkg install curl
			

2.4.4. delete
パッケージの削除
# pkg delete curl
			

2.4.5. info
すべてのパッケージ情報を表示
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
			

2.4.6. query
# 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]
\ version[%v]
\ origin[%o]
\ prefix[%p]
\ maintainer[%m]
\ comment[%c]
\ www[%w]
\ licenselogic[%l]
\ flatsize[%sh]
\ flatsizebytes[%sb]
\ orphan[%a]
\ message[%M]
\ " libxml2 typescript package[libxml2] typescript version[2.7.8_5] typescript origin[textproc/libxml2] typescript prefix[/usr/local] typescript maintainer[[email protected]] 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.4.7. upgrade
# pkg upgrade

 
2.5.1. Shared object "libarchive.so.5"not found, required by "pkg"
問題はFreeBSD 9.2からFreeBSD 10.0にアップグレードされ、pkgのアップグレードで解決できます.
# pkg-static upgrade
			

2.5.2. pkg: PACKAGESITE in pkg.conf is deprecated. Please create a repository configuration file
次のファイルを編集
# 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