dpkg-buildpackage.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. set -e
  3. version="1.3.0"; # This line modified by Makefile
  4. progname="`basename \"$0\"`"
  5. usageversion () {
  6. cat >&2 <<END
  7. Debian GNU/Linux dpkg-buildpackage $version. Copyright (C) 1996
  8. Ian Jackson. This is free software; see the GNU General Public Licence
  9. version 2 or later for copying conditions. There is NO warranty.
  10. Usage: dpkg-buildpackage [options]
  11. Options: -r<gain-root-command>
  12. -p<pgp-command>
  13. -b (binary-only)
  14. -B (binary-only, no arch-indep files)
  15. -us (unsigned source)
  16. -uc (unsigned changes)
  17. END
  18. }
  19. rootcommand=''
  20. pgpcommand=pgp
  21. signsource=signfile
  22. signchanges=signfile
  23. while [ $# != 0 ]
  24. do
  25. value="`echo x\"$1\" | sed -e 's/^x-.//'`"
  26. case "$1" in
  27. -h) usageversion; exit 0 ;;
  28. -r*) rootcommand="$value" ;;
  29. -p*) pgpcommand="$value" ;;
  30. -us) signsource=: ;;
  31. -uc) signchanges=: ;;
  32. -b|-B) binaryonly=$1 ;;
  33. *) echo >&2 "$progname: unknown option or argument $1"
  34. usageversion; exit 2 ;;
  35. esac
  36. shift
  37. done
  38. mustsetvar () {
  39. if [ "x$2" = x ]; then
  40. echo >&2 "$progname: unable to determine $3"
  41. exit 1
  42. else
  43. echo "$progname: $3 is $2"
  44. eval "$1=\"\$2\""
  45. fi
  46. }
  47. curd="`pwd`"
  48. dirn="`basename \"$curd\"`"
  49. mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" "source package"
  50. mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" "source version"
  51. mustsetvar arch "`dpkg --print-architecture`" "build architecture"
  52. pv="${package}_${version}"
  53. pva="${package}_${version}_${arch}"
  54. signfile () {
  55. $pgpcommand -fast <"../$1" >"../$1.asc"
  56. mv -- "../$1.asc" "../$1"
  57. }
  58. set -x -e
  59. $rootcommand debian/rules clean
  60. if [ x$binaryonly = x ]; then
  61. cd ..; dpkg-source -b "$dirn"; cd "$dirn"
  62. fi
  63. debian/rules build
  64. $rootcommand debian/rules binary
  65. $signsource "$pv.dsc"
  66. dpkg-genchanges $binaryonly >../"$pva.changes"
  67. $signchanges "$pva.changes"