Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues if rear is installed in non-default path #774

Closed
abbbi opened this issue Feb 15, 2016 · 6 comments
Closed

issues if rear is installed in non-default path #774

abbbi opened this issue Feb 15, 2016 · 6 comments

Comments

@abbbi
Copy link
Contributor

abbbi commented Feb 15, 2016

hi there,

im struggeling to get rear correctly working on a non-standard installation path.
Im using the DESTDIR= parameter to install rear into another path than usually, that results in some
issues which should at least be discussed.

For example, installing rear into /opt/rear/ with the following command:

make install DESTDIR=/opt/rear/

will result in the following error:

linux-fhta:~/rear # /opt/rear/usr/sbin/rear mkrescue -v
/opt/rear/usr/sbin/rear: line 282: /usr/share/rear/conf/default.conf: No such file or directory
/opt/rear/usr/sbin/rear: line 290: IsInArray: command not found
/opt/rear/usr/sbin/rear: line 296: has_binary: command not found
ERROR: Required program 'pidof' missing, please check your PATH

Issue is that the Makefile does not use the DESTDIR parameter in all places to replace the paths within the rear exectuable. I think i have created a patch for this sometime in the past and it was reverted as it lead to break rear in other modules or situations, the diff is one like this:

diff --git a/Makefile b/Makefile
index 16df320..b098d4b 100644
--- a/Makefile
+++ b/Makefile
@@ -136,9 +136,9 @@ install-config:
 install-bin:
        @echo -e "\033[1m== Installing binary ==\033[0;0m"
        install -Dp -m0755 $(rearbin) $(DESTDIR)$(sbindir)/rear
-       sed -i -e 's,^CONFIG_DIR=.*,CONFIG_DIR="$(sysconfdir)/rear",' \
-               -e 's,^SHARE_DIR=.*,SHARE_DIR="$(datadir)/rear",' \
-               -e 's,^VAR_DIR=.*,VAR_DIR="$(localstatedir)/lib/rear",' \
+       sed -i -e 's,^CONFIG_DIR=.*,CONFIG_DIR="$(DESTDIR)$(sysconfdir)/rear",' \
+               -e 's,^SHARE_DIR=.*,SHARE_DIR="$(DESTDIR)$(datadir)/rear",' \
+               -e 's,^VAR_DIR=.*,VAR_DIR="$(DESTDIR)$(localstatedir)/lib/rear",' \
                $(DESTDIR)$(sbindir)/rear

 install-data:

Is there another way to install REAR into a non-default path than using DESTDIR=?

Another problem is that with a recent change, the "os.conf" file is allways forcibly installed into the /etc/rear directory of the resulting image. This causes rear to not find the os.conf configuration file and exit upon execution during recovery. One has to copy the os.conf configuration file within the recovery image from /etc/rear/os.conf to $DESTDIR/etc/rear/os.conf:

commit 5507548d9796706dfbab13f5617c854121694728
    write os.conf to /etc/rear/

    os.conf MUST be at /etc/rear/os.conf in the rescue image. $CONF_DIR may have been different depending on the rear installation directory.


diff --git a/usr/share/rear/build/default/99_update_os_conf.sh b/usr/share/rear/build/default/99_update_os_conf.sh
index f9ffcb6..9b51782 100644
--- a/usr/share/rear/build/default/99_update_os_conf.sh
+++ b/usr/share/rear/build/default/99_update_os_conf.sh
@@ -1,6 +1,6 @@
 # add os/version info to os.conf in the rescue system so that we don't need to pull lsb into the rescue system

-echo -e "#\n# WARNING ! This information was added automatically by the $WORKFLOW workflow !!!" >> $ROOTFS_DIR/$CONFIG_DIR/os.conf
+echo -e "#\n# WARNING ! This information was added automatically by the $WORKFLOW workflow !!!" >> $ROOTFS_DIR/etc/rear/os.conf
 for var in ARCH OS OS_VERSION OS_VENDOR OS_VENDOR_VERSION OS_VENDOR_ARCH ; do
        echo "$var='${!var}'"
