MKPKG

build packages from source

Synopsis

mkpkg [ -d ] [ -i | -u ] [ -r path ] [ -F ] [ -n ] [ -w ] [ -g file ]
mkpkg -o { d | e | u }
mkpkg -c [ d ][ f ][ s ]
mkpkg -u { f | s | x | p }
mkpkg -x
mkpkg -t
mkpkg -p

Description

mkpkg reads a MAKEPKG(5) file from the current directory, downloads sources, verifies checksums and signatures, and produces a binary package archive. The build pipeline executes in this order:
shell() [pre]       setup wrappers (runs in port directory)
download            fetch sources to PKGMK_SOURCE_DIR
checksums           verify sha256sums or b2sums
signature           verify port signature
extract() or auto   unpack sources into $SRC
patch()             apply patches (runs in $SRC)
build()             compile and install to $PKG (runs in $SRC)
post_build()        post-build fixups (runs in $SRC)
strip               strip binaries (unless -n)
compress            gzip man pages
meta                write declarative metadata to package
footprint           generate and check .footprint
shell() [post]      cleanup wrappers (runs in port directory)
The shell() hook runs twice: the first definition runs before download, the second after packaging. Both run in the port directory (PKGMK_SOURCE_DIR) and source /etc/mkpkg.conf . The extract() and patch() hooks do

not

source mkpkg.conf since they don't need build flags. The build(), post_build(), and shell() hooks source mkpkg.conf for access to CC, CFLAGS, etc.

Options

Build

mkpkg
Build package. Sources must already exist in PKGMK_SOURCE_DIR.
mkpkg -d
Download sources, then build.
mkpkg -i
Build and install (calls pkg.add(8)).
mkpkg -u
Build and upgrade (calls pkg.add -u ).
mkpkg -r path
Build and install to an alternative root filesystem.

Download / Extract Only

mkpkg -od
Download sources without building.
mkpkg -oe
Extract sources without building.
mkpkg -ou
Check if the package is up to date.

Clean (composable)

mkpkg -c
Remove the built package archive.
mkpkg -cd
Remove package and downloaded sources.
mkpkg -cf
Remove package and .footprint.
mkpkg -cs
Remove package and .signature.
mkpkg -cdfs
Remove everything (package, sources, footprint, signature).

Update

mkpkg -uf
Regenerate the .footprint file.
mkpkg -us
Regenerate the .signature file.
mkpkg -ux
Update checksums in the MAKEPKG file.
mkpkg -up
Update or insert the signify() public key in the MAKEPKG file. Reads the public key matching the configured secret key and writes it into a signify() function block.

Generate / Verify

mkpkg -x
Print checksums to stdout.
mkpkg -t
Verify port signature.
mkpkg -p
Print the signify public key embedded in the MAKEPKG's signify() function.

Ignore (composable, build modifiers)

mkpkg -If
Ignore footprint mismatch.
mkpkg -IN
Ignore new files in footprint (treat additions as OK).
mkpkg -Is
Ignore missing or invalid signature.
mkpkg -Ic
Ignore checksum mismatch.

Modifiers

-F, --force
Force build even if the package is up to date.
-n, --no-strip
Do not strip binaries.
-w, --keep-work
Keep the work directory after build. On a subsequent -w run, the existing work/src is reused (resume) and only work/pkg is recreated.
-g file, --config file
Use an alternative configuration file instead of /etc/mkpkg.conf .

Environment

The following variables are exported to all hook functions:
$PKG
Package staging directory (work/pkg). Files installed here end up in the archive.
$SRC
Source directory (work/src). Build hooks start with cd $SRC .
$PKGMK_SOURCE_DIR
The port directory where MAKEPKG, patches, and downloaded source tarballs live. Equivalent to the directory mkpkg was invoked from.
$name
Package name from MAKEPKG.
$version
Package version from MAKEPKG.
$release
Package release from MAKEPKG.
Custom variables defined in MAKEPKG are also exported.

Files

__IBLOCK__MAKEPKG
Package build recipe. See MAKEPKG(5).
__IBLOCK__/etc/mkpkg.conf
Build configuration. See mkpkg.conf(5).
__IBLOCK__.footprint
Expected file list of the built package.
__IBLOCK__.signature
Signify signature for the port.
__IBLOCK__.nostrip
List of file patterns to exclude from stripping.

Exit Status

0
Success.
1-10
Various errors (general, pkgfile, directory, download, unpack, checksum, footprint, build, install, signature).

See Also

Pure LLVM musl libc Source-Based Independent