]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: work-around to make systemd build in Fedora images that lack populated /etc
authorLennart Poettering <lennart@poettering.net>
Thu, 1 Apr 2021 15:58:54 +0000 (17:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Apr 2021 15:45:28 +0000 (17:45 +0200)
On Fedora /usr/bin/ld is a symlink managed via the "alternatives"
system. This unfortunately means the binary is not usable in
environments where /var or /etc are unpopulated. Let's address this by
redirecting "ld" to "ld.bfd" manually if such an environment is
detected, via $PATH.

This is useful for building systemd in mkosi with UsrOnly=1 set.

mkosi.build

index a74fc196be5b3630536b8cf7b01f38c087ac5c95..ff339b440c29f1950878dd02dcbd3fc146241f36 100755 (executable)
@@ -14,6 +14,18 @@ if ! mountpoint -q "$SRCDIR"; then
         umask 022
 fi
 
+# On Fedora "ld" is (unfortunately — if you ask me) managed via
+# "alternatives". Since we'd like to support building images in environments
+# with only /usr/ around (e.g. mkosi's UsrOnly=1 option), we have the problem
+# that /usr/bin/ld is a symlink that points to a non-existing file in
+# /etc/alternative/ in this mode. Let's work around this for now by manually
+# redirect "ld" to "ld.bfd", i.e. circumventing the /usr/bin/ld symlink.
+if [ ! -x /usr/bin/ld -a -x /usr/bin/ld.bfd ] ; then
+        mkdir -p "$HOME"/bin
+        ln -s /usr/bin/ld.bfd "$HOME"/bin/ld
+        PATH="$HOME/bin:$PATH"
+fi
+
 # If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it
 # as out-of-tree build dir. Otherwise, let's make up our own builddir.
 [ -z "$BUILDDIR" ] && BUILDDIR=build