OLD | NEW |
(Empty) | |
| 1 #!/bin/bash -e |
| 2 |
| 3 # This takes one commandline argument, the name of the package. If no |
| 4 # name is given, then we'll end up just using the name associated with |
| 5 # an arbitrary .tar.gz file in the rootdir. That's fine: there's probably |
| 6 # only one. |
| 7 # |
| 8 # Run this from the 'packages' directory, just under rootdir |
| 9 |
| 10 ## Set LIB to lib if exporting a library, empty-string else |
| 11 LIB= |
| 12 #LIB=lib |
| 13 |
| 14 PACKAGE="$1" |
| 15 |
| 16 # We can only build Debian packages, if the Debian build tools are installed |
| 17 if [ \! -x /usr/bin/debuild ]; then |
| 18 echo "Cannot find /usr/bin/debuild. Not building Debian packages." 1>&2 |
| 19 exit 0 |
| 20 fi |
| 21 |
| 22 # Double-check we're in the packages directory, just under rootdir |
| 23 if [ \! -r ../Makefile -a \! -r ../INSTALL ]; then |
| 24 echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2 |
| 25 echo "Also, you must run \"make dist\" before running this script." 1>&2 |
| 26 exit 0 |
| 27 fi |
| 28 |
| 29 # Find the top directory for this package |
| 30 topdir="${PWD%/*}" |
| 31 |
| 32 # Find the tar archive built by "make dist" |
| 33 archive="$(basename "$(ls -1 ${topdir}/$PACKAGE*.tar.gz | tail -n 1)" .tar.gz)" |
| 34 if [ -z "${archive}" ]; then |
| 35 echo "Cannot find ../$PACKAGE*.tar.gz. Run \"make dist\" first." 1>&2 |
| 36 exit 0 |
| 37 fi |
| 38 |
| 39 # Create a pristine directory for building the Debian package files |
| 40 trap 'rm -rf '`pwd`/tmp'; exit $?' EXIT SIGHUP SIGINT SIGTERM |
| 41 |
| 42 rm -rf tmp |
| 43 mkdir -p tmp |
| 44 cd tmp |
| 45 |
| 46 # Debian has very specific requirements about the naming of build |
| 47 # directories, and tar archives. It also wants to write all generated |
| 48 # packages to the parent of the source directory. We accommodate these |
| 49 # requirements by building directly from the tar file. |
| 50 ln -s "${topdir}/${archive}.tar.gz" "${LIB}${archive}.orig.tar.gz" |
| 51 tar zfx "${LIB}${archive}.orig.tar.gz" |
| 52 [ -n "${LIB}" ] && mv "${archive}" "${LIB}${archive}" |
| 53 cd "${LIB}${archive}" |
| 54 # This is one of those 'specific requirements': where the deb control files live |
| 55 ln -s "packages/deb" "debian" |
| 56 |
| 57 # Now, we can call Debian's standard build tool |
| 58 debuild -uc -us |
| 59 cd ../.. # get back to the original top-level dir |
| 60 |
| 61 # We'll put the result in a subdirectory that's named after the OS version |
| 62 # we've made this .deb file for. |
| 63 destdir="debian-$(cat /etc/debian_version 2>/dev/null || echo UNKNOWN)" |
| 64 |
| 65 rm -rf "$destdir" |
| 66 mkdir -p "$destdir" |
| 67 mv $(find tmp -mindepth 1 -maxdepth 1 -type f) "$destdir" |
| 68 |
| 69 echo |
| 70 echo "The Debian package files are located in $PWD/$destdir" |
OLD | NEW |