From 1128f8a44524a98ae63daf738d07079dbe375e4a Mon Sep 17 00:00:00 2001 From: Ivan Razumov <ivan.razumov@cern.ch> Date: Thu, 14 Apr 2016 15:44:27 +0200 Subject: [PATCH] Copy fixed post-install script from master (see commits 338b8510, c5d6f583, d06f8508) --- cmake/scripts/post-install.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/cmake/scripts/post-install.sh b/cmake/scripts/post-install.sh index 49e5d15178..c7d876020b 100755 --- a/cmake/scripts/post-install.sh +++ b/cmake/scripts/post-install.sh @@ -7,28 +7,38 @@ listname=".filelist" THIS="$0" PREFIX="$(/bin/sh -c "dirname $THIS")" +# Use INSTALLDIR env variable or automatic RPM_INSTALL_DIR as target prefix while [ ! -d "$INSTALLDIR" ]; do [ ! -z "$RPM_INSTALL_PREFIX" ] && INSTALLDIR="$RPM_INSTALL_PREFIX" || read -e -p "Type new install directory : " INSTALLDIR done +# extract old install dir from .filelist (should be first line) OLDINSTALLDIR="$(head -1 $PREFIX/$listname)" -sed -i -e '1d' $PREFIX/$listname +sed -i -e '1d' $PREFIX/$listname # delete first line echo echo "Replacing $OLDINSTALLDIR -> $INSTALLDIR" echo # prepare package list for replacing +# loop over files (lines without '->') cat $PREFIX/$listname | grep -v -- '->' | while read name; do + test "$name" == ".filelist" && continue # skip .filelist echo "=== Patching $name ... ===" - old=$(mktemp -t lcg.XXX) + old=$(mktemp -t lcg.XXXXX) cp -f "$PREFIX/$name" "$old" - # patch files - cat $PREFIX/$listname | grep -- '->' | while read line; do - olddir="$(echo $line | awk -F'->' '{print $1}')" - newdir="${INSTALLDIR}/$(echo $line | awk -F'->' '{print $2}')" - test ! -z "$olddir" && sed -i -e "s@$olddir@$newdir@g" "$PREFIX/$name" + # loop over all target paths (after '->' delimiter) + cat $PREFIX/$listname | grep -- '->' | awk -F'->' '{print $2}'| sort | uniq | while read newpath; do + # loop over all source paths for given target path, use sorting by path length to resolve issues like /var/build/... and /build/... + # 1 target path is related with multiple (at least 2 -- real and 'usual') source paths + cat $PREFIX/$listname | grep -- '->' | grep -- "$newpath" | awk -F'->' '{ print length($1) " " $0; }' | sort -r -n | cut -d ' ' -f 2- | while read line; do + olddir="$(echo $line | awk -F'->' '{print $1}')" + newdir="${INSTALLDIR}/$(echo $line | awk -F'->' '{print $2}')" + # patching + test ! -z "$olddir" && test ! -z "$newdir" && sed -i -e "s@$olddir@$newdir@g" -e '/afs/s,/\.cern.ch,/cern.ch,g' "$PREFIX/$name" + done done + # show diff diff -u "$old" "$PREFIX/$name" rm -f "$old" echo -- GitLab