summaryrefslogtreecommitdiff
path: root/localcowbuilder-create
blob: 94264c06f6880ef41629f78a37660e44d6f3f1d8 (plain)
  1. #!/bin/sh
  2. set -e
  3. PRG=$(basename "$0")
  4. exit() {
  5. echo "ERROR: $1"
  6. exit 1
  7. }
  8. showhelp() {
  9. cat <<EOF
  10. Usage: $PRG POOL [ DISTRIBUTION [ OTHERMIRROR] ]
  11. Examples:
  12. $PRG sarge
  13. $PRG sarge+hacks sarge 'deb http://example.com/ sarge hacks'
  14. EOF
  15. }
  16. if [ $# -eq 0 ]; then
  17. showhelp
  18. exit1 "not enough parameters"
  19. fi
  20. pool=$1
  21. distro=${2:-$pool}
  22. basepath="/var/cache/pbuilder/cow-$pool"
  23. aptcache="/var/cache/pbuilder/aptcache-$pool/"
  24. buildresult="$HOME/src/pbuild-$pool/"
  25. makepaths=''
  26. for path in "$basepath" "$aptcache" "$buildresult"; do
  27. if [ ! -d "$path" ]; then
  28. echo "W: path \"$path\" does not exist"
  29. makepaths='yes'
  30. fi
  31. done
  32. if [ "$makepaths" = 'yes' ]; then
  33. if [ "$force" != 'yes' ]; then
  34. echo -n 'Create the missing paths (y/N)? '
  35. read response
  36. case "$response" in
  37. y|Y)
  38. :
  39. ;;
  40. *)
  41. exit1 "Cannot continue without those missing paths"
  42. ;;
  43. esac
  44. fi
  45. mkdir -p "$buildresult"
  46. sudo mkdir -p "$basepath" "$aptcache"
  47. i
  48. sudo cowbuilder --create \
  49. --buildresult "$buildresult" \
  50. --distribution "$distro" \
  51. --basepath "$basepath" \
  52. --aptcache "$aptcache" \
  53. ${3:+--othermirror "$3"}