dpkg-buildpackage.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 always includes orig }
  22. -sd uploaded src is diff and .dsc only }
  23. -h print this message
  24. END
  25. }
  26. rootcommand=''
  27. pgpcommand=pgp
  28. signsource='withecho signfile'
  29. signchanges='withecho 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 +clearsig=on -fast <"../$1" >"../$1.asc"
  75. echo
  76. mv -- "../$1.asc" "../$1"
  77. }
  78. withecho () {
  79. echo " $@" >&2
  80. "$@"
  81. }
  82. set -- $binaryonly
  83. if [ -n "$maint" ]; then set -- "$@" "-m$maint" ; fi
  84. if [ -n "$version" ]; then set -- "$@" "-v$version" ; fi
  85. if [ -n "$desc" ]; then set -- "$@" "-C$desc" ; fi
  86. withecho $rootcommand debian/rules clean
  87. if [ x$binaryonly = x ]; then
  88. cd ..; withecho dpkg-source -b "$dirn"; cd "$dirn"
  89. fi
  90. withecho debian/rules build
  91. withecho $rootcommand debian/rules $binarytarget
  92. $signsource "$pv.dsc"
  93. chg=../"$pva.changes"
  94. withecho dpkg-genchanges $binaryonly $sourcestyle >"$chg"
  95. fileomitted () {
  96. set +e
  97. test -z "`sed -n '/^Files:/,/^[^ ]/ s/'$1'$//p' <$chg`"
  98. fir=$?
  99. set -e
  100. return $fir
  101. }
  102. if fileomitted '\.dsc'; then
  103. srcmsg='no source included in upload'
  104. elif fileomitted '\.diff\.gz'; then
  105. srcmsg='Debian-specific package; upload is full source'
  106. elif fileomitted '\.orig\.tar\.gz'; then
  107. srcmsg='diff-only upload (original source NOT included)'
  108. else
  109. srcmsg='full upload (original source is included)'
  110. fi
  111. $signchanges "$pva.changes"
  112. echo "dpkg-buildpackage: $srcmsg"