summaryrefslogtreecommitdiffstats
path: root/debian/bin/gencontrol.sh
blob: 66c2fe5e1b3f158eea76ddee608bddcf13b1dd97 (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
63
64
65
#!/bin/sh -e

die() {
	echo >&2 "$@"
	return 1
}

# This script assumes to have CWD = toplevel of OSELAS.Toolchain
test -f debian/changelog || die "debian/changelog not found"
test "$(dpkg-vendor --query Vendor)" = "Debian" || die "This script only works on Debian"

toolchain_version=$(dpkg-parsechangelog -SVersion | sed -e 's/-[^-]*$//')
newcontrol=$(mktemp debian/control.XXXXXXXXX)
trap 'rm -v -- "$newcontrol"' INT QUIT EXIT

cat > "$newcontrol" << EOF
Source: oselas.toolchain
Section: devel
Priority: optional
Maintainer: PTXdist Devevelopers <ptxdist@pengutronix.de>
Homepage: https://www.pengutronix.de/software/toolchain.html
Bugs: mailto:bugs@pengutronix.de
Build-Depends: debhelper (>= 9), libncurses-dev, python3-dev, bison, flex
EOF

find ptxconfigs -maxdepth 2 -name \*.ptxconfig |
while read configfile; do
	toolchain_name="$(basename "${configfile}" .ptxconfig | sed s/_/-/g)"
	pkg="oselas.toolchain-${toolchain_version}-${toolchain_name}"
	gnutriplet="$(sed -n 's/^PTXCONF_GNU_TARGET="\(.*\)"/\1/p' "$configfile")"

	cat >> "$newcontrol" << EOF

Package: $pkg
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: OSELAS Toolchain for ${gnutriplet}
 
Package: oselas.toolchain-${toolchain_version}-${gnutriplet}
Architecture: all
Depends: $pkg
Description: Meta package depending on latest OSELAS Toolchain for ${gnutriplet}

Package: oselas.toolchain-${toolchain_version%.*}-${gnutriplet}
Architecture: all
Depends: $pkg
Description: Meta package depending on latest OSELAS Toolchain for ${gnutriplet}
EOF

	echo "/opt/OSELAS.Toolchain-2018.02.0/${gnutriplet}" > "debian/${pkg}.install"
done

if ! cmp -s "$newcontrol" "debian/control"; then
	mv "$newcontrol" "debian/control"
	trap '' INT QUIT EXIT

	echo >&2 debian/control was updated successfully.
	echo >&2 Nevertheless return failure here to eventually abort
	echo >&2 building because the debian/control must not change
	echo >&2 during a build.

	exit 1
else
	touch "debian/control"
fi