Home

PKGBUILDs

PKGBUILDs are shell-script based metadata and build instructions used in Arch Linux and related distributions to create packages from sources. They allow maintainers to define how a program is fetched, built, and installed, producing a package that can be managed by a package manager such as pacman.

A PKGBUILD is a plain text file named PKGBUILD. It declares variables such as pkgname, pkgver, pkgrel,

The typical build process starts with makepkg reading the PKGBUILD and fetching sources listed in source, then

Usage typically involves running makepkg in the directory containing the PKGBUILD. Common options control dependency installation,

arch,
url,
license,
depends,
makedepends,
source,
and
sha256sums.
It
may
also
specify
optional
fields
like
provides,
conflicts,
replaces,
optdepends,
and
arrays
or
functions
such
as
prepare(),
build(),
check(),
and
package().
The
file
is
designed
to
be
executed
by
makepkg
to
perform
the
packaging
steps.
validating
their
checksums.
The
prepare()
function
can
apply
patches
or
modify
sources,
build()
compiles
the
software,
check()
runs
tests
if
provided,
and
package()
installs
the
built
artifacts
into
a
staging
directory
to
create
the
final
package
file,
usually
named
pkgname-pkgver-pkgrel-arch.pkg.tar.zst.
During
this
process,
metadata
is
written
to
.PKGINFO
or
the
package
database,
and
a
.SRCINFO
file
can
be
generated
for
version
control
and
repository
use.
signing,
and
cleaning,
and
may
include
-s,
-i,
or
-c.
PKGBUILDs
emphasize
reproducibility
and
security
through
explicit
sources
and
checksums,
and
they
are
central
to
Arch
Linux
packaging
workflows
and
community
distributions
that
adopt
the
Arch
Build
System.