#718 Issue closed: DISKLAYOUT_FILE versus LAYOUT_FILE inconsistency

Labels: cleanup, won't fix / can't fix / obsolete, minor bug

jsmeix opened issue at 2015-11-26 13:20:

I am confused about DISKLAYOUT_FILE versus LAYOUT_FILE.

Both are used but it seems both mean usually
the same "$VAR_DIR/layout/disklayout.conf".

But sometimes it seems to mean something else
like "$TMP_DIR/backuplayout.conf" and others.

It is so confusing that I regard it even as a bug
(not a bug in runtime function but a bug in programming style).

I suggest to use DISKLAYOUT_FILE everywhere
when "$VAR_DIR/layout/disklayout.conf" is meant
because its name is more descriptive (i.e. what kind of layout it is)
and its name matches better to the file name "disklayout.conf".

The other meanings must use different variable names.

Where DISKLAYOUT_FILE versus LAYOUT_FILE is currently set:

github/rear $ find * | xargs grep 'LAYOUT_FILE='
usr/sbin/rear:DISKLAYOUT_FILE="$VAR_DIR/layout/disklayout.conf"
usr/share/rear/finalize/GNU/Linux/15_migrate_disk_devices_layout.sh:        LAYOUT_FILE="$file"
usr/share/rear/finalize/GNU/Linux/15_migrate_disk_devices_layout.sh:        LAYOUT_FILE=$tmp_layout
usr/share/rear/layout/prepare/default/01_prepare_files.sh:LAYOUT_FILE="$VAR_DIR/layout/disklayout.conf"
usr/share/rear/layout/save/GNU/Linux/10_create_layout_file.sh:DISKLAYOUT_FILE=${DISKLAYOUT_FILE:-$VAR_DIR/layout/disklayout.conf}
usr/share/rear/layout/save/GNU/Linux/10_create_layout_file.sh:LAYOUT_FILE="$DISKLAYOUT_FILE"
usr/share/rear/lib/checklayout-workflow.sh:    DISKLAYOUT_FILE=$TEMP_LAYOUT
usr/share/rear/lib/mkbackuponly-workflow.sh:    DISKLAYOUT_FILE=$TMP_DIR/backuplayout.conf
usr/share/rear/lib/savelayout-workflow.sh:    #DISKLAYOUT_FILE=$VAR_DIR/layout/disklayout.conf # defined in default.conf now (issue #678)

gdha commented at 2015-11-26 15:05:

This code was original written by Jeroen - I'll assign the issue to him

jsmeix commented at 2015-11-27 08:37:

@jhoekx
I could fix it provided I do really understand the exceptional cases
where DISKLAYOUT_FILE / LAYOUT_FILE is not
set to "$VAR_DIR/layout/disklayout.conf".

I would first change the exceptional cases
to use a different separated variable name like

readonly BACKUPLAYOUT_FILE="$TMP_DIR/backuplayout.conf"

when this is menat to be used globally or

local backuplayout_file="$TMP_DIR/backuplayout.conf"

when this is only used in a limited scope, cf.
https://github.com/rear/rear/wiki/Coding-Style

After the exceptional cases have been fixed,
I would like to have

readonly DISKLAYOUT_FILE="$VAR_DIR/layout/disklayout.conf"

in usr/sbin/rear see https://github.com/rear/rear/pull/710 and https://github.com/rear/rear/issues/678#issuecomment-159196316

Finally I would like to change the scripts to
use $DISKLAYOUT_FILE everywhere.

jsmeix commented at 2016-09-21 12:59:

Perhaps in the future as time permits I can clean it up on my own.


[Export of Github issue for rear/rear.]