summaryrefslogtreecommitdiffstats
path: root/.github/workflows/debuilder.sh
blob: 9c3958a98dfd19b5f8b370a36e433fdf212ec1e0 (plain)
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
set -e

# A debian ruleset file which runs on Github's distro
DEB_FNAME="zbar_0.23.90-*.debian.tar.xz"
DEB_URL="http://deb.debian.org/debian/pool/main/z/zbar/"

# Should be the same version as provided by the host OS
COMPAT=12

# Set directories used during the build

ZBARDIR=${PWD}
BUILDDIR=${ZBARDIR}/../build

echo "Generating an origin tarball"

cd "${ZBARDIR}"

VER=$(cat "${ZBARDIR}/configure.ac" | grep AC_INIT | perl -ne 'print $1 if /(\d+[.\d]+)/')
TAR=${ZBARDIR}/../zbar_${VER}.orig.tar.gz

git archive --format tgz -o "${TAR}" HEAD

echo "Retrieving Debian ruleset"
lftp -e "mget -c ${DEB_FNAME}; exit" "${DEB_URL}"

# Ensure to use just one version, in case multiple ones were downloaded
DEB_FNAME=$(ls -1 ${DEB_FNAME} | tail -1)

echo "Preparing build environment"
rm -rf "${BUILDDIR}/" || true
mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"

tar xf "${TAR}"
tar xf "${ZBARDIR}/${DEB_FNAME}"

# Ensure that debhelper-compat will use the one expected by the build distro
sed -E "s#debhelper-compat.*,#debhelper-compat (= $COMPAT),#" -i debian/control

# Ignore missing SONAME for libs, if any, as it is not a build robot's task
# to update ${DEB_FNAME} ruleset
echo -e "\noverride_dh_shlibdeps:" >> debian/rules
echo -e "\tdh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info" >> debian/rules

# We want it to build cleanly - so drop all patches from it
rm -rf debian/patches

# Override the changelog to ensure that it will contain the current version
cat << EOF > debian/changelog
zbar (${VER}) unstable; urgency=medium

  * Upstream version

 -- LinuxTV bot <linuxtv-commits@linuxtv.org>  $(date -R)
EOF

OS_VERSION=$(. /etc/os-release && echo "$ID-$VERSION_ID")

echo "Building ZBar packages for ${OS_VERSION}"
debuild -us -uc