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

方法一:

			
# /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
			

2.4.2. 转换数据库

运行 pkg2ng 命令

# 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]\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.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			
目录
相关文章
|
1月前
|
数据建模 Linux C++
linux交叉编译live555
linux交叉编译live555
32 1
|
1天前
|
Ubuntu Linux 开发工具
WSL2(3)安装Linux headers完美解决方案
WSL2(3)安装Linux headers完美解决方案
3 0
|
Linux
Linux ldd时某个依赖库so not found的一种特殊情形
Linux ldd时某个依赖库so not found的一种特殊情形
590 0
|
Ubuntu Linux 编译器
iperf-2.0.9 在 Linux下的编译 与 海思(arm)平台的交叉编译
iperf-2.0.9 在 Linux下的编译 与 海思(arm)平台的交叉编译
444 0
iperf-2.0.9 在 Linux下的编译 与 海思(arm)平台的交叉编译
|
Ubuntu 编译器 Linux
linux(arm、hi3531A)交叉编译live555最新代码
linux(arm、hi3531A)交叉编译live555最新代码
247 0
linux(arm、hi3531A)交叉编译live555最新代码
|
Ubuntu Linux
Linux Command apt 软件包管理
Linux Command apt 软件包管理
|
安全 Linux
Linux下find与exec的联手干大事
Linux下find与exec的联手干大事
141 0
Linux下find与exec的联手干大事
|
Java Shell Linux
centos7环境下的erlang otp的编译(★firecat推荐★)
centos7环境下的erlang otp的编译(★firecat推荐★)
200 0
|
存储 弹性计算 运维
ubuntu touch: deepin pc os和deepin mobile os的天然融合
本文关键字:ubuntu touch as deepin mate os,second pc os
391 0
ubuntu touch: deepin pc os和deepin mobile os的天然融合
|
Ubuntu
Ubantu apt source 国内
位置 /etc/apt/sources.list apt-get update   deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse deb http://mirrors.
1209 0