summaryrefslogtreecommitdiff
path: root/localcowbuilder-create
diff options
context:
space:
mode:
Diffstat (limited to 'localcowbuilder-create')
-rwxr-xr-xlocalcowbuilder-create55
1 files changed, 34 insertions, 21 deletions
diff --git a/localcowbuilder-create b/localcowbuilder-create
index 94264c0..14495d3 100755
--- a/localcowbuilder-create
+++ b/localcowbuilder-create
@@ -4,11 +4,6 @@ set -e
PRG=$(basename "$0")
-exit() {
- echo "ERROR: $1"
- exit 1
-}
-
showhelp() {
cat <<EOF
Usage: $PRG POOL [ DISTRIBUTION [ OTHERMIRROR] ]
@@ -19,6 +14,25 @@ Examples:
EOF
}
+exit1() {
+ echo "ERROR: $1"
+ exit 1
+}
+
+ask() {
+ echo -n "$1 (y/N)? "
+ read response
+ case "$response" in
+ y|Y)
+ :
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+ return
+}
+
if [ $# -eq 0 ]; then
showhelp
exit1 "not enough parameters"
@@ -32,28 +46,27 @@ aptcache="/var/cache/pbuilder/aptcache-$pool/"
buildresult="$HOME/src/pbuild-$pool/"
makepaths=''
-for path in "$basepath" "$aptcache" "$buildresult"; do
+for path in "$aptcache" "$buildresult"; do
if [ ! -d "$path" ]; then
- echo "W: path \"$path\" does not exist"
+ echo "W: Needed path \"$path\" does not exist"
makepaths='yes'
fi
done
if [ "$makepaths" = 'yes' ]; then
- if [ "$force" != 'yes' ]; then
- echo -n 'Create the missing paths (y/N)? '
- read response
- case "$response" in
- y|Y)
- :
- ;;
- *)
- exit1 "Cannot continue without those missing paths"
- ;;
- esac
- fi
+ [ "$force" = 'yes' ] \
+ || ask 'Create the missing path(s)' \
+ || exit1 "Cannot continue without those missing paths"
mkdir -p "$buildresult"
- sudo mkdir -p "$basepath" "$aptcache"
-i
+ sudo mkdir -p "$aptcache"
+fi
+
+if [ -d "$basepath" ]; then
+ echo "W: Needed path \"$path\" 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" \