删除FreeBSD软件包中不需要的/未使用的依赖项

时间:2020-01-09 10:39:36  来源:igfitidea点击:

我使用pkg remove foo命令删除了一个软件包。
但是,它剩下30多个依赖项。
这些依赖关系是FreeBSD Unix系统上任何其他软件包都不需要的,只是占用了我的硬盘空间。
如何删除FreeBSD 11.x服务器中不需要的或未使用的依赖项?
您需要将autoremove选项传递给pkg命令以删除孤立包,这些孤立包是在依赖关系解析期间安装的,不再需要。
软件依赖性不过是软件依赖于另一种。
例如,bash包取决于Readline库。

GNU Readline库提供了一组供应用程序使用的功能,这些功能允许用户在执行命令时编辑命令行。
因此,在FreeBSD中添加bash shell时,也会安装GNU Readline。

该快速教程介绍了如何在FreeBSD系统上删除孤立的软件包。

语法使用pkg删除FreeBSD中未使用的依赖项

语法是

pkg autoremove
pkg -n autoremove
pkg -y autoremove

其中:

  • -n或--dry-run:空运行模式。软件包的更改列表始终会打印,但实际上不会进行更改。
  • -y:在自动删除软件包之前要求确认时,假定为是。
  • -q:不要显示太多信息,即在屏幕上强制输出。

在FreeBSD中删除未使用的依赖项的示例

执行以下命令:

# pkg autoremove

或者

$ sudo pkg autoremove

输出示例:

Password:
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 33 packages:
 
Installed packages to be REMOVED:
	curl-7.56.0
	libgit2-0.25.1_1
	py36-pygit2-0.25.1
	ca_root_nss-3.32.1
	python36-3.6.2_1
	py36-setuptools-36.2.2
	py36-pycparser-2.10
	py36-cffi-1.7.0
	py36-cryptography-2.0.3
	py36-openssl-17.3.0
	py36-urllib3-1.22
	py36-requests-2.18.1_1
	py36-idna-2.5
	py36-six-1.11.0
	py36-pyasn1-0.2.2
	py36-pysocks-1.6.7
	py36-chardet-3.0.4
	py36-certifi-2016.7.27.1
	py36-humanfriendly-4.4.1
	py36-coloredlogs-7.3
	py36-texttable-0.9.1
	py36-tqdm-4.18.0
	py36-verboselogs-1.6
	py36-pytest-runner-2.11.1
	py36-libzfs-1.0.20160814
	py36-click-6.7
	python3-3_3
	libffi-3.2.1_1
	libnghttp2-1.26.0
	libssh2-1.8.0,3
	uclcmd-0.1_2
	libucl-0.8.0
	readline-7.0.3
 
Number of packages to be removed: 33
 
The operation will free 134 MiB.
 
