]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
ci: add KDIR to the environment
authorEmil Velikov <emil.l.velikov@gmail.com>
Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 3 Sep 2024 17:01:21 +0000 (12:01 -0500)
The environment variable is used in multiple places, so just set it
once.

While in there, check that only a single kernel is installed. It's
better to error out with a clear message.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
.github/workflows/main.yml

index d91155883aa3be22f5d0f18209f634dd1d1d4fdd..6e25c26f192b45886a719916ce83123c2aed8daa 100644 (file)
@@ -59,6 +59,19 @@ 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"
+
       - name: configure
         run: |
           mkdir build
@@ -74,7 +87,7 @@ jobs:
         if: ${{ matrix.test == 'yes' }}
         run: |
           cd build
-          make KDIR=/usr/lib/modules/*/build -j$(nproc) check
+          make -j$(nproc) check
 
       - name: install
         run: |
@@ -85,4 +98,4 @@ jobs:
         if: ${{ matrix.test == 'yes' }}
         run: |
           cd build
-          make KDIR=/usr/lib/modules/*/build distcheck
+          make distcheck