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