mkpkg

build packages from source

Synopsis

mkpkg [ dir ] [ -d ] [ -e ] [ -w ] [ -r path ] [ -n ] [ -g file ]
mkpkg [ dir ] -c [ dfs ]
mkpkg [ dir ] -u { x | f | s | p | any combination }
mkpkg [ dir ] -i [ fsc ]
mkpkg [ dir ] -o { d | e }
mkpkg [ dir ] { -x | -f | -p | -s }

Description

mkpkg reads a MAKEPKG(5) file from the current directory (or from

dir

if given), downloads sources, verifies checksums and signatures, and produces a binary package archive. The build pipeline:
shell() [pre]       setup wrappers (port directory)
download            fetch sources
checksums           verify sha256sums
signature           verify port signature
extract() or auto   unpack sources into $SRC
patch()             apply patches
build()             compile and install to $PKG
post_build()        post-build fixups
strip               strip binaries (unless -n)
compress            gzip man pages
meta                write declarative metadata
footprint           check .footprint; sign if clean
shell() [post]      cleanup wrappers (port directory)
The package is only signed if the footprint check passes cleanly.

Options

Build

mkpkg
Build package. Sources must already exist in PKGMK_SOURCE_DIR.
mkpkg -d
Download sources, then build.

Extract

mkpkg -e
Extract sources into the work directory and stop.

Show / Verify

mkpkg -c
Print SHA256 checksums for all source files to stdout.
mkpkg -f
Print the footprint of the built package archive to stdout.
mkpkg -p
Print the signify public key embedded in the MAKEPKG.
mkpkg -s
Verify the port signature.

Clean — -c [dfs]

mkpkg -c
Remove the built package archive and work directory.
mkpkg -cd
Also remove downloaded source files.
mkpkg -cf
Also remove the .footprint file.
mkpkg -cs
Also remove the .signature file.
Letters compose: -cdfs removes everything.

Update — -u [xfsp]

mkpkg -ux
Regenerate checksums and write them into the MAKEPKG file.
mkpkg -uf
Regenerate the .footprint file from the built package archive.
mkpkg -us
Regenerate the .signature file. If the package is up to date, skips the build and signs directly.
mkpkg -up
Insert or replace the signify() function block in the MAKEPKG with the current public key.
Letters compose: -uxfs updates checksums, footprint, and signature in one step.

Ignore — -i [fsc]

Specific checks are skipped; the build runs normally.
mkpkg -if
Ignore footprint mismatch.
mkpkg -is
Ignore missing or invalid signature.
mkpkg -ic
Ignore checksum mismatch.

Only — -o [de]

mkpkg -od
Download sources without building.
mkpkg -oe
Extract sources without building.

Modifiers

-r path
Build and install directly to an alternative root using addpkg(8).
-n
Do not strip binaries.
-w
Keep the work directory after build. On a subsequent -w run, the existing work/src is reused and only work/pkg is recreated.
-g file
Use an alternative configuration file instead of /etc/mkpkg.conf .

Environment

$PKG
Package staging directory ( work/pkg ). Files installed here end up in the archive.
$SRC
Source directory ( work/src ).
$PKGMK_SOURCE_DIR
Port directory where MAKEPKG, patches, and source archives live.
$name, $version, $release
Package metadata from MAKEPKG.

Files

MAKEPKG
Package build recipe. See MAKEPKG(5).
/etc/mkpkg.conf
Build configuration. See mkpkg.conf(5).
.footprint
Expected file list of the built package.
.signature
Signify signature for the port.
.nostrip
File patterns excluded from binary stripping.

Exit Status

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

Examples

mkpkg /usr/ports/core/zlib -d        # build from anywhere
mkpkg -od && mkpkg -is               # download then build
mkpkg -up && mkpkg -us               # sign a port
mkpkg -cdfs && mkpkg -d             # full clean rebuild

See Also

LLVM musl libc libressl Independent