]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - mkosi.build
basic: use -EINVAL for _MANAGED_OOM_PREFERENCE_INVALID
[thirdparty/systemd.git] / mkosi.build
index 4a13f1075eb47987528b85997653dc7151a0e5b5..a74fc196be5b3630536b8cf7b01f38c087ac5c95 100755 (executable)
@@ -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.
@@ -9,8 +9,10 @@ set -ex
 # so the files keep those permissions, otherwise details of what umask
 # was set at the time the git tree was cloned will leak all the way
 # through. Also set umask explicitly during the build.
-chmod -R u+w,go-w,a+rX .
-umask 022
+if ! mountpoint -q "$SRCDIR"; then
+        chmod -R u+w,go-w,a+rX .
+        umask 022
+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.
@@ -21,21 +23,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
 
@@ -84,18 +86,33 @@ 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" \
+                -D translations=false \
+                -D version-tag="${VERSION_TAG}"
 fi
 
-ninja -C "$BUILDDIR" all
+cd "$BUILDDIR"
+ninja "$@"
 if [ "$WITH_TESTS" = 1 ] ; then
         for id in 1 2 3; do
-                groupadd -g $id testgroup$id || :
+                getent group $id > /dev/null || groupadd -g $id testgroup$id
         done
 
-        ninja -C "$BUILDDIR" test
+        ninja test
+fi
+cd "$SRCDIR"
+
+# 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 --only-changed
+else
+        meson install -C "$BUILDDIR" --no-rebuild --only-changed
 fi
-ninja -C "$BUILDDIR" install
 
 mkdir -p "$DESTDIR"/etc