| MKPKG(8) | System Manager's Manual | MKPKG(8) |
mkpkg — build
packages from source
mkpkg |
[dir] [-bdw]
[-i[bcfs]]
[-g file]
[-r root] |
mkpkg |
[dir] -c |
-e | -f |
-p | -s |
mkpkg |
[dir]
-od |
-oe |
mkpkg |
[dir]
-u[cfsp]
[-i[bcfs]] |
mkpkg |
[dir]
-x[dfsw] |
mkpkg |
-h | -v |
mkpkg reads a
MAKEPKG(5) recipe from the current
directory, or from dir if given, and builds a binary
package from it. The package is written as
name#version-release.pkg.tar.ext
into the package directory, where ext follows
MKPKG_COMPRESSION_MODE in
mkpkg.conf(5).
If MAKEPKG.lock exists, it is built instead of MAKEPKG; see LOCKED PORTS.
A build runs these steps, in order:
-is.-d is given, in
which case they are fetched with wget(1).-ic.-x.shell()
hook. If it fails, the second shell() hook runs to
clean up and nothing is built.extract()
or unpack the sources automatically, then
patch().build() and
post_build().shell() hook. If the build failed
at an earlier step, it runs right then, so the first hook's setup is
always undone.-r, install the package with
addpkg(8).The hooks are described in MAKEPKG(5).
Options are single letters and may be combined in one argument, as
in -dw. The letters x,
u, i and
o start a group: every letter after them in the same
argument belongs to that group, so -xdf removes
downloads and the footprint, and -ic ignores
checksums.
The options are as follows:
-blockbox=(yes); see
lockbox(7).-c-d-e-oe.-f-g
fileMKPKG_* settings and in the hooks that source it.
A relative file is taken relative to the directory
mkpkg is started in.-h,
--help-i[bcfs]-od-oe-psignify()
block.-r
root-u; if the same version is installed,
addpkg(8) refuses.-s-u[cfsp]p, c, then with
s the build if one is needed,
f, and signing last, so the signature covers what
the others wrote.
cfs-d is given, and
the sha256sums are verified unless
-ic is given. The package is built if it is
not up to date. Signing is refused if the footprint does not match,
unless f or -if is
also given, and fails if there is no secret key.psignify() block with the public key
belonging to the secret key into the recipe, replacing any existing
one. The public key is looked for next to the secret key, with
.sec replaced by .pub,
then in /etc/ports/keys/.-v,
--version-w-ww resumes: the existing work directory is used
as it is,
extract()
and
patch()
are skipped and
build()
runs again. Neither work/src nor
work/pkg is cleaned first. Resuming needs the work
directory of an earlier -w run, so it does not
work with a tmpfs MKPKG_WORK_DIR, which is created
per process.-x[dfsw]When several modes are given, only the first of these runs:
-x, -f,
-c, -p,
-s, -od,
-e, -u, build.
The footprint is the sorted list of files in the package, with mode, owner and group, and the target of each symbolic link. On the first build, when there is no .footprint, it is created.
On later builds a mismatch is printed as “changed”,
“missing” and “new” entries. The package is kept
and mkpkg exits 0, so a long build is never lost to
a footprint change; the package is just not signed. Review the list, then
accept it with -uf and sign with
-us.
addpkg(8) refuses to install a
package whose footprint does not match.
Before every build, and with -s,
mkpkg verifies the port in three steps and fails on
any of them:
signify()
block must equal the key of a .pub file in
/etc/ports/keys/. That trusted file is used for
the next step, never the key from the recipe: the recipe and its
.signature arrive by the same way, so a key
carried in the recipe can only vouch for itself.MAKEPKG line of that list must match the
recipe on disk, and the .footprint line, when
present, the footprint on disk. Sources are covered by the recipe's
sha256sums.After a build whose footprint check passed, the
port is signed if the recipe has a
signify()
block and a secret key is found: MKPKG_SECRET_KEY
from the configuration file or the environment, else
/etc/ports/keys/rawnix.sec. Without a key, signing
is skipped silently. After signing, mkpkg verifies
the new signature and warns if it can never pass.
The list names the recipe MAKEPKG and the
footprint .footprint whichever files were hashed;
see LOCKED PORTS.
When MAKEPKG.lock exists in the port
directory, mkpkg builds it instead of
MAKEPKG, and uses
.footprint.lock and
.signature.lock in place of
.footprint and .signature
for every check, update and signature.
ports(8) does not sync
*.lock, so upstream updates never touch a locked
port's recipe, footprint or signature. The lock files are created by
pkg lock.
A fresh lock carries upstream's signature, which still verifies
the unedited recipe. After editing MAKEPKG.lock,
sign it again with -us. To sign with your own key,
run -up with
MKPKG_SECRET_KEY pointing at it, then
-us, and install the matching
.pub into
/etc/ports/keys/.
mkpkg exports to every hook:
PKGSRCPKGMK_SOURCE_DIRMKPKG_SOURCE_DIR if set, otherwise the port
directory.name,
version, releaseWith per-command lockbox, build() also
gets MKPKG_WORK_DIR,
MKPKG_DEPENDS and
MKPKG_MAKEDEPENDS for
lbexec(8).
mkpkg itself reads:
MKPKG_DEBUGset
-x.MKPKG_SECRET_KEYPKG_DBDIRTMPDIR-f; matching files, as paths relative to
PKG, are not stripped.-us refused to
sign because it did not match.-r failed.-us
found no secret key.Build a port from anywhere, downloading its sources:
$ mkpkg /usr/ports/core/zlib
-dAccept a changed footprint after a build, then sign:
$ mkpkg -uf && mkpkg
-usAfter a version bump: download, update the checksums, build, accept the new footprint and sign:
$ mkpkg -od && mkpkg
-ucfsClean everything and rebuild:
$ mkpkg -xdfsw && mkpkg
-dsignify(1), MAKEPKG(5), mkpkg.conf(5), lockbox(7), addpkg(8), bulk(8), lbexec(8), pkg(8), ports(8)
| September 27, 2026 | mkpkg 1.6.0 |