diff --git a/cmake/scripts/post-install.sh b/cmake/scripts/post-install.sh index 5b66ba376f18172f1b7338956ffead01755e4db5..7f46c2a64421e2ebe4af79670eb1ab15ffaecb6d 100755 --- a/cmake/scripts/post-install.sh +++ b/cmake/scripts/post-install.sh @@ -27,6 +27,26 @@ fi echo "Replacing $OLDINSTALLDIR -> $INSTALLDIR [or $LCGRELEASES] ..." # prepare package list for replacing +# This part quicly checks using grep if the path is inside of any file, and creates shofter list called "filteredPaths". +ALLMYFILES=$(cat $PREFIX/$listname | grep -v -- '->' | while read myfile; do + test "$myfile" = ".filelist" && continue # skip .filelist + echo ${myfile} +done) + +ALLMYFILES=$(echo $ALLMYFILES | tr '\n' ' ' ) +ALLMYFILES=$(echo $ALLMYFILES | tr -s " " ) + +filteredPaths=$(cat $PREFIX/$listname | grep -- '->'| while read name; do + dir2test="$(echo $name | grep -- '->'| awk -F'->' '{print $1}')" + dir2test=$(echo $dir2test | tr '\n' ' ' ) + dir2test=$(echo $dir2test | tr -s " ") + IFS=' ' + grep -q -- "$dir2test" ${ALLMYFILES} + retVal=$? + if [ $retVal -eq 0 ]; then + echo ${name} + fi +done) # loop over files (lines without '->') cat $PREFIX/$listname | grep -v -- '->' | while read name; do @@ -34,10 +54,12 @@ cat $PREFIX/$listname | grep -v -- '->' | while read name; do #old=$(mktemp -t lcg.XXXXX) #cp -f "$PREFIX/$name" "$old" # loop over all target paths (after '->' delimiter) - cat $PREFIX/$listname | grep -- '->' | awk -F'->' '{print $2}'| sort | uniq | while read newpath; do +# cat $PREFIX/$listname | grep -- '->' | awk -F'->' '{print $2}'| sort | uniq | while read newpath; do + echo $filteredPaths | 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 +# cat $PREFIX/$listname | grep -- '->' | grep -- "$newpath" | awk -F'->' '{ print length($1) " " $0; }' | sort -r -n | cut -d ' ' -f 2- | while read line; do + echo $filteredPaths | 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}')" for install_dir in $INSTALLDIR $LCGRELEASES; do if test -z "$NIGHTLY_MODE"; then