-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakedeb
executable file
·507 lines (499 loc) · 20.4 KB
/
makedeb
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
#!/bin/bash
#################################################################
# makedeb
#
# Make a Debian installer package from source files
#
# Author: DA
# Company: CyberRadio Solutions, Inc.
# Copyright: Copyright (c) 2015-2022 CyberRadio Solutions, Inc.
# All rights reserved.
#################################################################
#################################################################
#
# usage: makedeb {options} [Source folder name]
#
# -v [TAG],--version=[TAG] Use version tag [TAG] rather than
# tagging with the default (either
# today's date or the version number
# from a setup.py/configure.ac file)
# -p [PACKAGE],--package=[PACKAGE] Use PACKAGE as the package name
# instead of basing the package name
# off of the source folder name
# -s [SUBGROUP],--subgroup=[SUBGROUP] For source folders that support
# subgroups, build only subgroup
# SUBGROUP instead of everything
# -n,--no-cleanup Do not clean up intermediate files
# after making the package
# -2, --python2 Force package to build under
# Python 2
# -3, --python3 Force package to build under
# Python 3
#
# Source folder MUST contain a "debian" sub-folder with package building
# information.
#
# The makedeb script can automatically determine package name and version
# number from a variety of sources. Sources are checked in the following
# order:
# (1) Version information file (version.txt)
# (2) Python distutils setup file (setup.py)
# (3) GNU Autotools configuration file (configure.ac)
# (4) CMake lists file (CMakeLists.txt)
#
#################################################################
print_usage()
{
echo "usage: $0 {options} [Source folder name]"
echo " "
echo "-v [TAG],--version=[TAG] Use version tag [TAG] rather than "
echo " tagging with the default (either "
echo " today's date or the version number "
echo " from a setup.py/configure.ac file)"
echo "-x [INFO],--extra=[INFO] Extra information to append to the "
echo " version tag"
echo "-p [PACKAGE],--package=[PACKAGE] Use PACKAGE as the package name "
echo " instead of basing the package name "
echo " off of the source folder name"
echo "-s [SUBGROUP],--subgroup=[SUBGROUP] For source folders that support "
echo " subgroups, build only subgroup "
echo " SUBGROUP instead of everything"
echo "-n,--no-cleanup Do not clean up intermediate files "
echo " after making the package"
echo "-2, --python2 Force package to build under"
echo " Python 2"
echo "-3, --python3 Force package to build under"
echo " Python 3"
echo " "
echo "Source folder MUST contain a \"debian\" sub-folder with package building "
echo "information."
echo " "
echo "The makedeb script can automatically determine package name and version"
echo "number from a variety of sources. Sources are checked in the following"
echo "order:"
echo "(1) Version information file (version.txt)"
echo "(2) Python distutils setup file (setup.py)"
echo "(3) GNU Autotools configuration file (configure.ac)"
echo "(4) CMake lists file (CMakeLists.txt)"
echo " "
}
exit_with_usage()
{
# $1: Exit code
# $2: Error message to display
echo "ERROR: $2"
echo " "
print_usage
exit $1
}
exit_if_error()
{
# $1: Exit code from prior command
if [ $1 -ne 0 ]
then
echo "ERROR: Command returned error code: $1"
echo "ERROR condition detected. Exiting script."
exit $1
fi
}
#########################################################
# Set options and variables
#########################################################
# SRC_FOLDER_NAME: Source folder name
# DEB_PKG_NAME: Debian package name
# DEB_PKG_VERSION: Debian package version
# DEB_PKG_VERSION_MAJOR: Debian package major version
# DEB_PKG_ARCH: Debian package architecture
# DEB_PKG_ARCH_GNU: Debian package GNU system type
# DEB_PKG_OS: Debian package OS name
# DEB_PKG_OS_VER: Debian package OS version number
# CLEANUP: Whether to do cleanup (1) or not (0)
# DEB_PKG_SUBGROUP: Subgroup of code to be included in package
DEB_PKG_VERSION=
DEB_PKG_EXTRA=
DEB_PKG_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH)
DEB_PKG_ARCH_GNU=$(dpkg-architecture -qDEB_BUILD_GNU_CPU)
DEB_PKG_OS=$(lsb_release -si)
DEB_PKG_OS_VER=$(lsb_release -sr)
CLEANUP=1
DEB_PKG_SUBGROUP=ALL
# Determine the default Python version (2 or 3) on the build machine.
# -- NOTE that some OSes don't have /usr/bin/python at all. In this
# case, fall back to /usr/bin/python3. -- DA
for PY_EXEC in /usr/bin/python /usr/bin/python3
do
if [ -e ${PY_EXEC} ]
then
PYTHON_EXECUTABLE=${PY_EXEC}
PYTHON_VERSION=$(${PY_EXEC} -V 2>&1 | cut -d. -f1)
break
fi
done
# Parse command-line options
set -- `getopt -n $0 -o hv:x:p:s:n23 -l "help version: extra: package: subgroup: no-cleanup python2 python3" -- "$@"`
while [ $# -gt 0 ]
do
case "$1" in
-v|--version)
DEB_PKG_VERSION=$(eval echo $2)
shift
;;
-x|--extra)
DEB_PKG_EXTRA=$(eval echo $2)
shift
;;
-p|--package)
DEB_PKG_NAME=$(eval echo $2)
shift
;;
-s|--subgroup)
DEB_PKG_SUBGROUP=$(eval echo $2)
shift
;;
-n|--no-cleanup)
CLEANUP=0
;;
-2|--python2)
PYTHON_VERSION="Python 2"
PYTHON_EXECUTABLE=/usr/bin/python2
;;
-3|--python3)
PYTHON_VERSION="Python 3"
PYTHON_EXECUTABLE=/usr/bin/python3
;;
-h|--help)
print_usage
exit 2
;;
-*)
break
;;
*)
SRC_FOLDER_NAME=$1
break
;;
esac
shift
done
# Get the source folder name from the command line, and make sure
# that there is no trailing slash (from bash command line completion
# or some other source)
if [ $# -gt 1 ]
then
SRC_FOLDER_NAME=$(eval echo $2)
exit_if_error $? "Source folder name is not a directory or does not exist."
SRC_FOLDER_NAME=${SRC_FOLDER_NAME%/}
# Sanity check: Make sure source folder provided is actually a folder
if [ ! -d "${SRC_FOLDER_NAME}" ]
then
exit_if_error $? "Source folder name is not a directory or does not exist."
fi
fi
# Use the installed version of gnuradio-dev to determine build/runtime
# dependencies for packages involving GNU Radio
GNURADIO_DEV_VERSION=$(dpkg -s gnuradio-dev 2>/dev/null | grep 'Version:' | sed -e 's/Version: //g')
dpkg --compare-versions "${GNURADIO_DEV_VERSION}" "ge" "3.8"
if [ $? -eq 0 ]
then
DEB_GNURADIO_PKG_DEP="gnuradio (>= 3.8)"
DEB_GNURADIO_DEV_PKG_DEP="gnuradio-dev (>= 3.8)"
else
DEB_GNURADIO_PKG_DEP="gnuradio (<< 3.8)"
DEB_GNURADIO_DEV_PKG_DEP="gnuradio-dev (<< 3.8)"
fi
# For GNU Radio out-of-tree module packages (that is, the source folder
# name starts with "gr-"), automatically target the Python version used by
# whatever version of GNU Radio we are using
if [[ $(basename ${SRC_FOLDER_NAME}) == gr-* ]]
then
dpkg --compare-versions "${GNURADIO_DEV_VERSION}" "ge" "3.8"
if [ $? -eq 0 ]
then
PYTHON_VERSION="Python 3"
else
PYTHON_VERSION="Python 2"
fi
fi
# Set some configuration variables based on which Python version we are
# using.
DEB_PYTHON2_EXECUTABLE=/usr/bin/python2
DEB_PYTHON3_EXECUTABLE=/usr/bin/python3
if [ "${PYTHON_VERSION}" == "Python 3" ]
then
DEB_PYTHON_EXECUTABLE=/usr/bin/python3
DEB_PYTHON_PKG_PREFIX=python3
DEB_PYTHON_PKG_DEP="python3 (>= 3.5)"
DEB_PYTHON_XPY_DEP="X-Python3-Version: >= 3.5"
DEB_PYTHON_DHPY=python3
DEB_TWISTD_EXECUTABLE=/usr/bin/twistd3
else
DEB_PYTHON_EXECUTABLE=/usr/bin/python2
DEB_PYTHON_PKG_PREFIX=python
DEB_PYTHON_PKG_DEP="python (>= 2.7)"
DEB_PYTHON_XPY_DEP="X-Python-Version: >= 2.7"
DEB_PYTHON_DHPY=python2
DEB_TWISTD_EXECUTABLE=/usr/bin/twistd
fi
# If the source folder contains a version.txt file, extract the package
# name and package version number from the file, if the user didn't
# override them on the command line
if [ -e ${SRC_FOLDER_NAME}/version.txt ]
then
QQQ=$(< ${SRC_FOLDER_NAME}/version.txt )
exit_if_error $? "Failed to obtain version info from version.txt."
eval ZZZ=(${QQQ})
exit_if_error $? "Failed to obtain version info from version.txt."
if [ -z ${DEB_PKG_NAME} ]
then
DEB_PKG_NAME=${ZZZ[0]}
fi
if [ -z ${DEB_PKG_VERSION} ]
then
DEB_PKG_VERSION=${ZZZ[1]}
fi
# Or, if the source folder contains a setup.py file, use the
# package name (prepending "python-" or "python3-", depending on Python
# version) and package version number provided by the setup.py file, if
# the user didn't override them on the command line
elif [ -e ${SRC_FOLDER_NAME}/setup.py ]
then
QQQ=$(${PYTHON_EXECUTABLE} ${SRC_FOLDER_NAME}/setup.py --name --version)
exit_if_error $? "Failed to obtain version info from setup.py."
eval ZZZ=(${QQQ})
exit_if_error $? "Failed to obtain version info from setup.py."
if [ -z ${DEB_PKG_NAME} ]
then
DEB_PKG_NAME=${DEB_PYTHON_PKG_PREFIX}-${ZZZ[0]}
fi
if [ -z ${DEB_PKG_VERSION} ]
then
DEB_PKG_VERSION=${ZZZ[1]}
fi
# Or, if the source folder contains a configure.ac file, use the
# package name and package version number provided by the AC_INIT line
# in the setup.py file, if the user didn't override them on the command
# line
elif [ -e ${SRC_FOLDER_NAME}/configure.ac ]
then
QQQ=$($(grep '^AC_INIT' ${SRC_FOLDER_NAME}/configure.ac | sed -e 's/AC_INIT(//g' -e 's/)//g' -e 's/,//g'))
exit_if_error $? "Failed to obtain version info from configure.ac."
eval ZZZ=(${QQQ})
exit_if_error $? "Failed to obtain version info from configure.ac."
if [ -z ${DEB_PKG_NAME} ]
then
DEB_PKG_NAME=${ZZZ[0]}
fi
if [ -z ${DEB_PKG_VERSION} ]
then
DEB_PKG_VERSION=${ZZZ[1]}
fi
# Or, if the source folder contains a CMakeLists.txt file, determine
# the project name and project version from CMake cache variables, if
# the user didn't override them on the command line.
# NOTE: The CMakeLists.txt file needs to be set up so that PROJECT_NAME
# and PROJECT_VERSION are defined as cache variables.
elif [ -e ${SRC_FOLDER_NAME}/CMakeLists.txt ]
then
CMAKE_SRC=$(readlink -f ${SRC_FOLDER_NAME})
exit_if_error $? "Failed to obtain version info from CMakeLists.txt."
rm -rf /tmp/makedeb
mkdir -p /tmp/makedeb
pushd /tmp/makedeb >/dev/null 2>&1
cmake ${CMAKE_SRC} -L -DPACKAGE_SUBGROUP=${DEB_PKG_SUBGROUP} >cmake_results.txt
exit_if_error $? "Failed to obtain version info from CMakeLists.txt."
if [ -z ${DEB_PKG_NAME} ]
then
ZZZ=$(grep 'PROJECT_NAME' cmake_results.txt)
#exit_if_error $?
DEB_PKG_NAME=${ZZZ##PROJECT_NAME:STRING=}
fi
if [ -z ${DEB_PKG_VERSION} ]
then
ZZZ=$(grep 'PROJECT_VERSION' cmake_results.txt)
#exit_if_error $?
DEB_PKG_VERSION=${ZZZ##PROJECT_VERSION:STRING=}
fi
popd >/dev/null 2>&1
rm -rf /tmp/makedeb
fi
# If the user did not specify a package name on the command line,
# and if the package name cannot be obtained from some other source,
# form the package name from the source folder name.
if [ -z ${DEB_PKG_NAME} ]
then
DEB_PKG_NAME=$(basename "${SRC_FOLDER_NAME}")
fi
# If the user did not specify a version number, and if
# the version number cannot be obtained by some other
# source, then use today's date for the version number
if [ -z ${DEB_PKG_VERSION} ]
then
DEB_PKG_VERSION=$(eval date +%y.%m.%d)
fi
# Try to make the provided package name conform to Debian naming
# conventions.
# NOTE -- doing this may still result in a failure if the package
# name cannot be made compliant!
DEB_PKG_NAME=$(echo "${DEB_PKG_NAME}" | tr "[:upper:]" "[:lower:]" | tr "_" "-")
# Append the extra info (if any) to the version number
if [ ! -z ${DEB_PKG_EXTRA} ]
then
DEB_PKG_VERSION=${DEB_PKG_VERSION}-${DEB_PKG_EXTRA}
fi
# Extract the package's major version number
DEB_PKG_VERSION_MAJOR=$(cut -d"." -f1 <<<"${DEB_PKG_VERSION}")
#########################################################
# Build the Debian package
#########################################################
# Make sure the source folder has been specified
if [ -z ${SRC_FOLDER_NAME} ]
then
exit_with_usage 2 "Source folder was not provided"
else
echo "Debian package parameters:"
echo "* Source folder name: ${SRC_FOLDER_NAME}"
echo "* Debian package name: ${DEB_PKG_NAME}"
echo "* Debian package version: ${DEB_PKG_VERSION}"
echo "* Debian package major version: ${DEB_PKG_VERSION_MAJOR}"
echo "* Debian package architecture: ${DEB_PKG_ARCH}"
echo "* Debian package GNU system type: ${DEB_PKG_ARCH_GNU}"
echo "* Debian package OS: ${DEB_PKG_OS}"
echo "* Debian package OS version: ${DEB_PKG_OS_VER}"
echo "* Debian package subgroup: ${DEB_PKG_SUBGROUP}"
echo "* Python version: ${PYTHON_VERSION}"
echo "* Python executable: ${DEB_PYTHON_EXECUTABLE}"
echo "* Debian Python package prefix: ${DEB_PYTHON_PKG_PREFIX}"
echo "* Debian Python package dependency: ${DEB_PYTHON_PKG_DEP}"
echo "* Debian Python X- spec: ${DEB_PYTHON_XPY_DEP}"
echo "* Debian dh_python version: ${DEB_PYTHON_DHPY}"
echo "* Debian twistd executable: ${DEB_TWISTD_EXECUTABLE}"
echo "* Debian GNU Radio package dependency: ${DEB_GNURADIO_PKG_DEP}"
echo "* Debian GNU Radio development package dependency: ${DEB_GNURADIO_DEV_PKG_DEP}"
# Create temporary build folder
DEB_BUILD_FOLDER_NAME=${DEB_PKG_NAME}-${DEB_PKG_VERSION}
echo "Creating temporary build folder: ${DEB_BUILD_FOLDER_NAME}"
if [ -e ${DEB_BUILD_FOLDER_NAME} ]
then
rm -rf ${DEB_BUILD_FOLDER_NAME}
exit_if_error $?
fi
mkdir -p ${DEB_BUILD_FOLDER_NAME}
exit_if_error $?
# Copy files from source folder into build folder
echo "Copying files: ${SRC_FOLDER_NAME} ==> ${DEB_BUILD_FOLDER_NAME}"
cp -rf ${SRC_FOLDER_NAME}/* ${DEB_BUILD_FOLDER_NAME}
exit_if_error $? "In copying files"
cp -rf ${SRC_FOLDER_NAME}/.[1-9a-zA-Z]* ${DEB_BUILD_FOLDER_NAME}
# [HACK] To get around Debian's "reproducible builds" hang-up,
# search for C/C++ sources and replace __DATE__, __TIME__, and
# __FILE__ directives as needed
DEB_BUILD_DATE=$(date +"%b %e %Y")
DEB_BUILD_TIME=$(date +"%H:%M:%S")
echo "Massaging C/C++ files in ${SRC_FOLDER_NAME}"
for CXXFILE in $(find ${DEB_BUILD_FOLDER_NAME} -type f \
-name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \
-o -name "*.h" -o -name "*.hpp" -o -name "*.hxx")
do
sed -i -e "s|__DATE__|\"${DEB_BUILD_DATE}\"|g" -e "s|__TIME__|\"${DEB_BUILD_TIME}\"|g" \
-e "s|__FILE__|\"${CXXFILE}\"|g" ${CXXFILE}
done
# Python shebanging fixes for Python (since "/usr/bin/env python[3]" syntax is
# deprecated)
# -- NOTE: Make sure that we ignore *this* script in all cases -- DA
grep -rlZ --exclude=makedeb "#!/usr/bin/twistd" ${DEB_BUILD_FOLDER_NAME} | \
xargs -0 -r sed -i -e "1 s|#!/usr/bin/twistd|#!${DEB_TWISTD_EXECUTABLE}|"
# -- Replace "#!/usr/bin/env python3" with the Python 3 executable
grep -rlZ "#!/usr/bin/env python3" ${DEB_BUILD_FOLDER_NAME} | \
xargs -0 -r sed -i -e "1 s|#!/usr/bin/env python3|#!${DEB_PYTHON3_EXECUTABLE}|"
# -- Replace "#!/usr/bin/env python2" with the Python 2 executable
grep -rlZ "#!/usr/bin/env python2" ${DEB_BUILD_FOLDER_NAME} | \
xargs -0 -r sed -i -e "1 s|#!/usr/bin/env python2|#!${DEB_PYTHON2_EXECUTABLE}|"
# -- Replace "#!/usr/bin/env python" with the Python executable for the
# Python version we are building for
grep -rlZ "#!/usr/bin/env python" ${DEB_BUILD_FOLDER_NAME} | \
xargs -0 -r sed -i -e "1 s|#!/usr/bin/env python|#!${DEB_PYTHON_EXECUTABLE}|"
# Twisted daemon executable fixes
# -- NOTE: Make sure that we ignore *this* script in all cases -- DA
# -- Replace /usr/bin/twistd with /usr/bin/twistd3 if this is a Python 3
# package
grep -rlZ --exclude=makedeb "/usr/bin/twistd" ${DEB_BUILD_FOLDER_NAME} | \
xargs -0 -r sed -i -e "s|/usr/bin/twistd|${DEB_TWISTD_EXECUTABLE}|g"
# For files in debian sub-folder, replace DEB_PKG_* placeholders
# with our parameters
echo "Versioning Debian package: ${DEB_PKG_NAME}"
for FNAME in $(find ${DEB_BUILD_FOLDER_NAME}/debian -type f)
do
#echo "* ${FNAME}"
sed -i -e '/^#[^!]/ d' \
-e "s|DEB_PKG_NAME|${DEB_PKG_NAME}|g" \
-e "s|DEB_PKG_VERSION_MAJOR|${DEB_PKG_VERSION_MAJOR}|g" \
-e "s|DEB_PKG_VERSION|${DEB_PKG_VERSION}|g" \
-e "s|DEB_PKG_ARCH_GNU|${DEB_PKG_ARCH_GNU}|g" \
-e "s|DEB_PKG_ARCH|${DEB_PKG_ARCH}|g" \
-e "s|DEB_PKG_OS_VER|${DEB_PKG_OS_VER}|g" \
-e "s|DEB_PKG_OS|${DEB_PKG_OS}|g" \
-e "s|DEB_PKG_SUBGROUP|${DEB_PKG_SUBGROUP}|g" \
-e "s|DEB_PYTHON_EXECUTABLE|${DEB_PYTHON_EXECUTABLE}|g" \
-e "s|DEB_PYTHON_PKG_PREFIX|${DEB_PYTHON_PKG_PREFIX}|g" \
-e "s|DEB_PYTHON_PKG_DEP|${DEB_PYTHON_PKG_DEP}|g" \
-e "s|DEB_PYTHON_XPY_DEP|${DEB_PYTHON_XPY_DEP}|g" \
-e "s|DEB_PYTHON_DHPY|${DEB_PYTHON_DHPY}|g" \
-e "s|DEB_TWISTD_EXECUTABLE|${DEB_TWISTD_EXECUTABLE}|g" \
-e "s|DEB_GNURADIO_PKG_DEP|${DEB_GNURADIO_PKG_DEP}|g" \
-e "s|DEB_GNURADIO_DEV_PKG_DEP|${DEB_GNURADIO_DEV_PKG_DEP}|g" \
${FNAME}
exit_if_error $? "In versioning file ${FNAME}"
done
# Build the Debian package
# -- Note that this Debian package will be an *unsigned* package.
# -- Also note that PYTHONPATH will be honored. This is primarily
# intended to support automated builds in Jenkins, but can easily
# break things, so be VERY careful with this one.
# -- We set DEB_BUILD_OPTIONS to "noautodbgsym" so that we don't
# generate debug symbol packages. Not all Ubuntu versions
# support this, but it is ignored on the versions that don't.
echo "Building Debian package: ${DEB_PKG_NAME}"
cd ${DEB_BUILD_FOLDER_NAME}
DEB_BUILD_OPTIONS=noautodbgsym debuild --preserve-envvar=PYTHONPATH --no-tgz-check --no-lintian -uc -us
exit_if_error $? "In building package"
cd ..
# If the build process resulted in a documentation tarball, then
# move it into the current directory
echo "Preserving documentation tarballs"
DEB_DOCS_TARBALLS=$(find ${DEB_BUILD_FOLDER_NAME} -name "*-docs.tar.gz")
for DEB_DOC_TARBALL in ${DEB_DOCS_TARBALLS}
do
echo "* Doc tarball: ${DEB_DOC_TARBALL}"
mv ${DEB_DOC_TARBALL} .
done
# Clean up
if [ ${CLEANUP} -eq 1 ]
then
echo "Cleaning up: ${DEB_PKG_NAME}"
for FEXT in build changes dsc tar.gz tar.xz buildinfo ddeb
do
#echo "-- rm -fv ${DEB_PKG_NAME}_${DEB_PKG_VERSION}*.${FEXT}"
rm -fv ${DEB_PKG_NAME}_${DEB_PKG_VERSION}*.${FEXT}
done
rm -rf ${DEB_BUILD_FOLDER_NAME}
else
echo "Not cleaning up at user request"
fi
# Rename Debian packages to reflect OS and GNU system type
echo "Renaming built packages"
for DEBPKG in $(ls *.deb)
do
if [[ "${DEBPKG}" == *"_all.deb" ]]
then
DEBPKGTGT=${DEBPKG/_all.deb/_${DEB_PKG_OS}-${DEB_PKG_OS_VER}-all.deb}
echo "* Arch-independent: ${DEBPKG} ==> ${DEBPKGTGT}"
mv ${DEBPKG} ${DEBPKGTGT}
elif [[ "${DEBPKG}" == *"_${DEB_PKG_ARCH}.deb" ]]
then
DEBPKGTGT=${DEBPKG/_${DEB_PKG_ARCH}.deb/_${DEB_PKG_OS}-${DEB_PKG_OS_VER}-${DEB_PKG_ARCH_GNU}.deb}
echo "* Arch-dependent: ${DEBPKG} ==> ${DEBPKGTGT}"
mv ${DEBPKG} ${DEBPKGTGT}
fi
done
echo "PACKAGE BUILD COMPLETE"
fi