home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / bin / dpkg-buildpackage < prev    next >
Encoding:
Text File  |  2001-09-18  |  3.9 KB  |  146 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. version=""; # This line modified by Makefile
  6.  
  7. progname="`basename \"$0\"`"
  8. usageversion () {
  9.     cat >&2 <<END
  10. Debian GNU/Linux dpkg-buildpackage $version.  Copyright (C) 1996
  11. Ian Jackson.  This is free software; see the GNU General Public Licence
  12. version 2 or later for copying conditions.  There is NO warranty.
  13.  
  14. Usage: dpkg-buildpackage [options]
  15. Options: -r<gain-root-command>
  16.          -p<pgp-command>
  17.          -us           unsigned source
  18.          -uc           unsigned changes
  19.          -a<arch>      architecture field of the changes _file_name_
  20.          -b            binary-only, do not build source } also passed to
  21.          -B            binary-only, no arch-indep files } dpkg-genchanges
  22.          -v<version>   changes since version <version>      }
  23.          -m<maint>     maintainer for release is <maint>    } only passed
  24.          -C<descfile>  changes are described in <descfile>  }  to dpkg-
  25.          -si (default) src includes orig for rev. 0 or 1    } genchanges
  26.          -sa           uploaded src always includes orig    }
  27.          -sd           uploaded src is diff and .dsc only   }
  28.          -tc           clean source tree when finished
  29.          -h            print this message
  30. END
  31. }
  32.  
  33. rootcommand=''
  34. pgpcommand=pgp
  35. signsource='withecho signfile'
  36. signchanges='withecho signfile'
  37. cleansource=false
  38. binarytarget=binary
  39. sourcestyle=''
  40. version=''
  41. since=''
  42. maint=''
  43. desc=''
  44.  
  45. while [ $# != 0 ]
  46. do
  47.     value="`echo x\"$1\" | sed -e 's/^x-.//'`"
  48.     case "$1" in
  49.     -h)    usageversion; exit 0 ;;
  50.     -r*)    rootcommand="$value" ;;
  51.     -p*)    pgpcommand="$value" ;;
  52.     -us)    signsource=: ;;
  53.     -uc)    signchanges=: ;;
  54.     -a*)    opt_a=1; arch="$value" ;;
  55.     -si)    sourcestyle=-si ;;
  56.     -sa)    sourcestyle=-sa ;;
  57.     -sd)    sourcestyle=-sd ;;
  58.     -tc)    cleansource=true ;;
  59.     -b)    binaryonly=-b ;;
  60.     -B)    binaryonly=-B; binarytarget=binary-arch ;;
  61.     -v*)    since="$value" ;;
  62.     -m*)    maint="$value" ;;
  63.     -C*)    descfile="$value" ;;
  64.     *)    echo >&2 "$progname: unknown option or argument $1"
  65.         usageversion; exit 2 ;;
  66.     esac
  67.     shift
  68. done
  69.  
  70. mustsetvar () {
  71.     if [ "x$2" = x ]; then
  72.         echo >&2 "$progname: unable to determine $3"
  73.         exit 1
  74.     else
  75.         echo "$progname: $3 is $2"
  76.         eval "$1=\"\$2\""
  77.     fi
  78. }
  79.  
  80. curd="`pwd`"
  81. dirn="`basename \"$curd\"`"
  82. mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" "source package"
  83. mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" "source version"
  84. if [ -n "$maint" ]; then maintainer="$maint"; 
  85. else mustsetvar maintainer "`dpkg-parsechangelog | sed -n 's/^Maintainer: //p'`" "source maintainer"; fi
  86. test "${opt_a}" \
  87.     || mustsetvar arch "`dpkg --print-architecture`" "build architecture"
  88.  
  89. sversion=`echo "$version" | perl -pe 's/^\d+://'`
  90. pv="${package}_${sversion}"
  91. pva="${package}_${sversion}${arch:+_${arch}}"
  92.  
  93. signfile () {
  94.     $pgpcommand -u "$maintainer" +clearsig=on -fast <"../$1" >"../$1.asc"
  95.     echo
  96.     mv -- "../$1.asc" "../$1"
  97. }
  98.  
  99. withecho () {
  100.         echo " $@" >&2
  101.     "$@"
  102. }
  103.  
  104. set -- $binaryonly $sourcestyle
  105. if [ -n "$maint"    ]; then set -- "$@" "-m$maint"        ; fi
  106. if [ -n "$since"    ]; then set -- "$@" "-v$since"        ; fi
  107. if [ -n "$desc"        ]; then set -- "$@" "-C$desc"        ; fi
  108.  
  109. withecho $rootcommand debian/rules clean
  110. if [ x$binaryonly = x ]; then
  111.     cd ..; withecho dpkg-source -b "$dirn"; cd "$dirn"
  112. fi
  113. withecho debian/rules build
  114. withecho $rootcommand debian/rules $binarytarget
  115. if [ x$binaryonly = x ]; then
  116.         $signsource "$pv.dsc"
  117. fi
  118. chg=../"$pva.changes"
  119. withecho dpkg-genchanges "$@" >"$chg"
  120.  
  121. fileomitted () {
  122.     set +e
  123.     test -z "`sed -n '/^Files:/,/^[^ ]/ s/'$1'$//p' <$chg`"
  124.     fir=$?
  125.     set -e
  126.     return $fir
  127. }    
  128.  
  129. if fileomitted '\.dsc'; then
  130.     srcmsg='no source included in upload'
  131. elif fileomitted '\.diff\.gz'; then
  132.     srcmsg='Debian-specific package; upload is full source'
  133. elif fileomitted '\.orig\.tar\.gz'; then
  134.     srcmsg='diff-only upload (original source NOT included)'
  135. else
  136.     srcmsg='full upload (original source is included)'
  137. fi
  138.  
  139. $signchanges "$pva.changes"
  140.  
  141. if $cleansource; then
  142.     withecho $rootcommand debian/rules clean
  143. fi
  144.  
  145. echo "dpkg-buildpackage: $srcmsg"
  146.