# SPDX-License-Identifier: LGPL-2.1-or-later
set -ex
-if [ ! -f "pkg/$PKG_SUBDIR/PKGBUILD" ]; then
- echo "PKGBUILD not found at pkg/$PKG_SUBDIR/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2
+# shellcheck source=/dev/null
+. /usr/lib/os-release
+
+if [ ! -f "pkg/$ID/PKGBUILD" ]; then
+ echo "PKGBUILD not found at pkg/$ID/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2
exit 1
fi
# We can't configure the source or build directory so we use bind mounts instead to make sure they are in the
# expected locations.
-mount --mkdir --bind "$SRCDIR" "pkg/$PKG_SUBDIR/systemd-stable/"
-mount --mkdir --bind "$BUILDDIR" "pkg/$PKG_SUBDIR/build/"
+mount --mkdir --bind "$SRCDIR" "pkg/$ID/systemd-stable/"
+mount --mkdir --bind "$BUILDDIR" "pkg/$ID/build/"
# Because we run with --noextract we are responsible for making sure the source files appear in src/.
-mount --mkdir --rbind "$PWD/pkg/$PKG_SUBDIR" "pkg/$PKG_SUBDIR/src/"
+mount --mkdir --rbind "$PWD/pkg/$ID" "pkg/$ID/src/"
# shellcheck source=/dev/null
. /etc/makepkg.conf
TS="${SOURCE_DATE_EPOCH:-$(date +%s)}"
fi
-sed --in-place "pkg/$PKG_SUBDIR/PKGBUILD" \
+sed --in-place "pkg/$ID/PKGBUILD" \
--expression "s/^_tag=.*/_tag=$(cat meson.version)/" \
--expression "s/^pkgrel=.*/pkgrel=$(date "+%Y%m%d%H%M%S" --date "@$TS")/"
# We get around makepkg's root check by setting EUID to something else.
# shellcheck disable=SC2046
-env --chdir="pkg/$PKG_SUBDIR" \
+env --chdir="pkg/$ID" \
EUID=123 \
makepkg \
--noextract \
--force \
_systemd_UPSTREAM=1 \
_systemd_QUIET=1 \
- BUILDDIR="$PWD/pkg/$PKG_SUBDIR" \
+ BUILDDIR="$PWD/pkg/$ID" \
PKGDEST="$OUTPUTDIR" \
PKGEXT=".pkg.tar" \
MESON_EXTRA_CONFIGURE_OPTIONS="-D mode=developer -D b_sanitize=${SANITIZERS:-none}"
# https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/merge_requests/8 is merged.
[Content]
Environment=
- PKG_SUBDIR="arch"
SYSTEMD_PACKAGES="systemd systemd-ukify systemd-sysvcompat systemd-resolvconf systemd-tests"
Packages=
exit 0
fi
-if [ ! -f "pkg/$PKG_SUBDIR/PKGBUILD" ]; then
- echo "PKGBUILD not found at pkg/$PKG_SUBDIR/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2
+# shellcheck source=/dev/null
+. "$BUILDROOT/usr/lib/os-release"
+
+if [ ! -f "pkg/$ID/PKGBUILD" ]; then
+ echo "PKGBUILD not found at pkg/$ID/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2
exit 1
fi
# We get depends and optdepends from .SRCINFO as getting them from the PKGBUILD is rather complex.
-sed --expression 's/^[ \t]*//' "pkg/$PKG_SUBDIR/.SRCINFO" |
+sed --expression 's/^[ \t]*//' "pkg/$ID/.SRCINFO" |
grep --regexp '^depends =' --regexp '^optdepends =' |
sed --expression 's/^depends = //' --expression 's/^optdepends = //' --expression 's/:.*//' |
xargs --delimiter '\n' mkosi-install
# We get makedepends from the PKGBUILD as .SRCINFO can't encode conditional dependencies depending on
# whether some environment variable is set or not.
# shellcheck source=/dev/null
-_systemd_UPSTREAM=1 . "pkg/$PKG_SUBDIR/PKGBUILD"
+_systemd_UPSTREAM=1 . "pkg/$ID/PKGBUILD"
# shellcheck disable=SC2154
mkosi-install "${makedepends[@]}"
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
-if [ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]; then
- echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
+# shellcheck source=/dev/null
+. /usr/lib/os-release
+
+if [ ! -f "pkg/$ID/systemd.spec" ]; then
+ echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
exit 1
fi
$( ((WITH_TESTS)) || echo "--nocheck") \
$( ((WITH_DOCS)) || echo "--without docs") \
--define "_topdir /var/tmp" \
- --define "_sourcedir pkg/$PKG_SUBDIR" \
+ --define "_sourcedir pkg/$ID" \
--define "_rpmdir $OUTPUTDIR" \
${BUILDDIR:+--define} \
${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \
--define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
--define "__script_requires %{nil}" \
--undefine _lto_cflags \
- "pkg/$PKG_SUBDIR/systemd.spec"
+ "pkg/$ID/systemd.spec"
cp "$OUTPUTDIR"/*.rpm "$PACKAGEDIR"
exit 0
fi
-if [ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]; then
- echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi with -ff to make sure the spec is cloned" >&2
+# shellcheck source=/dev/null
+. "$BUILDROOT/usr/lib/os-release"
+
+if [ ! -f "pkg/$ID/systemd.spec" ]; then
+ echo "spec not found at pkg/$ID/systemd.spec, run mkosi with -ff to make sure the spec is cloned" >&2
exit 1
fi
--query \
"$DEPS" \
--define "_topdir /var/tmp" \
- --define "_sourcedir pkg/$PKG_SUBDIR" \
- "pkg/$PKG_SUBDIR/systemd.spec" |
+ --define "_sourcedir pkg/$ID" \
+ "pkg/$ID/systemd.spec" |
grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev |
sort --unique |
tee /tmp/buildrequires |
# rpmbuild -br tries to build a source package which means all source files have to exist which isn't the
# case when using --build-in-place so we get rid of the source file that doesn't exist to make it happy.
# TODO: Use -bd instead of -br and get rid of this once we don't need to build on CentOS Stream 9 anymore.
-sed '/Source0/d' --in-place "pkg/$PKG_SUBDIR/systemd.spec"
+sed '/Source0/d' --in-place "pkg/$ID/systemd.spec"
until mkosi-chroot \
rpmbuild \
--build-in-place \
--with upstream \
--define "_topdir /var/tmp" \
- --define "_sourcedir pkg/$PKG_SUBDIR" \
+ --define "_sourcedir pkg/$ID" \
--define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
- "pkg/$PKG_SUBDIR/systemd.spec"
+ "pkg/$ID/systemd.spec"
do
EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 11 ]; then
Distribution=centos
[Content]
-Environment=
- PKG_SUBDIR="centos"
-
Packages=
kernel-modules # For squashfs support
rpmautospec-rpm-macros
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
-if [ ! -d "pkg/$PKG_SUBDIR/debian" ]; then
- echo "deb rules not found at pkg/$PKG_SUBDIR/debian, run mkosi once with -ff to make sure the rules are cloned" >&2
+# shellcheck source=/dev/null
+. /usr/lib/os-release
+
+if [ ! -d "pkg/$ID/debian" ]; then
+ echo "deb rules not found at pkg/$ID/debian, run mkosi once with -ff to make sure the rules are cloned" >&2
exit 1
fi
# We transplant the debian/ folder from the deb package sources into the upstream sources.
-mount --mkdir --bind "$SRCDIR/pkg/$PKG_SUBDIR/debian" "$SRCDIR"/debian
+mount --mkdir --bind "$SRCDIR/pkg/$ID/debian" "$SRCDIR"/debian
# We hide the patches/ directory by mounting an empty directory on top so they don't get applied.
TMP=$(mktemp -d)
[Content]
Environment=
- PKG_SUBDIR="debian"
SYSTEMD_PACKAGES="systemd
systemd-userdbd
systemd-oomd
exit 0
fi
-if [ ! -d "pkg/$PKG_SUBDIR/debian" ]; then
- echo "deb rules not found at pkg/$PKG_SUBDIR/debian, run mkosi once with -ff to make sure the rules are cloned" >&2
+# shellcheck source=/dev/null
+. "$BUILDROOT/usr/lib/os-release"
+
+if [ ! -d "pkg/$ID/debian" ]; then
+ echo "deb rules not found at pkg/$ID/debian, run mkosi once with -ff to make sure the rules are cloned" >&2
exit 1
fi
-cd "pkg/$PKG_SUBDIR"
+cd "pkg/$ID"
DEB_BUILD_PROFILES="pkg.systemd.upstream" apt-get build-dep .
Distribution=fedora
[Content]
-Environment=
- PKG_SUBDIR="fedora"
-
Packages=
btrfs-progs
compsize
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
-if [ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]; then
- echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
+# shellcheck source=/dev/null
+. /usr/lib/os-release
+ID="${ID%-*}"
+
+if [ ! -f "pkg/$ID/systemd.spec" ]; then
+ echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
exit 1
fi
# The openSUSE filelists hardcode the manpage compression extension. This causes rpmbuild errors since we
# disable manpage compression as the files cannot be found. Fix the issue by removing the compression
# extension.
-find "pkg/$PKG_SUBDIR" -name "files.*" -exec sed --in-place 's/\.gz$//' {} \;
+find "pkg/$ID" -name "files.*" -exec sed --in-place 's/\.gz$//' {} \;
build() {
# TODO: Replace meson_build and meson_install overrides with "--undefine __meson_verbose" once
--with upstream \
$( ((WITH_TESTS)) || echo --nocheck) \
--define "_topdir /var/tmp" \
- --define "_sourcedir pkg/$PKG_SUBDIR" \
+ --define "_sourcedir pkg/$ID" \
--define "_rpmdir $OUTPUTDIR" \
${BUILDDIR:+--define} \
${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \
--define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
--define "__script_requires %{nil}" \
"$@" \
- "pkg/$PKG_SUBDIR/systemd.spec"
+ "pkg/$ID/systemd.spec"
}
if ! build; then
# warnings.
rm systemd.lang
- cat /tmp/unpackaged-files >>"pkg/$PKG_SUBDIR/files.systemd"
+ cat /tmp/unpackaged-files >>"pkg/$ID/files.systemd"
build --noprep --nocheck
fi
[Content]
Environment=
- PKG_SUBDIR="opensuse"
SYSTEMD_PACKAGES="systemd
udev
systemd-experimental
exit 0
fi
-if [ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]; then
- echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
+# shellcheck source=/dev/null
+. "$BUILDROOT/usr/lib/os-release"
+ID="${ID%-*}"
+
+if [ ! -f "pkg/$ID/systemd.spec" ]; then
+ echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
exit 1
fi
--query \
"$DEPS" \
--define "_topdir /var/tmp" \
- --define "_sourcedir pkg/$PKG_SUBDIR" \
- "pkg/$PKG_SUBDIR/systemd.spec" |
+ --define "_sourcedir pkg/$ID" \
+ "pkg/$ID/systemd.spec" |
grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev |
sort --unique |
tee /tmp/buildrequires |
--build-in-place \
--with upstream \
--define "_topdir /var/tmp" \
- --define "_sourcedir pkg/$PKG_SUBDIR" \
+ --define "_sourcedir pkg/$ID" \
--define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
- "pkg/$PKG_SUBDIR/systemd.spec"
+ "pkg/$ID/systemd.spec"
do
EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 11 ]; then
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
-if [ -z "$(ls --almost-all "pkg/$PKG_SUBDIR")" ] || [ -f "pkg/$PKG_SUBDIR/.git" ]; then
- git submodule sync "pkg/$PKG_SUBDIR"
- git submodule update --init "pkg/$PKG_SUBDIR"
+if [ -z "$(ls --almost-all "pkg/$DISTRIBUTION")" ] || [ -f "pkg/$DISTRIBUTION/.git" ]; then
+ PKG_SUBDIR="$(realpath "pkg/$DISTRIBUTION" --relative-to "$PWD")"
+ git submodule sync "$PKG_SUBDIR"
+ git submodule update --init "$PKG_SUBDIR"
fi
--- /dev/null
+debian
\ No newline at end of file