This repository contains a small script used to build and manage a custom xbps repository.
Find a file
2026-07-26 17:08:33 +00:00
.gitignore Basic version 2026-05-12 16:43:07 +02:00
builder replacing old shlibs logic 2026-07-26 16:41:51 +00:00
README.md document new changes to builder 2026-07-26 16:52:58 +00:00

This repository contains a small script used to build and manage a custom xbps repository.

Usage

The script uses the following environment variables:

Name Default Description
VOID_PACKAGES ./void-packages Path to the void-packages repo
PKGS_DIR ./pkgs Directory containing the packages to build
REPO_DIR ./repo Directory to output place the built packages
COMMON_DIR ./common Directory containing a custom common/ overlay
ETC_DIR ./etc Directory containing a custom etc/ overlay
SIGN_KEY Path to the key used to sign the packages/repo
SIGNED_BY Signature details (e.g. "name ")
EXTRA_ARGS Extra arguments to pass to xbps-src

If the provided $VOID_PACKAGES exists it will be resetted and cleaned of all modifications and unstaged changes to ensure a correct and sane environment to build the packages. Otheriwse if the specified directory doesn't exist it will be cloned automatically.

If the provided $COMMON_DIR exists its contents are copied into $VOID_PACKAGES/common, overwriting anything already there. The exception is shlibs: instead of being overwritten, it's merged in line by line, replacing any existing entry for the same library rather than duplicating it.

If the provided $ETC_DIR exists its contents are copied into $VOID_PACKAGES/etc, overwriting anything already there.

Example

# create a directory for the custom repository.
mkdir ~/custom-void-repo
cd ~/custom-void-repo

# clone the builder
git clone https://git.voiders.dev/voiders-community/builder builder

# create the needed directory
mkdir pkgs repo

# create a package
mkdir pkgs/svc
cat <<-EOF >pkgs/svc/template
# Template file for 'svc'
pkgname=svc
version=1.0.0
revision=1
build_style=gnu-makefile
make_build_args="CC=clang"
make_install_args="PREFIX=/usr"
hostmakedepends="clang"
short_desc="Small and simple reimplementation of sv for runit"
maintainer="Haris <plavpxl@proton.me>"
license="AGPL-3.0-only"
homepage="https://github.com/WladimirBec/svc"
distfiles="https://github.com/WladimirBec/svc/archive/refs/tags/1.0.0.tar.gz"
checksum=da46f8a65a2c18aa8ca502a0988ac6129ee2e973555c54c9bca37dcd94690701

post_extract() {
	# remove -march=native so it builds portably
	vsed -i 's/-march=native//g' Makefile

	# use void CFLAGS
	# see: https://github.com/void-linux/void-packages/tree/master/common/build-profiles
	# see: https://github.com/void-linux/void-packages/blob/master/common/environment/configure/hardening.sh
	vsed -i 's/CFLAGS :=/CFLAGS +=/g' Makefile
}

post_install() {
	vlicense LICENSE
}
EOF

# generate your custom key
ssh-keygen -t rsa -b 4096 -m PEM -f privkey.pem

# build the package
SIGN_KEY=privkey.pem SIGNED_BY="me" ./builder/builder svc

# your custom repository now contains the svc package
ls repo/binpkgs

# add your custom repository to your repositories list
echo "repository=$PWD/repo/binpkgs" | sudo tee /etc/xbps.d/my-custom-repo.conf

# update your local cache
sudo xbps-install -Sy

# list the packages in your repo
xbps-query -i --repository="$PWD/repo/binpkgs" -s ""

Example building for multiple archs

The builder calls xbps-rindex to sign the packages and the repository so we can use the XBPS_TARGET_ARCH env to specify for which architecture the packages must be added, on top of that we can use the EXTRA_ARGS env, as shown here:

# build the package for x86_64 (glibc)
SIGN_KEY="privkey.pem" \
SIGNED_BY="me" \
EXTRA_ARGS="-m masterdir-x86_64 -A x86_64" \
XBPS_TARGET_ARCH="x86_64" \
./builder/builder svc

# build the package for x86_64 (musl)
SIGN_KEY="privkey.pem" \
SIGNED_BY="me" \
EXTRA_ARGS="-m masterdir-x86_64-musl -A x86_64-musl" \
XBPS_TARGET_ARCH="x86_64-musl" \
./builder/builder svc

# both the glibc and musl .xbps files are present
ls repo/binpkgs

# both the glibc and musl packages are queryable
XBPS_TARGET_ARCH=x86_64 xbps-query -i --repository=$PWD/repo/binpkgs -s ""
XBPS_TARGET_ARCH=x86_64-musl xbps-query -i --repository=$PWD/repo/binpkgs -s ""

Example overlaying common/ and etc/

mkdir common
cat <<-EOF >common/shlibs
libsvc.so.2 svc-1.0.0_1
EOF

mkdir etc
echo 'XBPS_ALLOW_RESTRICTED=yes' >> etc/conf

SIGN_KEY="privkey.pem" SIGNED_BY="me" ./builder/builder svc