#1562 PR merged: Update and export LD_LIBRARY_PATH when using TSM

Labels: bug, fixed / solved / done, external tool

schabrolles opened issue at 2017-11-05 09:07:

As explain in #1533, rear mkrescue failed when using with TSM because of the need of additional libraries.
This error comes from the image rescue check made in build/default/980_verify_rootfs.sh.
Two solutions here:

1- Update and export LD_LIBRARY_PATH in prep/TSM/default/400_prep_tsm.sh. When exported, LD_LIBRARY_PATH will be inherit into the chrooted environment used in build/default/980_verify_rootfs.sh:

for binary in $( find $ROOTFS_DIR -type f -executable -printf '/%P\n' ) ; do
    chroot $ROOTFS_DIR /bin/ldd $binary | grep -q 'not found' && broken_binaries="$broken_binaries $binary"
done

2- We don't need all the stuff provided by the TSM client in the rescue image (~300MB). Only dsmc (tsm client) binary, with some libraries and config files.
I usually use the following COPY_AS_IS_TSM within my conf file which do not complain about missing libraries during rear mkrescue and reduced the size of TSM client to (~30MB).

COPY_AS_IS_TSM=( /etc/adsm/TSM.PWD /opt/tivoli/tsm/client/ba/bin/dsmc /opt/tivoli/tsm/client/ba/bin/tsmbench_inclexcl /opt/tivoli/tsm/client/ba/bin/dsm.sys /opt/tivoli/tsm/client/ba/bin/dsm.opt /opt/tivoli/tsm/client/api/bin64/libgpfs.so /opt/tivoli/tsm/client/api/bin64/libdmapi.so /opt/tivoli/tsm/client/ba/bin/EN_US/dsmclientV3.cat /usr/local/ibm/gsk8* )

Even if the 2nd option seems to be more optimized (size, time saving during initrd compression) it could be also source of issues because we cannot be sure that this set of file (name, libraries, config files) will remain the same with the next version of TSM. So I prefer to use the First solution (LD_LIBRARY_PATH) and let the users update themselves their local.conf file if they want to optimize initrd size.

@jsmeix, I know you don't have TSM, but I would like to get your feedback about this PR.
Do you think we can use export LD_LIBRARY_PATH ?
Could you confirm that prep/TSM/default/400_prep_tsm.shis the best place for that ?
Thanks for your help and review here.

jsmeix commented at 2017-11-06 10:44:

@schabrolles
I fear setting a global TSM-specific LD_LIBRARY_PATH
for all programs in all ReaR scripts that run after
prep/TSM/default/400_prep_tsm.sh
might lead to unexpected side effects like
https://github.com/rear/rear/issues/1533#issuecomment-336622504
because libraries via LD_LIBRARY_PATH have
precedence over the "normal" ones.

I would prefer to keep "dirty hacks" as local as possible.

Accordingly I suggest the TSM-specific LD_LIBRARY_PATH
is only locally set for the particular 'ldd' command
where it is actually needed.

E.g. only in build/default/980_verify_rootfs.sh something like:

local old_LD_LIBRARY_PATH
test $LD_LIBRARY_PATH && old_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
if test "TSM" = "$BACKUP" ; then
    # Use a TSM-specific LD_LIBRARY_PATH to find TSM libraries
    # see https://github.com/rear/rear/issues/1533
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/tivoli/tsm/client/ba/bin:/opt/tivoli/tsm/client/api/bin64:/opt/tivoli/tsm/client/api/bin:/opt/tivoli/tsm/client/api/bin64/cit/bin
fi
for binary in $( find $ROOTFS_DIR -type f -executable -printf '/%P\n' ) ; do
    chroot $ROOTFS_DIR /bin/ldd $binary | grep -q 'not found' && broken_binaries="$broken_binaries $binary"
done
test $old_LD_LIBRARY_PATH && export LD_LIBRARY_PATH=$old_LD_LIBRARY_PATH || unset LD_LIBRARY_PATH

I tried to avoid to have a possibly empty LD_LIBRARY_PATH
set at the end.

I guess in case of an initially empty LD_LIBRARY_PATH
the resulting TSM-specific LD_LIBRARY_PATH with
a leading colon ":/opt/tivoli/tsm/client/ba/bin:/opt/..."
also works?

@schabrolles
I wonder if the hardcoded TSM-specific LD_LIBRARY_PATH
is sufficiently future proof?
Perhaps in default.conf a

TSM_LD_LIBRARY_PATH="/opt/tivoli/tsm/client/ba/bin:/opt/tivoli/tsm/client/api/bin64:/opt/tivoli/tsm/client/api/bin:/opt/tivoli/tsm/client/api/bin64/cit/bin"

and then

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSM_LD_LIBRARY_PATH

is better?

FWIW:
Currently things nicely fall apart when someone has
blanks in the directories in his LD_LIBRARY_PATH ;-)
cf. https://github.com/rear/rear/issues/1372

jsmeix commented at 2017-11-06 10:52:

@schabrolles
and - by the way - I think you should add a comment in default.conf
about how TSM users could optimize their COPY_AS_IS_TSM
(I think a really small recovery ISO is required at least on
some POWER systems where the initrd must be small)
and what issues such an optimization might cause.

schabrolles commented at 2017-11-06 13:20:

@jsmeix, thanks ;-)
I'm currently testing it

schabrolles commented at 2017-11-06 13:48:

@jsmeix, it is working. tested with rhel 6 + tsm 7
I'm gonna merge this one soon if you agree.

jsmeix commented at 2017-11-06 13:54:

@schabrolles
I agree

jsmeix commented at 2017-11-07 10:47:

@schabrolles
would you accept a pull request from me
with what I proposed in
https://github.com/rear/rear/pull/1562#issuecomment-342113626
or do you not want to have that described in default.conf
and in this case I would like to know why.

schabrolles commented at 2017-11-07 11:45:

@jsmeix, Sorry, I'm a bit busy with a lot a different project those days and I totally forget to do it.
It is now done in #1566

jsmeix commented at 2017-11-07 12:51:

No need to say sorry for anything!
I do appreciate all your work and contributions.


[Export of Github issue for rear/rear.]