]> git.ipfire.org Git - thirdparty/systemd.git/blame - mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot
Merge pull request #31648 from neighbourhoodie/review-content
[thirdparty/systemd.git] / mkosi.images / system / mkosi.conf.d / 10-debian-ubuntu / mkosi.build.chroot
CommitLineData
4d0f1451
DDM
1#!/bin/bash
2# SPDX-License-Identifier: LGPL-2.1-or-later
3set -e
4
d6f206b9
DDM
5# shellcheck source=/dev/null
6. /usr/lib/os-release
7
8if [ ! -d "pkg/$ID/debian" ]; then
9 echo "deb rules not found at pkg/$ID/debian, run mkosi once with -ff to make sure the rules are cloned" >&2
4d0f1451
DDM
10 exit 1
11fi
12
13# We transplant the debian/ folder from the deb package sources into the upstream sources.
d6f206b9 14mount --mkdir --bind "$SRCDIR/pkg/$ID/debian" "$SRCDIR"/debian
4d0f1451
DDM
15
16# We hide the patches/ directory by mounting an empty directory on top so they don't get applied.
17TMP=$(mktemp -d)
18mount --bind "$TMP" "$SRCDIR"/debian/patches
19
20# While the build directory can be specified through DH_OPTIONS, the default one is hardcoded everywhere so
21# we have to use that. Because it is architecture dependent, we query it using dpkg-architecture first.
22DEB_HOST_GNU_TYPE="$(dpkg-architecture --query DEB_HOST_GNU_TYPE)"
23mount --mkdir --bind "$BUILDDIR" "$SRCDIR/obj-$DEB_HOST_GNU_TYPE"
24
25if [ -d .git/ ] && [ -z "$(git status --porcelain)" ]; then
26 TS="$(git show --no-patch --format=%ct HEAD)"
27else
28 TS="${SOURCE_DATE_EPOCH:-$(date +%s)}"
29fi
30
31# Add a new changelog entry to update the version. We use a fixed date since a dynamic one causes a full
32# rebuild every time.
33cat >debian/changelog.new <<EOF
42e2ec23 34systemd ($(cat meson.version)-$(date "+%Y%m%d%H%M%S" --date "@$TS")) UNRELEASED; urgency=low
4d0f1451
DDM
35
36 * Automatic build from mkosi
37
38 -- systemd test <systemd-devel@lists.freedesktop.org> $(date --rfc-email --date "@$TS")
39
40EOF
41cat debian/changelog >>debian/changelog.new
42mv debian/changelog.new debian/changelog
43
44build() {
4980ae0f
DDM
45 DEB_BUILD_OPTIONS="\
46 $( ((WITH_TESTS)) || echo nocheck) \
47 $( ((WITH_DOCS)) || echo nodoc) \
48 $( ((WITH_DEBUG)) || echo nostrip) \
49 terse
50 optimize=-lto \
51 " \
52 DEB_BUILD_PROFILES="\
53 $( ((WITH_TESTS)) || echo nocheck) \
54 $( ((WITH_DOCS)) || echo nodoc) \
55 pkg.systemd.upstream \
56 " \
4d0f1451
DDM
57 DEB_CFLAGS_APPEND="-Og" \
58 DPKG_FORCE="unsafe-io" \
59 DPKG_DEB_COMPRESSOR_TYPE="none" \
60 DH_MISSING="--fail-missing" \
61 CONFFLAGS_UPSTREAM="-D mode=developer -D b_sanitize=${SANITIZERS:-none}" \
62 dpkg-buildpackage \
63 --no-pre-clean \
64 --unsigned-changes \
65 --build=binary
66}
67
68if ! build; then
69 # debhelper installs files for each package to debian/<package> so we figure out which files were
70 # packaged by querying all the package names from debian/control and running find on each of the
71 # corresponding package directory in debian/.
72 grep "Package:" debian/control |
73 sed "s/Package: //" |
74 xargs -d '\n' -I {} sh -c "[ -d debian/{} ] && (cd debian/{} && find . ! -type d ! -path "*dh-exec*" -printf '%P\n')" |
75 # Remove compression suffix from compressed manpages as the manpages in debian/tmp will be uncompressed.
76 sed --regexp-extended 's/([0-9])\.gz$/\1/' |
77 sort --unique >/tmp/packaged-files
78
79 # We figure out the installed files by running find on debian/tmp/ which contains the files installed
80 # by meson install.
81 (cd debian/tmp/ && find . ! -type d ! -path "*dh-exec*" -printf '%P\n') >/tmp/installed-files
82
83 if [ -f debian/not-installed ]; then
84 grep --invert-match "^#" debian/not-installed >>/tmp/installed-files
85 fi
86
87 sort --unique --output /tmp/installed-files /tmp/installed-files
88
89 # We get all the installed files that were not packaged by finding entries in the installed file that are
90 # not in the packaged file.
91 comm -23 /tmp/installed-files /tmp/packaged-files > /tmp/unpackaged-files
92 # If there are no unpackaged files something else went wrong.
93 if [ ! -s /tmp/unpackaged-files ]; then
94 exit 1
95 fi
96
97 # Otherwise, we append the unpackaged files to the filelist for the systemd package and retry the build.
98 cat /tmp/unpackaged-files >>debian/systemd.install
99 build
100fi
101
5524d283
DDM
102cp ../*.deb "$PACKAGEDIR"
103cp ../*.deb "$OUTPUTDIR"