#1962 PR merged: cleanup REQUIRED_PROGS checks (issue 892)

Labels: enhancement, cleanup, fixed / solved / done, minor bug

jsmeix opened issue at 2018-11-12 10:56:

1.)
using REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}" qqqq ) in local.conf
and then "rear mkrescue" errors out as follows

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 9292)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
ERROR: Cannot find required programs:  qqqq
Some latest log messages since the last called script 950_check_missing_programs.sh:
  2018-11-12 11:49:44.968520950 Including init/default/950_check_missing_programs.sh
  2018-11-12 11:49:44.969355108 Entering debugscripts mode via 'set -x'.
  /root/rear.github.master/usr/share/rear/lib/_input-output-functions.sh: line 331: type: qqqq: not found
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 9292) and its descendant processes
Running exit tasks
Terminated

2.)
adding REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}" qqqq ) to the
beginning of usr/share/rear/rescue/GNU/Linux/310_network_devices.sh
and then "rear mkrescue" errors out as follows

# usr/sbin/rear -D mkrescue
...
ERROR: Cannot find required programs:  qqqq
Some latest log messages since the last called script 950_check_missing_programs.sh:
  2018-11-12 11:51:48.184373955 Entering debugscripts mode via 'set -x'.
  2018-11-12 11:51:48.196512748 Leaving debugscripts mode (back to previous bash flags and options settings).
  2018-11-12 11:51:48.200021423 Including build/GNU/Linux/630_verify_resolv_conf_file.sh
  2018-11-12 11:51:48.200942085 Entering debugscripts mode via 'set -x'.
  2018-11-12 11:51:48.204695351 Leaving debugscripts mode (back to previous bash flags and options settings).
  2018-11-12 11:51:48.208254856 Including build/default/950_check_missing_programs.sh
  2018-11-12 11:51:48.209174466 Entering debugscripts mode via 'set -x'.
  /root/rear.github.master/usr/share/rear/lib/_input-output-functions.sh: line 331: type: qqqq: not found
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 9576) and its descendant processes
Running exit tasks
You should also rm -Rf /tmp/rear.fvNmDTnnd1tA1SC
Terminated
  • Brief description of the changes in this pull request:

Moved usr/share/rear/prep/default/950_check_missing_programs.sh
to usr/share/rear/init/default/950_check_missing_programs.sh
and removed the dulicated code from usr/sbin/rear which is now
obsolete because the init stage scripts are run in any case.

Added usr/share/rear/build/default/950_check_missing_programs.sh symlink
that points to usr/share/rear/init/default/950_check_missing_programs.sh
so that this check is run again during 'build' stage (i.e. after the 'prep'
and 'layout/save' and 'rescue' stages where additional required programs
are added to the REQUIRED_PROGS array during "rear mkrescue").

jsmeix commented at 2018-11-12 13:37:

@gdha
do you think I should further enhance it and add
an additional verification step to build/default/980_verify_rootfs.sh
that checks that each program in the REQUIRED_PROGS array
(and perhaps also each program in the PROGS array)
is actually executable within the recovery system?

jsmeix commented at 2018-11-13 15:25:

I added a simple verification step to build/default/980_verify_rootfs.sh
that checks that each program in the REQUIRED_PROGS array and also
each program in the PROGS array (provided it exists on the original system)
is an executable command within the recovery system.

Tested with

REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}" /usr/bin/dircolors )
PROGS=( "${PROGS[@]}" /usr/bin/realpath )

where "rear -D mkrescue" works well (at least for me)
according to the debug log messages.

Additionally tested the error behaviour with an artificial

rm $ROOTFS_DIR/sbin/dircolors $ROOTFS_DIR/sbin/realpath

at the beginning of usr/share/rear/build/default/980_verify_rootfs.sh
where now "rear -D mkrescue" correctly bug-errors out with

Testing that the recovery system in /tmp/rear.PRdNVcGhDQJaTS3/rootfs contains a usable system
There are programs that cannot be found as executable command in the ReaR recovery system
 realpath
ReaR recovery system in '/tmp/rear.PRdNVcGhDQJaTS3/rootfs' lacks programs, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Required programs cannot be found as executable command in the ReaR recovery system (bug error)
 dircolors
ReaR recovery system in '/tmp/rear.PRdNVcGhDQJaTS3/rootfs' lacks required programs, check /root/rear.github.master/var/log/rear/rear-g243.log for details
ERROR: 
====================
BUG in /root/rear.github.master/usr/share/rear/build/default/980_verify_rootfs.sh line 168:
'ReaR recovery system in '/tmp/rear.PRdNVcGhDQJaTS3/rootfs' not usable (required programs are missing)'
--------------------
Please report this issue at https://github.com/rear/rear/issues
and include the relevant parts from /root/rear.github.master/var/log/rear/rear-g243.log
preferably with full debug information via 'rear -D mkrescue'
====================
Some latest log messages since the last called script 980_verify_rootfs.sh:
  efibootmgr is /sbin/efibootmgr
  wipefs is /sbin/wipefs
  cryptsetup is /sbin/cryptsetup
  dmsetup is /sbin/dmsetup
  ldconfig is /sbin/ldconfig
  2018-11-13 16:20:37.637771255 Required programs cannot be found as executable command in the ReaR recovery system (bug error)
  2018-11-13 16:20:37.639224313  dircolors
  2018-11-13 16:20:37.641133749 ReaR recovery system in '/tmp/rear.PRdNVcGhDQJaTS3/rootfs' lacks required programs, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 16063) and its descendant processes
Running exit tasks
You should also rm -Rf /tmp/rear.PRdNVcGhDQJaTS3
Terminated

jsmeix commented at 2018-11-13 15:25:

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


[Export of Github issue for rear/rear.]