makepkg
From ArchWiki
Dansk – Deutsch – English – Español – Français – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Polski – Português – Română – Slovenský – Suomi – Svenska – Türkçe – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어
| Summary |
|---|
| An overview of Arch Linux's package build utility. |
| Related |
| Arch Build System |
| Arch User Repository |
| Creating Packages |
| makepkg.conf |
| pacman |
| PKGBUILD |
| Resources |
| AUR |
| makepkg(8) Manual Page |
makepkg is used for compiling and building packages suitable for installation with pacman, Arch Linux's package manager. makepkg is a script that automates the building of packages; it can download and validate source files, check dependencies, configure build-time settings, compile the sources, install into a temporary root, make customizations, generate meta-info, and package everything together.
makepkg is provided by the pacman package.
Configuration
/etc/makepkg.conf is the main configuration file for makepkg. Most users will wish to fine-tune makepkg configuration options prior to building any packages. (For example, modifying the MAKEFLAGS variable on SMP systems for a reduction in compile times, or modifying the PACKAGER variable to personalize packages.) See makepkg.conf for detailed information.
To be able to install dependencies with makepkg as an unprivileged user (with makepkg -s, see below) install sudo and add desired users to /etc/sudoers:
USER_NAME ALL=(ALL) NOPASSWD: /usr/bin/pacman
The above will negate the need to enter a password with pacman. See the sudo wiki article for detailed information.
Next, one can configure where finished packages should be placed. This step is optional; packages will be created in the working directory where makepkg is run by default.
Create the directory:
$ mkdir /home/$USER/packages
Then modify the PKGDEST variable in /etc/makepkg.conf accordingly.
fakeroot
fakeroot simply allows a normal user the necessary root permissions to create packages in the build environment without being able to alter the wider system. If the build process attempts to alter files outside of the build environment then errors are produced and the build fails -- this is very useful for checking the quality/safety/integrity of PKGBUILDs for distribution. By default, fakeroot is enabled in /etc/makepkg.conf; users can prefix the option with a ! in the BUILDENV array to disable it.
Usage
Before continuing, ensure the "base-devel" group is installed. Packages belonging to this group are not required to be listed as dependencies in PKGBUILD files. Install the "base-devel" group by issuing (as root):
# pacman -S base-devel
To build a package, one must first create a PKGBUILD, or build script, as described in Creating Packages, or obtain one from the ABS tree, Arch User Repository, or some other source.
Once in possession of a PKGBUILD, change to the directory where it is saved and issue the following command to build the package described by said PKGBUILD:
$ makepkg
If required dependencies are missing, makepkg will issue a warning before failing. To build the package and install needed dependencies automatically, simply use the command:
$ makepkg -s
Note that these dependencies must be available in the configured repositories; see pacman#Repositories for details. Alternatively, one can manually install dependencies prior to building (pacman -S dep1 dep2).
Once all dependencies are satisfied and the package builds successfully, a package file (pkgname-pkgver.pkg.tar.gz) will be created in the working directory. To install, run (as root):
# pacman -U pkgname-pkgver.pkg.tar.gz