blob: 14495d390893a2fddaab6bac9751e06f7c8013e4 (
plain)
- #!/bin/sh
- set -e
- PRG=$(basename "$0")
- showhelp() {
- cat <<EOF
- Usage: $PRG POOL [ DISTRIBUTION [ OTHERMIRROR] ]
- Examples:
- $PRG sarge
- $PRG sarge+hacks sarge 'deb http://example.com/ sarge hacks'
- 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"
- fi
- pool=$1
- distro=${2:-$pool}
- basepath="/var/cache/pbuilder/cow-$pool"
- aptcache="/var/cache/pbuilder/aptcache-$pool/"
- buildresult="$HOME/src/pbuild-$pool/"
- makepaths=''
- for path in "$aptcache" "$buildresult"; do
- if [ ! -d "$path" ]; then
- echo "W: Needed path \"$path\" does not exist"
- makepaths='yes'
- fi
- done
- if [ "$makepaths" = 'yes' ]; then
- [ "$force" = 'yes' ] \
- || ask 'Create the missing path(s)' \
- || exit1 "Cannot continue without those missing paths"
- mkdir -p "$buildresult"
- 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" \
- --distribution "$distro" \
- --basepath "$basepath" \
- --aptcache "$aptcache" \
- ${3:+--othermirror "$3"}
|