From fc5f5c2a3c7adb54369d4d2851ba772b914afbcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 2 Sep 2021 14:19:19 +0200 Subject: [PATCH 1/4] mkosi: drop the code to determine nobody user name The comments were outdated: at least "nfsnobody" is not used in Fedora since a few years. So I hope we don't need this anymore. The meson build scripts do autodetection on their own. --- mkosi.build | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/mkosi.build b/mkosi.build index 201b1888d5..4924bf300c 100755 --- a/mkosi.build +++ b/mkosi.build @@ -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 From 068d133881305adcbc5f60c7a92b22ad4ac5556c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 2 Sep 2021 14:22:19 +0200 Subject: [PATCH 2/4] mkosi: make mkosi.build shellcheck-clean Also remove the space after redirection operators. (Some redirections were with, some without, and I think it's nicer without.) --- mkosi.build | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mkosi.build b/mkosi.build index 4924bf300c..e73cf554ca 100755 --- a/mkosi.build +++ b/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 @@ -76,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 @@ -92,7 +92,7 @@ fi mkdir -p "$DESTDIR"/etc -cat > "$DESTDIR"/etc/issue <"$DESTDIR"/etc/issue < Date: Thu, 2 Sep 2021 14:39:37 +0200 Subject: [PATCH 4/4] mkosi: move distro files to mkosi.default.d/ With this change, "mkosi build" will automatically build systemd for the current distro without any further configuration. If people want to do a cross-distro build by default, they can still create mkosi.default, but I assume that this is relatively rare. If people have symlinked mkosi.default to one of the files in .mkosi/, they'll need to adjust the symlink. (Building without configuration would always fail, since systemd has many many required dependencies. I think it's nicer to do the most commonly expected thing by default, i.e. rebuild for the current distro.) Mkosi is nowadays packaged for most distros, so recommend installing of distro packages as the primary installation mechanism. --- docs/HACKING.md | 11 ++++------- {.mkosi => mkosi.default.d/arch}/mkosi.arch | 0 {.mkosi => mkosi.default.d/debian}/mkosi.debian | 0 {.mkosi => mkosi.default.d/fedora}/mkosi.fedora | 0 {.mkosi => mkosi.default.d/opensuse}/mkosi.opensuse | 0 {.mkosi => mkosi.default.d/ubuntu}/mkosi.ubuntu | 0 6 files changed, 4 insertions(+), 7 deletions(-) rename {.mkosi => mkosi.default.d/arch}/mkosi.arch (100%) rename {.mkosi => mkosi.default.d/debian}/mkosi.debian (100%) rename {.mkosi => mkosi.default.d/fedora}/mkosi.fedora (100%) rename {.mkosi => mkosi.default.d/opensuse}/mkosi.opensuse (100%) rename {.mkosi => mkosi.default.d/ubuntu}/mkosi.ubuntu (100%) diff --git a/docs/HACKING.md b/docs/HACKING.md index 7982be34d0..3131597c22 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -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: ``` diff --git a/.mkosi/mkosi.arch b/mkosi.default.d/arch/mkosi.arch similarity index 100% rename from .mkosi/mkosi.arch rename to mkosi.default.d/arch/mkosi.arch diff --git a/.mkosi/mkosi.debian b/mkosi.default.d/debian/mkosi.debian similarity index 100% rename from .mkosi/mkosi.debian rename to mkosi.default.d/debian/mkosi.debian diff --git a/.mkosi/mkosi.fedora b/mkosi.default.d/fedora/mkosi.fedora similarity index 100% rename from .mkosi/mkosi.fedora rename to mkosi.default.d/fedora/mkosi.fedora diff --git a/.mkosi/mkosi.opensuse b/mkosi.default.d/opensuse/mkosi.opensuse similarity index 100% rename from .mkosi/mkosi.opensuse rename to mkosi.default.d/opensuse/mkosi.opensuse diff --git a/.mkosi/mkosi.ubuntu b/mkosi.default.d/ubuntu/mkosi.ubuntu similarity index 100% rename from .mkosi/mkosi.ubuntu rename to mkosi.default.d/ubuntu/mkosi.ubuntu