summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalcowbuilder-create35
1 files changed, 20 insertions, 15 deletions
diff --git a/localcowbuilder-create b/localcowbuilder-create
index 8edf579..f64e095 100755
--- a/localcowbuilder-create
+++ b/localcowbuilder-create
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright © 2006-2008 Jonas Smedegaard <dr@jones.dk>
+# Copyright © 2006-2011 Jonas Smedegaard <dr@jones.dk>
# Description: Create Copy-On-Write environment
#
# This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@ PRG=$(basename "$0")
showhelp() {
cat <<EOF
-Usage: $PRG POOL [ DISTRIBUTION [ OTHERMIRROR] ]
+Usage: $PRG POOL [ DISTRIBUTION [ OTHERMIRROR ... ] ]
Examples:
$PRG sid
@@ -61,6 +61,9 @@ fi
pool=
distro=
+arch=
+newline='
+'
while [ $# -gt 0 ]; do
case $1 in
-h|--help)
@@ -68,16 +71,15 @@ while [ $# -gt 0 ]; do
exit 0
;;
--arch|-a)
- opts="$opts --debootstrapopts --arch --debootstrapopts $2"
- shift 2
+ arch="$2"
+ shift 2 || exit1 "option \"--arg\" requires an argument"
;;
--)
shift
break
;;
--*|-*)
- opts="$opts $1"
- shift
+ exit1 "options (apart from --arch) are curently unsupported"
;;
*)
if [ -z "$pool" ]; then
@@ -85,13 +87,16 @@ while [ $# -gt 0 ]; do
elif [ -z "$distro" ]; then
distro="$1"
else
- othermirrors="$othermirrors --othermirror \"$1\""
+ othermirrors="${othermirrors:+$othermirrors$newline}$1"
fi
shift
;;
esac
done
+if [ -z "$pool" ]; then
+ exit1 "no pool provided"
+fi
if [ -z "$distro" ]; then
distro="$pool"
fi
@@ -115,17 +120,17 @@ if [ "$makepaths" = 'yes' ]; then
fi
if [ -d "$basepath" ]; then
- echo "W: Needed path \"$path\" already exists"
+ echo "W: Needed path \"$basepath\" already exists"
[ "$force" = 'yes' ] \
|| ask 'Remove the path' \
|| exit1 "Cannot continue with that path already there"
sudo rm -rf "$basepath"
fi
-sudo cowbuilder --create \
- --buildresult "$buildresult" \
- --distribution "$distro" \
- --basepath "$basepath" \
- --aptcache "$aptcache" \
- $othermirrors \
- $opts $@
+if [ -n "$arch" ]; then
+echo "$othermirrors" | perl -e "while (<>) {/\w/ and unshift @m, '--othermirror', \$_};"\
+"exec 'sudo', 'cowbuilder', '--create', '--buildresult', '$buildresult', '--distribution', '$distro', '--basepath', '$basepath', '--aptcache', '$aptcache', '--debootstrapopts', '--arch', '--debootstrapopts', '$arch', @m"
+else
+echo "$othermirrors" | perl -e "while (<>) {/\w/ and unshift @m, '--othermirror', \$_};"\
+"exec 'sudo', 'cowbuilder', '--create', '--buildresult', '$buildresult', '--distribution', '$distro', '--basepath', '$basepath', '--aptcache', '$aptcache', @m"
+fi