mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-04-29 11:01:29 +00:00
254 lines
5.7 KiB
Bash
Executable File
254 lines
5.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright by:
|
|
# Jamin W. Collins <jcollins@asgardsrealm.net>
|
|
# Jordan Mantha <mantha@ubuntu.com>
|
|
# Siegfried-A. Gevatter <rainct@ubuntu.com>
|
|
# License: GPLv2 or later
|
|
#
|
|
# This script is a wrapper to be able to easily use pbuilder with
|
|
# differentd istributions (eg, Gutsy, Hardy, Debian unstable, etc).
|
|
#
|
|
# You can create symlinks to a pbuilder-dist executable to get different
|
|
# configurations. For example, a symlink called pbuilder-hardy will assume
|
|
# that the target distribution is always Ubuntu Hardy.
|
|
|
|
# Base directory where pbuilder will put all the files it creates.
|
|
# This is overriden by the global variable $PBUILDFOLDER
|
|
BASE_DIR="$HOME/pbuilder"
|
|
|
|
# Change this to 0 if you don't want additional components to be used.
|
|
# That is, 'universe' and 'multiverse' for Ubuntu chroots and 'contrib'
|
|
# and 'non-free' for Debian.
|
|
EXTRACOMP=1
|
|
|
|
# Change this to 1 if you want the log for the last operation to be saved
|
|
# in the base directory by default (it will be named '.lastlog').
|
|
SAVELOG=0
|
|
|
|
# Allow this script to use /var/cache/apt/archives/ when possible
|
|
if [ -z $SYSCACHE ]
|
|
then
|
|
SYSCACHE=1
|
|
fi
|
|
|
|
|
|
################################
|
|
|
|
ARCH=`dpkg-architecture -qDEB_HOST_ARCH`
|
|
SYSDIST=`lsb_release -cs`
|
|
|
|
if [ $PBUILDFOLDER ] && [ $PBUILDFOLDER != "" ]
|
|
then
|
|
BASE_DIR=$PBUILDFOLDER
|
|
fi
|
|
|
|
help()
|
|
{
|
|
echo "Insufficient number of arguments."
|
|
echo "Usage: $0 "$( [ "$1" != 'show-dist-flag' ] || echo "<distribution> " )$( [ $ARCH != "amd64" ] || echo "[i386|amd64] " )"[mainonly|allcomp] [withlog|nolog] <operation>"
|
|
exit 1
|
|
}
|
|
|
|
if [ ! -z `echo \`basename $0\` | grep -- '-'` ] && [ `basename $0` != 'pbuilder-dist' ]
|
|
then
|
|
if [ $# -lt 1 ]
|
|
then
|
|
help
|
|
fi
|
|
|
|
BINARCH=`basename $0 | cut -f3 -d '-'`
|
|
DISTRIBUTION=`basename $0 | cut -f2 -d '-'`
|
|
else
|
|
if [ $# -lt 2 ]
|
|
then
|
|
help show-dist-flag
|
|
fi
|
|
|
|
BINARCH=$ARCH ##
|
|
DISTRIBUTION=$1
|
|
shift 1
|
|
fi
|
|
|
|
|
|
if [ $1 = "i386" ] || [ $1 = "amd64" ]
|
|
then
|
|
if [ $ARCH = "amd64" ]; then
|
|
BINARCH=$1
|
|
else
|
|
echo "Warning: Architecture switching is not supported on your system; ignoring argument."
|
|
fi
|
|
|
|
shift 1
|
|
fi
|
|
|
|
|
|
if [ $1 = "mainonly" ]; then
|
|
EXTRACOMP=0
|
|
shift 1
|
|
elif [ $1 = "allcomp" ]; then
|
|
EXTRACOMP=1
|
|
shift 1
|
|
fi
|
|
|
|
|
|
if [ $1 = "withlog" ]; then
|
|
SAVELOG=1
|
|
shift 1
|
|
elif [ $1 = "nolog" ]; then
|
|
SAVELOG=0
|
|
shift 1
|
|
fi
|
|
|
|
|
|
distdata()
|
|
{
|
|
if [ "$1" = "debian" ]
|
|
then
|
|
# Set Debian specific data
|
|
ISDEBIAN=True
|
|
if [ -z $ARCHIVE ]
|
|
then
|
|
ARCHIVE="http://ftp.debian.org"
|
|
fi
|
|
COMPONENTS="main"$( [ $EXTRACOMP = 0 ] || echo " contrib non-free" )
|
|
else
|
|
# Set Ubuntu specific data
|
|
ISDEBIAN=False
|
|
if [ -z $ARCHIVE ]
|
|
then
|
|
ARCHIVE="http://archive.ubuntu.com/ubuntu"
|
|
fi
|
|
COMPONENTS="main restricted"$( [ $EXTRACOMP = 0 ] || echo " universe multiverse" )
|
|
fi
|
|
}
|
|
|
|
|
|
case $DISTRIBUTION in
|
|
dapper|edgy|feisty|gutsy|hardy) # warty|hoary|breezy
|
|
distdata ubuntu
|
|
;;
|
|
|
|
oldstable|sarge|stable|etch|testing|lenny|unstable|sid|experimental)
|
|
distdata debian
|
|
;;
|
|
|
|
*)
|
|
if [ ! -d $BASE_DIR/${DISTRIBUTION}-* ]
|
|
then
|
|
echo -n "Warning: Unknown distribution «$DISTRIBUTION». Do you want to continue [y/N]? "
|
|
read continue
|
|
|
|
if [ "$continue" != 'y' ] && [ "$continue" != 'Y' ]
|
|
then
|
|
echo "Aborting..."
|
|
exit 1
|
|
fi
|
|
fi
|
|
distdata
|
|
;;
|
|
esac
|
|
|
|
|
|
OPERATION=$1
|
|
|
|
case $OPERATION in
|
|
create|update|build|clean|login|execute)
|
|
shift 1
|
|
;;
|
|
|
|
*)
|
|
if [ ${1##*.} = 'dsc' ]
|
|
then
|
|
OPERATION=build
|
|
else
|
|
echo "Unrecognized argument. Please use one of those:"
|
|
echo " create"
|
|
echo " update"
|
|
echo " build"
|
|
echo " clean"
|
|
echo " login"
|
|
echo " execute"
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
FOLDERBASE="${DISTRIBUTION}-$( ([ "$BINARCH" != "" ] && echo $BINARCH) || echo $ARCH )"
|
|
|
|
if [ ! -d $BASE_DIR/${FOLDERBASE}_result ]
|
|
then
|
|
mkdir -p $BASE_DIR/${FOLDERBASE}_result
|
|
fi
|
|
|
|
if [ $SYSCACHE != 0 ] && [ "$SYSDIST" = "$DISTRIBUTION" ] && [ "$ARCH" = "$BINARCH" -o -z $BINARCH ]
|
|
then
|
|
DEBCACHE='/var/cache/apt/archives/'
|
|
fi
|
|
|
|
if [ -n $http_proxy ] || [ -n $HTTP_PROXY ]
|
|
then
|
|
if [ -n $http_proxy ]
|
|
then
|
|
PROXY=$http_proxy
|
|
else
|
|
PROXY=$HTTP_PROXY
|
|
fi
|
|
fi
|
|
|
|
if [ $ISDEBIAN = "False" ]
|
|
then
|
|
if [ ! -d $BASE_DIR/etc/$DISTRIBUTION/apt.conf/ ]
|
|
then
|
|
mkdir -p $BASE_DIR/etc/$DISTRIBUTION/apt.conf
|
|
fi
|
|
if [ ! -e $BASE_DIR/etc/$DISTRIBUTION/apt.conf/sources.list ]
|
|
then
|
|
echo "deb $ARCHIVE $DISTRIBUTION $COMPONENTS" > $BASE_DIR/etc/$DISTRIBUTION/apt.conf/sources.list
|
|
case $DISTRIBUTION in
|
|
dapper|edgy|feisty|gutsy )
|
|
cat >> $BASE_DIR/etc/$DISTRIBUTION/apt.conf/sources.list <<EOF
|
|
deb $ARCHIVE $DISTRIBUTION-security $COMPONENTS
|
|
deb $ARCHIVE $DISTRIBUTION-updates $COMPONENTS
|
|
EOF
|
|
;;
|
|
* )
|
|
;;
|
|
esac
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$PBUILDAUTH" ]
|
|
then
|
|
if [ -n "$DESKTOP_SESSION" ]
|
|
then
|
|
case $DESKTOP_SESSION in
|
|
gnome )
|
|
SUDOREPLACE="gksudo -D \"Pbuilder\" "
|
|
;;
|
|
kde|kde4 )
|
|
SUDOREPLACE="kdesudo -d --comment \"Pbuilder\""
|
|
;;
|
|
* )
|
|
SUDOREPLACE="sudo"
|
|
;;
|
|
esac
|
|
else
|
|
SUDOREPLACE=sudo
|
|
fi
|
|
else
|
|
SUDOREPLACE=$PBUILDAUTH
|
|
fi
|
|
|
|
sudo pbuilder $OPERATION \
|
|
--basetgz "$BASE_DIR/${FOLDERBASE}-base.tgz" \
|
|
--distribution "$DISTRIBUTION" \
|
|
--debootstrapopts --arch \
|
|
--debootstrapopts "$BINARCH" \
|
|
$( [ $SAVELOG = 0 ] || echo "--logfile $BASE_DIR/.lastlog" ) \
|
|
$( [ -z $PROXY ] || echo "--http-proxy $PROXY" ) \
|
|
$( [ -z $DEBCACHE ] || echo "--aptcache $DEBCACHE" ) \
|
|
--buildresult "$BASE_DIR/${FOLDERBASE}_result" \
|
|
--mirror "$ARCHIVE" \
|
|
--aptconfdir "$BASE_DIR/etc/$DISTRIBUTION/apt.conf/" \
|
|
$@
|