forked from varnishcache/pkg-varnish-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-deb
executable file
·97 lines (78 loc) · 3.25 KB
/
package-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
#!/bin/bash
#
# Build Debian and Ubuntu packages from a tarball.
#
# This is the script that our Jenkins/CI system runs. Yes, it is a bit messy.
#
#
# For running this on your own computer (jessie), see https://wiki.debian.org/mk-sbuild
# for information on setting up sbuild.
# Short version: 1) apt-get install ubuntu-dev-tools 2) mk-sbuild jessie
#
# To CHANGE the golden image: sudo schroot -c source:jessie-amd64 -u root
# To ENTER an image snapshot: schroot -c jessie-amd64
# To BUILD within a snapshot: sbuild -A -d jessie-amd64 PACKAGE*.dsc
BINDISTS=${BINDISTS:-jessie}
if [[ -n "${JENKINS_HOME}" ]]; then
set -x
if [ "$HOSTNAME" != "cbuild" ]; then
# Handle old chroot naming on our jenkins servers. Used in the bottom.
chroot_postfix="-sbuild";
fi
fi
set -o errexit
. common.sh
rm -rf build
mkdir -p build
SOURCE=$(ls -1 sources/varnish-*.tar.gz 2>/dev/null || ls -1 sources/varnish-*.tgz 2>/dev/null)
findversion "$SOURCE"
tar xf "${SOURCE}" -C build
# Modify varnish.install to match version
if [ "$V" = "3.0" ] || [ "$V" = "4.0" ] || [ "$V" = "4.1" ]; then
# Legacy packages don't have separate directory with VCL files
sed -i "s|^usr/share/varnish/vcl|#usr/share/varnish/vcl|" debian/varnish.install
sed -i "s|^usr/share/varnish/vsctool.py|#usr/share/varnish/vsctool.py|" debian/varnish-dev.install
else
# Make sure to revert if mangled by older build-job
sed -i "s|^#usr/share/varnish/vcl|usr/share/varnish/vcl|" debian/varnish.install
sed -i "s|^#usr/share/varnish/vsctool.py|usr/share/varnish/vsctool.py|" debian/varnish-dev.install
fi
# Use the non-systemd versions of rules and control for legacy distros
if [[ $BINDISTS =~ .*precise.* || $BINDISTS =~ .*wheezy.* ]]; then
echo "INFO: Building non-systemd packages."
mv debian/control.nosystemd debian/control
mv debian/rules.nosystemd debian/rules
fi
cd build/varnish-*
# Copy our debian metadata into the build/varnish-$version directory
cp -r ../../debian .
rm -f debian/.*.sw? # Delete any vim temporary files.
ln "../../$SOURCE" "../varnish_$V.$MINOR.orig.tar.gz"
# Modify Section to suit our repository software.
sed -i -e "s|^Section: \([^/]*\)\$|Section: varnish-$V/\1|" debian/control
# Take version override set on Jenkins builds into account.
if [ -n "$WEEKLY_VERSION" ]; then
FULL_VERSION="${WEEKLY_VERSION}+${DEBVERSION}"
dch -v "$FULL_VERSION" "Release build #$BUILD_NUMBER ID: $BUILD_ID"
elif [[ -n "${DEBVERSION}" ]]; then
if [ "$RELEASE" == "" ]; then
FULL_VERSION="$V.$MINOR-$DEBVERSION"
else
FULL_VERSION="$V.$MINOR~$RELEASE-$DEBVERSION"
fi
dch -v "$FULL_VERSION" "Release build #$BUILD_NUMBER ID: $BUILD_ID"
else
FULL_VERSION="$V.$MINOR-0${RELEASE}+daily+$(date +%Y%m%d.%H%M%S)"
dch -v "$V.$MINOR-0${RELEASE}+daily+$(date +%Y%m%d.%H%M%S)" "Automatic build from git"
fi
# Generate the source package used by subsequent sbuilds
dpkg-buildpackage -us -uc -S -j10
# Work dir is build/
cd ..
# By now we are done setting up and building the source package.
# Build binary packages for the requested releases inside chroots.
for dist in $BINDISTS; do
# Legacy packages embedded the release into the package version.
export DEBIAN_OVERRIDE_BINARY_VERSION="$FULL_VERSION~$dist"
sbuild -v -A -c "$dist-amd64$chroot_postfix" -d "$dist" varnish_*.dsc
done