This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
forked from NEAT-project/usrsctp-neat
-
Notifications
You must be signed in to change notification settings - Fork 2
/
make-deb
executable file
·329 lines (284 loc) · 12.1 KB
/
make-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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/bash -e
# $Id: make-deb 2770 2013-05-30 08:46:46Z dreibh $
#
# Debian Packaging Scripts
# Copyright (C) 2002-2017 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: dreibh@iem.uni-due.de
# ---------------------------------------------------------------------------
# USAGE:
# ./make-deb default => for Ubuntu REVU
# Note: Replaces "Maintainer" by Ubuntu Developers and
# writes original maintainer entry to "XSBC-Original-Maintainer"
# ./make-deb unstable => for Debian Mentors
# ./make-deb natty|maverick|... => for Launchpad PPA
# ---------------------------------------------------------------------------
DISTRIBUTIONS=`\
( \
while [ x$1 != "x" ] ; do \
echo $1
shift
done \
) | sort -u`
if [ "$DISTRIBUTIONS" == "" ] ; then
DISTRIBUTIONS="default"
fi
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
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Calling wrap-and-sort ==========================================\x1b[0m"
echo -e ""
wrap-and-sort -a -v || exit 1
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Creating upstream package ======================================\x1b[0m"
echo -e ""
UPSTREAM_PACKAGE="`find . -maxdepth 1 -name "$PACKAGE-*.gz" -printf '%f'`"
UPSTREAM_PACKAGE_TYPE="gz"
if [ ! -e "$UPSTREAM_PACKAGE" ] ; then
UPSTREAM_PACKAGE="`find . -maxdepth 1 -name "$PACKAGE-*.bz2" -printf '%f'`"
UPSTREAM_PACKAGE_TYPE="bz2"
fi
if [ ! -e "$UPSTREAM_PACKAGE" ]; then
rm -f $PACKAGE-*.gz $PACKAGE"_"*.gz $PACKAGE-*.bz2 $PACKAGE"_"*.bz2
echo -e "\x1b[34m------ Running MAKE_DIST ... ------\x1b[0m"
echo "\$ $MAKE_DIST"
eval "$MAKE_DIST"
echo -e "\x1b[34m------ Looking for upstream package ... ------\x1b[0m"
UPSTREAM_PACKAGE="`find . -maxdepth 1 -name $PACKAGE-*.gz -printf '%f'`"
UPSTREAM_PACKAGE_TYPE="gz"
if [ ! -e "$UPSTREAM_PACKAGE" ] ; then
UPSTREAM_PACKAGE="`find . -maxdepth 1 -name $PACKAGE-*.bz2 -printf '%f'`"
UPSTREAM_PACKAGE_TYPE="bz2"
fi
if [ ! -e "$UPSTREAM_PACKAGE" ] ; then
echo -e "\x1b[34mERROR: No upstrem package found!\x1b[0m"
exit 1
fi
fi
echo -e ""
echo -e "\x1b[34m==> Upstream package is $UPSTREAM_PACKAGE (type is $UPSTREAM_PACKAGE_TYPE)\x1b[0m"
echo -e ""
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Creating packages ==============================================\x1b[0m"
for DISTRIBUTION in $DISTRIBUTIONS ; do
echo -e ""
echo -e "\x1b[34m------ Creating package for $DISTRIBUTION ------\x1b[0m"
success=1
cp ${UPSTREAM_PACKAGE} ${PACKAGE}_${UPSTREAM_VERSION}.orig.tar.$UPSTREAM_PACKAGE_TYPE
cp ${UPSTREAM_PACKAGE} ${PACKAGE}_$OUTPUT_VERSION.orig.tar.$UPSTREAM_PACKAGE_TYPE
cp ${UPSTREAM_PACKAGE} ${PACKAGE}_$DEBIAN_VERSION.orig.tar.$UPSTREAM_PACKAGE_TYPE
rm -rf ${PACKAGE}-${UPSTREAM_VERSION}
rm -rf ${PACKAGE}-${UPSTREAM_VERSION}.orig
if [ "$UPSTREAM_PACKAGE_TYPE" = "gz" ] ; then
tar xzf ${UPSTREAM_PACKAGE}
elif [ "$UPSTREAM_PACKAGE_TYPE" = "bz2" ] ; then
tar xjf ${UPSTREAM_PACKAGE}
else
echo 2>&1 "ERROR: Bad archive format: $UPSTREAM_PACKAGE"
exit 1
fi
cp -r ${PACKAGE}-${UPSTREAM_VERSION} ${PACKAGE}-${UPSTREAM_VERSION}.orig
cp -r debian ${PACKAGE}-${UPSTREAM_VERSION}
find ${PACKAGE}-${UPSTREAM_VERSION} -name .svn | xargs --no-run-if-empty rm -rf
cd ${PACKAGE}-${UPSTREAM_VERSION}
success=0
if [ $success -ne 0 ] ; then
exit 1
fi
if [ "$DISTRIBUTION" != "default" ] ; then
if [ "$DISTRIBUTION" = "unstable" -o "$DISTRIBUTION" = "testing" -o "$DISTRIBUTION" = "stable" ] ; then
# Debian: Also remove Launchpad Bug IDs.
sed -e "s/$PACKAGE_DISTRIBUTION;/$DISTRIBUTION;/1" \
-e "s/\(ubuntu\|ppa\)[0-9]//1" \
-e "/(LP: #/D" \
<debian/changelog | ../filter-empty-entries "$DEBIAN_LAST_ENTRY" >debian/changelog.new
else
# Ubuntu PPA
# Naming example: 2.7.7-0ubuntu1~natty1~ppa0
# Ubuntu: Also remove Debian Bug IDs.
sed -e "s/$PACKAGE_DISTRIBUTION;/$DISTRIBUTION;/1" \
-e "s/$PACKAGE_VERSION/$PACKAGE_VERSION~${DISTRIBUTION}1~ppa0/1" \
-e "/(Closes: #/D" \
<debian/changelog | ../filter-empty-entries "$UBUNTU_LAST_ENTRY" >debian/changelog.new
# ------ Old distributions not supporting c++/regex style symbols --
if [ "$DISTRIBUTION" = "dapper" -o \
"$DISTRIBUTION" = "edgy" -o \
"$DISTRIBUTION" = "feisty" -o \
"$DISTRIBUTION" = "hardy" -o \
"$DISTRIBUTION" = "intrepid" -o \
"$DISTRIBUTION" = "jaunty" -o \
"$DISTRIBUTION" = "karmic" -o \
"$DISTRIBUTION" = "lucid" ] ; then
# Just skip the symbols ...
find debian/ -maxdepth 1 -name "*.symbols" | xargs --no-run-if-empty rm -f
fi
fi
mv debian/changelog.new debian/changelog
# ------ Old distributions not supporting new Debian format -----------
if [ "$DISTRIBUTION" = "dapper" -o \
"$DISTRIBUTION" = "edgy" -o \
"$DISTRIBUTION" = "feisty" -o \
"$DISTRIBUTION" = "hardy" -o \
"$DISTRIBUTION" = "intrepid" -o \
"$DISTRIBUTION" = "jaunty" ] ; then
rm -rf debian/source
fi
# ---------------------------------------------------------------------
else
# Ubuntu: Remove Debian Bug IDs.
sed -e "/(Closes: #/D" \
<debian/changelog >debian/changelog.new
mv debian/changelog.new debian/changelog
sed -e "s/^Maintainer:/Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>\nXSBC-Original-Maintainer:/g" <debian/control >debian/control.new
mv debian/control.new debian/control
fi
echo -e ""
echo -e "\x1b[34m------ Creating diff file $PACKAGE-$PACKAGE_VERSION.diff.gz ------\x1b[0m"
(
cd ..
diff -urN "--exclude=*~" "--exclude=.svn" "--exclude=.git" \
$PACKAGE-$UPSTREAM_VERSION.orig $PACKAGE-$UPSTREAM_VERSION \
| gzip -c >$PACKAGE-$PACKAGE_VERSION.diff.gz
)
echo -e ""
echo -e "\x1b[34m------ Building source package ------\x1b[0m"
# Without signature:
# debuild -us -uc
# For sources:
# debuild -S
# For binaries:
# debuild -b
# Use -i to ignore .svn files!
if [ "$SKIP_PACKAGE_SIGNING" = "" ] ; then
SKIP_PACKAGE_SIGNING=0
fi
if [ $SKIP_PACKAGE_SIGNING -eq 1 ] ; then
# Build source package without signature:
debuild -us -uc -S "-k$MAINTAINER" -i || exit 1
else
# Build source package including signature:
debuild -sa -S "-k$MAINTAINER" -i || exit 1
fi
# Important: In /etc/pbuilderrc, set COMPONENTS="main universe"!
# Important: After that, update with option "--override-config"!
# sudo pbuilder update --override-config
cd ..
if [ "$DISTRIBUTION" = "unstable" -o \
"$DISTRIBUTION" = "testing" -o \
"$DISTRIBUTION" = "stable" -o \
"$DISTRIBUTION" = "default" ] ; then
if [ "$DISTRIBUTION" = "default" ] ; then
version=${PACKAGE_VERSION}
else
version=${DEBIAN_VERSION}
fi
dscFile=`ls ${PACKAGE}_${version}.dsc | tail -n1`
else
dscFile=`ls ${PACKAGE}_${PACKAGE_VERSION}~${DISTRIBUTION}[0-9]~ppa[0-9].dsc | tail -n1`
fi
if [ ! -e $dscFile ] ; then
echo -e "\x1b[34mERROR: $dscFile has not been generated successfully -> Aborting!\x1b[0m"
exit 1
fi
done
if [ -e "$UPSTREAM_PACKAGE.asc" ] ; then
rm -f "$UPSTREAM_PACKAGE.asc"
fi
if [ "$SKIP_PACKAGE_SIGNING" != "" -a ! $SKIP_PACKAGE_SIGNING -eq 1 ] ; then
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Sign upstream package ==========================================\x1b[0m"
echo -e ""
echo -e "\x1b[34mSigning upstream package $UPSTREAM_PACKAGE ...\x1b[0m"
gpg -sab "$UPSTREAM_PACKAGE"
fi
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Command overview ===============================================\x1b[0m"
echo -e ""
echo -e "\x1b[34mUpload to PPA:\x1b[0m"
for DISTRIBUTION in $DISTRIBUTIONS ; do
if [ "$DISTRIBUTION" = "unstable" -o \
"$DISTRIBUTION" = "testing" -o \
"$DISTRIBUTION" = "stable" -o \
"$DISTRIBUTION" = "default" ] ; then
if [ "$DISTRIBUTION" = "default" ] ; then
ppa="revu"
version=${PACKAGE_VERSION}
else
ppa="mentors"
version=${DEBIAN_VERSION}
fi
changesFile=`ls ${PACKAGE}_${version}_source.changes | tail -n1`
else
ppa="ppa"
changesFile=`ls ${PACKAGE}_${PACKAGE_VERSION}~${DISTRIBUTION}[0-9]~ppa[0-9]_source.changes | tail -n1`
fi
echo -e "\x1b[34m dput $ppa $changesFile\x1b[0m"
done
echo -e ""
if [ -e make-symbols ] ; then
echo -e "\x1b[34m################################################################\x1b[0m"
echo -e "\x1b[34mDo not forget to run make-symbols after library version changes!\x1b[0m"
echo -e "\x1b[34m################################################################\x1b[0m"
echo -e ""
fi
echo -e "\x1b[34mBuild Test Commands:\x1b[0m"
for DISTRIBUTION in $DISTRIBUTIONS ; do
if [ "$DISTRIBUTION" = "unstable" -o \
"$DISTRIBUTION" = "testing" -o \
"$DISTRIBUTION" = "stable" -o \
"$DISTRIBUTION" = "default" ] ; then
if [ "$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}~${DISTRIBUTION}[0-9]~ppa[0-9]_*.changes"
dscFile=`ls ${PACKAGE}_${PACKAGE_VERSION}~${DISTRIBUTION}[0-9]~ppa[0-9].dsc | tail -n1`
fi
echo -e "\x1b[34m sudo pbuilder build $dscFile && lintian -iIEv --pedantic /var/cache/pbuilder/result/$changesFilesPattern\x1b[0m"
done
echo -e ""