mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
Merge pull request #20629 from keszybz/mkosi-host-distro-by-default
mkosi: build for the host distro by default
This commit is contained in:
commit
2c1591b91e
4
.gitignore
vendored
4
.gitignore
vendored
@ -36,6 +36,6 @@ __pycache__/
|
||||
/mkosi.builddir/
|
||||
/mkosi.output/
|
||||
/mkosi.default
|
||||
mkosi.default.d/*
|
||||
!mkosi.default.d/10-systemd.conf
|
||||
# Ignore any mkosi config files with "local" in the name
|
||||
/mkosi.default.d/*local*.conf
|
||||
/tags
|
||||
|
@ -34,13 +34,10 @@ possible, however. In order to simplify testing for cases like this we provide
|
||||
a set of `mkosi` build files directly in the source tree. `mkosi` is a tool for
|
||||
building clean OS images from an upstream distribution in combination with a
|
||||
fresh build of the project in the local working directory. To make use of this,
|
||||
please acquire `mkosi` from https://github.com/systemd/mkosi first, unless your
|
||||
distribution has packaged it already and you can get it from there. After the
|
||||
tool is installed, symlink the settings file for your distribution of choice
|
||||
from .mkosi/ to mkosi.default in the project root directory (note that the
|
||||
package manager for this distro needs to be installed on your host system).
|
||||
After doing that, it is sufficient to type `mkosi` in the systemd project
|
||||
directory to generate a disk image `image.raw` you can boot either in
|
||||
please install the `mkosi` package (if not packaged for your distro, it can be
|
||||
downloaded from https://github.com/systemd/mkosi). `mkosi` will build an image
|
||||
for the host distro by default. It is sufficient to type `mkosi` in the systemd
|
||||
project directory to generate a disk image `image.raw` you can boot either in
|
||||
`systemd-nspawn` or in an UEFI-capable VM:
|
||||
|
||||
```
|
||||
|
52
mkosi.build
52
mkosi.build
@ -20,7 +20,7 @@ fi
|
||||
# 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
|
||||
if [ ! -x /usr/bin/ld ] && [ -x /usr/bin/ld.bfd ]; then
|
||||
mkdir -p "$HOME"/bin
|
||||
ln -s /usr/bin/ld.bfd "$HOME"/bin/ld
|
||||
PATH="$HOME/bin:$PATH"
|
||||
@ -35,7 +35,7 @@ fi
|
||||
# So let's ensure we're running under UTF-8.
|
||||
#
|
||||
# If our current locale already is UTF-8, then we don't need to do anything:
|
||||
if [ "$(locale charmap 2> /dev/null)" != "UTF-8" ] ; then
|
||||
if [ "$(locale charmap 2>/dev/null)" != "UTF-8" ] ; then
|
||||
# Try using C.UTF-8 locale, if available. This locale is not shipped
|
||||
# by upstream glibc, so it's not available in all distros.
|
||||
# (In particular, it's not available in Arch Linux.)
|
||||
@ -54,9 +54,9 @@ if [ "$(locale charmap 2> /dev/null)" != "UTF-8" ] ; then
|
||||
fi
|
||||
|
||||
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`
|
||||
init_path=$(realpath /sbin/init 2>/dev/null)
|
||||
if [ -z "$init_path" ] ; then
|
||||
rootprefix=""
|
||||
else
|
||||
@ -64,46 +64,10 @@ if [ ! -f "$BUILDDIR"/build.ninja ] ; then
|
||||
rootprefix=/${rootprefix#/}
|
||||
fi
|
||||
|
||||
nobody_user=`id -u -n 65534 2> /dev/null`
|
||||
if [ "$nobody_user" != "" ] ; then
|
||||
# Validate that we can translate forth and back
|
||||
if [ "`id -u $nobody_user`" != 65534 ] ; then
|
||||
nobody_user=""
|
||||
fi
|
||||
fi
|
||||
if [ "$nobody_user" = "" ] ; then
|
||||
if id -u nobody 2> /dev/null ; then
|
||||
# The "nobody" user is defined already for something else, pick the Fedora name
|
||||
nobody_user=nfsnobody
|
||||
else
|
||||
# The "nobody" user name is free, use it
|
||||
nobody_user=nobody
|
||||
fi
|
||||
fi
|
||||
|
||||
nobody_group=`id -g -n 65534 2> /dev/null`
|
||||
if [ "$nobody_group" != "" ] ; then
|
||||
# Validate that we can translate forth and back
|
||||
if [ "`id -g $nobody_group`" != 65534 ] ; then
|
||||
nobody_group=""
|
||||
fi
|
||||
fi
|
||||
if [ "$nobody_group" = "" ] ; then
|
||||
if id -u nobody 2> /dev/null ; then
|
||||
# The "nobody" group is defined already for something else, pick the Fedora name
|
||||
nobody_group=nfsnobody
|
||||
else
|
||||
# The "nobody" group name is free, use it
|
||||
nobody_group=nobody
|
||||
fi
|
||||
fi
|
||||
|
||||
meson "$BUILDDIR" \
|
||||
-D "sysvinit-path=$sysvinit_path" \
|
||||
-D "rootprefix=$rootprefix" \
|
||||
-D man=false \
|
||||
-D "nobody-user=$nobody_user" \
|
||||
-D "nobody-group=$nobody_group" \
|
||||
-D translations=false \
|
||||
-D version-tag="${VERSION_TAG}"
|
||||
fi
|
||||
@ -112,7 +76,7 @@ cd "$BUILDDIR"
|
||||
ninja "$@"
|
||||
if [ "$WITH_TESTS" = 1 ] ; then
|
||||
for id in 1 2 3; do
|
||||
getent group $id > /dev/null || groupadd -g $id testgroup$id
|
||||
getent group $id >/dev/null || groupadd -g $id testgroup$id
|
||||
done
|
||||
|
||||
ninja test
|
||||
@ -128,7 +92,7 @@ fi
|
||||
|
||||
mkdir -p "$DESTDIR"/etc
|
||||
|
||||
cat > "$DESTDIR"/etc/issue <<EOF
|
||||
cat >"$DESTDIR"/etc/issue <<EOF
|
||||
\S (built from systemd tree)
|
||||
Kernel \r on an \m (\l)
|
||||
|
||||
@ -138,7 +102,7 @@ if [ -n "$IMAGE_ID" ] ; then
|
||||
mkdir -p "$DESTDIR"/usr/lib
|
||||
sed -n \
|
||||
-e '/^IMAGE_ID=/!p' \
|
||||
-e '$aIMAGE_ID='$IMAGE_ID < /usr/lib/os-release > "$DESTDIR"/usr/lib/os-release
|
||||
-e "\$aIMAGE_ID=$IMAGE_ID" <"/usr/lib/os-release" >"${DESTDIR}/usr/lib/os-release"
|
||||
|
||||
OSRELEASEFILE="$DESTDIR"/usr/lib/os-release
|
||||
else
|
||||
@ -150,7 +114,7 @@ if [ -n "$IMAGE_VERSION" ] ; then
|
||||
mkdir -p "$DESTDIR"/usr/lib
|
||||
sed -n \
|
||||
-e '/^IMAGE_VERSION=/!p' \
|
||||
-e '$aIMAGE_VERSION='$IMAGE_VERSION < $OSRELEASEFILE > /tmp/os-release.tmp
|
||||
-e "\$aIMAGE_VERSION=$IMAGE_VERSION" <$OSRELEASEFILE >"/tmp/os-release.tmp"
|
||||
|
||||
cat /tmp/os-release.tmp > "$DESTDIR"/usr/lib/os-release
|
||||
rm /tmp/os-release.tmp
|
||||
|
Loading…
Reference in New Issue
Block a user