From 6de5aee07bc687c66e32577c379245cc0f666bcf Mon Sep 17 00:00:00 2001 From: Ryan Kavanagh Date: Sat, 14 Mar 2009 17:03:09 -0400 Subject: [PATCH] mk-sbuild-lv: Added support for Debian chroots. Updated manpage. (LP: #342158) --- debian/changelog | 5 ++++ doc/mk-sbuild-lv.1 | 3 +++ mk-sbuild-lv | 63 ++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index d7c3140..c82160e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,15 @@ ubuntu-dev-tools (0.67) UNRELEASED; urgency=low + [ Jonathan Davies ] * mk-sbuild-lv: Changed default behaviour so that the initial build and log directories are not created on first run; instead read settings file and check if they exist (LP: #342154). * requestsync: Reverted old madison.php workaround (LP: #183346). + [ Ryan Kavanagh ] + * mk-sbuild-lv: Added support for Debian chroots. Updated manpage. + (LP: #342158) + -- Jonathan Davies Mon, 09 Mar 2009 16:03:09 +0000 ubuntu-dev-tools (0.66) jaunty; urgency=low diff --git a/doc/mk-sbuild-lv.1 b/doc/mk-sbuild-lv.1 index 8d735b3..7c5ff3a 100644 --- a/doc/mk-sbuild-lv.1 +++ b/doc/mk-sbuild-lv.1 @@ -35,6 +35,9 @@ Use FILE as the sources.list template (defaults to $HOME/.mk\-sbuild\-lv.sources .B \-\-debootstrap\-mirror=URL Use URL as the debootstrap source (defaults to http://ports.ubuntu.com for lpia, official Ubuntu repositories for the supported architectures). +.TP +.B \-\-debian +Make a Debian schroot environment. .SH ENVIRONMENT VARIABLES .TP diff --git a/mk-sbuild-lv b/mk-sbuild-lv index c32d421..a3bd1ea 100755 --- a/mk-sbuild-lv +++ b/mk-sbuild-lv @@ -2,6 +2,7 @@ # # Copyright 2006-2007 (C) Canonical Ltd. # Created by Kees Cook +# Copyright 2009 (C) Ryan Kavanagh # # ################################################################## # @@ -108,6 +109,7 @@ function usage() echo " --skip-updates Do not include -updates pocket in sources.list" echo " --source-template=FILE Use FILE as the sources.list template" echo " --debootstrap-mirror=URL Use URL as the debootstrap source" + echo " --debian Make a Debian schroot environment" echo "" echo "Configuration (via ~/.mk-sbuild-lv.rc)" echo " LV_SIZE Size of source LVs (default ${LV_SIZE})" @@ -121,7 +123,7 @@ function usage() if [ -z "$1" ]; then usage fi -OPTS=`getopt -o '' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,personality:" -- "$@"` +OPTS=`getopt -o '' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,personality:,debian" -- "$@"` eval set -- "$OPTS" name="" @@ -165,6 +167,10 @@ while :; do DEBOOTSTRAP_MIRROR="$2" shift 2 ;; + --debian) + DEBIAN=True + shift + ;; --) shift break @@ -199,6 +205,11 @@ if [ -r ~/.mk-sbuild-lv.rc ]; then fi # Settings check. +if [ $DEBIAN ] && [ ! -x /usr/bin/cdebootstrap ]; then + echo "Please install the cdebootstrap package to create a Debian schroot." + exit 1 +fi + if [ ! -d $build_dir ]; then echo "Build directory $build_dir does not exist." echo "Please create it or change the setting in ~/.sbuildrc ." @@ -225,7 +236,7 @@ else fi # are we doing an lpia build? -if [ -z "$DEBOOTSTRAP_MIRROR" ] && [ "$arch_opt" = "--arch lpia" ]; then +if [ -z "$DEBOOTSTRAP_MIRROR" ] && [ "$arch_opt" = "--arch lpia" ] && [ ! $DEBIAN ]; then DEBOOTSTRAP_MIRROR="http://ports.ubuntu.com/" fi @@ -236,7 +247,11 @@ sudo mkfs -t ext3 "$CHROOT_PATH" # Mount and debootstrap the chroot MNT=`mktemp -d -t schroot-XXXXXX` sudo mount "$CHROOT_PATH" "$MNT" -sudo debootstrap $arch_opt $variant_opt "$RELEASE" "$MNT" "${DEBOOTSTRAP_MIRROR:-http://archive.ubuntu.com/ubuntu}" +if [ $DEBIAN ]; then + sudo cdebootstrap -f build $arch_opt $variant_opt "$RELEASE" "$MNT" "${DEBOOTSTRAP_MIRROR:-http://ftp.debian.org/debian}" +else + sudo debootstrap $arch_opt $variant_opt "$RELEASE" "$MNT" "${DEBOOTSTRAP_MIRROR:-http://archive.ubuntu.com/ubuntu}" +fi # Update the package sources TEMP_SOURCES=`mktemp -t sources-XXXXXX` if [ -z "$TEMPLATE_SOURCES" ]; then @@ -245,20 +260,37 @@ fi if [ -r "$TEMPLATE_SOURCES" ]; then cat "$TEMPLATE_SOURCES" > "$TEMP_SOURCES" else - cat > "$TEMP_SOURCES" < "$TEMP_SOURCES" << EOM +deb ${DEBOOTSTRAP_MIRRORS:-http://ftp.debian.org/debian} RELEASE main non-free contrib +deb-src ${DEBOOTSTRAP_MIRRORS:-http://ftp.debian.org/debian} RELEASE main non-free contrib +EOM + if [ "$RELEASE" != "sid" ]; then + cat >> "$TEMP_SOURCES" << EOM +deb http://security.debian.org/ ${RELEASE}/updates main +deb-src http://security.debian.org/ ${RELEASE}/updates main +EOM + fi + # End Debian + else + # Start Ubuntu + cat > "$TEMP_SOURCES" <> "$TEMP_SOURCES" <> "$TEMP_SOURCES" <> "$TEMP_SOURCES" <> "$TEMP_SOURCES" < $MNT/etc/apt/sources.list" @@ -307,7 +339,11 @@ BUILD_PKGS="build-essential fakeroot devscripts apt-utils" if [ "$RELEASE" != "breezy" ] && [ "$RELEASE" != "dapper" ]; then # Disable recommends for a smaller chroot (gutsy and later only) # Add buildd tools - BUILD_PKGS="--no-install-recommends $BUILD_PKGS pkg-create-dbgsym pkgbinarymangler" + # No need to do this for debian, --flavour=build in cdebootstrap + # takes care of it. + if [ ! $DEBIAN ]; then + BUILD_PKGS="--no-install-recommends $BUILD_PKGS" + fi fi sudo bash -c "cat >> $MNT/finish.sh" < ${MNT}/finish.sh" sudo chmod +x "$MNT"/finish.sh sudo umount "$MNT" rmdir "$MNT"