Created
February 7, 2017 13:16
-
-
Save bzed/d488847361213c397266b132ed0e9b3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Idea stolen at https://wiki.ubuntu.com/PbuilderHowto | |
# Enhanced to support experimental, backports and oldstable. | |
# Does not build with non-free by default anymore. | |
# DIST NONFREE ARCH CUSTOM should be added to env_keep in your sudoers config. | |
OLDOLDSTABLE="squeeze" | |
OLDSTABLE="wheezy" | |
OLDSTABLE_ARCHIVED="false" | |
STABLE="jessie" | |
TESTING="stretch" | |
UNSTABLE="sid" | |
# Codenames for Debian suites according to their alias. Update these when | |
# needed. | |
UNSTABLE_CODENAME="unstable" | |
TESTING_CODENAME="testing" | |
STABLE_CODENAME="stable" | |
OLDSTABLE_CODENAME="oldstable" | |
OLDOLDSTABLE_CODE="oldoldstable" | |
OTHERS_ARCHIVED="lenny sarge etch woody potato" | |
# List of Debian suites. | |
DEBIAN_SUITES=($UNSTABLE_CODENAME $TESTING_CODENAME $STABLE_CODENAME $OLDSTABLE_CODENAME | |
$UNSTABLE $TESTING $STABLE $OLDOLDSTABLE $OLDOLDSTABLE_CODENAME | |
$OLDSTABLE experimental $OTHERS_ARCHIVED ) | |
# List of Ubuntu suites. Update these when needed. | |
UBUNTU_SUITES=("quantal" "precise" "jaunty" "intrepid" "hardy" "gutsy" "lucid" "maverick" "natty") | |
# Mirrors to use. Update these to your preferred mirror. | |
DEBIAN_MIRROR="debian.conova.eu" | |
UBUNTU_MIRROR="at.archive.ubuntu.com" | |
# Optionally use the changelog of a package to determine the suite to use if | |
# none set. | |
if [ -z "${DIST}" ] && [ -r "debian/changelog" ]; then | |
DIST=$(dpkg-parsechangelog | awk '/^Distribution: / {print $2}') | |
fi | |
# Optionally set a default distribution if none is used. Note that you can set | |
# your own default (i.e. ${DIST:="unstable"}). | |
: ${DIST:="unstable"} | |
# Optionally change Debian codenames in $DIST to their aliases. | |
case "$DIST" in | |
$UNSTABLE_CODENAME|UNRELEASED) | |
DIST="$UNSTABLE" | |
;; | |
$TESTING_CODENAME|$TESTING_CODENAME-proposed-updates|$TESTING_CODENAME-security) | |
DIST="$TESTING" | |
;; | |
$STABLE_CODENAME|$STABLE_CODENAME-proposed-updates|$STABLE_CODENAME-security) | |
DIST="$STABLE" | |
;; | |
$OLDSTABLE_CODENAME|$OLDSTABLE_CODENAME-proposed-updates|$OLDSTABLE_CODENAME-security) | |
DIST="$OLDSTABLE" | |
;; | |
$OLDOLDSTABLE_CODENAME|$OLDSTABLE_CODENAME-lts) | |
DIST="$OLDOLDSTABLE" | |
;; | |
esac | |
# Optionally set the architecture to the host architecture if none set. Note | |
# that you can set your own default (i.e. ${ARCH:="i386"}). | |
: ${ARCH:="$(dpkg --print-architecture)"} | |
DEBOOTSTRAPOPTS=( | |
'--variant=buildd' | |
) | |
NAME="$DIST" | |
if [ -n "${ARCH}" ]; then | |
NAME="$NAME-$ARCH" | |
DEBOOTSTRAPOPTS=("--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}") | |
fi | |
if [ -n "${NONFREE}" ]; then | |
NAME="$NAME-nonfree" | |
fi | |
#CUSTOM allows to create chroots per customer, or for whatever you need it | |
if [ -n "${CUSTOM}" ]; then | |
NAME="$NAME-$CUSTOM" | |
fi | |
BASETGZ="/var/cache/pbuilder/$NAME-base.tgz" | |
BASEPATH="/var/cache/pbuilder/$NAME-base.cow" | |
BUILDRESULT="/var/cache/pbuilder/$NAME/result/" | |
BUILDPLACE="/var/cache/pbuilder/build/" | |
if $(echo ${DEBIAN_SUITES[@]} | grep -q ${DIST%-backports}); then | |
COMPONENTS="main" | |
if [ -n "${NONFREE}" ]; then | |
COMPONENTS="$COMPONENTS contrib non-free" | |
fi | |
KEYRING='/usr/share/keyrings/debian-archive-keyring.gpg' | |
case "$DIST" in | |
$OLDSTABLE) | |
if [ "$OLDSTABLE_ARCHIVED" = "true" ]; then | |
MIRRORSITE="http://archive.debian.org/debian/" | |
else | |
MIRRORSITE="http://$DEBIAN_MIRROR/debian/" | |
fi | |
;; | |
sarge|potato|etch) | |
MIRRORSITE="http://archive.debian.org/debian/" | |
KEYRING='/usr/share/keyrings/debian-archive-removed-keys.gpg' | |
;; | |
experimental) | |
if [ -z "$OTHERMIRROR" ]; then | |
OTHERMIRROR="deb http://$DEBIAN_MIRROR/debian experimental $COMPONENTS" | |
else | |
OTHERMIRROR="deb http://$DEBIAN_MIRROR/debian experimental $COMPONENTS | ${OTHERMIRROR}" | |
fi | |
;; | |
lenny-backports|etch-backports|sarge-backports) | |
MIRRORSITE="http://debian.conova.eu/debian/" | |
if [ -z "$OTHERMIRROR" ]; then | |
OTHERMIRROR="deb http://archive.debian.org/debian-backports/ $DIST $COMPONENTS" | |
else | |
OTHERMIRROR="deb http://archive.debian.org/debian-backports/ $DIST $COMPONENTS | ${OTHERMIRROR}" | |
fi | |
;; | |
squeeze-backports) | |
if [ -z "$OTHERMIRROR" ]; then | |
OTHERMIRROR="deb http://$DEBIAN_MIRROR/debian-backports/ $DIST $COMPONENTS" | |
else | |
OTHERMIRROR="deb http://$DEBIAN_MIRROR/debian-backports/ $DIST $COMPONENTS | ${OTHERMIRROR}" | |
fi | |
;; | |
*-backports) | |
if [ -z "$OTHERMIRROR" ]; then | |
OTHERMIRROR="deb http://$DEBIAN_MIRROR/debian/ $DIST $COMPONENTS" | |
else | |
OTHERMIRROR="deb http://$DEBIAN_MIRROR/debian/ $DIST $COMPONENTS | ${OTHERMIRROR}" | |
fi | |
;; | |
$UNSTABLE) | |
# EXTRAPACKAGES="eatmydata" | |
# if [ -z "$LD_PRELOAD" ]; then | |
# LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libeatmydata.so.1.1.1 | |
# else | |
# LD_PRELOAD="$LD_PRELOAD":/usr/lib/x86_64-linux-gnu/libeatmydata.so.1.1.1 | |
# fi | |
# export LD_PRELOAD | |
;; | |
esac | |
DEBOOTSTRAPOPTS=( | |
'--keyring' ${KEYRING} | |
${DEBOOTSTRAPOPTS[@]} | |
) | |
elif $(echo ${UBUNTU_SUITES[@]} | grep -q ${DIST%-backports}); then | |
# Ubuntu configuration | |
MIRRORSITE="http://$UBUNTU_MIRROR/ubuntu/" | |
COMPONENTS="main universe" | |
if [ -n "${NONFREE}" ]; then | |
COMPONENTS="$COMPONENTS multiverse" | |
fi | |
if [ -r /usr/share/keyrings/ubuntu-archive-keyring.gpg ]; then | |
DEBOOTSTRAPOPTS=( | |
'--keyring' '/usr/share/keyrings/ubuntu-archive-keyring.gpg' | |
${DEBOOTSTRAPOPTS[@]} | |
) | |
fi | |
case "$DIST" in | |
*-backports) | |
OTHERMIRROR="deb $MIRRORSITE $DIST $COMPONENTS" | |
;; | |
esac | |
else | |
echo "Unknown distribution: $DIST" | |
exit 1 | |
fi | |
case "$0" in | |
*/pdebuild) | |
: do nothing | |
;; | |
*) | |
DIST=${DIST%-backports} | |
DIST=${DIST/experimental/$UNSTABLE} | |
DISTRIBUTION=$DIST | |
;; | |
esac | |
if [ "$DIST" = "unstable" ]; then | |
HOOKDIR="/home/bzed/.pbuilder/hooks.d" | |
fi | |
PKGNAME_LOGFILE="yes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment