James Kuszmaul | 4cb043c | 2021-01-17 11:25:51 -0800 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | # $Id: build-deb 2770 2013-05-30 08:46:46Z dreibh $ |
| 3 | # |
| 4 | # Debian Packaging Scripts |
| 5 | # Copyright (C) 2002-2013 by Thomas Dreibholz |
| 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation, either version 3 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | # |
| 20 | # Contact: dreibh@iem.uni-due.de |
| 21 | |
| 22 | if [ ! -e ./debian.conf ] ; then |
| 23 | echo >&2 "ERROR: debian.conf does not exist -> no configuration for the new package!" |
| 24 | exit 1 |
| 25 | fi |
| 26 | . ./debian.conf |
| 27 | |
| 28 | OVERRIDE_PACKAGE_DISTRIBUTION="$1" |
| 29 | |
| 30 | |
| 31 | CHANGELOG_HEADER="`head -n1 debian/changelog`" |
| 32 | |
| 33 | # The package name, e.g. MyApplication |
| 34 | PACKAGE=`echo $CHANGELOG_HEADER | sed -e "s/(.*//" -e "s/ //g"` |
| 35 | # The package distribution, e.g. precise, raring, ... |
| 36 | PACKAGE_DISTRIBUTION=`echo $CHANGELOG_HEADER | sed -e "s/[^)]*)//" -e "s/;.*//g" -e "s/ //g"` |
| 37 | # The package's version, e.g. 1.2.3-1ubuntu1 |
| 38 | PACKAGE_VERSION=`echo $CHANGELOG_HEADER | sed -e "s/.*(//" -e "s/).*//" -e "s/ //g" -e "s/ //g" -e "s/^[0-9]://g"` |
| 39 | # The package's output version, e.g. 1.2.3-1ubuntu |
| 40 | OUTPUT_VERSION=`echo $PACKAGE_VERSION | sed -e "s/\(ubuntu\)[0-9]*$/\1/"` |
| 41 | # The package's Debian version, e.g. 1.2.3-1 |
| 42 | DEBIAN_VERSION=`echo $OUTPUT_VERSION | sed -e "s/ubuntu$//1"` |
| 43 | # The package's upstream version, e.g. 1.2.3 |
| 44 | UPSTREAM_VERSION=`echo $DEBIAN_VERSION | sed -e "s/-[0-9]*$//"` |
| 45 | # The package's plain upstream version, e.g. 1.2.3 (without e.g. ~svn<xxxx>) |
| 46 | PLAIN_VERSION=`echo $UPSTREAM_VERSION | sed -e "s/\([0-9\.]*\)[-+~].*$/\1/"` |
| 47 | |
| 48 | |
| 49 | echo -e "\x1b[34m######################################################################\x1b[0m" |
| 50 | echo -e "\x1b[34mCHANGELOG_HEADER: $CHANGELOG_HEADER\x1b[0m" |
| 51 | echo -e "\x1b[34mPACKAGE: $PACKAGE\x1b[0m" |
| 52 | echo -e "\x1b[34mPACKAGE_DISTRIBUTION: $PACKAGE_DISTRIBUTION\x1b[0m" |
| 53 | echo -e "\x1b[34mPACKAGE_VERSION $PACKAGE_VERSION\x1b[0m" |
| 54 | echo -e "\x1b[34mOUTPUT_VERSION: $OUTPUT_VERSION\x1b[0m" |
| 55 | echo -e "\x1b[34mDEBIAN_VERSION: $DEBIAN_VERSION\x1b[0m" |
| 56 | echo -e "\x1b[34mUPSTREAM_VERSION: $UPSTREAM_VERSION\x1b[0m" |
| 57 | echo -e "\x1b[34mPLAIN_VERSION: $PLAIN_VERSION\x1b[0m" |
| 58 | echo -e "\x1b[34m######################################################################\x1b[0m" |
| 59 | |
| 60 | |
| 61 | if [ "$OVERRIDE_PACKAGE_DISTRIBUTION" != "" ] ; then |
| 62 | PACKAGE_DISTRIBUTION="$OVERRIDE_PACKAGE_DISTRIBUTION" |
| 63 | echo "" |
| 64 | echo -e "\x1b[34m**** Overriding PACKAGE_DISTRIBUTION: PACKAGE_DISTRIBUTION=${PACKAGE_DISTRIBUTION}! ****\x1b[0m" |
| 65 | echo "" |
| 66 | fi |
| 67 | |
| 68 | |
| 69 | echo -e "" |
| 70 | echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Generating source package ======================================\x1b[0m" |
| 71 | echo -e "" |
| 72 | |
| 73 | sudo echo "" |
| 74 | ./clean-deb |
| 75 | ./make-deb ${PACKAGE_DISTRIBUTION} |
| 76 | |
| 77 | if [ "$PACKAGE_DISTRIBUTION" = "unstable" -o \ |
| 78 | "$PACKAGE_DISTRIBUTION" = "testing" -o \ |
| 79 | "$PACKAGE_DISTRIBUTION" = "stable" -o \ |
| 80 | "$PACKAGE_DISTRIBUTION" = "default" ] ; then |
| 81 | if [ "$PACKAGE_DISTRIBUTION" = "default" ] ; then |
| 82 | version=${PACKAGE_VERSION} |
| 83 | else |
| 84 | version=${DEBIAN_VERSION} |
| 85 | fi |
| 86 | changesFilesPattern="${PACKAGE}_${version}_*.changes" |
| 87 | dscFile=`ls ${PACKAGE}_${version}.dsc | tail -n1` |
| 88 | else |
| 89 | changesFilesPattern="${PACKAGE}_${PACKAGE_VERSION}~${PACKAGE_DISTRIBUTION}[0-9]~ppa[0-9]_*.changes" |
| 90 | dscFile=`ls ${PACKAGE}_${PACKAGE_VERSION}~${PACKAGE_DISTRIBUTION}[0-9]~ppa[0-9].dsc | tail -n1` |
| 91 | fi |
| 92 | |
| 93 | |
| 94 | echo -e "" |
| 95 | echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Building source package ========================================\x1b[0m" |
| 96 | echo -e "" |
| 97 | |
| 98 | if [ ! -e "$dscFile" ] ; then |
| 99 | echo >&2 "ERROR: Unable to find description file $dscFile!" |
| 100 | exit 1 |
| 101 | fi |
| 102 | sudo pbuilder build $dscFile |
| 103 | |
| 104 | |
| 105 | echo -e "" |
| 106 | echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Running lintian ================================================\x1b[0m" |
| 107 | echo -e "" |
| 108 | |
| 109 | changesFile=`find /var/cache/pbuilder/result/ -name "${changesFilesPattern}"` |
| 110 | if [ ! -e "$changesFile" ] ; then |
| 111 | echo >&2 "ERROR: Unable to find changes file $changesFile!" |
| 112 | exit 1 |
| 113 | fi |
| 114 | lintian -iIEv --pedantic $changesFilesPattern |