MAKEPKG-TEMPLATE(1)

πŸ’– MAKEPKG-TEMPLATE πŸ’–

okay so bestie, this is makepkg-template from the Pacman Manual β€” it's a package build templating utility and honestly? it's giving "I have 47 nearly-identical PKGBUILDs and I refuse to suffer" energy. πŸŽ€


✨ NAME ✨

makepkg-template β€” package build templating utility 🫢


🌸 SYNOPSIS 🌸

makepkg-template [options]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so makepkg-template is a script that eases the work of maintaining multiple similar PKGBUILDs. no cap. it lets you move most of the code from the PKGBUILD into a template file, and it uses markers so it can update your existing PKGBUILDs in-place whenever the template changes. iconic behaviour fr fr. πŸ’…

Template files can contain any code that's allowed in a PKGBUILD. think of them like external files you'd pull in with . or source, except makepkg-template inlines them right into the PKGBUILD β€” so when you actually build the package, you are NOT depending on the template file at all. bestie, it's self-contained. periodt.

Markers are bash comments and they look like this:

# template start; key=value; key2=value2; ...

and

# template end;

The keys used rn are: name (mandatory, like you literally cannot skip it) and version. Template names are limited to alphanumerics, @, +, ., -, and _. Versions are limited to numbers and .. that's it, that's the whole vibe check. ✨

For initial creation there's a one-line short cut that does NOT need an end marker:

# template input; key=value;

Using this short-cut means makepkg-template will replace it with start + end markers and the template code on the first run. it does the work for you, as it should. πŸ‘‘

Template files should be stored in one directory, and filenames should be "$template_name-$version.template", with a symlink "$template_name.template" pointing to the most recent template. If the version is not set in the marker, makepkg-template will automatically use the target of "$template_name.template". Otherwise, the version you specified gets used. This makes it way easier to verify untrusted PKGBUILDs when the template itself is trusted β€” you verify the non-template code, then run a command similar to this:

diff -u <(makepkg-template -o -) PKGBUILD

Template files may <em>also</em> contain markers, which leads to nested templates in the resulting PKGBUILD. and if you use markers inside a template, pls pls pls set the version you used/tested with in the start/input marker, so other people can properly recreate from templates. do it for the girlies. 🫢


πŸ’… OPTIONS πŸ’…

  • -p, --input <build script> β€” read the package script build script instead of the default. πŸ“
  • -o, --output <build script> β€” write the updated file to build script instead of overwriting the input file. no accidental destruction, we love that for us.
  • -n, --newest β€” always use the newest available template file. newest is bestest, obviously. ✨
  • --template-dir <dir> β€” change the dir where we are looking for template files. this option may be given multiple times, in which case files found in the directory given last will take precedence. last one wins, main character energy. πŸ‘‘

🌈 EXAMPLE PKGBUILD 🌈

pkgname=perl-config-simple
pkgver=4.58
pkgrel=1
pkgdesc="simple configuration file class"
arch=('any')
license=('PerlArtistic' 'GPL')
depends=('perl')
source=("http://search.cpan.org/CPAN/authors/id/S/SH/SHERZODR/Config-Simple-${pkgver}.tar.gz")
sha256sums=('dd9995706f0f9384a15ccffe116c3b6e22f42ba2e58d8f24ed03c4a0e386edb4')
_distname="Config-Simple"

# template start; name=perl-module; version=1.0;
_distdir="${_distname}-${pkgver}"
url="https://metacpan.org/release/${_distname}"
options+=('!emptydirs')

build() {
        cd "$srcdir/$_distdir"
        perl Makefile.PL INSTALLDIRS=vendor
        make
}

check() {
        cd "$srcdir/$_distdir"
        make test
}

package() {
        cd "$srcdir/$_distdir"
        make DESTDIR="$pkgdir" install
}
# template end;

🧚 SEE ALSO 🧚

makepkg(8), PKGBUILD(5)

See the pacman website at https://archlinux.org/pacman/ for current information on pacman and its related tools. go look, it's cute. πŸ’œ


πŸ’€ BUGS πŸ’€

Bugs? you must be kidding; there are no bugs in this software. 😭

but if we happen to be wrong (πŸ™ˆ), please report them to the issue tracker at https://gitlab.archlinux.org/pacman/pacman/-/issues with specific information such as your command-line, the nature of the bug, and even the package database if it helps. give us the receipts bestie, we need the whole story. πŸ“


πŸ‘‘ AUTHORS πŸ‘‘

Current maintainers:

  • Allan McRae <allan@archlinux.org>
  • Andrew Gregory <andrew.gregory.8@gmail.com>
  • Morgan Adamiec <morganamilo@archlinux.org>

Past major contributors:

  • Judd Vinet <jvinet@zeroflux.org>
  • Aurelien Foret <aurelien@archlinux.org>
  • Aaron Griffin <aaron@archlinux.org>
  • Dan McGee <dan@archlinux.org>
  • Xavier Chantry <shiningxc@gmail.com>
  • Nagy Gabor <ngaba@bibl.u-szeged.hu>
  • Dave Reisner <dreisner@archlinux.org>
  • Eli Schwartz <eschwartz@archlinux.org>

For additional contributors, use git shortlog -s on the pacman.git repository. ✨


okay that's the whole page bestie, we ate and left no crumbs. πŸ’…

this was Pacman 7.1.0, dated 2026-10-15 β€” mwah, love u, go template ur PKGBUILDs πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from