diff options
author | Jonas Smedegaard <dr@jones.dk> | 2008-03-23 02:02:50 +0000 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2008-03-23 02:02:50 +0000 |
commit | b2ba56eb62499c5760fdde4bd3b598927ee9f495 (patch) | |
tree | bd40c29a8eaaf9c092fbba1a9c1e2b28a4efa4ba /localpbuilder-create | |
parent | 0d5de751e67f400dd1415992d08c84c08e477efa (diff) |
Major rewrite to use getopt, and support --arch.
Diffstat (limited to 'localpbuilder-create')
-rwxr-xr-x | localpbuilder-create | 84 |
1 files changed, 77 insertions, 7 deletions
diff --git a/localpbuilder-create b/localpbuilder-create index 944d451..cde3a92 100755 --- a/localpbuilder-create +++ b/localpbuilder-create @@ -4,33 +4,103 @@ set -e PRG=$(basename "$0") -function showhelp() { +showhelp() { cat <<EOF Usage: $PRG POOL [ DISTRIBUTION [ OTHERMIRROR] ] Examples: - $PRG sarge - $PRG sarge+hacks sarge 'deb http://example.com/ sarge hacks' + $PRG sid + $PRG sid+mm sid 'deb http://debian-multimedia.org/ sid main' + $PRG sid-ia32 sid --arch i386 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 - exit 1 + exit1 "not enough parameters" fi -pool=$1 -distro=${2:-$pool} +pool= +distro= +while [ $# -gt 0 ]; do + case $1 in + -h|--help) + showhelp + exit 0 + ;; + --arch|-a) + opts="$opts --debootstrapopts --arch --debootstrapopts $2" + shift 2 + ;; + --*|-*) + opts="$opts $1" + shift + ;; + --) + shift + break + ;; + *) + if [ -z "$pool" ]; then + pool="$1" + elif [ -z "$distro" ]; then + distro="$1" + else + othermirrors="$othermirrors --othermirror \"$1\"" + fi + shift + ;; + esac +done + +if [ -z "$distro" ]; then + distro="$pool" +fi basetgz="/var/cache/pbuilder/base-$pool.tgz" buildplace="/var/cache/pbuilder/build-$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 + sudo pbuilder create \ --buildresult "$buildresult" \ --distribution "$distro" \ --basetgz "$basetgz" \ --buildplace "$buildplace" \ --aptcache "$aptcache" \ - ${3:+--othermirror "$3"} + $othermirrors \ + $opts $@ |