Determine distribution from release name (via distro-info).

This commit is contained in:
Stefano Rivera 2011-04-24 16:17:55 +02:00
parent ebe04d88b0
commit 7218468e18
3 changed files with 24 additions and 8 deletions

1
debian/changelog vendored
View File

@ -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 <stefanor@debian.org> Sun, 24 Apr 2011 12:45:31 +0200

View File

@ -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

View File

@ -5,6 +5,7 @@
# Kees Cook <kees@ubuntu.com>
# Emmet Hikory <persia@ubuntu.com>
# Scott Moser <smoser@ubuntu.com>
# Stefano Rivera <stefanor@ubuntu.com>
#
# ##################################################################
#
@ -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"