]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
make.sh: Don't try to create a time NS on older kernels
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 28 Aug 2024 15:41:55 +0000 (15:41 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 29 Aug 2024 07:37:38 +0000 (07:37 +0000)
This is not supported on kernels < 5.6.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
make.sh

diff --git a/make.sh b/make.sh
index f41477a5f7ba3d4e9ded94233957f020056aca08..3442709b03f9b1cf0190581f2ee3425fcf6b3ba0 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -54,9 +54,19 @@ ARCHES=(
 )
 
 HOST_ARCH="${HOSTTYPE}"
+HOST_KERNEL="$(uname -r)"
 LC_ALL=POSIX
 PS1='\u:\w$ '
 
+HAS_TIME_NAMESPACE="true"
+
+# Disable time namespaces for older kernels
+case "${HOST_KERNEL}" in
+       4.*|5.[12345].*)
+               HAS_TIME_NAMESPACE="false"
+               ;;
+esac
+
 # Are we reading from/writing to a terminal?
 is_terminal() {
        [ -t 0 ] && [ -t 1 ] && [ -t 2 ]
@@ -674,9 +684,6 @@ execute() {
                        "--pid"
                        "--fork"
 
-                       # Create a new time namespace
-                       "--time"
-
                        # Create a new UTS namespace
                        "--uts"
 
@@ -687,6 +694,11 @@ execute() {
                        # If unshare is asked to terminate, terminate all child processes
                        "--kill-child"
                )
+
+               # Optionally set up a new time namespace
+               if [ "${HAS_TIME_NAMESPACE}" = "true" ]; then
+                       unshare+=( "--time" )
+               fi
        fi
 
        while [ $# -gt 0 ]; do