Package Management Policy
glaucus uses the filesystem tree as its database to store package information and build scripts.
Anatomy of a Package
Section titled “Anatomy of a Package”The info file
Section titled “The info file”- An
infofile is a TOML file that stores package information (aka metadata) infofiles are also valid POSIX shell scripts due to the way they are written; can be sourced by.- To create a new package, create a directory with the package name under a cluster of yours, then create an
infofile inside that directory with the mandatory variablenominside;nomshould be equal to the package directory’s name - The following is a list of all the variables supported by
infofiles:nom: package name, mandatory- Do not put version numbers in
nom
- Do not put version numbers in
ver: package version number, or commit number ifurlis a git repositoryurl: package source url- Prefer
httpsoverhttpandftp - Order of tarball preference:
.zst>.gz>.xz>.bz2 - Prefer cdn mirrors when available:
- GNU packages should use:
https://ftpmirror.gnu.org/ - Kernel packages should use:
https://cdn.kernel.org/pub/linux/ - Non GNU packages should use:
https://download.savannah.nongnu.org/releases/ - Packages from OpenBSD should use:
https://cdn.openbsd.org/pub/OpenBSD/
- GNU packages should use:
- Prefer
sum: packageXXH3_128bitschecksum, mandatory ifurlis not a git repository;xxhsum -H2 sourceTarballbld: package build time dependencies sorted alphabetically- Do not add common packages that are expected to exist at build time as build time dependencies (e.g.
make,linux-headersand so on)
- Do not add common packages that are expected to exist at build time as build time dependencies (e.g.
run: package run time dependencies sorted alphabeticallyopt: package options and includes:bootstrap: install package to/; only relevant in bootstrap stage crossno-check: do not runcheck(); mandatory ifbuilddoes not havecheck()doc,man: do not remove documentationempty: do not remove empty directoriesla,libtool: do not remove libtool archives (.lafiles) in native; they are deleted either ways in crossno-lto: do not use LTOno-parallel: do not parallelizebuild(); force-j 1instead of the default-j 5no-purge/no-prune: do not remove unwanted filesstatic: do not remove static libraries (.a files)
The build file
Section titled “The build file”- A
buildfile is a POSIX shell script that includes the build instructions of a package - The build process of a package is split into 5 different phases:
- Preparation: handled by the function
prepare() - Configuration: handled by the function
configure() - Compilation: handled by the function
build(); not to be confused with thebuildfile itself; for further reading, ifbuildis used then we are addressing the script, otherwise ifbuild()is used then the intention is the function - Checking: handled by the function
check() - Packaging: handled by the function
package(), mandatory
- Preparation: handled by the function
- Some packages include special versions of the
buildfile calledbuild-toolchainandbuild-cross; these are only intended to be run in the bootstrap process during thetoolchainandcrossstages, and regular users should not bother with them
prepare() function
Section titled “prepare() function”- glaucus package manager
radautomatically does acdinto$TMPD/$nom/$nom-$verif the package’surlis not a git repository, and into$TMPD/$nomif it is a git repository - If extracting the source tarball provided by
urldoes not follow the$nom-$verrule then you are expected to manuallycdinto whatever the directory name is (e.g. forpythonwe do acd "$TMPD"/$nom/Python-$ver); only interact with$TMPD - If a package uses autotools, always run
autoreconf -vfisto update its files - If the package provides an
autogen.shor abootstrap.shthen prefer these over manually runningautoreconf -vfis - This is done because updating
config.guess,config.subandconfig.rpathis usually not enough - Disable
po4ageneration andgtkdocizewhen runningautoreconf -vfis,autogen.shorbootstrap.sh - If a patch is absolutely necessary, then it is applied here in
prepare(); otherwise, keep things vanilla - All patches should use
-p 0 - Prefer
patchtosed - Avoid modifications and patches to documentation and manual pages as they render
autoreconfharder; require more stuff - Double check if the package’s build system requires that it be built out-of-tree; if so then
mkdir -p buildandcd build meson/muonandcmakebuild systems automatically create thebuilddirectory for you; no need tomkdir -p build
configure() function
Section titled “configure() function”- glaucus provides wrappers for various build systems that come with the required installation paths and basic configuration options
- Use
glaucus-configureforautotoolsbuild system - Use
glaucus-cmakeforcmakebuild system - Use
glaucus-muonformuonandmesonbuild systems - Use the officially supported build system by upstream; e.g.
zstdhas multiple third party build systems but the only officially maintained build system ismake - Use the newer build system if a package has multiple officially supported and maintained build systems and/or is in the process of moving to a newer build system (e.g.
kmod) - For developers who are bootstrapping the
toolchainandcrossstages use full paths toglaucus-*inbuild-toolchainandbuild-crossrespectively - Avoid substituting flag strings with variables like
nom; e.g.pcre2has a flag--enable-pcre2-32, do not type--enable-$nom-32
Disable
Section titled “Disable”- It is preferred to disable the following options:
- assert
- audit
- dbus
- debug
- doc
- examples
- fuzzing
- gettext
- gtk-doc
- i18n
- iconv
- idn
- intltool
- l10n
- logind
- man
- nls
- pam
- polkit
- rpath
- selinux
- static
- symvers
- systemd
- tests
- x11
- year2038
Enable
Section titled “Enable”- It is also preferred to enable the following options:
- acl
- attr
- ipv6
- lto
- pic
- pie
- pthreads
- shared
- threads=posix
- tls
- xattr
build() function
Section titled “build() function”- The general
build()process is ran in parallel with the default number of jobs being-j 5 - Pass
CFLAGS,CXXFLAGSandLDFLAGSas arguments tomakeand not as environment variables, so they are propagated correctly:
## Correctmake foo=bar
## Incorrect, might get unexported in the Makefile and not get passed to submakesfoo=bar make- Prefer
make(tomuon samu) ascmakegenerator/build tool
check() function
Section titled “check() function”- Only relevant for native
buildrecipes; will not be called incrossandtoolchainstages (do not add acheck()function inbuild-crossandbuild-toolchain) - Report packages without a test suite
- Report failing tests
- Try
VERBOSE=1 V=1formake check - Prefer
make -k checkto keep going until all tests are checked - If tests fail in parallel, try
-j1 - Compare failing tests with Alpine and LFS
package() function
Section titled “package() function”package()is the only required function to declarebuildfiles- Do not install in:
/bin,/boot,/dev,/home,/lib,/mnt,/proc,/root,/run,/sbin,/sys,/tmp,/usr/sbin - Everything related to
s6should reside under/etc/s6 - All text files must end with a newline (POSIX)
- Prefer strip targets
install-strip(andinstall/stripforcmake) over manual strip - For developers, do not create fifo files when in
crossstage as they can’t be copied - Consider removing the following files if unnecessary:
- .a (static libraries whenever possible)
- .alias
- .bs (perl files)
- .cmd (kernel files)
- .dbg
- .e2x (perl files)
- .install (kernel files)
- .la (libtool archives)
- .packlist (perl files)
- .pod (perl files)
- .py (python files)
- .pyc (python files) (ewe)
- .pyo (python files) (ewe)
- alias
- application (kiss)
- bash
- charset
- cmake
- completion
- consolekit (kiss)
- dbus
- doc (kiss)
- extralibs (perl files)
- fish
- gdb (kiss)
- gettext (kiss)
- gtk-doc (kiss)
- i18n
- icon (kiss)
- info (kiss)
- intl (kiss)
- locale
- logind (kiss)
- man (kiss)
- pam
- polkit (kiss)
- pulse (kiss)
- sound (kiss)
- systemd
- test (ewe)
- zsh (kiss)
- Avoid
-eand-xin the shebang (vague behavior) - Do not store commands inside variables
- Do not declare empty functions; if a function does nothing then it shoul not be declared
prepare() { :}- Brace expansion is not POSIX
- Use
mkdir -poverinstall -d; usingmkdiralone is discouraged cp -ais not POSIX; usecp -fPpfor files andcp -fPpRfor directoriescp -vandmv -vare not POSIX;rm -vis POSIX thoughln -randln -nare not POSIX; useln -fsinstead; prefer symbolic links to hard links, and relative links to absolute linkspatchonly accepts one diff/patch file at a time when using-i; if multiple files are provided it will use the last onetouchis faster than:>command -vis faster thantype- Group commands that deal with multiple arguments into one (e.g.
cp,rm,mkdir(if same permissions)…) - Group commands that are repeated 3 or more times into
forloops - Only quote shell variables with whitespace characters
- Separate options that accept arguments from ones that do not; prefer this:
mkdir -m 555 -pto this:
mkdir -pm 555- Use a single space character to separate arguments from their options; prefer this:
patch -p 0 ...to this:
patch -p0 ...Layout
Section titled “Layout”/var/cache/rad/build: Persistent cache store for build artefacts/var/cache/rad/src: Persistent read-only cache store for upstream source tarballs/var/lib/rad/local: Local database of installed packages/var/lib/rad/repo/core: Core repository;$core/var/lib/rad/repo/extra: Extra repository;$extra/var/log/rad: Log directory/var/tmp/rad: Temporary store for build artefacts;$tmp
References
Section titled “References”- https://crux.nu/doc/handbook.html
- https://devmanual.gentoo.org/general-concepts/dependencies/
- https://devmanual.gentoo.org/general-concepts/dependencies/#implicit-system-dependency
- https://devmanual.gentoo.org/quickstart/index.html
- https://docs.voidlinux.org/xbps/index.html
- https://github.com/kreatolinux
- https://github.com/pibuxd/vanilla
- https://github.com/venomlinux/scratchpkg
- https://github.com/void-linux/void-packages/blob/master/Manual.md
- https://google.github.io/styleguide/shell.xml
- https://linux.die.net/man/8/apt-get
- https://linux.die.net/man/8/aptitude
- https://man7.org/linux/man-pages/man8/dnf.8.html
- https://man.archlinux.org/man/pacman.8.en
- https://man.voidlinux.org/xbps-install.1
- https://man.voidlinux.org/xbps-query.1
- https://man.voidlinux.org/xbps-remove.1
- https://michael.stapelberg.ch/posts/2020-05-09-distri-hermetic-packages/
- https://os-wiki.ewe.moe/dev/guide/packaging
- https://pubs.opengroup.org/onlinepubs/9799919799/
- https://superuser.com/questions/195826/bash-shebang-for-dummies
- https://tincan-linux.github.io/wiki/arc
- https://wiki.alpinelinux.org/wiki/Package_policies
- https://wiki.archlinux.org/title/Arch_package_guidelines
- https://wiki.archlinux.org/title/creating_packages
- https://wiki.archlinux.org/title/Makepkg#Building_optimized_binaries
- https://wiki.archlinux.org/title/Meta_package_and_package_group
- https://wiki.archlinux.org/title/Official_repositories
- https://wiki.archlinux.org/title/Pacman/Rosetta
- https://wiki.archlinux.org/title/PKGBUILD
- https://wiki.debian.org/ReduceDebian
- https://wiki.gentoo.org/wiki/Stage_file
- https://www.debian.org/releases/bookworm/amd64/ch03s04.en.html
- https://www.gnu.org/software/make/manual/html_node/Testing.html
- https://www.tldp.org/LDP/abs/html/unofficialst.html
- https://www.unix.com/unix-for-dummies-questions-and-answers/247059-run-command-stored-variable.html