= Arch Linux Packaging = <> ---- == Distributed Design == The Arch Linux project encourages and empowers users to create their own software packages. * The package manager [[Linux/Arch/Pacman|pacman]] is designed to mix and match official binary packages with unofficial, locally compiled packages. * Packages are never split between software and development headers. * Build options and flags are coordinated through system configuration packages. * Tools for isolated build processes are well tested and documented. The Arch Linux project also supports code for running public and private mirrors of the official binary packages. ---- == PKGBUILD == A '''`PKGBUILD`''' is a shell script to build a software package installable by `pacman(8)`. The shell script is called by the `makepkg(8)` utility. A `PKGBUILD`... * mandatorily defines the `pkgname`, `pkgver`, `pkgrel`, and `arch` variables * defines dependencies as an array variable, wherein each element is a package name with versioning constraints * try: `depends=('foobar>=1.8.0' 'foobar<2.0.0')` * defines well-known functions that will be called by `makepkg(8)` * `prepare` applies patches to the source code * `build` calls the build pipeline, including any configuration steps * `check` calls the test suite * `package` creates the package It's also possible to specify build-time dependencies with the `makedepends` variable (same format as `depends`), test suite dependencies with the `checkdepends` variables (again, same format), and optional (feature gate) dependencies with the `optdepends` variable (try: `optdepends=('cups: printing support')`). If a package provides software that may be depended upon by other packages, set the `provides` array variable accordingly. Try: `provides=('foobar=1.2.3')`. ---- == makepkg == The '''`makepkg(8)`''' utility uses `PKGBUILD` scripts to build a package. To build a package, try: {{{ makepkg }}} To install all of a package's dependencies, built it, and install it, try: {{{ makepkg --syncdeps --install }}} To build a source code only package ''(a tarball that does not include sources that can be fetched via a download URL)'', try: {{{ makepkg -S }}} `makepkg(8)` is configured with `makepkg.conf(5)` and through environment variables. In particular, these variables are often configured: ||'''Variable'''||'''Default'''||'''Suggested Value'''||'''Meaning''' || ||`PKGDEST` ||`.` ||`$HOME/packages` ||built package base directory || ||`SRCDEST` ||`.` ||`$HOME/sources` ||package source code base directory || ||`SRCPKGDEST` ||`.` ||`$HOME/srcpackages` ||source code only package base directory|| ||`LOGDEST` ||`.` ||`$HOME/makepkglogs` ||build logs base directory || ||`PACKAGER` ||`` || ||packager name and contact info || ||`GPGKEY` ||`` || ||packager GPG key || ---- == makechrootpkg == The '''`makechrootpkg(8)`''' utility builds packages in a clean chroot. The chroot must first be setup like: {{{ mkdir ~/chroot export CHROOT=$HOME/chroot mkarchroot $CHROOT/root base-devel }}} To keep the chroot up-to-date, run: {{{ arch-nspawn $CHROOT/root pacman -Syu }}} Lastly, build packages with: {{{ makechrootpkg -c -r $CHROOT }}} ---- == Arch User Repository == The '''AUR''' ('''Arch User Repository''') is a public git repository of user-created and user-maintained `PKGBUILD` scripts. The AUR is chiefly a way to coordinate the distribution of non-free and closed source applications on Arch Linux. Because a `PKGBUILD` script ''itself'' does not contain copyrighted material, they can be distributed freely and developed as open source code. While these `PKGBUILD` scripts can be cloned and used directly, there are a number of 'AUR helpers' that automate this process. See [[Linux/Arch/Pacaur|pacaur]], [[Linux/Arch/Paru|paru]], [[Linux/Arch/Pikaur|pikaur]], [[Linux/Arch/Trizen|trizen]], [[Linux/Arch/Yaourt|yaourt]], and [[Linux/Arch/Yay|yay]]. ---- CategoryRicottone