summaryrefslogtreecommitdiff
path: root/localcowbuilder-create
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2011-05-21 20:06:26 +0200
committerJonas Smedegaard <dr@jones.dk>2011-05-21 20:06:26 +0200
commit957962b586598378283e6872c983ba5cb6f5389a (patch)
tree674e979107d7c1a672fb7cb416608119fabf5e4b /localcowbuilder-create
parent35ec60f02489c9f81ac9ae37b3930353c2c37820 (diff)
Extend localcowbuilder-create to support multiple extramirrors.
Diffstat (limited to 'localcowbuilder-create')
-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