-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·89 lines (71 loc) · 3.13 KB
/
run.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
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
#!/bin/bash
set -e
if [ "$#" -eq 0 ]; then
echo "run.sh: missing operands"
echo "Requires source package name as argument"
exit 1
fi
DEB_SUITE="${DEB_SUITE:-trixie}"
topdir=$(git rev-parse --show-toplevel)
projdir="${topdir}/$1"
sourcedir="${topdir}/build/sources"
builddir="${topdir}/build/${DEB_SUITE}/$1"
debcontroldir="${projdir}/suite/${DEB_SUITE}"
if [ ! -d ${projdir} ]; then
echo "This project does not exist."
echo "Exiting."
exit 1
fi
source ${projdir}/version.sh
mkdir -p ${builddir}
package_name=$(cd ${debcontroldir} && dpkg-parsechangelog --show-field Source)
deb_version=$(cd ${debcontroldir} && dpkg-parsechangelog --show-field Version)
package_version=$(echo $deb_version | sed 's/\(.*\)-.*/\1/')
last_tested_commit=$(echo $package_version | sed 's/.*+//')
package_full="${package_name}-${package_version}"
package_full_ll="${package_name}_${package_version}"
echo "Building " $package_name " version " $deb_version
# Generate original source tarball if none found
if [ ! -f "${builddir}/${package_full_ll}.orig.tar.gz" ]; then
mkdir -p "${sourcedir}"
if [ ! -d "${sourcedir}/${package_name}" ]; then
git clone "${git_repo}" "${sourcedir}/${package_name}"
fi
git -C "${sourcedir}/${package_name}" remote update
git -C "${sourcedir}/${package_name}" checkout "${last_tested_commit}"
tar -czf "${builddir}/${package_full_ll}.orig.tar.gz" \
--exclude-vcs \
--absolute-names "${sourcedir}/${package_name}" \
--transform "s,${sourcedir}/${package_name},${package_full},"
fi
# Generate source package if none found
if [ ! -f "${builddir}/${package_name}_${deb_version}.dsc" ]; then
# Extract original source tarball
tar -xzmf "${builddir}/${package_full_ll}.orig.tar.gz" -C "${builddir}"
# Deploy our Debian control files
cp -rv "${debcontroldir}/debian" "${builddir}/${package_full}/"
# Build source package
(cd "${builddir}/${package_full}" && dpkg-source -b .)
# Cleanup intermediate source directory
rm -r "${builddir}/${package_full}"
fi
# Generate binary package for this arch if not found
build_arch=$(dpkg --print-architecture)
if [ ! -f "${builddir}/${package_name}_${deb_version}_${build_arch}.buildinfo" ]; then
run_prep || true
# Extract source package
if [ ! -d "${builddir}/${package_name}_${deb_version}" ]; then
dpkg-source -x "${builddir}/${package_name}_${deb_version}.dsc" "${builddir}/${package_name}_${deb_version}"
fi
# Install build dependencies
(cd "${builddir}/${package_name}_${deb_version}" && mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y --no-install-recommends")
# Build debian package.
# HACK: There is an issue with building source package for Linux Kernel. So only build binary packages for Linux.
if [[ "${package_name}" == "ti-linux-kernel"* ]]; then
(cd "${builddir}/${package_name}_${deb_version}" && debuild --no-lintian --no-sign -b || true)
else
(cd "${builddir}/${package_name}_${deb_version}" && debuild --no-lintian --no-sign -sa || true)
fi
# Cleanup intermediate build directory
rm -r "${builddir}/${package_name}_${deb_version}"
fi