dpkg-buildpackage.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. -us unsigned source
  14. -uc unsigned changes
  15. -b binary-only, do not build source } also passed to
  16. -B binary-only, no arch-indep files } dpkg-genchanges
  17. -v<version> changes since version <version> }
  18. -m<maint> maintainer for release is <maint> } only passed
  19. -C<descfile> changes are described in <descfile> } to dpkg-
  20. -si (default) src includes orig for rev. 0 or 1 } genchanges
  21. -sa uploaded src includes orig (default) }
  22. -sd uploaded src is diff and .dsc only }
  23. -h print this message
  24. END
  25. }
  26. rootcommand=''
  27. pgpcommand=pgp
  28. signsource=signfile
  29. signchanges=signfile
  30. binarytarget=binary
  31. sourcestyle=''
  32. version=''
  33. maint=''
  34. desc=''
  35. while [ $# != 0 ]
  36. do
  37. value="`echo x\"$1\" | sed -e 's/^x-.//'`"
  38. case "$1" in
  39. -h) usageversion; exit 0 ;;
  40. -r*) rootcommand="$value" ;;
  41. -p*) pgpcommand="$value" ;;
  42. -us) signsource=: ;;
  43. -uc) signchanges=: ;;
  44. -si) sourcestyle=-si ;;
  45. -sa) sourcestyle=-sa ;;
  46. -sd) sourcestyle=-sd ;;
  47. -b) binaryonly=-b ;;
  48. -B) binaryonly=-b; binarytarget=binary-arch ;;
  49. -v*) version="$value" ;;
  50. -m*) maint="$value" ;;
  51. -C*) descfile="$value" ;;
  52. *) echo >&2 "$progname: unknown option or argument $1"
  53. usageversion; exit 2 ;;
  54. esac
  55. shift
  56. done
  57. mustsetvar () {
  58. if [ "x$2" = x ]; then
  59. echo >&2 "$progname: unable to determine $3"
  60. exit 1
  61. else
  62. echo "$progname: $3 is $2"
  63. eval "$1=\"\$2\""
  64. fi
  65. }
  66. curd="`pwd`"
  67. dirn="`basename \"$curd\"`"
  68. mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" "source package"
  69. mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" "source version"
  70. mustsetvar arch "`dpkg --print-architecture`" "build architecture"
  71. pv="${package}_${version}"
  72. pva="${package}_${version}_${arch}"
  73. signfile () {
  74. $pgpcommand -fast <"../$1" >"../$1.asc"
  75. mv -- "../$1.asc" "../$1"
  76. }
  77. set -- $binaryonly
  78. if [ -n "$maint" ]; then set -- "$@" "-m$maint" ; fi
  79. if [ -n "$version" ]; then set -- "$@" "-v$version" ; fi
  80. if [ -n "$desc" ]; then set -- "$@" "-C$desc" ; fi
  81. set -x
  82. $rootcommand debian/rules clean
  83. if [ x$binaryonly = x ]; then
  84. cd ..; dpkg-source -b "$dirn"; cd "$dirn"
  85. fi
  86. debian/rules build
  87. $rootcommand debian/rules $binarytarget
  88. $signsource "$pv.dsc"
  89. dpkg-genchanges $binaryonly $sourcestyle >../"$pva.changes"
  90. $signchanges "$pva.changes"