Package Management Policy
glaucus uses the filesystem tree as its database to store package information and build scripts.
Anatomy of a Package
info
file
- An
info
file is a TOML file that stores package information (aka metadata) info
files 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
info
file inside that directory with the mandatory variablenom
inside;nom
should be equal to the package directory’s name - The following is a list of all the variables supported by
info
files:nom
: package name, mandatory- Do not put version numbers in
nom
- Do not put version numbers in
ver
: package version number, or commit number ifurl
is a git repositoryurl
: package source url- Prefer
https
overhttp
andftp
- 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
: package checksum, only valid if theurl
is not a git repositorybld
: 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-headers
and 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 alphabeticallynop
: package “no operation” and includes:bootstrap
: install package to/
; only available in crosscheck
: do not runcheck()
; must be provided forbuild
withoutcheck()
doc
,man
: do not remove documentationempty
: do not remove empty directoriesla
,libtool
: do not remove libtool archives (.la
files) in native; they are deleted either ways in crosslto
: do not use LTOparallel
: use-j 1
purge
,prune
: do not remove unwanted filesstatic
: do not remove static libraries (.a files)
build
file
- A
build
file 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()
- 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
build
file calledbuild-toolchain
andbuild-cross
; these are only intended to be run by developers when bootstrapping thetoolchain
andcross
stages of glaucus
prepare()
function
- glaucus package manager
rad
automatically does acd
into$TMPD/$nom/$nom-$ver
if the package’surl
is not a git repository, and into$TMPD/$nom
if it is a git repository - If extracting the source tarball provided by
url
does not follow the$nom-$ver
rule then you are expected to manuallycd
into whatever the directory name is (e.g. forpython
we do acd "$TMPD"/$nom/Python-$ver
); do not interact with$SRCD
, only$TMPD
- If a package uses autotools, always run
autoreconf -vfis
to update its files - If the package provides an
autogen.sh
or abootstrap.sh
then prefer these over manually runningautoreconf -vfis
- This is done because updating
config.guess
,config.sub
andconfig.rpath
is usually not enough - Disable
po4a
generation andgtkdocize
when runningautoreconf -vfis
,autogen.sh
orbootstrap.sh
- If a patch is absolutely necessary, then it is applied here in
prepare()
; otherwise, keep things vanilla - All patches should use
-p 0
- Avoid modifications and patches to documentation and manual pages as they render
autoreconf
harder; require more stuff - Double check if the package’s build system requires that it be built out-of-tree; if so then
mkdir -p build
andcd build
configure()
function
- glaucus provides wrappers for various build systems that come with the required installation paths and basic configuration options
- Use
glaucus-configure
forautotools
build system - Use
glaucus-cmake
forcmake
build system - Use
glaucus-muon
formuon
andmeson
build systems - For developers who are bootstrapping the
toolchain
andcross
stages use full paths toglaucus-*
inbuild-toolchain
andbuild-cross
respectively - Avoid substituting flag strings with variables like
nom
; e.g.pcre2
has a flag--enable-pcre2-32
, do not type--enable-$nom-32
Disable
- In glaucus, 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
- It is also preferred to enable the following options:
- acl
- attr
- ipv6
- lto
- pic
- pie
- pthreads
- shared
- threads=posix
- tls
- xattr
build()
function
- Pass
CFLAGS
,CXXFLAGS
andLDFLAGS
as arguments tomake
and 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
check()
function
- Only relevant for native
build
recipes; will not be called incross
andtoolchain
stages (do not add acheck()
function inbuild-cross
andbuild-toolchain
) - Report packages without a test suite
- Report failing tests
- Try
VERBOSE=1 V=1
formake check
- Prefer
make -k check
to keep going until all tests are checked - If tests fail in parallel, try
-j1
- Compare failing tests with Alpine and LFS
package()
function
package()
is the only required function to declarebuild
files- Do not install in:
/bin
,/boot
,/dev
,/home
,/lib
,/mnt
,/proc
,/root
,/run
,/sbin
,/sys
,/tmp
,/usr/sbin
- Everything related to
s6
should reside under/etc/s6
- All text files must end with a newline (POSIX)
- Prefer strip targets
install-strip
to manually running strip - For developers, do not create fifo files when in
cross
stage 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)
Misc
- Avoid
-e
and-x
in 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 -p
overinstall -d
cp -a
is not POSIX; usecp -fPp
for files andcp -fPpR
for directoriescp -v
andmv -v
are not POSIX;rm -v
is POSIX thoughln -r
andln -n
are not POSIX; useln -fs
insteadpatch
only accepts one diff/patch file at a time when using-i
; if multiple files are provided it will use the last onetouch
is faster than:>
command -v
is 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
for
loops - Only quote shell variables with whitespace characters
- Separate options that accept arguments from ones that do not; prefer this:
mkdir -m 555 -p
to this:
mkdir -pm 555
- Use a single space character to separate arguments from their options; prefer this:
patch -p 0 ...
to this:
patch -p0 ...
Repository Layout
/var/cache/rad/pkg
(built packages withcontents
)/var/cache/rad/src
(source tarballs, read-only, equals$SRCD
)/var/lib/rad/clusters/cerata
(official cluster, equals$CERD
)/var/lib/rad/clusters/custom
(custom cluster)/var/lib/rad/clusters/fleet
(community cluster)/var/lib/rad/pkg
(installed packages withcontents
)/var/log/rad
(log files, equals$LOGD
)/var/tmp/rad
(temporary build artefacts)
References
- 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.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://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