diff options
author | Wolfgang Müller | 2022-04-26 18:30:05 +0200 |
---|---|---|
committer | Wolfgang Müller | 2022-04-26 18:30:05 +0200 |
commit | c51013909b5eb64671902e02b9a19d0fd11fbd46 (patch) | |
tree | 1544a3decae734f6b7823e2702ed13bb3c352aed | |
parent | c2d7609c36af239aa5146b8efa213fee9f446058 (diff) | |
download | kern-c51013909b5eb64671902e02b9a19d0fd11fbd46.tar.gz |
Check for kernel source directory
Some commands need to be launched inside the kernel source directory.
Even though the manual points this out, users may not know or forget.
Make sure to refuse working on a non-kernel directory: this will point
users in the right direction and avoid doing unnecessary work.
To detect a kernel source tree, check for existence of the 'Kbuild' and
'Kconfig' files.
Diffstat (limited to '')
-rwxr-xr-x | kern | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -13,6 +13,10 @@ errx() { exit 1 } +need_kernel_source() { + test -r Kbuild -a -r Kconfig || errx "current directory does not contain a kernel source tree, refusing" +} + has_boot_mount() { awk '{print $2}' /etc/fstab | grep -q ^/boot$ } @@ -65,6 +69,7 @@ set_kernel() { } config_kernel() { + need_kernel_source host=${1:-$(hostname)} test -d "$KERNFRAG" || errx "No such file or directory: $KERNFRAG" @@ -76,6 +81,7 @@ config_kernel() { } diff_kernel() { + need_kernel_source diff=${1:-$(get_running_config)} if command -v git >/dev/null; then @@ -86,10 +92,12 @@ diff_kernel() { } build_kernel() { + need_kernel_source make -j"$(nproc)" } install_kernel() { + need_kernel_source mount_boot_on_demand sudo make install modules_install } |