mkosi: Use distro-invariant rootprefix

Distributions may be build with various configs, e.g. customized
rootprefix. It'd be unmaintanable to have specific mkosi.build for each
supported distro. Hence, make the build script flexible yet distro
oblivious.
This commit is contained in:
Michal Koutný 2020-04-21 18:08:23 +02:00
parent 9df91db5e0
commit bac567a53b
1 changed files with 9 additions and 1 deletions

View File

@ -42,6 +42,14 @@ fi
if [ ! -f "$BUILDDIR"/build.ninja ] ; then if [ ! -f "$BUILDDIR"/build.ninja ] ; then
sysvinit_path=`realpath /etc/init.d` sysvinit_path=`realpath /etc/init.d`
init_path=`realpath /sbin/init 2>/dev/null`
if [ -z "$init_path" ] ; then
rootprefix=""
else
rootprefix=${init_path%/lib/systemd/systemd}
rootprefix=/${rootprefix#/}
fi
nobody_user=`id -u -n 65534 2> /dev/null` nobody_user=`id -u -n 65534 2> /dev/null`
if [ "$nobody_user" != "" ] ; then if [ "$nobody_user" != "" ] ; then
# Validate that we can translate forth and back # Validate that we can translate forth and back
@ -76,7 +84,7 @@ if [ ! -f "$BUILDDIR"/build.ninja ] ; then
fi fi
fi fi
meson "$BUILDDIR" -D "sysvinit-path=$sysvinit_path" -D default-hierarchy=unified -D man=false -D "nobody-user=$nobody_user" -D "nobody-group=$nobody_group" meson "$BUILDDIR" -D "sysvinit-path=$sysvinit_path" -D "rootprefix=$rootprefix" -D default-hierarchy=unified -D man=false -D "nobody-user=$nobody_user" -D "nobody-group=$nobody_group"
fi fi
ninja -C "$BUILDDIR" all ninja -C "$BUILDDIR" all