From 7212902eb88751d399c6e27b35c1f04f680b94b1 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 24 Apr 2011 20:36:27 +0200 Subject: [PATCH] Understand Debian distribution synonyms, and store the chroot under the code name. --- debian/changelog | 6 +++-- mk-sbuild | 57 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/debian/changelog b/debian/changelog index d96bbb1..c2d5ddc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -ubuntu-dev-tools (0.123) UNRELEASED; urgency=low +ubuntu-dev-tools (0.124) UNRELEASED; urgency=low * mk-sbuild: - Disable daemons with a policy-rc.d script (like pbuilder does) @@ -9,8 +9,10 @@ ubuntu-dev-tools (0.123) UNRELEASED; urgency=low - Install qemu-user-static instead of qemu-kvm-extras-static. - Correctly substitute release into security suite name. - Put schroot configuration in chroot.d/sbuild-$chroot (LP: #736808) + - Understand Debian distribution synonyms, and store the chroot under the + code name. - -- Stefano Rivera Sun, 24 Apr 2011 12:45:31 +0200 + -- Stefano Rivera Sun, 24 Apr 2011 20:35:51 +0200 ubuntu-dev-tools (0.122) unstable; urgency=low diff --git a/mk-sbuild b/mk-sbuild index 362491b..544f4a3 100755 --- a/mk-sbuild +++ b/mk-sbuild @@ -226,24 +226,48 @@ if [ -z "$RELEASE" ]; then usage fi -# Determine distribution -if [ -z "$DISTRO" ]; then - if debian-distro-info --all | grep -Fqx "$RELEASE"; then - DISTRO=debian - elif ubuntu-distro-info --all | grep -Fqx "$RELEASE"; then - DISTRO=ubuntu - elif [ "$RELEASE" = "unstable" -o "$RELEASE" = "testing" \ - -o "$RELEASE" = "stable" -o "$RELEASE" = "oldstable" ]; then - DISTRO=debian - else - echo "Unable to determine distribution, please provide --distro" >&2 - exit 1 +# Determine distribution and possible synonyms +synonym="" +if debian-distro-info --all | grep -Fqx "$RELEASE"; then + DISTRO="${DISTRO:-debian}" + if [ "$RELEASE" = $(debian-distro-info --devel) ]; then + synonym=unstable + elif [ "$RELEASE" = $(debian-distro-info --testing) ]; then + synonym=testing + elif [ "$RELEASE" = $(debian-distro-info --stable) ]; then + synonym=stable + elif [ "$RELEASE" = $(debian-distro-info --old) ]; then + synonym=oldstable fi +elif ubuntu-distro-info --all | grep -Fqx "$RELEASE"; then + DISTRO="${DISTRO:-ubuntu}" +elif [ "$RELEASE" = "unstable" ]; then + DISTRO="${DISTRO:-debian}" + synonym="$RELEASE" + RELEASE=$(debian-distro-info --devel) +elif [ "$RELEASE" = "testing" ]; then + DISTRO="${DISTRO:-debian}" + synonym="$RELEASE" + RELEASE=$(debian-distro-info --testing) +elif [ "$RELEASE" = "stable" ]; then + DISTRO="${DISTRO:-debian}" + synonym="$RELEASE" + RELEASE=$(debian-distro-info --stable) +elif [ "$RELEASE" = "oldstable" ]; then + DISTRO="${DISTRO:-debian}" + synonym="$RELEASE" + RELEASE=$(debian-distro-info --old) +elif [ -z "$DISTRO" ]; then + echo "Unable to determine distribution, please provide --distro" >&2 + exit 1 fi # By default, name the schroot the same as the release if [ -z "$name" ]; then name="$RELEASE" +else + # Disable synonym when a custom name is used: + synonym="" fi # By default, use the native architecture. @@ -254,6 +278,12 @@ fi CHROOT_NAME="${name}-${CHROOT_ARCH}" +if [ -z "$synonym" ]; then + CHROOT_SYNONYM="" +else + CHROOT_SYNONYM="${synonym}-${CHROOT_ARCH}" +fi + # Load customizations if [ -r ~/.mk-sbuild.rc ]; then . ~/.mk-sbuild.rc @@ -548,6 +578,9 @@ fi if [ ! -z "$personality" ]; then echo "personality=$personality" >> "$TEMP_SCHROOTCONF" fi +if [ ! -z "$CHROOT_SYNONYM" ]; then + echo "aliases=$CHROOT_SYNONYM" >> "$TEMP_SCHROOTCONF" +fi if [ ! -z "$SCHROOT_CONF_SUFFIX" ]; then echo "$SCHROOT_CONF_SUFFIX" >> "$TEMP_SCHROOTCONF" fi