From 58cc975f127c5b2d05eb5b5b57b8437604d21edd Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Mon, 30 Mar 2009 12:40:15 -0700 Subject: [PATCH] * mk-sbuild-lv: - Fully handle missing build log directories (LP: #342154). - More generalized approach to Distro-specific logic (LP: #342158). --- debian/changelog | 12 ++++-- doc/mk-sbuild-lv.1 | 5 ++- mk-sbuild-lv | 95 +++++++++++++++++++++++++++++----------------- 3 files changed, 72 insertions(+), 40 deletions(-) diff --git a/debian/changelog b/debian/changelog index 2128255..10c6551 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,17 +7,21 @@ ubuntu-dev-tools (0.72) UNRELEASED; urgency=low [ Siegfried-Angel Gevatter Pujals ] * pbuilder-dist: - Add squeeze as a Debian distribution. Thanks to Marco Rodrigues. - + [ Nathan Handler ] * pull-debian-source: - Add support for etch/oldstable - Make script work for codenames (etch, lenny, squeeze, sid) - + [ Ryan Kavanagh ] - * Fixed mk-sbuild-lv (s/DEBOOTSTRAP_MIRRORS/DEBOOTSTRAP_MIRROR/). * Ported devscripts' build-rdeps to Ubuntu and replaced reverse-build-depends. Updated it's manpage. (LP: #272273) - + + [ Kees Cook ] + * mk-sbuild-lv: + - Fully handle missing build log directories (LP: #342154). + - More generalized approach to Distro-specific logic (LP: #342158). + -- Nathan Handler Sat, 28 Mar 2009 15:19:26 +0100 ubuntu-dev-tools (0.71) jaunty; urgency=low diff --git a/doc/mk-sbuild-lv.1 b/doc/mk-sbuild-lv.1 index 7c5ff3a..406b9a9 100644 --- a/doc/mk-sbuild-lv.1 +++ b/doc/mk-sbuild-lv.1 @@ -36,8 +36,9 @@ Use FILE as the sources.list template (defaults to $HOME/.mk\-sbuild\-lv.sources 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. +.B \-\-distro +Enable distro-specific logic. Currently known distros: "ubuntu" (default) +and "debian". .SH ENVIRONMENT VARIABLES .TP diff --git a/mk-sbuild-lv b/mk-sbuild-lv index c6631b4..3aec1d8 100755 --- a/mk-sbuild-lv +++ b/mk-sbuild-lv @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright 2006-2007 (C) Canonical Ltd. -# Created by Kees Cook +# Copyright 2006-2009 (C) Canonical Ltd. +# Author: Kees Cook # # ################################################################## # @@ -9,7 +9,7 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 3 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -23,19 +23,7 @@ # Much love to "man sbuild-setup", https://wiki.ubuntu.com/PbuilderHowto, # and https://help.ubuntu.com/community/SbuildLVMHowto. # -# It assumes that sbuild has not be installed and configured before. -# -# If using schroot earlier than 1.1.4-1, it's a good idea to apply the -# process-cleaning patch to /etc/schroot/setup.d/10mount. Without this, any -# processes left running from the build (like cron, dbus, etc) will stop -# schroot from umounting and shutting down cleanly: -# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391319 -# -# If using sbuild 0.50 or earlier, and you intend to use the "arch" argument -# to do i386 builds on amd64, you will need to patch "sbuild" to correctly -# detect the chroot architecture: -# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=392992 - +# It will deal with sbuild having not be installed and configured before. set -e # Make sure we've got a regular user @@ -116,12 +104,15 @@ 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 " --distro=DISTRO Install specific distro (defaults to 'ubuntu')" echo "" echo "Configuration (via ~/.mk-sbuild-lv.rc)" echo " LV_SIZE Size of source LVs (default ${LV_SIZE})" echo " SNAPSHOT_SIZE Size of snapshot LVs (default ${SNAPSHOT_SIZE})" echo " SCHROOT_CONF_SUFFIX Lines to append to schroot.conf entries" echo " SKIP_UPDATES Enable --skip-updates" + echo " TEMPLATE_SOURCES A template for sources.list" + echo " TEMPLATE_SCHROOTCONF A template for schroot.conf stanza" exit 1 } @@ -129,9 +120,10 @@ 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:,distro:" -- "$@"` eval set -- "$OPTS" +DISTRO="ubuntu" name="" while :; do case "$1" in @@ -173,6 +165,10 @@ while :; do DEBOOTSTRAP_MIRROR="$2" shift 2 ;; + --distro) + DISTRO="$2" + shift 2 + ;; --) shift break @@ -206,12 +202,6 @@ if [ -r ~/.mk-sbuild-lv.rc ]; then . ~/.mk-sbuild-lv.rc fi -# Settings check. -if [ $DEBIAN ] && [ ! -x /usr/bin/cdebootstrap ]; then - echo "Please install the cdebootstrap package to create a Debian schroot." - exit 1 -fi - # Does the specified VG exist? (vgdisplay doesn't set error codes...) if [ `sudo vgdisplay -c "$VG" | wc -l` -eq 0 ]; then exit 1 @@ -225,10 +215,47 @@ else variant_opt="--variant=buildd" fi -# are we doing an lpia build? -if [ -z "$DEBOOTSTRAP_MIRROR" ] && [ "$arch_opt" = "--arch lpia" ]; then - DEBOOTSTRAP_MIRROR="http://ports.ubuntu.com/" -fi +# Handle distro-specific logic, unknown to debootstrap +case "$DISTRO" in +ubuntu) + # are we doing an lpia build? + if [ -z "$DEBOOTSTRAP_MIRROR" ] && [ "$arch_opt" = "--arch lpia" ]; then + DEBOOTSTRAP_MIRROR="http://ports.ubuntu.com/" + fi + if [ -z "$DEBOOTSTRAP_MIRROR" ]; then + DEBOOTSTRAP_MIRROR="http://archive.ubuntu.com/ubuntu" + fi + if [ -z "$COMPONENTS" ]; then + COMPONENTS="main restricted universe multiverse" + fi + if [ -z "$SOURCES_SECURITY_SUITE" ]; then + SOURCES_SECURITY_SUITE="RELEASE-updates" + fi + if [ -z "$SOURCES_SECURITY_URL" ]; then + SOURCES_SECURITY_URL="http://security.ubuntu.com/ubuntu" + fi + ;; +debian) + if [ -z "$DEBOOTSTRAP_MIRROR" ]; then + DEBOOTSTRAP_MIRROR="http://ftp.debian.org/debian" + fi + if [ -z "$COMPONENTS" ]; then + COMPONENTS="main non-free contrib" + fi + # Debian only performs security updates + SKIP_UPDATES=1 + if [ -z "$SOURCES_SECURITY_SUITE" ]; then + SOURCES_SECURITY_SUITE="RELEASE/updates" + fi + if [ -z "$SOURCES_SECURITY_URL" ]; then + SOURCES_SECURITY_URL="http://security.debian.org/" + fi + ;; +*) + echo "Unknown --distro '$DISTRO': aborting" >&2 + exit 1 + ;; +esac # Allocate the "golden" chroot LV sudo lvcreate -n "$CHROOT_LV" -L "$LV_SIZE" "$VG" @@ -247,18 +274,18 @@ if [ -r "$TEMPLATE_SOURCES" ]; then cat "$TEMPLATE_SOURCES" > "$TEMP_SOURCES" else cat > "$TEMP_SOURCES" <> "$TEMP_SOURCES" <> "$TEMP_SOURCES" <