Hi,
it *is* possible, see the attached file. There are some workarounds,
especially for when adding cowbuilder, and you have to have a wrapper
(also attached) that sets $DIST appropriately, but it works.
bye,
//mirabilos
--
https://toot.mirbsd.org/@mirabilos/statuses/01KNQD9RNZM1Z2A61AZHG857MP
long list of references on why “AI”/LLMs are bad for everyone
# -*- mode: sh -*-
# $MirOS: contrib/hosted/tg/deb/pbuilderrc,v 1.112 2025/10/19 00:33:06 tg Exp $
#-
# Copyright © 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
# 2019, 2020, 2021, 2022, 2023, 2024, 2025
# mirabilos <m$(date +%Y)@mirbsd.de>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
# is granted to deal in this work without restriction, including un‐
# limited rights to use, publicly perform, distribute, sell, modify,
# merge, give away, or sublicence.
#
# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
# the utmost extent permitted by applicable law, neither express nor
# implied; without malicious intent or gross negligence. In no event
# may a licensor, author or contributor be held liable for indirect,
# direct, other damage, loss, or other issues arising in any way out
# of dealing in the work, even if advised of the possibility of such
# damage or existence of a defect, except proven that it results out
# of said person’s immediate fault when using the work as intended.
#-
# Sample ~/.pbuilderrc for multiple architecture, distribution and
# suite support. For me, works rather well; may just as well break.
#
# To debug on cowbuilder:
#exec 2>/dev/tty; set -x
#
# Example uses include setting DIST=sid (regular package build),
# DIST=lenny-backports-sloppy/i386 or DIST=sid/amd64 CUSTOM=foo
# (with linux32 or linux64 (possibly --uname-2.6 also), respectively,
# prepended to build for the other architecture, and select chroots
# appropriately). Hint: use this nice wrapper script:
#
https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=shellsnippets/shellsnippets.git;a=blob;f=mksh/debian-dev/c;hb=HEAD
#
# Remember to add --debbuildopts "-m'$DEBEMAIL'" for porter uploads!
#
# For backports, use hookdir/D25backports and DIST=bp:dist[/arch],
# or instantiate a separate DIST=dist-backports[-sloppy][/arch] chroot.
#
# Prepend q: to avoid the uname warning with qemu-user-static on --create.
#
# You need to add in /etc/default/grub to GRUB_CMDLINE_LINUX these:
# "syscall.x32=y", to build x32 packages on x86 (amd64) hosts, and/or
# "vsyscall=emulate" for Linux 4.8+ on amd64, to use amd64 chroots
# with glibc 2.13 (wheezy) or older.
#-
# debian.org: sarge etch lenny squeeze wheezy jessie stretch buster
# bullseye bookworm trixie forky sid
# debian LTS: squeeze (extra mirror retired for wheezy LTS)
# (add ELTS which is not doable here without the keyring package)
# debian-ports.org: dpo (unstable+unreleased)
# not supported: etch-m68k jessie-kfreebsd
# Debian derivate from Canonical that cannot be named:
# dapper hardy jaunty karmic lucid maverick natty oneiric
# precise quantal raring saucy trusty utopic vivid wily
# xenial yakkety zesty artful bionic cosmic disco eoan
# focal groovy hirsute impish jammy kinetic lunar mantic
# noble oracular plucky questing resolute
# *-backports: sarge etch lenny squeeze wheezy jessie stretch buster
# bullseye bookworm trixie forky
# (plus all Debian derivate from Canonical that cannot be named)
# *-backports-sloppy: lenny squeeze wheezy jessie stretch buster
# bullseye bookworm trixie
# experimental: use sid or dpo, with xp: prefix when building,
# in combination with hookdir/D40experimental
# univention: not supported… yet…
#
# NOTE for sarge: bootstrapping includes sarge-backports for
# the use of cowdancer; you MUST change sources.list in its
# base.cow after creating and before updating!
#
# NOTE for all: run cowbuilder --update after --create once.
#
# TODO: changes to the mirrors don’t apply to existing chroots
# as they are read on --create only… move into a sources.list
# update script instead.
#
# TODO: find a solution to the various problems with Secure APT,
# including (but not limited to) Valid-Until repo headers on old
# distributions and expired PGP keys.
# ownership of /var/cache/pbuilder/result*/*
export BUILDRESULTUID=1000
export BUILDRESULTGID=1000
# uid used to run the actual build process tree under
export BUILDUSERID=1234
export BUILDUSERNAME=pbuilder
# for dch and possibly DEBBUILDOPTS (see below)
[[ -z $DEBEMAIL ]] || export DEBEMAIL='mirabilos <m$(date$IFS+%Y)@mirbsd.de>'
# desirable, unless you *want* to run most time-consuming
# testsuites, which usually fail anyway… (yay for optimism)
#DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nobench nocheck"
# skip -dbgsym package generation
#DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS noautodbgsym"
# retain debian/changelog fully in binary packages
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS notrimdch"
# do not change below this line (normally)
# sane environment
unset LANG LANGUAGE LC_ADDRESS LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
LC_TELEPHONE LC_TIME EXPERIMENTAL TMP TEMP TMPDIR
export LC_ALL=C
shopt -s extglob
setuptofail() {
# this makes cowbuilder succeed and pbuilder fail
if [[ -n $PBUILDER_OPERATION ]]; then
echo >&2 "E: MirDebian pbuilderrc: aborting"
echo >&2
exit 1
fi
export BASEPATH=/var/cache/pbuilder/MirDebian_pbuilderrc_aborted
}
# known distributions and distribution-specific things (suites, mirrors, …)
DISTROS='debian dpo ubuntu'
DISTS_debian='sarge etch lenny squeeze wheezy jessie stretch buster bullseye
bookworm trixie forky sid'
DISTS_dpo='dpo'
DISTS_ubuntu='dapper hardy jaunty karmic lucid maverick natty oneiric precise
quantal raring saucy trusty utopic vivid wily xenial yakkety zesty artful
bionic cosmic disco eoan focal groovy hirsute impish jammy kinetic lunar mantic
noble oracular plucky questing resolute'
DISTBACKPORTS_debian=sarge:etch:lenny:squeeze:wheezy:jessie:stretch:buster:bullseye:bookworm:trixie:forky
DISTBACKPORTSLOPPY_debian=lenny:squeeze:wheezy:jessie:stretch:buster:bullseye:bookworm:trixie
MIRROR_sarge=http://archive.debian.org/debian/
MIRROR_etch=http://archive.debian.org/debian/
MIRROR_lenny=http://archive.debian.org/debian/
MIRROR_squeeze=http://archive.debian.org/debian/
MIRROR_wheezy=http://archive.debian.org/debian/
MIRROR_jessie=http://archive.debian.org/debian/
MIRROR_stretch=http://archive.debian.org/debian/
MIRROR_buster=http://archive.debian.org/debian/
MIRROR_bullseye=http://deb.debian.org/debian/
MIRROR_bookworm=http://deb.debian.org/debian/
MIRROR_trixie=http://deb.debian.org/debian/
MIRROR_forky=http://deb.debian.org/debian/
MIRROR_sid=http://deb.debian.org/debian/
MIRROR_unstable=http://deb.debian.org/debian-ports/
MIRROR_unreleased=http://deb.debian.org/debian-ports/
MIRROR_dapper=http://old-releases.ubuntu.com/ubuntu/
MIRROR_hardy=http://old-releases.ubuntu.com/ubuntu/
MIRROR_jaunty=http://old-releases.ubuntu.com/ubuntu/
MIRROR_karmic=http://old-releases.ubuntu.com/ubuntu/
MIRROR_lucid=http://old-releases.ubuntu.com/ubuntu/
MIRROR_maverick=http://old-releases.ubuntu.com/ubuntu/
MIRROR_natty=http://old-releases.ubuntu.com/ubuntu/
MIRROR_oneiric=http://old-releases.ubuntu.com/ubuntu/
MIRROR_precise=http://old-releases.ubuntu.com/ubuntu/
MIRROR_quantal=http://old-releases.ubuntu.com/ubuntu/
MIRROR_raring=http://old-releases.ubuntu.com/ubuntu/
MIRROR_saucy=http://old-releases.ubuntu.com/ubuntu/
MIRROR_trusty=http://archive.ubuntu.com/ubuntu/
MIRROR_utopic=http://old-releases.ubuntu.com/ubuntu/
MIRROR_vivid=http://old-releases.ubuntu.com/ubuntu/
MIRROR_wily=http://old-releases.ubuntu.com/ubuntu/
MIRROR_xenial=http://archive.ubuntu.com/ubuntu/
MIRROR_yakkety=http://old-releases.ubuntu.com/ubuntu/
MIRROR_zesty=http://old-releases.ubuntu.com/ubuntu/
MIRROR_artful=http://old-releases.ubuntu.com/ubuntu/
MIRROR_bionic=http://archive.ubuntu.com/ubuntu/
MIRROR_cosmic=http://old-releases.ubuntu.com/ubuntu/
MIRROR_disco=http://old-releases.ubuntu.com/ubuntu/
MIRROR_eoan=http://old-releases.ubuntu.com/ubuntu/
MIRROR_focal=http://archive.ubuntu.com/ubuntu/
MIRROR_groovy=http://old-releases.ubuntu.com/ubuntu/
MIRROR_hirsute=http://old-releases.ubuntu.com/ubuntu/
MIRROR_impish=http://old-releases.ubuntu.com/ubuntu/
MIRROR_jammy=http://archive.ubuntu.com/ubuntu/
MIRROR_kinetic=http://old-releases.ubuntu.com/ubuntu/
MIRROR_lunar=http://old-releases.ubuntu.com/ubuntu/
MIRROR_mantic=http://old-releases.ubuntu.com/ubuntu/
MIRROR_noble=http://archive.ubuntu.com/ubuntu/
MIRROR_oracular=http://old-releases.ubuntu.com/ubuntu/
MIRROR_plucky=http://archive.ubuntu.com/ubuntu/
MIRROR_questing=http://archive.ubuntu.com/ubuntu/
MIRROR_resolute=http://archive.ubuntu.com/ubuntu/
MIRRORSECURITY_sarge=http://archive.debian.org/debian-security/
MIRRORSECURITY_etch=http://archive.debian.org/debian-security/
MIRRORSECURITY_lenny=http://archive.debian.org/debian-security/
MIRRORSECURITY_squeeze=http://archive.debian.org/debian-security/
MIRRORSECURITY_wheezy=http://archive.debian.org/debian-security/
MIRRORSECURITY_jessie=http://archive.debian.org/debian-security/
MIRRORSECURITY_stretch=http://archive.debian.org/debian-security/
MIRRORSECURITY_buster=http://archive.debian.org/debian-security/
MIRRORSECURITY_buster=http://archive.debian.org/debian-security/
MIRRORSECURITY_bullseye=http://deb.debian.org/debian-security/
MIRRORSECURITY_bookworm=http://deb.debian.org/debian-security/
MIRRORSECURITY_trixie=http://deb.debian.org/debian-security/
MIRRORSECURITY_forky=http://deb.debian.org/debian-security/
MIRRORSECURITY_sid=NO
MIRRORBACKPORTS_sarge=http://archive.debian.org/debian-backports/
MIRRORBACKPORTS_etch=http://archive.debian.org/debian-backports/
MIRRORBACKPORTS_lenny=http://archive.debian.org/debian-backports/
MIRRORBACKPORTS_squeeze=http://archive.debian.org/debian-backports/
MIRRORBACKPORTS_wheezy=http://archive.debian.org/debian/
MIRRORBACKPORTS_jessie=http://archive.debian.org/debian/
MIRRORBACKPORTS_stretch=http://archive.debian.org/debian/
MIRRORBACKPORTS_buster=http://archive.debian.org/debian/
MIRRORBACKPORTS_bullseye=http://archive.debian.org/debian/
MIRRORBACKPORTS_bookworm=http://deb.debian.org/debian/
MIRRORBACKPORTS_trixie=http://deb.debian.org/debian/
MIRRORBACKPORTS_forky=http://deb.debian.org/debian/
MIRRORBACKPORTSLOPPY_lenny=http://archive.debian.org/debian-backports/
MIRRORBACKPORTSLOPPY_squeeze=http://archive.debian.org/debian-backports/
MIRRORBACKPORTSLOPPY_wheezy=http://archive.debian.org/debian/
MIRRORBACKPORTSLOPPY_jessie=http://archive.debian.org/debian/
MIRRORBACKPORTSLOPPY_stretch=http://archive.debian.org/debian/
MIRRORBACKPORTSLOPPY_buster=http://archive.debian.org/debian/
MIRRORBACKPORTSLOPPY_bullseye=http://archive.debian.org/debian/
MIRRORBACKPORTSLOPPY_bookworm=http://deb.debian.org/debian/
MIRRORBACKPORTSLOPPY_trixie=http://deb.debian.org/debian/
COMPONENTS_debian=main
COMPONENTS_dpo=main
COMPONENTS_ubuntu='main universe'
# to have a different shell prompt inside the chroot
export debian_chroot="pbuild$$-$DIST"
# option processing
export SOURCE_ONLY_CHANGES=no
DISTpfx=
isbackports=no
isexp=false
isnotqemuuserstatic=true
x=true
while $x; do
case $DIST in
(q:*)
# support overriding uname arch check
isnotqemuuserstatic=false
DIST=${DIST#*:} ;;
(bp:*)
# support manual flagging as backports build
# using ./hookdir/D25backports
DISTpfx=${DISTpfx}bp:
isbackports=manual
isexp=false
DIST=${DIST#*:} ;;
(xp:*)
# force pbuilder-satisfydepends-experimental
DISTpfx=${DISTpfx}xp:
isbackports=no
isexp=true
DIST=${DIST#*:} ;;
(soc:*)
# want a _source.changes for uploading
SOURCE_ONLY_CHANGES=yes
DIST=${DIST#*:} ;;
(*)
x=false ;;
esac
done
determine_basecow() {
BASEPATH=/var/cache/pbuilder/base.cow-$DIST$ARCHSUFFIX${CUSTOM:+-$CUSTOM}/
test -d "$BASEPATH/etc/." || if test -z "$ARCHSUFFIX"; then
ARCHSUFFIX=-$ARCHITECTURE
determine_basecow
fi
}
# check $DIST for architecture
case $DIST in
*/*)
ARCHITECTURE=${DIST##*/}
DIST=${DIST%/*}
if test x"$ARCHITECTURE" = x"$(dpkg-architecture -qDEB_HOST_ARCH \
-a"$ARCHITECTURE" 2>/dev/null)"; then
: $ARCHITECTURE is a valid Debian architecture
else
echo >&2 "E: Unknown Debian architecture: '$ARCHITECTURE'"
setuptofail
return
fi
build_ARCHITECTURE=$(dpkg --print-architecture)
if test x"$ARCHITECTURE" = x"$build_ARCHITECTURE"; then
ARCHSUFFIX=
else
ARCHSUFFIX=-$ARCHITECTURE
fi
determine_basecow
host_uname=$(test -d "$BASEPATH/etc/." && \
chroot "$BASEPATH" uname -m || uname -m)
case $host_uname in
(aarch64)
host_gnuarch=$host_uname-linux-gnu ;;
(armv[45678]*b)
host_gnuarch=armeb-linux-gnu ;;
(armv[45678]*l)
host_gnuarch=arm-linux-gnu ;;
(aarch64*|arm*)
host_gnuarch=$host_uname-invalid-cpu-subtype ;;
(mips64)
#XXX can be either endianness (big endian host_gnuarch)
#XXX also, needs testing for all three ABIs
host_gnuarch=$host_uname-linux-gnuabi64 ;;
(parisc*)
host_gnuarch=hppa-linux-gnu ;;
(ppc*)
host_gnuarch=powerpc${host_uname#ppc}-linux-gnu ;;
(*)
host_gnuarch=$host_uname-linux-gnu ;;
esac
host_ARCHITECTURE=$(dpkg-architecture -qDEB_HOST_ARCH \
-t"$host_gnuarch" 2>/dev/null)
case $ARCHITECTURE in
(armel|armhf)
# these use an identical $(uname -m)
tgt_ARCHITECTURE=arm ;;
(mips*el)
# select big endian as above host_gnuarch
tgt_ARCHITECTURE=${ARCHITECTURE%el} ;;
(x32)
# x32 has an expected $(uname -m) value mapping to amd64’s
tgt_ARCHITECTURE=amd64 ;;
(*)
tgt_ARCHITECTURE=$ARCHITECTURE ;;
esac
if test x"$tgt_ARCHITECTURE" = x"$host_ARCHITECTURE"; then
test x"$host_uname" = x"$(uname -m)" || echo >&2 \
"I: Targetting $ARCHITECTURE from $build_ARCHITECTURE via
qemu-user-static"
elif $isnotqemuuserstatic; then
echo >&2 "E: Want $tgt_ARCHITECTURE but got $host_ARCHITECTURE"
echo >&2 "W: Did you forget to prepend linux32 or linux64" \
"to cowbuilder?"
setuptofail
return
else
echo >&2 "W: Building for $ARCHITECTURE on $build_ARCHITECTURE"
echo >&2 "N: Hopefully with qemu-user-static; otherwise expect
trouble"
fi
;;
*)
ARCHITECTURE=$(dpkg --print-architecture)
ARCHSUFFIX=
determine_basecow
;;
esac
echo >&2 "I: Building for $DISTpfx$DIST/$ARCHITECTURE"
# check $DIST for validity and load settings
export DISTRIBUTION=${DIST%%-*}
distfound=0
for distro in $DISTROS; do
eval dists=\$DISTS_$distro
for dist in $dists; do
test x"$DISTRIBUTION" = x"$dist" || continue
distfound=1
DISTRO=$distro
case $DIST in
($dist)
;;
($dist-backports)
case $distro in
(debian)
case :$DISTBACKPORTS_debian: in
(*:$DISTRIBUTION:*)
isbackports=yes
;;
(*)
distfound=0
unset DISTRO
;;
esac
;;
(ubuntu)
case " $DISTS_ubuntu " in
(*\ $DISTRIBUTION\ *)
isbackports=ubuntu
;;
(*)
distfound=0
unset DISTRO
;;
esac
;;
(*)
distfound=0
unset DISTRO
;;
esac
;;
($dist-backports-sloppy)
eval x=\$DISTBACKPORTSLOPPY_$distro
case :$x: in
(*:$DISTRIBUTION:*)
isbackports=sloppy
;;
(*)
distfound=0
unset DISTRO
;;
esac
;;
(*)
distfound=0
unset DISTRO
;;
esac
break
done
test $distfound = 0 || break
done
if test $distfound = 0; then
echo >&2 "E: Unknown distribution/suite in \$DIST: '$DIST'"
setuptofail
return
fi
case $DISTRO in
(debian|dpo) export APTCACHE=/var/cache/pbuilder/aptcache-debian/ ;;
(*) export APTCACHE=/var/cache/pbuilder/aptcache-$DISTRO/ ;;
esac
export APTCACHEHARDLINK=yes
export ARCHITECTURE ARCH=$ARCHITECTURE
export AUTO_DEBSIGN=no
export BUILDDIR=/tmp/buildd
export BUILDPLACE=/var/cache/pbuilder/build/
export BUILDRESULT=/var/cache/pbuilder/result-$DIST/
# absolutely never use ccache with pbuilder, it is positively unsafe
export CCACHEDIR="" # requirement to empty it here!
export BASEPATH
export BUILDSOURCEROOTCMD=fakeroot
eval COMPONENTS=\$COMPONENTS_$DISTRO; export COMPONENTS
case $DISTRIBUTION in
(sarge|etch)
export DEBIAN_ETCH_WORKAROUND=1
;;
esac
DEB_BUILD_OPTIONS=${DEB_BUILD_OPTIONS##+( )}
DEB_BUILD_OPTIONS=${DEB_BUILD_OPTIONS%%+( )}
export DEB_BUILD_OPTIONS
export DEBOOTSTRAP=debootstrap
# add emile, elilo, etc. for nōn-x86 arches
REMOVEPACKAGES='grub grub2 grub-pc grub-legacy lilo tasksel tasksel-data'
case $DISTRO in
(debian)
x=cowdancer,apt,debian-archive-keyring
case $DIST:$DISTRIBUTION in
(*:sarge)
x=apt
EXTRAPACKAGES='apt fakeroot'
;;
(*:etch)
EXTRAPACKAGES='apt debian-archive-keyring fakeroot'
;;
(*:lenny|squeeze:*)
EXTRAPACKAGES='apt debian-archive-keyring fakeroot'
# keep pbuilder from both using and removing it;
# the “c” wrapper from the shellsnippets repo will
# when used take care of enabling it (from bpo)
EATMYDATA=not-available
;;
(*)
EXTRAPACKAGES='apt debian-archive-keyring eatmydata fakeroot'
# add sysvinit-core when creating!
EATMYDATA=yes
;;
esac
case $DIST in
(etch-backports|lenny-backports|lenny-backports-sloppy)
EXTRAPACKAGES="$EXTRAPACKAGES debian-backports-keyring"
;;
esac
case $DISTRIBUTION in
(sarge)
keyringfile=etch
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(etch)
keyringfile=lenny
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(lenny)
keyringfile=squeeze
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(squeeze)
keyringfile=wheezy
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(wheezy)
keyringfile=jessie
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(jessie)
keyringfile=stretch
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(stretch)
keyringfile=buster
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(buster)
keyringfile=bullseye
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
test -e "$keyringfile" ||
keyringfile=/usr/share/keyrings/debian-archive-keyring.gpg
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(bullseye)
keyringfile=bookworm
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
test -e "$keyringfile" ||
keyringfile=/usr/share/keyrings/debian-archive-keyring.gpg
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(bookworm)
keyringfile=trixie
keyringfile=$(set --
/var/cache/pbuilder/base.cow-$keyringfile-*/usr/share/keyrings/debian-archive-keyring.gpg;
echo "$1")
test -e "$keyringfile" ||
keyringfile=/usr/share/keyrings/debian-archive-keyring.gpg
EXTRAPACKAGES="$EXTRAPACKAGES datefudge"
x=$x,datefudge
;;
(*)
keyringfile=/usr/share/keyrings/debian-archive-keyring.gpg
;;
esac
DEBOOTSTRAPOPTS=(
--arch=$ARCHITECTURE
--include=$x
--exclude=ubuntu-keyring
--components=${COMPONENTS// /,}
--variant=buildd
--keyring=$keyringfile
)
;;
(dpo)
DISTRIBUTION=unstable
# Note: debootstrap cannot include packages from unreleased, so this
# fails if the architecture is not bootstrappable without unreleased
# (use multistrap or a custom repository then; adjust dist above)
EXTRAPACKAGES='apt debian-ports-archive-keyring eatmydata fakeroot'
EATMYDATA=yes
DEBOOTSTRAPOPTS=(
--arch=$ARCHITECTURE
--include=cowdancer,apt,debian-ports-archive-keyring
--exclude=ubuntu-keyring
--components=${COMPONENTS// /,}
--variant=buildd
--keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg
)
;;
(ubuntu)
case $DIST:$DISTRIBUTION in
(*:dapper|*:hardy|*:jaunty|*:karmic|*:lucid|maverick:*)
EXTRAPACKAGES='apt ubuntu-keyring fakeroot'
;;
(*)
EXTRAPACKAGES='apt ubuntu-keyring eatmydata fakeroot'
EATMYDATA=yes
;;
esac
DEBOOTSTRAPOPTS=(
--arch=$ARCHITECTURE
--include=cowdancer,pbuilder,apt,ubuntu-keyring
--exclude=debian-archive-keyring
--components=${COMPONENTS// /,}
--variant=buildd
--keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg
)
;;
(*)
echo >&2 "E: Internal error, unknown distro \$DISTRO: '$DISTRO'"
setuptofail
return
;;
esac
export DEBOOTSTRAPOPTS EXTRAPACKAGES REMOVEPACKAGES
export DEBIAN_FRONTEND=noninteractive
eval MIRRORSITE=\$MIRROR_$DISTRIBUTION; export MIRRORSITE
eval x=\$MIRRORSECURITY_$DISTRIBUTION
OTHERMIRROR=
case x$x:$DISTRO in
(*:ubuntu)
: security is same as normal mirrors
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $MIRRORSITE
$DISTRIBUTION-security $COMPONENTS"
;;
(*:dpo)
: always add unreleased
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $MIRROR_unreleased
unreleased $COMPONENTS"
: debian-ports has no security support
;;
(xNO:*)
: Debian unstable, for example, has no security support
;;
(x:*)
: No mirror set, possibly dangerous oversight
echo >&2 "E: Internal error, distro '$DISTRO' has no security mirror"
setuptofail
return
;;
(*:debian)
case $DISTRIBUTION in
(sarge|etch|lenny)
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $x
$DISTRIBUTION/updates $COMPONENTS"
;;
(squeeze)
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $x
$DISTRIBUTION/updates $COMPONENTS"
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $MIRRORSITE
$DISTRIBUTION-lts $COMPONENTS"
;;
(wheezy|jessie|stretch|buster)
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $x
$DISTRIBUTION/updates $COMPONENTS"
;;
(*)
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $x
$DISTRIBUTION-security $COMPONENTS"
;;
esac
;;
esac
case $isbackports:$DIST in
(yes:*|no:sarge)
eval x=\$MIRRORBACKPORTS_$DISTRIBUTION
if test x"$x" = x""; then
echo >&2 "E: Internal error, $DISTRIBUTION-backports mirror not
set"
setuptofail
return
fi
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $x
$DISTRIBUTION-backports $COMPONENTS"
;;
(no:*|manual:*)
;;
(sloppy:*)
eval x=\$MIRRORBACKPORTS_$DISTRIBUTION
if test x"$x" = x""; then
echo >&2 "E: Internal error, $DISTRIBUTION-backports mirror not
set"
setuptofail
return
fi
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $x
$DISTRIBUTION-backports $COMPONENTS"
eval x=\$MIRRORBACKPORTSLOPPY_$DISTRIBUTION
if test x"$x" = x""; then
echo >&2 "E: Internal error, $DISTRIBUTION-backports-sloppy
mirror not set"
setuptofail
return
fi
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $x
$DISTRIBUTION-backports-sloppy $COMPONENTS"
;;
(ubuntu:*)
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $MIRRORSITE
$DISTRIBUTION-updates $COMPONENTS"
OTHERMIRROR="${OTHERMIRROR:+$OTHERMIRROR|}deb $MIRRORSITE
$DISTRIBUTION-backports $COMPONENTS"
;;
(*)
echo >&2 "E: Internal error, \$isbackports '$isbackports' unknown"
setuptofail
return
;;
esac
# set to work around bootstrap trouble
test -z "$MIR_NO_OTHERMIRROR" || OTHERMIRROR=
export OTHERMIRROR
export PDEBUILD_PBUILDER=cowbuilder
export PKGNAME_LOGFILE_EXTENTION=_${ARCHITECTURE}.build
export PKGNAME_LOGFILE_EXTENSION=$PKGNAME_LOGFILE_EXTENTION
export PKGNAME_LOGFILE=yes
APTGETOPT=(-oAPT::Get::Purge=true)
export USEDEVFS=no
export USEDEVPTS=yes
export USEPROC=yes
unset ADDITIONAL_BUILDRESULTS
export isbackports
export PBUILDERSATISFYDEPENDSCMD=/bin/false
case $DISTRIBUTION in
(sarge)
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-experimental
;;
(etch)
if test x"$isbackports" = x"no"; then
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-classic
else
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-experimental
fi ;;
(lenny)
if test x"$isbackports" = x"no"; then
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-aptitude
else
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-experimental
fi ;;
(squeeze|wheezy|jessie|dapper|hardy|jaunty|karmic|lucid|maverick|natty|oneiric|precise|quantal|raring|saucy|trusty|utopic|vivid|wily|xenial|yakkety)
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-aptitude ;;
(*)
if $isexp; then
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-experimental
elif test x"$isbackports" = x"no"; then
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-apt
else
PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-aptitude
fi ;;
esac
PBUILDERSATISFYDEPENDSOPT=(--check-key)
case $DISTRIBUTION in
(sarge|etch|lenny|squeeze|dapper|hardy|jaunty|karmic|lucid|maverick|natty)
EXTRAPACKAGES="$EXTRAPACKAGES debconf-english"
;;
(*)
REMOVEPACKAGES="$REMOVEPACKAGES debconf-i18n"
;;
esac
test -d "$APTCACHE" || install -d -o 0 -g 0 -m 0755 -- "$APTCACHE"
test -d "$BUILDRESULT" || install -d -o "$BUILDRESULTUID" -g "$BUILDRESULTGID"
-m 0755 -- "$BUILDRESULT"
unset LD_LIBRARY_PATH LD_PRELOAD
if [[ -z $PBUILDER_OPERATION || $PBUILDER_OPERATION = create ]]; then
# harmless base for path search below
cd /usr/lib/pbuilder
else
cd "$BASEPATH"
fi
for x in usr/lib/*/libeatmydata.so; do
test -e "$x" || continue
# workaround for supporting old and new eatmydata; cf. #765579
export LD_LIBRARY_PATH=/usr/lib/libeatmydata
export LD_PRELOAD=libeatmydata.so
break
done
while [[ -n $DATEFUDGE ]]; do # not a loop, just so we can break
if [[ $PBUILDER_OPERATION = create ]]; then
if [[ $DISTRIBUTION = sarge ]]; then
# does not work, also omit MIR_NO_OTHERMIRROR
break
fi
# for the host (debootstrap)
for x in /usr/lib/*-*/datefudge/datefudge.so; do
test -e "$x" || continue
x=${x%/datefudge.so}
case :$LD_LIBRARY_PATH: in
(*:"$x":*) ;;
(*)
LD_LIBRARY_PATH=$x${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ;;
esac
done
# for the target
x=$(dpkg-architecture -qDEB_HOST_MULTIARCH \
-a"$ARCHITECTURE" 2>/dev/null) || x=
test -z "$x" || \
LD_LIBRARY_PATH=/usr/lib/$x/datefudge${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
elif [[ $DISTRIBUTION = @(squeeze|lenny|etch|sarge) ]]; then
# for old target
for x in usr/lib/*-*/datefudge/datefudge.so \
usr/lib/datefudge/datefudge.so usr/lib/datefudge.so; do
test -e "$x" || continue
LD_PRELOAD=/$x${LD_PRELOAD:+:$LD_PRELOAD}
done
else
# for the target
for x in usr/lib/*-*/datefudge/datefudge.so; do
test -e "$x" || continue
x=/${x%/datefudge.so}
case :$LD_LIBRARY_PATH: in
(*:"$x":*) ;;
(*)
LD_LIBRARY_PATH=$x${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ;;
esac
done
fi
LD_LIBRARY_PATH=/usr/lib/datefudge${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
LD_PRELOAD=datefudge.so${LD_PRELOAD:+:$LD_PRELOAD}
export LD_LIBRARY_PATH LD_PRELOAD
break
done
cd -
unset x
#!/bin/mksh
# -*- mode: sh -*-
#-
# Copyright © 2013, 2014, 2018, 2020, 2021, 2024, 2025
# mirabilos <m$(date +%Y)@mirbsd.de>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
# is granted to deal in this work without restriction, including un‐
# limited rights to use, publicly perform, distribute, sell, modify,
# merge, give away, or sublicence.
#
# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
# the utmost extent permitted by applicable law, neither express nor
# implied; without malicious intent or gross negligence. In no event
# may a licensor, author or contributor be held liable for indirect,
# direct, other damage, loss, or other issues arising in any way out
# of dealing in the work, even if advised of the possibility of such
# damage or existence of a defect, except proven that it results out
# of said person’s immediate fault when using the work as intended.
#-
# Simple-to-use wrapper around eatmydata plus cowbuilder to use with
# https://www.mirbsd.org/cvs.cgi/contrib/hosted/tg/deb/pbuilderrc to
# select the proper build chroot. Now relies on pbuilderrc to enable
# eatmydata and datefudge.
#
# Example:
# c lenny/i386 DEB_BUILD_OPTIONS=parallel=4 linux32 --build foo*.dsc
# c bp:stretch/i386 --debbuildopts -v1.0-1 foo*.dsc
# c bionic/amd64~neon --update
unset LANGUAGE
export LC_ALL=C
if [[ -n $DEB_BUILD_OPTIONS ]]; then
# lest sudo does not carry them over
print -ru2 -- 'W: set options like DEB_BUILD_OPTIONS after the REALDIST'
sleep 3
fi
if (( USER_ID == 0)) && [[ -z ${SUDO+set} ]]; then
# already root so omit the sudo call by default
SUDO=
fi
set -A cmd -- env --unset=XDG_RUNTIME_DIR
if [[ -z $1 ]]; then
print -u2 E: No operation specified
exit 1
fi
REALDIST=$1
if [[ $1 = *'~'* ]]; then
CUSTOM=${REALDIST#*'~'}
set -A cmd+ -- "CUSTOM=$CUSTOM"
REALDIST=${REALDIST%%'~'*}
fi
DIST=${REALDIST##*:}
shift
# construct command line
set -A cmd+ -- "DIST=$REALDIST" LANG=C LC_CTYPE=C LC_NUMERIC=C \
LC_TIME=C LC_COLLATE=C LC_MONETARY=C LC_MESSAGES=C LC_PAPER=C \
LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C \
LC_IDENTIFICATION=C LC_ALL=C
[[ -n $DATEFUDGE ]] && set -A cmd+ -- "DATEFUDGE=$DATEFUDGE"
while [[ $1 = *=* ]]; do
cmd[${#cmd[@]}]=$1
shift
done
setarch_seen=0
case $1 {
(--)
shift
;;
(linux32|linux64)
cmd[${#cmd[@]}]=$1
shift
if [[ $1 = --uname-2.6 ]]; then
cmd[${#cmd[@]}]=$1
shift
fi
setarch_seen=1
;;
}
#XXX add more architectures
case $DIST {
(*/amd64) setarch_cmd=linux64 ;;
(*/i386) setarch_cmd=linux32 ;;
(*/x32) setarch_cmd=linux64 ;;
(*/*) setarch_cmd= ;;
(*) setarch_cmd=- ;;
}
[[ $REALDIST != q:* ]] || setarch_cmd=-
case ${DIST%/*} {
(sarge|sarge-*) setarch_26=1 ;;
(etch|etch-*) setarch_26=1 ;;
(lenny|lenny-*) setarch_26=1 ;;
(squeeze|squeeze-*) setarch_26=1 ;;
(dapper|dapper-*) setarch_26=1 ;;
(hardy|hardy-*) setarch_26=1 ;;
(jaunty|jaunty-*) setarch_26=1 ;;
(karmic|karmic-*) setarch_26=1 ;;
(lucid|lucid-*) setarch_26=1 ;;
(maverick|maverick-*) setarch_26=1 ;;
(natty|natty-*) setarch_26=1 ;;
(*) setarch_26=0 ;;
}
(( setarch_seen )) || case x$setarch_cmd {
(x)
print -ru2 "W: no setarch for architecture part of '$REALDIST'!"
;;
(x-)
if (( setarch_26 )); then
cmd[${#cmd[@]}]=setarch
cmd[${#cmd[@]}]=uname26
cmd[${#cmd[@]}]=--
fi
;;
(*)
cmd[${#cmd[@]}]=$setarch_cmd
(( setarch_26 )) && cmd[${#cmd[@]}]=--uname-2.6
cmd[${#cmd[@]}]=--
;;
}
unset TMPDIR
set -x
exec ${SUDO-sudo} "${cmd[@]}" cowbuilder "$@"