-done >> $ROOTFS_DIR/$CONFIG_DIR/os.conf
+done >> $ROOTFS_DIR/etc/rear/os.conf
lines 1-13/13 (END)
@gdha
Copy link
Member

gdha commented Feb 15, 2016

See also #329 - SEP Sesam also tried it and it broke rear (pull request #324).
You can use rear from the directory where you ran the 'git cloneor untarred that archive as./usr/sbin/rear`

@abbbi
Copy link
Contributor Author

abbbi commented Feb 16, 2016

hi again,

yes, i know that just executing rear from a cloned repository or extracted archive will work.
This is solving our first "Problem".

This however still creates files in /etc/rear/, even if the user does not want it to. Is there a
special usecase or why has the os.conf been hardcodet to /etc/?

I know the old commit from SEP Sesam broke some Fedora related things :-)
We from SEP ship REAR with our client installation and we dont want to modify the system
in pathes which are not related to SEP Sesam. Of course we can change REAR to place os.conf in the right directory, but we dont want our shipped REAR components to differ from your release versions!

@abbbi
Copy link
Contributor Author

abbbi commented Feb 17, 2016

After some more testing: simply running rear from extracted tar or git checkout solves both problems. I think we can close this here :-)

@jsmeix
Copy link
Member

jsmeix commented Feb 17, 2016

@abbbi
it seems what you need is a general prefix for all of rear's files
so that in particular rear creates files in /etc/rear/.

In usr/sbin/rear there is

# Find out if we're running from checkout
REAR_DIR_PREFIX=""
readonly SCRIPT_FILE="$( readlink -f $( type -p "$0" || echo "$0" ) )"
if test "$SCRIPT_FILE" != "$( readlink -f /usr/sbin/$PROGRAM )" ; then
    REAR_DIR_PREFIX=${SCRIPT_FILE%/usr/sbin/$PROGRAM}
fi
readonly REAR_DIR_PREFIX
# Program directories - they must be set here. Everything else is then dynamic.
# Not yet readonly here because they are set via the /etc/rear/rescue.conf file
# in the recovery system that is sourced by the rear command in recover mode
# and CONFIG_DIR can also be changed via '-c' command line option:
SHARE_DIR="$REAR_DIR_PREFIX/usr/share/rear"
CONFIG_DIR="$REAR_DIR_PREFIX/etc/rear"
VAR_DIR="$REAR_DIR_PREFIX/var/lib/rear"
LOG_DIR="$REAR_DIR_PREFIX/var/log/rear"

Accordingly if for example $CONFIG_DIR is used in the scripts and no hardcoded "/etc/rear", rear should create files accordingly.

It seems currently it is hardcoded in usr/sbin/rear when a non-empty REAR_DIR_PREFIX will be used.

I assume you may need to adapt and enhance that for your needs and then verify if a non-empty REAR_DIR_PREFIX will really be used in all the various rear scripts as needed.

As far as I see there is a difference if rear runs in its recovery system (basically when "rear recover" is run) in contrast to when rear is run in the original system (e.g. when "rear mkbackup" is run).

As far as I see if rear runs in its recovery system then rear should use hardcoded paths like "/etc/rear/" to match the actual direcories in the recovery system.

In contrast when rear is run in the original system it should consistently use REAR_DIR_PREFIX where appropriate.

@jsmeix
Copy link
Member

jsmeix commented Feb 17, 2016

@abbbi
I did not see your #774 (comment) while I wrote my last comment.

As far as I see your #774 (comment) proves that rear works correctly when a non-empty REAR_DIR_PREFIX is used.

Accordingly I think all what you still may need to make rear working perfectly for your use-case is to to adapt and enhance the current hardcoded magic in usr/sbin/rear when a non-empty REAR_DIR_PREFIX will be used.

@gdha
Copy link
Member

gdha commented Feb 17, 2016

In recovery mode the /etc/rear/rescue.conf defines the rear paths

@gdha gdha closed this as completed Mar 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants