#710 PR merged: Have readonly constants in the main rear script

Labels: enhancement, cleanup, fixed / solved / done

jsmeix opened issue at 2015-11-24 16:24:

In particular have '/mnt/local' as readonly
variable RECOVERY_FS_ROOT in usr/sbin/rear
see https://github.com/rear/rear/issues/708
and use $RECOVERY_FS_ROOT in the scripts instead
of hardcoded '/mnt/local' but currently only a few scripts
are adapted so that I can test if it works at all (and for me
it does work).

Have several more readonly constants in the main rear script
like SHARE_DIR CONFIG_DIR VAR_DIR LOG_DIR ...
see https://github.com/rear/rear/issues/678
and fixed if readonly constants are modified in other scripts
as far as currently possible for me.

Additionally the DISKLAYOUT_FILE variable is moved from
usr/share/rear/conf/default.conf to usr/sbin/rear because
it is not meant to be configured by the user
see https://github.com/rear/rear/issues/678

By the way fixed creation of /media /media/cdrom /media/floppy in
usr/share/rear/restore/SUSE_LINUX/91_create_missing_directories.sh
because those directories ar no longer needed since SLE12.

jsmeix commented at 2015-11-24 16:29:

FYI:

My following test shows the remaining usage of readonly constants
in other scripts.

Readonly constants are only used in

Makefile
packaging/debian/rules

My test and its results:

github/rear $ for v in $( grep '^readonly' usr/sbin/rear | cut -d' ' -f2- | cut -d '=' -f1 ) ; do echo "v='$v'" ; find * | xargs grep "[^_]$v=" | grep -v ':[[:space:]]*#' ; echo ; done | grep -v '^usr/sbin/rear'
v='PRODUCT'
v='PROGRAM'
v='VERSION'
Makefile:version := $(shell awk 'BEGIN { FS="=" } /^VERSION=/ { print $$2}' $(rearbin))
Makefile:               -e 's#^VERSION=.*#VERSION=$(distversion)#' \
v='RELEASE_DATE'
Makefile:               -e 's#^RELEASE_DATE=.*#RELEASE_DATE="$(release_date)"#' \
v='STARTTIME'
v='CMD_OPTS'
v='SCRIPT_FILE'
v='REAR_DIR_PREFIX'
v='RECOVERY_FS_ROOT'
v='OPTS'
v='ARGS'
v='DEBUG'
v='DEBUGSCRIPTS'
v='DEBUGSCRIPTS_ARGUMENT'
v='DEBUGSCRIPTS_OPPOSITE_ARGUMENT'
v='SIMULATE'
v='STEPBYSTEP'
v='REAR_LOGFILE'
v='RECOVERY_MODE'
v='SHARE_DIR'
Makefile:               -e 's,^SHARE_DIR=.*,SHARE_DIR="$(datadir)/rear",' \
packaging/debian/rules:         -e 's#^SHARE_DIR=.*#SHARE_DIR="/usr/share/rear"#' \
v='CONFIG_DIR'
Makefile:       sed -i -e 's,^CONFIG_DIR=.*,CONFIG_DIR="$(sysconfdir)/rear",' \
packaging/debian/rules:         -e 's#^CONFIG_DIR=.*#CONFIG_DIR="/etc/rear"#' \
v='VAR_DIR'
Makefile:               -e 's,^VAR_DIR=.*,VAR_DIR="$(localstatedir)/lib/rear",' \
packaging/debian/rules:         -e 's#^VAR_DIR=.*#VAR_DIR="/var/lib/rear"#' \
v='LOG_DIR'
v='KERNEL_VERSION'
v='VERSION_INFO'

jsmeix commented at 2015-11-24 16:37:

For me rear still works with that pull request
on a SLES12-SP1 KVM/Qemu virtual machine
with 2.5TB virtual harddisk using SUSE's special 'gpt_sync_mbr'
and SLES12-SP1 default btrfs and xfs for /home
where I did

rear --debugscripts xv mkbackup

and

rear --debugscripts xv recover

Using

grep 'readonly variable' /var/log/rear/rear*.log

does not show any usage of a readonly variable
neither for "mkbackup" nor for "recover".

FYI regarding using a readonly variable:

# readonly foo=Foo
# readonly | grep foo
declare -r foo="Foo"
# foo=Bar
-bash: foo: readonly variable
# unset foo
-bash: unset: foo: cannot unset: readonly variable

jsmeix commented at 2015-11-25 12:49:

As neded we may add more readonly constants
but for now the issue is fixed.


[Export of Github issue for rear/rear.]