Proceed with deinstalling packages? [y/N]: y
[1/33] Deinstalling py36-requests-2.18.1_1...
[1/33] Deleting files for py36-requests-2.18.1_1: 100%
[2/33] Deinstalling py36-urllib3-1.22...
[2/33] Deleting files for py36-urllib3-1.22: 100%
[3/33] Deinstalling py36-openssl-17.3.0...
[3/33] Deleting files for py36-openssl-17.3.0: 100%
[4/33] Deinstalling py36-pygit2-0.25.1...
[4/33] Deleting files for py36-pygit2-0.25.1: 100%
[5/33] Deinstalling py36-cryptography-2.0.3...
[5/33] Deleting files for py36-cryptography-2.0.3: 100%
[6/33] Deinstalling py36-cffi-1.7.0...
[6/33] Deleting files for py36-cffi-1.7.0: 100%
[7/33] Deinstalling py36-coloredlogs-7.3...
[7/33] Deleting files for py36-coloredlogs-7.3: 100%
[8/33] Deinstalling py36-pycparser-2.10...
[8/33] Deleting files for py36-pycparser-2.10: 100%
[9/33] Deinstalling py36-idna-2.5...
[9/33] Deleting files for py36-idna-2.5: 100%
[10/33] Deinstalling py36-six-1.11.0...
[10/33] Deleting files for py36-six-1.11.0: 100%
[11/33] Deinstalling py36-pyasn1-0.2.2...
[11/33] Deleting files for py36-pyasn1-0.2.2: 100%
[12/33] Deinstalling py36-pysocks-1.6.7...
[12/33] Deleting files for py36-pysocks-1.6.7: 100%
[13/33] Deinstalling py36-chardet-3.0.4...
[13/33] Deleting files for py36-chardet-3.0.4: 100%
[14/33] Deinstalling py36-certifi-2016.7.27.1...
[14/33] Deleting files for py36-certifi-2016.7.27.1: 100%
[15/33] Deinstalling py36-humanfriendly-4.4.1...
[15/33] Deleting files for py36-humanfriendly-4.4.1: 100%
[16/33] Deinstalling py36-texttable-0.9.1...
[16/33] Deleting files for py36-texttable-0.9.1: 100%
[17/33] Deinstalling py36-tqdm-4.18.0...
[17/33] Deleting files for py36-tqdm-4.18.0: 100%
[18/33] Deinstalling py36-verboselogs-1.6...
[18/33] Deleting files for py36-verboselogs-1.6: 100%
[19/33] Deinstalling py36-pytest-runner-2.11.1...
[19/33] Deleting files for py36-pytest-runner-2.11.1: 100%
[20/33] Deinstalling py36-libzfs-1.0.20160814...
[20/33] Deleting files for py36-libzfs-1.0.20160814: 100%
[21/33] Deinstalling py36-click-6.7...
[21/33] Deleting files for py36-click-6.7: 100%
[22/33] Deinstalling libgit2-0.25.1_1...
[22/33] Deleting files for libgit2-0.25.1_1: 100%
[23/33] Deinstalling py36-setuptools-36.2.2...
[23/33] Deleting files for py36-setuptools-36.2.2: 100%
[24/33] Deinstalling python3-3_3...
[24/33] Deleting files for python3-3_3: 100%
[25/33] Deinstalling curl-7.56.0...
[25/33] Deleting files for curl-7.56.0: 100%
[26/33] Deinstalling python36-3.6.2_1...
[26/33] Deleting files for python36-3.6.2_1: 100%
[27/33] Deinstalling uclcmd-0.1_2...
[27/33] Deleting files for uclcmd-0.1_2: 100%
[28/33] Deinstalling ca_root_nss-3.32.1...
[28/33] Deleting files for ca_root_nss-3.32.1: 100%
[29/33] Deinstalling libffi-3.2.1_1...
[29/33] Deleting files for libffi-3.2.1_1: 100%
[30/33] Deinstalling libnghttp2-1.26.0...
[30/33] Deleting files for libnghttp2-1.26.0: 100%
[31/33] Deinstalling libssh2-1.8.0,3...
[31/33] Deleting files for libssh2-1.8.0,3: 100%
[32/33] Deinstalling libucl-0.8.0...
[32/33] Deleting files for libucl-0.8.0: 100%
[33/33] Deinstalling readline-7.0.3...
[33/33] Deleting files for readline-7.0.3: 100%

如何使用pkg命令删除FreeBSD中未使用的依赖项

在此示例中,我将删除名为py36-iocage-0.9.10的软件包:

# pkg remove py36-iocage-0.9.10

输出示例:

Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):
 
Installed packages to be REMOVED:
	py36-iocage-0.9.10
 
Number of packages to be removed: 1
 
Proceed with deinstalling packages? [y/N]: y
[1/1] Deinstalling py36-iocage-0.9.10...
[1/1] Deleting files for py36-iocage-0.9.10: 100%

接下来,我将通过执行以下pkg命令来删除孤立包:

# pkg autoremove -y

会话示例:

Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 22 packages:
 
Installed packages to be REMOVED:
	py36-cryptography-2.1.4
	py36-openssl-17.5.0_1
	py36-urllib3-1.22
	py36-requests-2.18.4
	py36-asn1crypto-0.22.0
	py36-certifi-2016.1.18
	py36-cffi-1.11.2
	py36-chardet-3.0.4
	py36-click-6.7
	py36-coloredlogs-9.0
	py36-dulwich-0.15.0
	py36-humanfriendly-4.9
	py36-idna-2.6
	py36-libzfs-1.0.20161215
	py36-pycparser-2.18
	py36-pysocks-1.6.8
	py36-pytest-runner-2.11.1
	py36-six-1.11.0
	py36-texttable-1.2.1
	py36-tqdm-4.19.6
	py36-setuptools-39.0.1
	python36-3.6.4
 
Number of packages to be removed: 22
 
The operation will free 126 MiB.
 
Proceed with deinstalling packages? [y/N]: y
[1/22] Deinstalling py36-requests-2.18.4...
[1/22] Deleting files for py36-requests-2.18.4: 100%
[2/22] Deinstalling py36-urllib3-1.22...
...
.....
..
[20/22] Deleting files for py36-tqdm-4.19.6: 100%
[21/22] Deinstalling py36-setuptools-39.0.1...
[21/22] Deleting files for py36-setuptools-39.0.1: 100%
[22/22] Deinstalling python36-3.6.4...
[22/22] Deleting files for python36-3.6.4: 100%

上面的命令将帮助您释放服务器上的磁盘空间。