#3615 PR merged: Error out when KERNEL_VERSION is not set¶
Labels: fixed / solved / done, minor bug
jsmeix opened issue at 2026-07-09 08:22:¶
-
Type: Bug Fix
-
Impact: Low
-
Reference to related issue (URL):
https://github.com/rear/rear/pull/3614#discussion_r3528343520 -
How was this pull request tested?
For me it Errors out for those wrong settings in local.conf
KERNEL_VERSION=''
KERNEL_VERSION=' '
KERNEL_VERSION='foo bar'
unset KERNEL_VERSION
- Description of the changes in this pull request:
In build/GNU/Linux/400_copy_modules.sh
KERNEL_VERSION must be set.
It is set in default.conf to $( uname -r )
if not set by the user via the '-r' option of sbin/rear
so if it is not set it is likely an error by the user
(e.g. empty setting in local.conf).
If we set it to $( uname -r ) if not set,
we would falsely hide an error, cf.
"In case of errors better abort than to blindly proceed" in
https://github.com/rear/rear/wiki/Coding-Style
So we Error out now, see
https://github.com/rear/rear/pull/3614#discussion_r3528343520
But now the test is moved from
build/GNU/Linux/400_copy_modules.sh
to
prep/GNU/Linux/400_guess_kernel.sh
because this is the first script that uses KERNEL_VERSION
and the test now ensures KERNEL_VERSION is
a single non empty and non blank word.
codacy-production commented at 2026-07-09 08:24:¶
Up to standards ✅¶
🟢 Issues 0 issues
> > > **Results:** > `0` new issues > > [View in > Codacy](https://app.codacy.com/gh/rear/rear/pull-requests/3615/issues) >
NEW Get contextual insights on your PRs based on Codacy's
metrics, along with PR and Jira context, without leaving GitHub. Enable
AI
reviewer
TIP This summary will be updated as you push new changes.
jsmeix commented at 2026-07-09 08:48:¶
Testing with the test
test "$KERNEL_VERSION" || Error "KERNEL_VERSION must be set"
in build/GNU/Linux/400_copy_modules.sh
With KERNEL_VERSION='' in local.conf I get
# usr/sbin/rear -D mkrescue
...
ERROR: FindStorageDrivers called but STORAGE_DRIVERS is empty and no builtin storage modules found
Some latest log messages since the last called script 260_storage_drivers.sh:
2026-07-09 10:35:57.401225807 Entering debugscript mode via 'set -x'.
2026-07-09 10:35:57.409746500 Trusted sourcing '/root/rear.github.master/usr/share/rear/rescue/GNU/Linux/260_storage_drivers.sh'
grep: /lib/modules//modules.builtin: No such file or directory
With KERNEL_VERSION=' ' in local.conf I get
# usr/sbin/rear -D mkrescue
...
No kernel found in /boot that matches KERNEL_VERSION ' '
ERROR: Cannot autodetect what to use as KERNEL_FILE, you have to manually specify it in /root/rear.github.master/etc/rear/local.conf
Some latest log messages since the last called script 400_guess_kernel.sh:
2026-07-09 10:35:22.860001867 Entering debugscript mode via 'set -x'.
2026-07-09 10:35:22.868958732 Trusted sourcing '/root/rear.github.master/usr/share/rear/prep/GNU/Linux/400_guess_kernel.sh'
2026-07-09 10:35:22.878055101 No kernel file '/boot/vmlinux- ' found
2026-07-09 10:35:23.694687290 No kernel found in /boot that matches KERNEL_VERSION ' '
Where KERNEL_VERSION appears in the code:
# find usr/sbin/rear usr/share/rear/ -type f | xargs grep -l 'KERNEL_VERSION'
usr/sbin/rear
usr/share/rear/conf/default.conf
usr/share/rear/finalize/Fedora/550_rebuild_initramfs.sh
usr/share/rear/prep/GNU/Linux/400_guess_kernel.sh
usr/share/rear/rescue/GNU/Linux/240_kernel_modules.sh
usr/share/rear/rescue/GNU/Linux/260_collect_initrd_modules.sh
usr/share/rear/rescue/GNU/Linux/230_storage_and_network_modules.sh
usr/share/rear/lib/help-workflow.sh
usr/share/rear/lib/linux-functions.sh
usr/share/rear/lib/bootloader-functions.sh
usr/share/rear/build/GNU/Linux/400_copy_modules.sh
usr/share/rear/output/USB/Linux-i386/300_create_extlinux.sh
So for 'rear mkrescue'
prep/GNU/Linux/400_guess_kernel.sh
is the first script that uses KERNEL_VERSION
For 'rear recover'
finalize/Fedora/550_rebuild_initramfs.sh
only mentions KERNEL_VERSION in a comment
so KERNEL_VERSION is not used for 'rear recover'.
I will move the test from
build/GNU/Linux/400_copy_modules.sh
to
prep/GNU/Linux/400_guess_kernel.sh
and
ensure KERNEL_VERSION is a single non empty and non blank word.
jsmeix commented at 2026-07-09 10:15:¶
@rear/contributors
provided no objections appear
I would like to merge it tomorrow afternoon.
[Export of Github issue for rear/rear.]