#1352 PR merged: cleanup linux-functions.sh as preparation for issue1202

Labels: cleanup, fixed / solved / done

jsmeix opened issue at 2017-05-09 14:45:

cleanup linux-functions.sh and some related code
in 390_copy_binaries…_libraries.sh and
in _input-output-functions.sh as a preparation step
that is related to solve issue1202

jsmeix commented at 2017-05-09 14:56:

This is a major cleanup.
I did "rear mkrescue" with and without that changes
on my SLES12 test system.
I compared the contents in the two /tmp/rear.XXXX/rootfs
and both contain same files (in particular same binaries
and same kernel modules).
Of course also "rear recover" still works with that changes for me
so that from my current point of view it looks promising...

jsmeix commented at 2017-05-09 15:04:

In linux-functions.sh I removed the leftover functions
FindDrivers has_module has_any_module add_module cp_bin rpmtopdir
because those functions are nowhere called (has_module was only
called by has_any_module and add_module).
Here my results in current rear master (without that cleanup):

# for f in FindDrivers has_module has_any_module add_module cp_bin rpmtopdir ; do echo $f ; find usr/sbin/rear usr/share/rear/ | xargs grep "$f" ; echo ; done

FindDrivers
usr/share/rear/lib/linux-functions.sh:FindDrivers() {

has_module
usr/share/rear/lib/linux-functions.sh:has_module () {
usr/share/rear/lib/linux-functions.sh:          has_module "$module" && return 0
usr/share/rear/lib/linux-functions.sh:          has_module "$module" || modules="$modules $module"

has_any_module
usr/share/rear/lib/linux-functions.sh:has_any_module () {

add_module
usr/share/rear/lib/linux-functions.sh:add_module () {

cp_bin
usr/share/rear/lib/linux-functions.sh:cp_bin () {

rpmtopdir
usr/share/rear/lib/linux-functions.sh:function rpmtopdir () {

jsmeix commented at 2017-05-09 15:17:

In linux-functions.sh in the ResolveModules function
I removed usage of print_modprobeconf because
that variable was nowhere set in the code before:

# find usr/sbin/rear usr/share/rear/ | xargs grep 'print_modprobeconf'

usr/share/rear/lib/linux-functions.sh:                  if [ "$print_modprobeconf" = 1 ]; then
usr/share/rear/lib/linux-functions.sh:                          print_modprobeconf=0

and I removed usage of $boot_dir/etc/modprobe.conf
because boot_dir is not set in any script that runs before
build/GNU/Linux/400_copy_modules.sh
which is the only script that calls ResolveModules
so that $boot_dir is always empty in ResolveModules.
FYI:
boot_dir is used later in output/default/940_grub2_rescue.sh as

local boot_dir="/boot"

but that is useless for ResolveModules and 940_grub2_rescue.sh
is only run when GRUB_RESCUE is 'true'.

jsmeix commented at 2017-05-09 15:43:

If there are no furious objections
I would like to merge it tomorrow.

For the fun of it:
There is now a nice 'awk' gem where the plain code
is totally incomprehensible without explanatory comments
(at least for me).


[Export of Github issue for rear/rear.]