| 1 |
#!/usr/bin/env bash |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
set -e |
| 4 |
|
| 5 |
if [[ "$1" == "build" ]] || ((NO_BUILD)); then |
| 6 |
exit 0 |
| 7 |
fi |
| 8 |
|
| 9 |
if [[ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]]; then |
| 10 |
echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi with -ff to make sure the spec is cloned" >&2 |
| 11 |
exit 1 |
| 12 |
fi |
| 13 |
|
| 14 |
mkosi-chroot \ |
| 15 |
rpmspec \ |
| 16 |
--with upstream \ |
| 17 |
--query \ |
| 18 |
--buildrequires \ |
| 19 |
--define "_topdir /var/tmp" \ |
| 20 |
--define "_sourcedir $PWD/pkg/$PKG_SUBDIR" \ |
| 21 |
"pkg/$PKG_SUBDIR/systemd.spec" | |
| 22 |
grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev --regexp grubby --regexp sdubby | |
| 23 |
sort --unique | |
| 24 |
tee /tmp/buildrequires | |
| 25 |
xargs --delimiter '\n' mkosi-install |
| 26 |
|
| 27 |
# rpmbuild -br tries to build a source package which means all source files have to exist which isn't the |
| 28 |
# case when using --build-in-place so we get rid of the source file that doesn't exist to make it happy. |
| 29 |
# TODO: Use -bd instead of -br and get rid of this once we don't need to build on CentOS Stream 9 anymore. |
| 30 |
sed '/Source0/d' "pkg/$PKG_SUBDIR/systemd.spec" >/tmp/systemd.spec |
| 31 |
mount --bind /tmp/systemd.spec "pkg/$PKG_SUBDIR/systemd.spec" |
| 32 |
|
| 33 |
until mkosi-chroot \ |
| 34 |
rpmbuild \ |
| 35 |
-br \ |
| 36 |
--noprep \ |
| 37 |
--build-in-place \ |
| 38 |
--with upstream \ |
| 39 |
--define "_topdir /var/tmp" \ |
| 40 |
--define "_sourcedir $PWD/pkg/$PKG_SUBDIR" \ |
| 41 |
--define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ |
| 42 |
"pkg/$PKG_SUBDIR/systemd.spec" |
| 43 |
do |
| 44 |
EXIT_STATUS=$? |
| 45 |
if [[ $EXIT_STATUS -ne 11 ]]; then |
| 46 |
exit $EXIT_STATUS |
| 47 |
fi |
| 48 |
|
| 49 |
mkosi-chroot \ |
| 50 |
rpm \ |
| 51 |
--query \ |
| 52 |
--package \ |
| 53 |
--requires \ |
| 54 |
/var/tmp/SRPMS/systemd-*.buildreqs.nosrc.rpm | |
| 55 |
grep --invert-match '^rpmlib(' | |
| 56 |
sort --unique >/tmp/dynamic-buildrequires |
| 57 |
|
| 58 |
sort /tmp/buildrequires /tmp/dynamic-buildrequires | |
| 59 |
uniq --unique | |
| 60 |
tee --append /tmp/buildrequires | |
| 61 |
xargs --delimiter '\n' mkosi-install |
| 62 |
done |