Skip to content

Instantly share code, notes, and snippets.

@Harry-Chen
Last active January 14, 2025 03:33
Show Gist options
  • Save Harry-Chen/bc09f0df609b931cb2b57479c43a1f24 to your computer and use it in GitHub Desktop.
Save Harry-Chen/bc09f0df609b931cb2b57479c43a1f24 to your computer and use it in GitHub Desktop.
Debian Builder Config
export CCACHE_DIR="/var/cache/pbuilder/ccache"
export PATH="/usr/lib/ccache:${PATH}"
EXTRAPACKAGES="ccache"
BINDMOUNTS="${CCACHE_DIR}"
# Set the chroot mode to be unshare.
$chroot_mode = 'unshare';
$external_commands = { "build-failed-commands" => [ [ '%SBUILD_SHELL' ] ] };
# Uncomment below to specify the distribution; this is the same as passing `-d unstable` to sbuild.
# Specifying the distribution is currently required for piuparts when the changelog targets UNRELEASED. See #1088928.
#$distribution = 'experimental';
$distribution = 'unstable';
#$distribution = 'bookworm-backports';
# Specify an extra repository; this is the same as passing `--extra-repository` to sbuild.
#$extra_repositories = ['deb http://deb.debian.org/debian bookworm-backports main'];
#$extra_repositories = ['deb http://deb.debian.org/debian experimental main'];
# Specify the build dependency resolver; this is the same as passing `--build_deps_resolver` to sbuild.
# When building with extra repositories, often 'aptitude' is better than 'apt' (the default).
#$build_dep_resolver = 'aptitude';
# Build Architecture: all packages; this is the same as passing `-A` to sbuild.
$build_arch_all = 1;
# Build the source package in addition to the other requested build artifacts; this is the same as passing `-s` to sbuild.
$build_source = 1;
# Produce a .changes file suitable for a source-only upload; this is the same as passing `--source-only-changes` to sbuild.
$source_only_changes = 1;
## Run lintian after every build (in the same chroot as the build); use --no-run-lintian to override.
$run_lintian = 0;
# Display info tags.
$lintian_opts = ['--display-info', '--verbose', '--fail-on', 'error,warning', '--info'];
# Display info and pedantic tags, as well as overrides.
#$lintian_opts = ['--display-info', '--verbose', '--fail-on', 'error,warning', '--info', '--pedantic', '--show-overrides'];
## Run autopkgtest after every build (in a new, clean, chroot); use --no-run-autopkgtest to override.
$run_autopkgtest = 0;
# Specify autopkgtest options. The commented example below is the default since trixie.
#$autopkgtest_opts = ['--apt-upgrade', '--', 'unshare', '--release', '%r', '--arch', '%a' ];
## Run piuparts after every build (in a new, temporary, chroot); use --no-run-piuparts to override.
# this does not work in bookworm
$run_piuparts = 0;
# Build a temporary chroot.
$piuparts_opts = ['--no-eatmydata', '--distribution=%r', '--fake-essential-packages=systemd-sysv'];
# Build a temporary chroot that uses apt-cacher-ng as a proxy to save bandwidth and time and doesn't disable eatmydata to speed up processing.
#$piuparts_opts = ['--distribution=%r', '--bootstrapcmd=mmdebstrap --skip=check/empty --variant=minbase --aptopt="Acquire::http { Proxy \"http://127.0.0.1:3142\"; }"'];
#$unshare_tmpdir_template = '/dev/shm/tmp.sbuild.XXXXXXXXXX';
$build_environment = {
"CCACHE_DIR" => "/build/ccache",
"LD_PRELOAD" => "/usr/lib/aarch64-linux-gnu/libeatmydata.so"
};
$path = "/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games";
$build_path = "/build/package/";
$dsc_dir = "package";
$unshare_bind_mounts = [ { directory => "/var/cache/ccache", mountpoint => "/build/ccache" } ];
$autopkgtest_opts = [ '--apt-upgrade', '--env=CCACHE_DIR=/build/ccache', '--env=PATH=/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games', '--', 'unshare', '--release', '%r', '--arch', '%a', '--prefix=/dev/shm/tmp.autopkgtest.', '--bind', "/var/cache/ccache", '/build/ccache' ];
$external_commands = {
'chroot-setup-commands' => [
'export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libeatmydata.so',
'ccache -M 20G',
]
};
$environment_filter=[Dpkg::BuildInfo::get_build_env_allowed(), '^LD_PRELOAD$'];
#!/bin/bash
mkdir /var/cache/ccache
chmod 777 /var/cache/ccache
install -d -m 2775 -o 1234 -g 1234 /var/cache/pbuilder/ccache
echo 'for i in $(echo {0..9}) $(echo {a..f}) tmp; do mkdir -p /var/cache/pbuilder/ccache/$i; done' | bash
chown -R 1234:1234 /var/cache/pbuilder/ccache
#!/bin/bash
# set any rewrite rule in /etc/apt-cacher-ng/acng.conf
# MIRROR=http://repo.myhuaweicloud.com/debian
MIRROR=http://deb.debian.org/debian
mmdebstrap --include=ca-certificates --skip=output/dev --variant=buildd unstable ~/.cache/sbuild/unstable-arm64.tar.zst "$MIRROR" --aptopt='Acquire::http { Proxy "http://127.0.0.1:3142"; }' --include=ccache --customize-hook='chroot "$1" update-ccache-symlinks' --include=eatmydata --components=main,contrib,non-free,non-free-firmware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment