]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Use same pkg/ subdirectory for debian and ubuntu
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 8 Mar 2024 11:57:31 +0000 (12:57 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 13 Mar 2024 11:07:09 +0000 (12:07 +0100)
Instead of cloning the same repository twice, let's make sure we
use the same directory for both debian/ubuntu.

14 files changed:
mkosi.images/base/mkosi.conf.d/10-arch/mkosi.build.chroot
mkosi.images/base/mkosi.conf.d/10-arch/mkosi.conf
mkosi.images/base/mkosi.conf.d/10-arch/mkosi.prepare
mkosi.images/base/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot
mkosi.images/base/mkosi.conf.d/10-centos-fedora/mkosi.prepare
mkosi.images/base/mkosi.conf.d/10-centos/mkosi.conf
mkosi.images/base/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot
mkosi.images/base/mkosi.conf.d/10-debian-ubuntu/mkosi.conf
mkosi.images/base/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare
mkosi.images/base/mkosi.conf.d/10-fedora/mkosi.conf
mkosi.images/base/mkosi.conf.d/10-opensuse/mkosi.build.chroot
mkosi.images/base/mkosi.conf.d/10-opensuse/mkosi.conf
mkosi.images/base/mkosi.conf.d/10-opensuse/mkosi.prepare
mkosi.images/base/mkosi.sync

index 9acfde1635b2542aa737b029b2e88db3bf94cbd5..aff566f94c24fb409cce0f334bff3b760bd5fda7 100755 (executable)
@@ -2,17 +2,17 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -ex
 
-if [ ! -f "pkg/$DISTRIBUTION/PKGBUILD" ]; then
-    echo "PKGBUILD not found at pkg/$DISTRIBUTION/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2
+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
     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/$DISTRIBUTION/systemd-stable/"
-mount --mkdir --bind "$BUILDDIR" "pkg/$DISTRIBUTION/build/"
+mount --mkdir --bind "$SRCDIR" "pkg/$PKG_SUBDIR/systemd-stable/"
+mount --mkdir --bind "$BUILDDIR" "pkg/$PKG_SUBDIR/build/"
 # Because we run with --noextract we are responsible for making sure the source files appear in src/.
-mount --mkdir --rbind "$PWD/pkg/$DISTRIBUTION" "pkg/$DISTRIBUTION/src/"
+mount --mkdir --rbind "$PWD/pkg/$PKG_SUBDIR" "pkg/$PKG_SUBDIR/src/"
 
 # shellcheck source=/dev/null
 . /etc/makepkg.conf
@@ -37,7 +37,7 @@ fi
 
 # We get around makepkg's root check by setting EUID to something else.
 # shellcheck disable=SC2046
-env --chdir="pkg/$DISTRIBUTION" \
+env --chdir="pkg/$PKG_SUBDIR" \
     EUID=123 \
     makepkg \
     --noextract \
@@ -45,7 +45,7 @@ env --chdir="pkg/$DISTRIBUTION" \
     --force \
     UPSTREAM=1 \
     QUIET=1 \
-    BUILDDIR="$PWD/pkg/$DISTRIBUTION" \
+    BUILDDIR="$PWD/pkg/$PKG_SUBDIR" \
     PKGDEST="$PACKAGEDIR" \
     PKGEXT=".pkg.tar" \
     PKGVER="$(cat meson.version)" \
index 58a57d02836524eec08b1d2b54493d4b4616d8ec..75dbbb2ddead62d866277418044f60bd65ed9024 100644 (file)
@@ -12,6 +12,7 @@ InitrdInclude=initrd/
 Environment=
         PKG_URL="https://gitlab.archlinux.org/daandemeyer/systemd"
         PKG_BRANCH="strip"
+        PKG_SUBDIR="arch"
         SYSTEMD_PACKAGES="systemd systemd-ukify systemd-sysvcompat systemd-resolvconf"
 
 Packages=
index d6e2d4eb3da556b4332dafaebdb6e3958b471c44..24c91e5665f62d586b57b41b2ba0e348f2ca17c5 100755 (executable)
@@ -2,14 +2,14 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -e
 
-if [ ! -f "pkg/$DISTRIBUTION/PKGBUILD" ]; then
-    echo "PKGBUILD not found at pkg/$DISTRIBUTION/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2
+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
     exit 1
 fi
 
 if [ "$1" = "final" ]; then
     # We get depends and optdepends from .SRCINFO as getting them from the PKGBUILD is rather complex.
-    sed --expression 's/^[ \t]*//' "pkg/$DISTRIBUTION/.SRCINFO" |
+    sed --expression 's/^[ \t]*//' "pkg/$PKG_SUBDIR/.SRCINFO" |
         grep --regexp '^depends =' --regexp '^optdepends =' |
         sed --expression 's/^depends = //' --expression 's/^optdepends = //' --expression 's/:.*//' |
         xargs --delimiter '\n' mkosi-install
@@ -17,7 +17,7 @@ else
     # 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
-    UPSTREAM=1 . "pkg/$DISTRIBUTION/PKGBUILD"
+    UPSTREAM=1 . "pkg/$PKG_SUBDIR/PKGBUILD"
 
     # shellcheck disable=SC2154
     mkosi-install "${makedepends[@]}"
index cf3be645386b2f59f7a808d19db461811e9a8fa0..3ee0900175aba3288ede4fbdf4b428f29c860d5c 100755 (executable)
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -ex
 
-if [ ! -f "pkg/$DISTRIBUTION/systemd.spec" ]; then
-    echo "spec not found at pkg/$DISTRIBUTION/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
+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
     exit 1
 fi
 
@@ -22,7 +22,7 @@ rpmbuild \
     --with upstream \
     $( ((WITH_TESTS)) || echo --nocheck) \
     --define "_topdir /var/tmp" \
-    --define "_sourcedir pkg/$DISTRIBUTION" \
+    --define "_sourcedir pkg/$PKG_SUBDIR" \
     --define "_rpmdir $PACKAGEDIR" \
     ${BUILDDIR:+--define} \
     ${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \
@@ -44,4 +44,4 @@ rpmbuild \
     --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
     --define "__script_requires %{nil}" \
     --undefine _lto_cflags \
-    "pkg/$DISTRIBUTION/systemd.spec"
+    "pkg/$PKG_SUBDIR/systemd.spec"
index c07251a7e18b881edb333cb5074d6b4b920ad37a..0b48e1e4749ea80f71ae93c5174273fbcd84f667 100755 (executable)
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -ex
 
-if [ ! -f "pkg/$DISTRIBUTION/systemd.spec" ]; then
-    echo "spec not found at pkg/$DISTRIBUTION/systemd.spec, run mkosi with -ff to make sure the spec is cloned" >&2
+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
     exit 1
 fi
 
@@ -19,8 +19,8 @@ mkosi-chroot \
     --query \
     "$DEPS" \
     --define "_topdir /var/tmp" \
-    --define "_sourcedir pkg/$DISTRIBUTION" \
-    "pkg/$DISTRIBUTION/systemd.spec" |
+    --define "_sourcedir pkg/$PKG_SUBDIR" \
+    "pkg/$PKG_SUBDIR/systemd.spec" |
         grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev |
         sort --unique |
         tee /tmp/buildrequires |
@@ -33,7 +33,7 @@ fi
 # 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/$DISTRIBUTION/systemd.spec"
+sed '/Source0/d' --in-place "pkg/$PKG_SUBDIR/systemd.spec"
 
 until mkosi-chroot \
     rpmbuild \
@@ -41,9 +41,9 @@ until mkosi-chroot \
     --build-in-place \
     --with upstream \
     --define "_topdir /var/tmp" \
-    --define "_sourcedir pkg/$DISTRIBUTION" \
+    --define "_sourcedir pkg/$PKG_SUBDIR" \
     --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
-    "pkg/$DISTRIBUTION/systemd.spec"
+    "pkg/$PKG_SUBDIR/systemd.spec"
 do
     EXIT_STATUS=$?
     if [ $EXIT_STATUS -ne 11 ]; then
index dd08467aaf2f782c8fcbb103db1af5292e03c13b..607c2d2dafef7b1e8f314d81f7c8b5e3d8bf1947 100644 (file)
@@ -7,6 +7,7 @@ Distribution=centos
 Environment=
         PKG_URL="https://git.centos.org/rpms/systemd"
         PKG_BRANCH="c9s-sig-hyperscale"
+        PKG_SUBDIR="centos"
 
 Packages=
         kernel-modules # For squashfs support
index d1ec8c189426ff371de066db6fe1abe0fc08cf8b..7fb650f5013bdf8f8df235e70309ea4e050ac371 100755 (executable)
@@ -2,13 +2,13 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -e
 
-if [ ! -d "pkg/$DISTRIBUTION/debian" ]; then
-    echo "deb rules not found at pkg/$DISTRIBUTION/debian, run mkosi once with -ff to make sure the rules are cloned" >&2
+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
     exit 1
 fi
 
 # We transplant the debian/ folder from the deb package sources into the upstream sources.
-mount --mkdir --bind "$SRCDIR/pkg/$DISTRIBUTION/debian" "$SRCDIR"/debian
+mount --mkdir --bind "$SRCDIR/pkg/$PKG_SUBDIR/debian" "$SRCDIR"/debian
 
 # We hide the patches/ directory by mounting an empty directory on top so they don't get applied.
 TMP=$(mktemp -d)
index c2a9c399e179f9f7a1fefd2ad40c21b0c052ad65..f6fc43a8480dc4ae2df9c81145ca8e926063094f 100644 (file)
@@ -11,6 +11,7 @@ InitrdInclude=initrd/
 Environment=
         PKG_URL="https://salsa.debian.org/systemd-team/systemd"
         PKG_BRANCH="debian/master"
+        PKG_SUBDIR="debian"
         SYSTEMD_PACKAGES="systemd
                           systemd-userdbd
                           systemd-oomd
index 32c60feb7eeb1dcc4da22e358ed5ce12203d21a0..ae0d6fd92ff5c9ed99e98d6d21f228a7f0080809 100755 (executable)
@@ -6,10 +6,10 @@ if [ "$1" = "final" ]; then
     exit 0
 fi
 
-if [ ! -d "pkg/$DISTRIBUTION/debian" ]; then
-    echo "deb rules not found at pkg/$DISTRIBUTION/debian, run mkosi once with -ff to make sure the rules are cloned" >&2
+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
     exit 1
 fi
 
-cd "pkg/$DISTRIBUTION"
+cd "pkg/$PKG_SUBDIR"
 DEB_BUILD_PROFILES="pkg.systemd.upstream" apt-get build-dep .
index cea31ed697c02968e1fbfdbbd7472ba0d4c0f4f0..1424709cef0aa54de0eb10fb5f8769690603094a 100644 (file)
@@ -7,6 +7,7 @@ Distribution=fedora
 Environment=
         PKG_URL="https://src.fedoraproject.org/rpms/systemd"
         PKG_BRANCH="rawhide"
+        PKG_SUBDIR="fedora"
 
 Packages=
         btrfs-progs
index e1abe0b1351c0db0e649379a9d148dfa7312e6b7..e6246e52d552a90c4db9c332113bd8f288694992 100755 (executable)
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -ex
 
-if [ ! -f "pkg/$DISTRIBUTION/systemd.spec" ]; then
-    echo "spec not found at pkg/$DISTRIBUTION/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
+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
     exit 1
 fi
 
@@ -16,7 +16,7 @@ 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/$DISTRIBUTION" -name "files.*" -exec sed --in-place 's/\.gz$//' {} \;
+find "pkg/$PKG_SUBDIR" -name "files.*" -exec sed --in-place 's/\.gz$//' {} \;
 
 build() {
     # TODO: Replace meson_build and meson_install overrides with "--undefine __meson_verbose" once
@@ -28,7 +28,7 @@ build() {
         --with upstream \
         $( ((WITH_TESTS)) || echo --nocheck) \
         --define "_topdir /var/tmp" \
-        --define "_sourcedir pkg/$DISTRIBUTION" \
+        --define "_sourcedir pkg/$PKG_SUBDIR" \
         --define "_rpmdir $PACKAGEDIR" \
         ${BUILDDIR:+--define} \
         ${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \
@@ -46,7 +46,7 @@ build() {
         --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
         --define "__script_requires %{nil}" \
         "$@" \
-        "pkg/$DISTRIBUTION/systemd.spec"
+        "pkg/$PKG_SUBDIR/systemd.spec"
 }
 
 if ! build; then
@@ -58,6 +58,6 @@ if ! build; then
     # warnings.
     rm systemd.lang
 
-    cat /tmp/unpackaged-files >>"pkg/$DISTRIBUTION/files.systemd"
+    cat /tmp/unpackaged-files >>"pkg/$PKG_SUBDIR/files.systemd"
     build --noprep --nocheck
 fi
index 4ef13b6ca5b0ef2b33e17b2ce56e08d9a32a001d..1fca47b7cbb731a07d124ccf56c5c8e784f1a9a6 100644 (file)
@@ -10,6 +10,7 @@ InitrdInclude=initrd/
 Environment=
         PKG_URL="https://code.opensuse.org/package/systemd"
         PKG_BRANCH="master"
+        PKG_SUBDIR="opensuse"
         SYSTEMD_PACKAGES="systemd
                           udev
                           systemd-experimental
index dd01a3f20e92314a9e53e5ef4b5647834af1e8fc..a35a8f3bba2a26adaa8f076dacf118bb62137fc2 100755 (executable)
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -e
 
-if [ ! -f "pkg/$DISTRIBUTION/systemd.spec" ]; then
-    echo "spec not found at pkg/$DISTRIBUTION/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
+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
     exit 1
 fi
 
@@ -19,8 +19,8 @@ mkosi-chroot \
     --query \
     "$DEPS" \
     --define "_topdir /var/tmp" \
-    --define "_sourcedir pkg/$DISTRIBUTION" \
-    "pkg/$DISTRIBUTION/systemd.spec" |
+    --define "_sourcedir pkg/$PKG_SUBDIR" \
+    "pkg/$PKG_SUBDIR/systemd.spec" |
         grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev |
         sort --unique |
         tee /tmp/buildrequires |
@@ -36,9 +36,9 @@ until mkosi-chroot \
     --build-in-place \
     --with upstream \
     --define "_topdir /var/tmp" \
-    --define "_sourcedir pkg/$DISTRIBUTION" \
+    --define "_sourcedir pkg/$PKG_SUBDIR" \
     --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
-    "pkg/$DISTRIBUTION/systemd.spec"
+    "pkg/$PKG_SUBDIR/systemd.spec"
 do
     EXIT_STATUS=$?
     if [ $EXIT_STATUS -ne 11 ]; then
index 5ab43befc17c238f06ede6cba78093703e02530e..b95a73bc08bb6b258e804d4facf29a36f38d6d4d 100755 (executable)
@@ -6,8 +6,8 @@ if ((CACHED)); then
     exit 0
 fi
 
-if [ -z "$(ls --almost-all "pkg/$DISTRIBUTION")" ]; then
-    git clone "$PKG_URL" --branch "$PKG_BRANCH" "pkg/$DISTRIBUTION"
-elif [ -d "pkg/$DISTRIBUTION/.git" ] && [ "$(git -C "pkg/$DISTRIBUTION" rev-parse --abbrev-ref HEAD)" = "$PKG_BRANCH" ]; then
-    git -C "pkg/$DISTRIBUTION" pull
+if [ -z "$(ls --almost-all "pkg/$PKG_SUBDIR")" ]; then
+    git clone "$PKG_URL" --branch "$PKG_BRANCH" "pkg/$PKG_SUBDIR"
+elif [ -d "pkg/$PKG_SUBDIR/.git" ] && [ "$(git -C "pkg/$PKG_SUBDIR" rev-parse --abbrev-ref HEAD)" = "$PKG_BRANCH" ]; then
+    git -C "pkg/$PKG_SUBDIR" pull
 fi