#! /bin/sh umask 022 VERSION=`cat version.txt` DEBVMAJ=`cat /etc/debian_version | cut -f 1 -d .` case "X$DEBVMAJ" in "X8") DEBVMAJ="jessie" cp debian/control8 debian/control ;; "X9") DEBVMAJ="stretch" cp debian/control9 debian/control ;; "X10") DEBVMAJ="buster" ;; "X") echo 'E: Not on a Debian system' exit 1 ;; *) echo 'E: Can not handle Debian major version' $DEBVMAJ exit 1 ;; esac # Make sure to run the script as unprivileged user if [ "X$LOGNAME" = "Xroot" ] then echo 'ERROR: This script must not be run as root!' exit 1 fi # Make sure we are in the correct directory if [ "X$VERSION" = "X" ] then echo 'ERROR: Failed to find version number!' echo 'Make sure to call this script in the correct directory!' exit 1 fi # Make sure the original archive is still in the parent directory if [ ! -f ../dktools-${VERSION}.tar.gz ] then echo 'ERROR: File' ../dktools-${VERSION}.tar.gz 'not found!' exit 1 fi # Create a .orig copy of the original archive if [ -f ../dktools_${VERSION}.orig.tar.gz ] then rm -f ../dktools_${VERSION}.orig.tar.gz fi ln ../dktools-${VERSION}.tar.gz ../dktools_${VERSION}.orig.tar.gz # The 'debian' subdirectory must be present if [ ! -d debian ] then echo 'ERROR: Missing directory debian!' exit 1 fi NP=`nproc` if [ "X" != "X$NP" -a "$NP" -gt 1 ] then MAKEFLAGS="-j$NP" fi # Build the package, save output for later inspection if [ "X$DEB_SIGN_KEYID" != "X" ] then dpkg-buildpackage $MAKEFLAGS 2>&1 | tee ../dpkg-buildpackage.out else dpkg-buildpackage -us -uc $MAKEFLAGS 2>&1 | tee ../dpkg-buildpackage.out fi # Finally list the created packages and show some notes echo 'If the dpkg-buildpackage command succeeded, you should find the' echo '*.deb archive in the parent directory.' echo '' ls -l ../dktools*${VERSION}*.deb echo '' echo 'Otherwise you should inspect the ../dpkg-buildpackage.out file' echo 'for error messages.' echo '' exit 0