pkg命令的安装
因为freebsd承认pkg, 如果没有, 它会自动安装。
root@VM-0-8-freebsd:/usr/ports # pkg info 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 from pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly, please wait... Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done Installing pkg-1.16.3... Newer FreeBSD version for package pkg: To ignore this error set IGNORE_OSVERSION=yes - package: 1104001 - running kernel: 1101001 Ignore the mismatch and continue? [y/N]: y Extracting pkg-1.16.3: 100% pkg-1.16.3 Package manager
获取ports collection
在您能使用 ports 之前, 您必须先获得 Ports Collection ── 本质上是 /usr/ports 目录下的一堆 Makefile、 补丁和描述文件。
root@VM-0-8-freebsd:/usr/ports # portsnap fetch Looking up portsnap.FreeBSD.org mirrors... 4 mirrors found. Fetching public key from ipv4.aws.portsnap.freebsd.org... failed. Fetching public key from ipv6.aws.portsnap.freebsd.org... failed. Fetching public key from your-org.portsnap.freebsd.org... done. Fetching snapshot tag from your-org.portsnap.freebsd.org... done. Fetching snapshot metadata... done. Fetching snapshot generated at Thu Apr 15 08:05:15 CST 2021: ef60c5b1017261ca97ddf43ff0bfef88e1af52d75ce8b3100% of 88 MB 2147 kBps 00m11s Extracting snapshot... done. Verifying snapshot integrity... done. Fetching snapshot tag from your-org.portsnap.freebsd.org... done. Latest snapshot on server matches what we already have. No updates needed.
首次使用port,需要解压下载的snapshot文件
root@VM-0-8-freebsd:/ # portsnap extract
每次安装软件前,更新一遍
root@VM-0-8-freebsd:/usr/ports # portsnap update
ports安装软件
范例:安装lsof
进入ports目录
root@VM-0-8-freebsd:~ # cd /usr/ports/
检索lsof port 路径
root@VM-0-8-freebsd:/usr/ports # make search name=lsof Port: p5-Net-Connection-lsof-0.2.0 Path: /usr/ports/net/p5-Net-Connection-lsof Info: Creates Net::Connection objects using lsof Maint: vvelox@vvelox.net B-deps: p5-Digest-HMAC-1.03_1 p5-Net-Connection-0.2.0 p5-Net-DNS-1.29,1 p5-Proc-ProcessTable-0.59 perl5-5.32.1_1 R-deps: p5-Digest-HMAC-1.03_1 p5-Net-Connection-0.2.0 p5-Net-DNS-1.29,1 p5-Proc-ProcessTable-0.59 perl5-5.32.1_1 WWW: Port: lsof-4.94.0,8 Path: /usr/ports/sysutils/lsof Info: Lists information about open files (similar to fstat(1)) Maint: ler@FreeBSD.org B-deps: R-deps: WWW: Port: p5-Unix-Lsof-0.1.0 Path: /usr/ports/sysutils/p5-Unix-Lsof Info: Perl wrapper for Unix lsof(8) utility Maint: gjvc@gjvc.com B-deps: p5-IPC-Run3-0.048_1 perl5-5.32.1_1 R-deps: p5-IPC-Run3-0.048_1 perl5-5.32.1_1 WWW: https://metacpan.org/release/Unix-Lsof
安装lsof
root@VM-0-8-freebsd:/usr/ports # cd /usr/ports/sysutils/lsof/ root@VM-0-8-freebsd:/usr/ports/sysutils/lsof # ls Makefile distinfo files pkg-descr pkg-message pkg-plist root@VM-0-8-freebsd:/usr/ports/sysutils/lsof # make install clean
pkg安装软件包
pkg类似于Redhat/CentOS的yum,配置文件/etc/pkg/FreeBSD.conf
pkg 帮助命令 pkg help
更新pkg内置仓库
pkg update
root@VM-0-8-freebsd:~ # pkg update Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date.
检索包 pkg search
root@VM-0-8-freebsd:~ # pkg search gcc
安装包 pkg install
root@VM-0-8-freebsd:~ # pkg install gcc Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. Updating database digests format: 100% The following 6 package(s) will be affected (of 0 checked): New packages to be INSTALLED: binutils: 2.33.1_4,1 gcc: 10_4 gcc10: 10.2.0_1 gmp: 6.2.1 mpc: 1.2.0 mpfr: 4.1.0 Number of packages to be installed: 6 The process will require 419 MiB more space. 73 MiB to be downloaded. Proceed with this action? [y/N]: