Skip to content

makechrootpkg 使用参考

tsuibin edited this page Jul 31, 2021 · 6 revisions

makechrootpkg 这个命令的作用就跟这个程序的名字一样直白,它可以创建一个干净的chroot环境用来打包,并且可以在需要时,向该chroot环境中安装需要的包,在下次需要打包新的文件时,默认情况是保留你上一次的打包环境, 当然你也可以在每次构建的时候清空chroot环境,创建一个新的环境来打包。它维护了一个干净的chroot环境,然后每次你打包的时候它都会克隆出一个新的打包环境。

可选参数:

Flags:
-h         This help
-c         Clean the chroot before building
-d <dir>   Bind directory into build chroot as read-write
-D <dir>   Bind directory into build chroot as read-only
-u         Update the working copy of the chroot before building
           This is useful for rebuilds without dirtying the pristine
           chroot
-r <dir>   The chroot dir to use
-I <pkg>   Install a package into the working copy of the chroot
-l <copy>  The directory to use as the working copy of the chroot
           Useful for maintaining multiple copies
           Default: tsuibin
-n         Run namcap on the package
-C         Run checkpkg on the package
-T         Build in a temporary directory
-U         Run makepkg as a specified user

PS:在单独使用这个命令时,目录中需要由PKGBUILD文件

举个例子 我们最常使用的参数如下:

sudo makechrootpkg -n -C -r /var/lib/archbuild/extra-x86_64 -I /var/cache/pacman/pkg/apr-util-1.6.1-8-x86_64.pkg.tar.zst

几个常用的参数

-n 是检查PKGBUILD这个文件是否是正常的,然后会检查打出来的软件包是否是正常的;
-C checkpkg 把当前打出来的包和仓库中的软件包进行比较,其中包括可执行文件的动态链接库 SONAME 是否一致
-r 指定chroot环境
-I 向chroot环境添加一个软件包
-l 当你需要在一台机器上同时打包多个软件的时候,指定-l参数可以从root目录克隆出一个新的副本,默认目录名称是你的用户名,你也可以指定目录名