-
Notifications
You must be signed in to change notification settings - Fork 0
/
dch_hook.sh
executable file
·62 lines (51 loc) · 1.83 KB
/
dch_hook.sh
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
#!/bin/bash -x
case "$distribution" in
jessie*)
release_num=0
;;
ascii*|stretch*)
release_num=1
;;
beowulf*|buster*)
release_num=2
;;
chimaera*|bullseye*)
release_num=3
;;
daedalus*|bookworm*)
release_num=4
;;
esac
_srcinfo="$(dpkg-parsechangelog -n 1 -l debian/changelog)"
_srcname="$(echo "$_srcinfo" | awk '/^Source: / {print $2}')"
_srcver="$(echo "$_srcinfo" | awk '/^Version: / {print $2}')"
_pkgname=$(grep 'Package: ' debian/control | sed 1q | cut -d' ' -f2)
# This should find the highest version (increment) of the wanted package.
_deb=$(find /srv/repository/leste/pool /srv/repository/extras/pool -type f \
-name "${_pkgname}_${_srcver#*:}+${release_num}m7*.deb" | sort -rV | sed 1q)
if [ -n "$_deb" ] ; then
_buildnum=$(basename $_deb | perl -pe 's,^.*\+(.*)_.*$,\1,')
echo "*** buildnum == $_buildnum ***"
if [ "$_buildnum" = "${release_num}m7" ]; then
echo "*** Found previous build (no rebuilds). Appending .1"
_buildnum="${_buildnum}.1"
elif echo $_buildnum | grep -q "^${release_num}m7\.."; then
echo "*** Found previous rebuild. Incrementing build number ***"
_buildnum=$(echo $_buildnum | perl -pe 's,(?<=\.)(\d+),$1+1,e')
else
echo "*** Did not find previous builds. Assuming +${release_num}m7 ***"
_buildnum="${release_num}m7"
fi
else
echo "*** Did not find previous builds. Assuming +${release_num}m7 ***"
_buildnum="${release_num}m7"
fi
_tempchangelog=$(mktemp)
cat << EOF | tee $_tempchangelog
$_srcname (${_srcver}+${_buildnum}) unstable; urgency=medium
* Increment build number
-- Jenkins Auto Builder <[email protected]> $(date -R)
EOF
cat debian/changelog >> $_tempchangelog
cat $_tempchangelog > debian/changelog
rm -f $_tempchangelog