#3228 PR merged: Set RECOVERY_MODE also in PORTABLE mode

Labels: cleanup, fixed / solved / done

jsmeix opened issue at 2024-05-21 10:55:

In sbin/rear set RECOVERY_MODE also in PORTABLE mode
because the PORTABLE mode is meant to be used only
to run 'rear recover' within a foreign rescue system.

jsmeix commented at 2024-05-27 07:53:

Yes, of course - I know.
My plan is to replace our leftover
direct usage of /etc/rear-release

# find usr/sbin/rear usr/share/rear/ -type f | xargs grep 'rear-release' | grep -v ': *#'

usr/sbin/rear:
test -e "/etc/rear-release" && RECOVERY_MODE='y' || RECOVERY_MODE=''

usr/share/rear/init/default/002_check_rear_recover_mode.sh:
if test -f /etc/rear-release ; then

usr/share/rear/lib/help-workflow.sh:
    test -f /etc/rear-release && currently_usable_workflows="recover layoutonly restoreonly finalizeonly mountonly opaladmin help"

usr/share/rear/lib/recover-workflow.sh:
        test -f /etc/rear-release -a -w /etc/motd && echo -e '\nWelcome to Relax-and-Recover.\n' >/etc/motd

usr/share/rear/lib/mountonly-workflow.sh:
        test -f /etc/rear-release -a -w /etc/motd && echo -e '\nWelcome to Relax-and-Recover.\n' >/etc/motd

usr/share/rear/build/default/970_add_rear_release.sh:
echo "$PRODUCT release $VERSION" >$ROOTFS_DIR/etc/rear-release

where direct usage of /etc/rear-release is not needed.
At first glance I think direct usage of /etc/rear-release
is only needed in

usr/sbin/rear:
test -e "/etc/rear-release" && RECOVERY_MODE='y' || RECOVERY_MODE=''

usr/share/rear/build/default/970_add_rear_release.sh:
echo "$PRODUCT release $VERSION" >$ROOTFS_DIR/etc/rear-release

so direct usage of /etc/rear-release in

usr/share/rear/init/default/002_check_rear_recover_mode.sh
usr/share/rear/lib/help-workflow.sh
usr/share/rear/lib/recover-workflow.sh
usr/share/rear/lib/mountonly-workflow.sh

should be replaced by using RECOVERY_MODE instead.
But that replacement belongs to another
separarated cleanup pull request
https://github.com/rear/rear/issues/3234
not to this one which is (only) about to
"Set RECOVERY_MODE also in PORTABLE mode",
cf. my Yes, yes, I know, I know part in
https://github.com/rear/rear/pull/3224#issuecomment-2122463410

By the way:
By chance I learned about RECOVERY_MODE in
https://github.com/rear/rear/pull/3112#issuecomment-1862738726

For the fun of it some code archeology:
RECOVERY_MODE
was introduced on Jun 9 2012 via
https://github.com/rear/rear/commit/f035085e26d22ce154cadd0c887e312cf954fab5
but three years later on Dec 11 2015 it was not used in
https://github.com/rear/rear/commit/ad2283c402736253e4f76d36659f353695aeceea
wherefrom I learned about /etc/rear-release
that again three years later I used on Jan 2 2018 in
https://github.com/rear/rear/commit/6ef640fd39ed5280b96def1644222269042d4f81
(that is also ancestor of lib/mountonly-workflow.sh)
and subsequently also on Oct 23 2018 in
https://github.com/rear/rear/commit/5e6ed355c1600041ff09564096870110e6d70dcd


[Export of Github issue for rear/rear.]