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			
目录
相关文章
|
8月前
|
Linux 编译器 vr&ar
Linux基础IO【软硬链接与动静态库】
Linux基础IO【软硬链接与动静态库】
77 1
|
7月前
|
Linux
dbus-cleanup-sockets`:Linux 中的 D-Bus 套接字清理工具
`dbus-cleanup-sockets` 是一个用于清理 Linux 中未正常关闭的 D-Bus 套接字文件的工具,旨在解决资源占用和潜在通信问题。通常在系统启动、关闭或检测到残留套接字时自动运行。用户可手动以 root 权限执行 `/usr/bin/dbus-cleanup-sockets` 进行清理。该工具对于处理系统崩溃或守护进程异常终止导致的残留文件十分有用。
|
7月前
|
XML Ubuntu Linux
探索Linux中的`busctl`命令:DBus的瑞士军刀
`busctl`是Linux下管理DBus消息总线的命令行工具,用于查看、监听和控制DBus服务。
|
8月前
|
安全 关系型数据库 Unix
OpenBSD 7.5现已正式发布
【4月更文挑战第8天】OpenBSD 7.5现已正式发布
120 3
|
存储 Linux 编译器
Linux基础IO【软硬链接和动静态库】
Linux软硬链接和动静态库,包括动软硬链接的原理和操作,动静态库的打包和使用等丰富内容,详细讲解,干货满满!
192 2
Linux基础IO【软硬链接和动静态库】
|
监控 NoSQL JavaScript
RTOS成功取代Linux成为天猫精灵OS的关键 -- AliOS Things 维测专题
# 背景 在2018年下半年,天猫精灵系统团队开始研发新一代方糖系列智能音箱,当时业内主流的音箱产品如百度小米等均采用Linux来做智能音箱,Linux系统优势无需多说——开源稳定,三方库完备,芯片厂商硬件支持完备,是快速研发进入市场的首选。但随着智能音箱大战的进一步升级,价格战愈演愈烈,成本就成为了智能音箱快速普及占领市场的关键因素之一,如何降低智能音箱BOM成本就成为了很重要
2678 0
RTOS成功取代Linux成为天猫精灵OS的关键 -- AliOS Things 维测专题
|
安全 Linux 数据安全/隐私保护
一、LINUX下blueZ的编程
  Linux下Bluez的编程实现 1、 蓝牙的各个协议栈的简介.........................................
2586 0
|
Unix 关系型数据库 Oracle

热门文章

最新文章