-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmakeDebianPackage
More file actions
executable file
·126 lines (101 loc) · 4.25 KB
/
makeDebianPackage
File metadata and controls
executable file
·126 lines (101 loc) · 4.25 KB
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
#!/bin/bash -e
PRESEED_REPOS=""
# check command line arguments
options=$(getopt -l "preseed,help" -o "p,h" -a -- "$@")
eval set -- "$options"
function showHelp() {
# print usage
echo "Usage: ./makeDebianPackage path/to/control/directory/created/by/configureRelease"
echo "Hint: configureRelease will print the full command line to run this script after creating the control directory."
}
while true; do
case $1 in
-h|--help)
showHelp
exit 0
;;
-p|--preseed)
PRESEED_REPOS="`pwd`/preseed"
;;
--)
shift
break;;
esac
shift
done
# Shell script to generate a debian package from a particular tag (configured during the cmake configuration).
# Parse command line arguments
if [ -z "$1" ] ; then
showHelp
exit 1
fi
CONTROLDIR="`pwd`/$1"
# load config
if [ ! -f "${CONTROLDIR}/makeDebianPackage.config" ]; then
echo "Wrong control directory given."
exit 1
fi
source "${CONTROLDIR}/makeDebianPackage.config"
source config.sh
export PROJECT_BUILDVERSION
if [ -z ${N_PBUILDER_THREADS} ]; then
export N_PBUILDER_THREADS=1
fi
echo "using ${N_PBUILDER_THREADS} thread(s)"
# directory where logfiles go
LOGDIR="`pwd`/buildlogs"
mkdir -p "${LOGDIR}"
# directory with local Debian repository and where the created packages should be placed
LOCAL_REPOS="`pwd`/pbuilder-result"
HOOKDIR="`pwd`/pbuilder-hooks"
# directory with pbuilder base image
PBUILDER_IMAGE="`pwd`/pbuilder-base/base-${DISTRIBUTION}.tgz"
PBUILDER_RC="`pwd`/pbuilderrc"
# Create a working directory in order not to merge with the rest in the build directory
rm -rf debian_package
mkdir debian_package
cd debian_package
BUILD_DIR_NAME=${PACKAGE_BASENAME}_${SOVERSION}
# Check out the correct tag from the master git repository.
git clone --recurse-submodules --branch ${TAGVERSION} ${SOURCE_URI} ${BUILD_DIR_NAME}
## Debian convention for 3.0 (quilt): file has to end on .orig.tar.gz
tar -czf ${BUILD_DIR_NAME}.orig.tar.gz --exclude-vcs ${BUILD_DIR_NAME}
# Copy the prepared debian packaging config files to the source code directroy
mkdir -p ${BUILD_DIR_NAME}/debian
cp -a ${CONTROLDIR}/* ${BUILD_DIR_NAME}/debian
cd ${BUILD_DIR_NAME}
# Before building the package we will update the changelog. This is easier from a shell script
# because debchange does the right format and the current date, user name and email automatically for us.
# Use the NAME and EMAIL environment variables to get correct values if needed (usually the email is
# user@host instead of first.last@institute, for instance killenb@mskpcx18571.desy.de instead of martin.killenberg@desy.de).
# TODO: move this into the configureRelease script and keep the changelog once it is created (in the DebianBuildVersions repo)
rm -f debian/changelog
debchange --create --package ${PACKAGE_BASENAME} -v ${PACKAGE_VERSION}-0 --distribution ${DISTRIBUTION} ${PACKAGE_MESSAGE}
# Now everything is prepared and we can actually build the package.
# If you have a gpg signature you can remove the -us and -uc flags and sign the package.
#Note: --debbuildopts must be before the -- to be effectice
# The pbuilder on Ubuntu 18.04 (and presumably later) mounts /dev and /run/shm by itself
# If we bind it into the container, it cannot unbind it properly if any browser is running on bionic
our_version=$(lsb_release -r | awk '{print $2}' | tr -d .)
bind_mounts="${LOCAL_REPOS} ${PRESEED_REPOS} ${ADDITIONAL_BIND_MOUNTS}"
if test "$our_version" -lt "1804"; then
bind_mounts="${bind_mounts} /dev /run/shm"
fi
# For the pbuilder hooks
export PRESEED_REPOS
export DISTRIBUTION
bash <<EOF
${PRE_PDEBUILD_HOOK}
EOF
LOGFILE="${LOGDIR}/pdebuild.${PACKAGE_BASENAME}.log"
time pdebuild --debbuildopts -j${N_PBUILDER_THREADS} -- --distribution ${DISTRIBUTION} \
--buildresult "${LOCAL_REPOS}/dists/${DISTRIBUTION}/main/binary-${ARCH}" \
--basetgz "${PBUILDER_IMAGE}" --bindmounts "${bind_mounts}" \
--configfile "${PBUILDER_RC}" --hookdir "${HOOKDIR}" 2>&1 | tee "${LOGFILE}"
if (( ${PIPESTATUS[0]} != 0 )); then
echo ""
echo "Building package ${PACKAGE_BASENAME} failed!"
exit 1
fi
echo ""
echo "You can find the resulting debian packages in this directory: ${LOCAL_REPOS}/dists/${DISTRIBUTION}/main/binary-${ARCH}"