Eclean
eclean 是一个清理仓库源文件和二进制包的工具。它是 app-portage/gentoolkit 包的一部分,并由 Portage-Tools 项目维护。
Also available on Gentoo is the eclean-kernel tool, available separately from the eclean tools installed with gentoolkit, in the app-admin/eclean-kernel package. eclean-kernel is used to automate the clean up of old Linux kernels.
安装
Emerge
安装 eclean:
root #
emerge --ask app-portage/gentoolkit
使用
默认情况下,源文件存储在 /usr/portage/distfiles 目录下, 二进制包存储在 /usr/portage/packages 目录下;可以通过修改 /etc/portage/make.conf 中的 DISTDIR 和 PKGDIR 变量更改对应的存储位置。如果不定期清理,这两个目录可能会悄然无声地变得非常巨大;这就是创建eclean的原因。
调用
使用 eclean --help 来查看全部的命令简介、参数列表和使用介绍:
user $
eclean --help
Usage: eclean [global-option] ... <action> [action-option] ... eclean-dist [global-option, distfiles-option] ... eclean-pkg [global-option, packages-option] ... eclean(-dist,-pkg) [--help, --version] Available global options: -C, --nocolor - turn off colors on output -d, --deep - only keep the minimum for a reinstallation -e, --exclude-file=<path> - path to the exclusion file -i, --interactive - ask confirmation before deletions -n, --package-names - protect all versions (when --deep -p, --pretend - only display what would be cleaned -q, --quiet - be as quiet as possible -t, --time-limit=<time> - don't delete files modified since <time> <time> is a duration: "1y" is "one year", "2w" is "two weeks", etc. Units are: y (years), m (months), w (weeks), d (days) and h (hours). -h, --help - display the help screen -V, --version - display version info Available actions: packages - clean outdated binary packages from PKGDIR distfiles - clean outdated packages sources files from DISTDIR Available options for the packages action: NONE :) Available options for the distfiles action: -f, --fetch-restricted - protect fetch-restricted files (when --deep) -s, --size-limit=<size> - don't delete distfiles bigger than <size> <size> is a size specification: "10M" is "ten megabytes", "200K" is "two hundreds kilobytes", etc. Units are: G, M, K and B. More detailed instruction can be found in `man eclean`
清理 源文件
通过 distfiles
参数清理源文件存放目录:
root #
eclean distfiles
或者使用更简短的命令:
root #
eclean-dist
清理二进制文件
使用下面的命令清理二进制包:
root #
eclean packages
或者使用更简短的命令:
root #
eclean-pkg
选项
默认情况下,当前存储库中的任何ebuild相对应的源文件和二进制包都不会被删除。这样,只要程序包仍在当前存储库树中,系统管理员就可以轻松地降级程序包或安装以前删除的程序包。
举个例子,比如包 foo-1.0 和 foo-1.1 都在存储库中。在从 foo-1.0 升级到 foo-1.1 之后,运行 elcean distfiles,两个版本的源文件依然被保留,因此如果 foo-1.1 出现问题,用户可以很方便的重新安装 foo-1.0,而不必重新下载。
另一个可能的情况是安装之前删除的包。假设系统安装了 foo 包(任一版本)。在(不经意地)删除了这个包并运行了 eclean disfiles 之后,foo 的源文件依然被保留,可以重新安装而无需再次下载。
对二进制包同样的例子也一样适用。
为节省更多磁盘空间,请添加--deep
选项:这将删除与某些当前安装的软件包(版本无关紧要)不对应的每个源文件或二进制软件包。请注意,这种方式当用户需要降级安装某个包或者重新安装之前删除的包的时候都必须重新下载。
一个替代方案是,同时使用 --deep
和 --package-names
选项:对于某些非当前安装的包(不管版本号是什么)的每个源文件或者二进制包都会被删除。这种方式当用户需重新安装之前删除的包的时候都必须重新下载,但是要降级安装某个包则不需要。
更多细节请参阅 eclean(1) man page:
user $
man 1 eclean
Troubleshooting
Cleaning leaves some distfiles
Problem: when trying to clean distfiles, some distfiles are not removed and the message "The following unavailable installed packages were found" is displayed. For example:
root #
eclean --deep distfiles
* Building file list for distfiles cleaning... * Your distfiles directory was already clean. The following unavailable installed packages were found sys-kernel/gentoo-sources-4.19.44 sys-kernel/gentoo-sources-4.19.45 sys-kernel/gentoo-sources-4.19.46
This situation occurs when a package's ebuild has been removed from the Gentoo ebuild repository and the package is currently installed on the system. Generally if the listed packages/distfiles are no longer needed; the reason they are not being removed is because they are listed in Portage's world file.
The solution is to to remove the packages from the world file, or remove the specific package atom(s) via:
root #
emerge --ask --depclean =sys-kernel/gentoo-sources-4.19.44
Then re-run eclean again in order to remove the distfiles.
另请参阅
- Gentoolkit — 一套简化Gentoo系统管理的工具
- 知识库:删除过时的 distfile
- DISTDIR — 定义了 Portage 将会把下载的源码存放到哪个路径