From 06ac1b1f2ce7c51f12019498e6ca305492f86c9f Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 6 Dec 2020 16:43:58 +0000 Subject: [PATCH 1/6] mkosi: Use meson install instead of ninja install in build script Allows using extra options not available when using ninja. --- mkosi.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.build b/mkosi.build index 4a13f1075e..192c194a2d 100755 --- a/mkosi.build +++ b/mkosi.build @@ -95,7 +95,7 @@ if [ "$WITH_TESTS" = 1 ] ; then ninja -C "$BUILDDIR" test fi -ninja -C "$BUILDDIR" install +meson install -C "$BUILDDIR" mkdir -p "$DESTDIR"/etc From 1394a3ec351048bae008627a0775d1f9a6c46294 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 6 Dec 2020 16:45:01 +0000 Subject: [PATCH 2/6] mkosi: Remove bash -x option from mkosi.build -x is for debugging purposes. During regular usage, using -x mostly prints useless output when building the mkosi image. --- mkosi.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.build b/mkosi.build index 192c194a2d..eb24798526 100755 --- a/mkosi.build +++ b/mkosi.build @@ -1,5 +1,5 @@ #!/bin/sh -set -ex +set -e # This is a build script for OS image generation using mkosi (https://github.com/systemd/mkosi). # Simply invoke "mkosi" in the project directory to build an OS image. From fe2b7631ad20b0e518b9f566608ff5f9b84d4d8b Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 6 Dec 2020 16:45:45 +0000 Subject: [PATCH 3/6] mkosi: Add --quiet and --no-rebuild options to meson install in mkosi.build By default, meson install prints a line for every file it installs. This is verbose and doesn't provide much value. Let's silence the meson install step to remove this output from the mkosi build step. The --no-rebuild option removes some additional duplicate output by the meson install step. Ubuntu Focal still has meson 0.53.0 so we add a version check and only use the new feature if the meson version supports it. --- mkosi.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mkosi.build b/mkosi.build index eb24798526..c16cd3c33b 100755 --- a/mkosi.build +++ b/mkosi.build @@ -95,7 +95,13 @@ if [ "$WITH_TESTS" = 1 ] ; then ninja -C "$BUILDDIR" test fi -meson install -C "$BUILDDIR" + +# Ubuntu Focal is stuck with meson 0.53.0. +if [ "$(meson -v | cut -d . -f 2)" -gt 53 ] ; then + meson install -C "$BUILDDIR" --quiet --no-rebuild +else + meson install -C "$BUILDDIR" --no-rebuild +fi mkdir -p "$DESTDIR"/etc From 3dab2a46971dd5493c6ca80e9e2504a1a0b9bcb7 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 6 Dec 2020 16:47:25 +0000 Subject: [PATCH 4/6] mkosi: Remove explicit default_hierarchy=unified option from mkosi.build default_hierarchy is set to unified in meson_options already so we can remove it from mkosi.build. --- mkosi.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.build b/mkosi.build index c16cd3c33b..113d2cdd55 100755 --- a/mkosi.build +++ b/mkosi.build @@ -84,7 +84,7 @@ if [ ! -f "$BUILDDIR"/build.ninja ] ; then fi fi - 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" + meson "$BUILDDIR" -D "sysvinit-path=$sysvinit_path" -D "rootprefix=$rootprefix" -D man=false -D "nobody-user=$nobody_user" -D "nobody-group=$nobody_group" fi ninja -C "$BUILDDIR" all From 5e577e1737a4fd603067536b3b21d32f7d180fee Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 6 Dec 2020 18:16:00 +0000 Subject: [PATCH 5/6] mkosi: Silence locale checking in mkosi.build Avoid warning and error logs from locale charmap and export LC_CTYPE by piping to dev/null and checking if locales are available before using them. --- mkosi.build | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mkosi.build b/mkosi.build index 113d2cdd55..f170f9b957 100755 --- a/mkosi.build +++ b/mkosi.build @@ -21,21 +21,21 @@ umask 022 # 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)" != "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.) - export LC_CTYPE=C.UTF-8 - if [ "$(locale charmap)" != "UTF-8" ] ; then - # Finally, try something like en_US.UTF-8, which should be - # available in Arch Linux, but is not present in Debian's - # minimal image in our mkosi config. + if locale -a | grep -q -E "C.UTF-8|C.utf8"; then + export LC_CTYPE=C.UTF-8 + # Finally, try something like en_US.UTF-8, which should be + # available in Arch Linux, but is not present in Debian's + # minimal image in our mkosi config. + elif locale -a | grep -q en_US.utf8; then export LC_CTYPE=en_US.UTF-8 - if [ "$(locale charmap)" != "UTF-8" ] ; then - # If nothing works, fail early. - echo "*** Could not find a valid locale that supports UTF-8. ***" >&2 - exit 1 - fi + else + # If nothing works, fail early. + echo "*** Could not find a valid locale that supports UTF-8. ***" >&2 + exit 1 fi fi From 09422f9a28481eb5c49d375a6b5b7ca2b773c1ae Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 6 Dec 2020 18:16:59 +0000 Subject: [PATCH 6/6] meson: Respect MESON_INSTALL_QUIET MESON_INSTALL_QUIET is set when --quiet is passed to meson install. Make sure we check the variable in our custom install scripts and don't output anything if it is set. --- tools/meson-make-symlink.sh | 12 +++++++++--- units/meson-add-wants.sh | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/meson-make-symlink.sh b/tools/meson-make-symlink.sh index cdd5214125..8c7e887f51 100755 --- a/tools/meson-make-symlink.sh +++ b/tools/meson-make-symlink.sh @@ -1,12 +1,18 @@ #!/bin/sh set -eu +if [ "${MESON_INSTALL_QUIET:-0}" = 1 ] ; then + VERBOSE="" +else + VERBOSE="v" +fi + # this is needed mostly because $DESTDIR is provided as a variable, # and we need to create the target directory... -mkdir -vp "$(dirname "${DESTDIR:-}$2")" +mkdir -${VERBOSE}p "$(dirname "${DESTDIR:-}$2")" if [ "$(dirname $1)" = . -o "$(dirname $1)" = .. ]; then - ln -vfs -T -- "$1" "${DESTDIR:-}$2" + ln -${VERBOSE}fs -T -- "$1" "${DESTDIR:-}$2" else - ln -vfs -T --relative -- "${DESTDIR:-}$1" "${DESTDIR:-}$2" + ln -${VERBOSE}fs -T --relative -- "${DESTDIR:-}$1" "${DESTDIR:-}$2" fi diff --git a/units/meson-add-wants.sh b/units/meson-add-wants.sh index a483d75b86..2241fc26a2 100755 --- a/units/meson-add-wants.sh +++ b/units/meson-add-wants.sh @@ -5,6 +5,12 @@ unitdir="$1" target="$2" unit="$3" +if [ "${MESON_INSTALL_QUIET:-0}" = 1 ] ; then + VERBOSE="" +else + VERBOSE="v" +fi + case "$target" in */?*) # a path, but not just a slash at the end dir="${DESTDIR:-}${target}" @@ -18,11 +24,11 @@ unitpath="${DESTDIR:-}${unitdir}/${unit}" case "$target" in */) - mkdir -vp -m 0755 "$dir" + mkdir -${VERBOSE}p -m 0755 "$dir" ;; *) - mkdir -vp -m 0755 "$(dirname "$dir")" + mkdir -${VERBOSE}p -m 0755 "$(dirname "$dir")" ;; esac -ln -vfs --relative "$unitpath" "$dir" +ln -${VERBOSE}fs --relative "$unitpath" "$dir"