PKG_CREATE(3)
π PKG_CREATE(3) β create packages π
okay so bestie, welcome to the Library Functions Manual page for pkg_create, and yeah it lives in the libpkg library β this is the whole toolkit for making packages, and I'm gonna walk you through every single bit, no cap β¨
πΈ NAME πΈ
pkg_create, pkg_create_i, pkg_create_new, pkg_create_free, pkg_create_set_format, pkg_create_set_overwrite, pkg_create_set_compression_level, pkg_create_set_rootdir, pkg_create_set_output_dir, pkg_create_set_timestamp, pkg_create_set_compression_threads β create packages π
π LIBRARY π
library βlibpkgβ β that's the one, periodt π
β¨ SYNOPSIS β¨
#include <pkg.h>
struct pkg_create *
pkg_create_new();
void
pkg_create_free(struct pkg_create *);
bool
pkg_create_set_format(struct pkg_create *, const char *);
void
pkg_create_set_compression_level(struct pkg_create *, int);
void
pkg_create_set_compression_threads(struct pkg_create *, int);
void
pkg_create_set_overwrite(struct pkg_create *, bool);
void
pkg_create_set_rootdir(struct pkg_create *, const char *);
void
pkg_create_set_output_dir(struct pkg_create *, const char *);
void
pkg_create_set_timestamp(struct pkg_create *, time_t);
int
pkg_create(struct pkg_create *, const char *, const char *, bool);
int
pkg_create_i(struct pkg_create *, struct pkg *, bool);
π¦ DESCRIPTION π¦
pkg_create_new() β allocates a shiny new struct pkg_create *, and bestie listen, you are the one who has to free it later with pkg_create_free(). Don't leave it hanging, that's not the vibe π
pkg_create_set_format() β picks the compression format, iconic. Default is "txz", unless pkg.conf(5) says otherwise π. It returns false if the compression format is unknown, and in that case it falls back to the default format. So like, it recovers, slay.
pkg_create_set_compression_level() β takes an int argument, which is the compression level you're expecting. There are 3 special values it accepts, and they're lowkey the main characters:
INT_MINβ set the fastest compression format value π₯0β set the default (as specified inlibarchive) βINT_MAXβ set the best compression ratio π
pkg_create_set_compression_threads() β takes an int argument, the expected number of threads used during compression. Parallelize, queen π§
pkg_create_set_overwrite() β accepts a boolean that defines the default behaviour when creating a package if a local file already exists. And the default behaviour? It overwrites. Yes, it just goes for it π
pkg_create_set_rootdir() β tells the program where to find the root directory used for packaging (this directory is also known as the staging area). If none is provided, pkg will consider /. Home sweet home π
pkg_create_set_output_dir() β tells the program where to create the new packages. By default it will consider the current directory of the running program. Very "work where you are" of it π«Ά
pkg_create_set_timestamp() β defines the timestamp to use as the creation and modification time for the files to be packaged. By default it uses the timestamp of the files on the filesystem. Time is fake but the mtime is real π
π pkg_create() β from scratch π
pkg_create() creates a package from scratch using the metadata and plist as input. The metadata can be either directly a UCL manifest, or a directory containing multiple files:
+MANIFESTβ the UCL manifest+DESCβ a textual description (optional)
shell scripts (optional):
+INSTALLβ shell script that will be run during both post and pre install (DEPRECATED)+PRE_INSTALLβ shell script that will be run during pre install phase+POST_INSTALLβ shell script that will be run during post install phase+DEINSTALLβ shell script that will be run during both post and pre deinstall (DEPRECATED)+PRE_DEINSTALLβ shell script that will be run during pre deinstall phase+POST_DEINSTALLβ shell script that will be run during post deinstall phasepkg-installβ shell script that will be run during both post and pre install (DEPRECATED)pkg-pre-installβ shell script that will be run during pre install phasepkg-post-installβ shell script that will be run during post install phasepkg-deinstallβ shell script that will be run during both post and pre deinstall (DEPRECATED)pkg-pre-deinstallβ shell script that will be run during pre deinstall phasepkg-post-deinstallβ shell script that will be run during post deinstall phase
lua scripts (optional):
pkg-pre-install.luaβ Lua script that will be run during pre install phasepkg-post-install.luaβ Lua script that will be run during post install phasepkg-pre-deinstall.luaβ Lua script that will be run during pre deinstall phasepkg-post-deinstall.luaβ Lua script that will be run during post deinstall phase
𫢠quick note bestie: those+INSTALL/+DEINSTALL/pkg-install/pkg-deinstallones are marked DEPRECATED in the original. They still get listed, but like⦠use the phase-specific ones, iykyk.
π pkg_create_i() β for an installed pkg π
pkg_create_i() creates a package for the provided installed pkg. If hash is set to true then the file name will be in the form:
<pkgname>-<pkgversion>-<shorthash>.<extention>
instead of:
<pkgname>-<pkgversion>.<extension>
(and yes, the original really does spell it extention the first time β character for character, we don't edit, we respect π)
and that's the whole page, bestie β you ate that π from the Debian crew, dated December 12, 2025, signing off with all the love πππ¦
π¦ where this page comes from
- nixos 26.05: pkg 2.7.5
- nixpkgs unstable: pkg 2.7.5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms