Skip to content

Instantly share code, notes, and snippets.

@rpavlik
Created July 31, 2014 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpavlik/b5faea075581489a28e7 to your computer and use it in GitHub Desktop.
Save rpavlik/b5faea075581489a28e7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 2009-04-09 tyler - use previously built packages as an apt source
# http://blog.edseek.com/~jasonb/articles/pbuilder_backports/pbuilderbuild.html#pbuilderhook
echo Calling $0
: ${DIST:=$(lsb_release --short --codename)}
: ${ARCH:=$(dpkg --print-architecture)}
NAME="$DIST-$ARCH"
BUILDRESULT="/var/cache/pbuilder/$NAME/result/"
# create apt archive of previously built packages
( cd $BUILDRESULT ; apt-ftparchive packages . > $BUILDRESULT/Packages )
# see ~/.pbuilderrc for creation of $BUILDRESULT/Release
apt-get update
# this is your configuration file for pbuilder.
# the file in /usr/share/pbuilder/pbuilderrc is the default template.
# /etc/pbuilderrc is the one meant for overwriting defaults in
# the default template
#
# read pbuilderrc.5 document for notes on specific options.
export MIRRORSITE=http://cdn.debian.net/debian/
export PDEBUILD_PBUILDER=cowbuilder
# based on http://www.tolaris.com/2009/03/31/backporting-debian-packages-with-pbuilder/
# and modified/updated
# 2008-08-13 tyler
# support building multiple distributions and architectures
: ${DIST:=jessie}
: ${ARCH:=$(dpkg --print-architecture)}
export NAME="$DIST-$ARCH"
export DISTRIBUTION="$DIST"
export DEBOOTSTRAPOPTS=("--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}")
export BASEPATH="/var/cache/pbuilder/$NAME/base.cow/"
export BUILDPLACE="/var/cache/pbuilder/$NAME/build/"
export BUILDRESULT="/var/cache/pbuilder/$NAME/result/"
export APTCACHE="/var/cache/pbuilder/$NAME/aptcache/"
# Don't rebuild source files (.diff.gz, .dsc), or list them in .changes
# See Ubuntu bug 118181
#DEBBUILDOPTS="-b"
case "$DIST" in
# karmic|jaunty|intrepid|hardy|dapper) # ubuntu specific
# MIRRORSITE="http://archive.ubuntu.com/ubuntu/"
# COMPONENTS="main restricted universe multiverse"
# ;;
sid|jessie) # debian specific
export COMPONENTS="main contrib non-free"
;;
*)
echo "Unknown distribution: $DIST"
exit 1
;;
esac
export HOOKDIR=/home/rpavlik/Dropbox/configs/pbuilder-hooks
# use previously built packages as local respository
export BINDMOUNTS="$BUILDRESULT"
export OTHERMIRROR="deb [trusted=yes] file://$BUILDRESULT ./"
# create local repository if it doesn't already exist,
# such as during initial 'pbuilder create'
if [ ! -d $BUILDRESULT ] ; then
mkdir -p $BUILDRESULT
fi
if [ ! -e $BUILDRESULT/Packages ] ; then
touch $BUILDRESULT/Packages
fi
if [ ! -e $BUILDRESULT/Release ] ; then
cat << EOF > $BUILDRESULT/Release
Archive: $DIST
Component: main
Origin: pbuilder
Label: pbuilder
Architecture: $ARCH
EOF
fi
# set permissions so I can delete files
chgrp -R sudo $BUILDRESULT
chmod -R g+rwx $BUILDRESULT
export EXTRAPACKAGES="apt-utils"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment