Makepkg (简体中文)

From ArchWiki

Jump to: navigation, search


i18n
English
Italiano
Ελληνικά
简体中文
Русский

makepkg 用来把软件打包成Pacman能够使用的软件包. It uses a script-based build system which can download and validate source files, check dependencies, configure build time settings, build the package, install the package into a temporary root, make customizations, generate meta-info and package the whole thing up. As you can see makepkg has a lot of features, the basics of which are described below.

Contents

Setting Things Up

ABS - The Arch Build System Arch软件包构建系统

首先,确认已经安装了能够运行abs/makepkg的软件包:

pacman -Sy base-devel

输入 'Y'或者直接敲Enter.

运行abs,更新Arch已经建好的原始软件包的PKGBUILDs:

abs

这将在/var/abs中重构一个SVN目录树结构。默认情况下一些仓库是禁止的;修改 /etc/abs.conf,反注释掉不用的标志。

一般地, /var/abs 只有root用户有读写权限 (it's part of the 'filesystem' package) ,and most people and guides assume for you to build packages inside /var/abs/local, 通过添加群abs,使得能够读写/var/abs:

groupadd abs
gpasswd -a $USER abs
chown root:abs /var/abs/local
chmod 775 /var/abs/local

打包Makepkg

如果你想用在普通账户下可以用makepkg安装一些依赖(通过命令:makepkg -s,看下面) 你需要安装sudo 并且把你自己的账户添加到/etc/sudoers:

USER_NAME    ALL=(ALL)    NOPASSWD: /usr/bin/pacman

以后,使用pacman就不用再输入密码了. 更多信息可见Sudo wiki。

接下来,要确定最后软件包安装的位置,例如,可以把软件包安装在/home目录下的一个独立文件夹,这一步可以省略的,文件产生的位置将和你makepkg的地方一致。

创建目录:

mkdir /home/$USER/packages

Then modify the PKGDEST variable in /etc/makepkg.conf accordingly.

While you're at it, you could also have a look at the other values in makepkg.conf. For example, you could edit PACKAGER, or remove the ! from docs in the default OPTIONS array, in case you don't want the /usr/share/doc/<package> directory to be deleted by makepkg. See Makepkg.conf for more.

创建软件安装包

创建一个安装包,第一种方法是根据 "The Arch package making HOWTO"所说,新建立一个PKGBUILD文件,第二种方法是去网站上获取一份PKGBUILD,比如到AUR或者ABS (see above) 或者其他网站。(小心哦,要从值得信赖的个人和网站上下载,以防万一。)

假设在AUR上找到了想要的软件包(比如例子中的 "rufus", 一个基于Python 的BT客户端). 并且能够从这its AUR page获取到 PKGBUILD 以及相关需要的文件, 点击链接"Tarball" 。

cd /path/to/file
tar -zxf rufus.tar.gz
cd rufus

此时,将发现在这目录下面,有好几个文件,其中就有用来打包安装程序所需的PKGBUILD脚本。 创建安装程序包 (使用一般用户权限——root用户权限在makepkg中不保险,容易破坏系统完整):

makepkg

开始创建、下载、打包安装程序。如果依赖没有满足要求,makepkg 将会给出错误提示。 To build your package and install these dependencies, simply use the command:

makepkg -s

Note that these dependences will need to be in your configured repositories. Alternatively, you can manually download the packages first using pacman -Sy dep1 dep2 etc.

在满足了所有依赖之后,软件安装包将在makepkg的目录下生成,上述例子中所生成的安装包的名字为:rufus-0.7.0-1.pkg.tar.gz 。 要安装这个软件包,只需输入(此时需要root权限):

pacman -U rufus-0.7.0-1.pkg.tar.gz

通过 buildscripts 安装软件

Sometimes from 3rd party repos we get *.pkgbuild file only.In that case use :-

makepkg -p


恭喜,到这一步已经成功安装了软件包!

有用的链接

Personal tools