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