summaryrefslogtreecommitdiffstats
path: root/debian/bin/build.sh
blob: c8a72f71c3809df45e1220502f34e3afed7c2b1a (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
#!/bin/bash

DIST="$(lsb_release -i -s)"
RELEASE="$(lsb_release -c -s)"
if [ "${DIST}" = "Debian" ]; then
	VERSION="$(cat /etc/debian_version)"
	VERSION="${VERSION%%.*}"
	PREFIX="~deb"
elif [ "${DIST}" = "Ubuntu" ]; then
	VERSION="$(lsb_release -r -s)"
	PREFIX="-ubuntu"
else
	echo "Unknown Distribution '${DIST}'"
	exit 1
fi

cfgs=( ptxconfigs/*.ptxconfig )
PTX_VERSION=$(sed -n -e 's/^PTXCONF_PROJECT="OSELAS.Toolchain-\(.*\)"$/\1/p' ${cfgs[0]})
DEBIAN_VERSION="$(sed -n '1s/.*(\([^-]*\)-.*).*/\1/p' debian/changelog)"
if [ "${PTX_VERSION}" != "${DEBIAN_VERSION}" ]; then
	echo "release version from the debian/changelog (${DEBIAN_VERSION}) does not match '${PTX_VERSION}'"
	exit 1
fi

if ! [[ "${VERSION}" =~ .*/sid ]]; then
	git checkout debian/changelog
	dch --local ${PREFIX}${VERSION}+ --distribution ${RELEASE} "Rebuild for ${RELEASE}" || exit
fi

debian/bin/gencontrol.sh "${@}"

dpkg-buildpackage -uc -b -nc