FreeBSD的两种软件包安装方式

1 概述

FreeBSD将许多系统工具捆绑作为基本系统的一部分。然而,可能还需要安装更多的第三方应用。FreeBSD提供了两种补充的技术,用来安装第三方软件:FreeBSD Ports套件(用于从源代码安装,二进制安装)以及packages(用以从预编译的二进制版本安装,类似于RPM或DEB)。这两种方法都可以用于从本地介质,或从网上直接安装。

2 软件安装预览

在UNIX系统,典型的第三方软件安装的步骤如下:

  1. 下载这个软件,软件的发行版可能是源代码格式,或是一个二进制包。
  2. 解开软件(其中代表性的是用 compress(1), gzip(1), 或 bzip2(1) 压缩过的tar包)。
  3. 阅读相关文档,了解如何安装。 (多半一个文件名是INSTALL或README, 或在doc/ 目录下的一些文档)
  4. 如果软件是以源代码形式发布的,那就需要编译它。可能需要编辑一个 Makefile文件, 或运行 configure脚本,和其他的一些工作。
  5. 测试和安装软件。

Packages和ports是互相依赖的。假设您想安装一个依赖于已经安装的特定库的应用程序。应用程序和那个库都已经应用于FreeBSD ports和packages。如果使用命令或ports系统来添加应用程序,两个都必须注意库是否被安装,如果没有,它会自动先安装库。

Package Benefits

  1. 一个压缩的package通常要比一个压缩的包含源代码的应用程序小得多。
  2. package不需要进行额外的编译。对于大型应用程序如Mozilla,KDE或GNOME来说这显得尤为重要,特别是在您的系统资源比较差的情况下。
  3. package不需要您知道如何在FreeBSD上编译软件的详细过程。

Ports Benefits

  1. package在编译时通常使用比较保守的选项,这是为了保证它们能够运行在大多数的系统上。通过从port安装,您可以细微调整编译选项来产生适合于处理器的代码。
  2. 一些软件包已经把与它们相关的能做和不能做的事情的选项都编译进去了。例如,Apache可能就配置了很多的选项。从port中安装时,您不一定要接受默认的选项,可以自己来设置。
  3. 在一些例子中,一个软件有不同的配置存在多个package。例如,Ghostscript存在ghostscript package和ghostscript-nox11 package两个配置package,这取决于您是否安装了X11服务器。这样的调整对package是可能的,但如果一个应用程序有超过一个或两个不同的编译时间选项时,就不行了。
  4. 一些软件的许可条件禁止采用二进制形式发行。它们必须带上源代码。
  5. 一些人不信任二进制发行形式。至少有了源代码,(理论上)可以亲自阅读它,寻找潜在的问题。
  6. 如果要自己对软件打补丁,就需要有源代码。
  7. 一些人喜欢整天围着源代码转,所以他们喜欢亲自阅读源代码,修改源代码等等。

2.1 一个package的安装

如果本地有安装包,可以直接安装,类似yum中的localinstall

root@FreeBSD:~ # ls
.cshrc			.k5login		.profile		.viminfo
.history		.login			.shrc			lsof-4.94.0,8.txz

root@FreeBSD:~ # pkg add lsof-4.94.0,8.txz 
Installing lsof-4.94.0,8...
Extracting lsof-4.94.0,8: 100%
=====
Message from lsof-4.94.0,8:

--
NOTE: Due to the way the FreeBSD build clusters make packages,
you may see a warning similar to the following:

lsof: WARNING: compiled for FreeBSD release 11.1-RELEASE-p6; this is 11.1-RELEASE-p4.

This is because the poudriere jails that build the packages don't have the  
corresponding kernel installed, so they don't know that the kernel version is different.

This warning can be ignored if you are using a system that is updated via freebsd-update
and are using pre-built packages.

root@FreeBSD:~ # pkg info lsof
lsof-4.94.0,8
Name           : lsof
Version        : 4.94.0,8
Installed on   : Thu Oct 14 20:19:09 2021 CST
Origin         : sysutils/lsof
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : sysutils
Licenses       : lsof
Maintainer     : [email protected]
WWW            : https://people.freebsd.org/~abe/
Comment        : Lists information about open files (similar to fstat(1))
Annotations    :
FreeBSD_version: 1300139
Flat size      : 235KiB
Description    :
Lsof (LiSt Open Files) lists information about files that are open by the
running processes.  An open file may be a regular file, a directory, a block
special file, a character special file, an executing text reference, a
library, a stream or a network file (Internet socket, NFS file or Unix domain
socket).

See also fstat(1) in the base system.

WWW: https://people.freebsd.org/~abe/

查找系统中软件包的位置

root@FreeBSD:~ # whereis lsof
lsof: /usr/local/sbin/lsof /usr/local/man/man8/lsof.8.gz

2.2 软件包管理

列出已安装的所有软件包列表和描述

root@FreeBSD:~ # pkg info
gettext-runtime-0.21           GNU gettext runtime libraries and programs
indexinfo-0.3.1                Utility to regenerate the GNU info page index
libffi-3.3_1                   Foreign Function Interface
mpdecimal-2.5.1                C/C++ arbitrary precision decimal floating point libraries
pkg-1.17.2                     Package manager
python38-3.8.12                Interpreted object-oriented programming language
readline-8.1.1                 Library for editing command lines as they are typed
tree-1.8.0                     Display a tree-view of directories with optional color or HTML output
vim-8.2.3458                   Improved version of the vi editor (console flavor)

统计安装包版本,并和仓库中的软件包做比较

root@FreeBSD:~ # pkg version
Updating FreeBSD repository catalogue...
Fetching meta.conf: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

-风中叮铃-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值