]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
ci: flesh out print-kdir.sh script, bash ftw
authorEmil Velikov <emil.l.velikov@gmail.com>
Sat, 14 Sep 2024 15:46:27 +0000 (16:46 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 17 Sep 2024 02:59:23 +0000 (21:59 -0500)
We'll be adding another action, where this script is handy. Flesh it out
to scripts and convert to bash.

v2:
 - move script to .github/

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/132
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
.github/print-kdir.sh [new file with mode: 0755]
.github/workflows/main.yml

diff --git a/.github/print-kdir.sh b/.github/print-kdir.sh
new file mode 100755 (executable)
index 0000000..42bb9b3
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -euo pipefail
+
+for moddir in /usr/lib/modules /lib/modules; do
+    if [[ -e "$moddir" ]]; then
+        kernel=$(find "$moddir" -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)
+        break
+    fi
+done
+
+# There should be one entry - the kernel we installed
+if (( $(echo "$kernel" | wc -l) != 1 )); then
+    echo >&2 "Error: exactly one kernel must be installed"
+fi
+echo "KDIR=$moddir/$kernel/build"
index 552e697fba77403d6fe581837c191f861914bb80..f8a386cad234197b23fb259bfd8d9ce387c711b8 100644 (file)
@@ -60,18 +60,7 @@ jobs:
           # doesn't quite work. Perhaps our double/sparse checkout is to blame?
           git config --global --add safe.directory '*'
 
-          for moddir in /usr/lib/modules /lib/modules; do
-            if [ -e "$moddir" ]; then
-              kernel=$(find "$moddir" -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)
-              break
-            fi
-          done
-
-          # There should be one entry - the kernel we installed
-          if [ $(echo "$kernel" | wc -l) -ne 1 ]; then
-            echo >&2 "Error: exactly one kernel must be installed"
-          fi
-          echo "KDIR=$moddir/$kernel/build" >> "$GITHUB_ENV"
+          .github/print-kdir.sh >> "$GITHUB_ENV"
 
       - name: configure (meson)
         if: ${{ matrix.build == 'meson' }}