From 7218468e18e4cb983e4da9b14642e7959114ad13 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 24 Apr 2011 16:17:55 +0200 Subject: [PATCH] Determine distribution from release name (via distro-info). --- debian/changelog | 1 + doc/mk-sbuild.1 | 10 ++++------ mk-sbuild | 21 +++++++++++++++++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0dc02e0..7b29941 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ ubuntu-dev-tools (0.123) UNRELEASED; urgency=low - Disable daemons with a policy-rc.d script (like pbuilder does) - Move package installation after option parsing. - Exit 0 when showing help, and support -h. + - Determine distribution from release name (via distro-info). -- Stefano Rivera Sun, 24 Apr 2011 12:45:31 +0200 diff --git a/doc/mk-sbuild.1 b/doc/mk-sbuild.1 index b28053e..b31c99b 100644 --- a/doc/mk-sbuild.1 +++ b/doc/mk-sbuild.1 @@ -4,10 +4,7 @@ mk\-sbuild \- creates chroots via schroot and sbuild .SH SYNOPSIS -\fBmk\-sbuild\fR [\fB\-\-arch=ARCH\fR] [\fB\-\-name=NAME\fR] -[\fB\-\-personality=PERSONALITY\fR] [\fB\-\-debug\fR] [\fB\-\-source\-template=FILE\fR] -[\fB\-\-debootstrap\-mirror=URL\fR] [\fB\-\-distro=DISTRO\fR] -[\fB\-\-vg=VOLUME_GROUP\fR] [\fB\-\-type=SCHROOT_TYPE\fR] <\fBRelease\fR> +\fBmk\-sbuild\fR [\fIoptions\fR...] <\fIrelease\fR> .SH DESCRIPTION \fBmk\-sbuild\fR creates chroots via schroot and sbuild. @@ -47,8 +44,9 @@ argument. WARNING: be careful using this option as you can end up excluding essential package. See debootstrap (8) for more details. .TP .B \-\-distro=DISTRO -Enable distro-specific logic. Currently known distros: "ubuntu" (default) -and "debian". +Enable distro-specific logic. +When not provided, the distribution is determined from \fIrelease\fR. +Currently known distros: "\fBdebian\fR" and "\fBubuntu\fR". .TP .B \-\-vg=VOLUME_GROUP Specify a volume group, and subsequently use a default SCHROOT_TYPE of diff --git a/mk-sbuild b/mk-sbuild index 4bf14cf..e995738 100755 --- a/mk-sbuild +++ b/mk-sbuild @@ -5,6 +5,7 @@ # Kees Cook # Emmet Hikory # Scott Moser +# Stefano Rivera # # ################################################################## # @@ -52,7 +53,8 @@ function usage() echo " --debootstrap-include=list Comma separated list of packages to include" echo " --debootstrap-exclude=list Comma separated list of packages to exclude" echo " --distro=DISTRO Install specific distro:" - echo " 'ubuntu'(default), or 'debian'" + echo " 'ubuntu' or 'debian' " + echo " (defaults to determining from release name)" echo " --type=SCHROOT_TYPE Define the schroot type:" echo " 'directory'(default), 'file', or 'btrfs-snapshot'" echo " 'lvm-snapshot' is selected via --vg" @@ -84,7 +86,7 @@ OPTS=`getopt -o 'h' --long "help,debug,skip-updates,arch:,name:,source-template: eval set -- "$OPTS" VG="" -DISTRO="ubuntu" +DISTRO="" name="" while :; do case "$1" in @@ -224,6 +226,21 @@ 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 + fi +fi + # By default, name the schroot the same as the release if [ -z "$name" ]; then name="$RELEASE"