Skip to content

Commit

Permalink
Update 250_find_all_libs.sh
Browse files Browse the repository at this point in the history
Removed unreliably working code that intends to filter out
duplicates in the LIBS and COPS_AS_IS arrays via
echo "${ARRAY[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '
that fails when array elements contain spaces
so better code should be used e.g. like
printf '%s\n' "${ARRAY[@]}" | awk '!seen[$0]++'
but filtering out duplicates is not needed, see
#2377
and by the way cleaned up the whole script a bit.
  • Loading branch information
jsmeix committed Apr 22, 2020
1 parent 8117948 commit 6d25fd1
Showing 1 changed file with 26 additions and 36 deletions.
62 changes: 26 additions & 36 deletions usr/share/rear/prep/DUPLICITY/default/250_find_all_libs.sh
Expand Up @@ -2,43 +2,33 @@
# Public License. Refer to the included COPYING for full text of license.

# 250_find_all_libs.sh
# This is to FInd Out Missing Librarys with Strace, if Strace isn't installed this is skipped
# This is to find out missing libraries with strace.
# If strace isn't installed this script is skipped.
# TODO: I <jsmeix@suse.de> wonder if it is really needed
# to find out missing libraries here or if (and why)
# it isn't sufficient via the RequiredSharedObjects function
# that is called in build/GNU/Linux/390_copy_binaries_libraries.sh

# Check if Strace Readlink File Is available and Backup_PROG=Duply
which strace > /dev/null 2>&1
STRACE_OK=$?
which readlink > /dev/null 2>&1
READLINK_OK=$?
which file > /dev/null 2>&1
FILE_OK=$?
if [ "x$BACKUP_PROG" == "xduply" ] && [ $STRACE_OK -eq 0 ] && [ $READLINK_OK -eq 0 ] && [ $FILE_OK -eq 0 ]; then
which strace || return 0
which readlink || return 0
which file || return 0
[ "x$BACKUP_PROG" == "xduply" ] || return 0

# Find Out the File used by duply status
FILES=`strace -Ff -e open duply $DUPLY_PROFILE status 2>&1 1>/dev/null|grep -v '= -1'|grep -i open|grep -v "open resumed" |cut -d \" -f 2|sort -u`
# Find Out the File used by duply status
FILES=$( strace -Ff -e open duply $DUPLY_PROFILE status 2>&1 1>/dev/null | grep -v '= -1' | grep -i open | grep -v "open resumed" | cut -d \" -f 2 | sort -u )

for name in $FILES ; do
# Libs ar often Links, Solve the Links
if [[ -f "$name" ]] || [[ -L "$name" ]] ; then
DATEI=$(readlink -f "$name")
# Determinate if its a Lib
LIB=$(file $DATEI|grep "shared object"|cut -d \: -f 1)
# Determinate if its a Script
SKRIPT_FILES=$(file $DATEI|grep "script,"|cut -d \: -f 1)
# Add the Lib
if [ "x$LIB" != "x" ] ; then
LIBS+=( "$name" )
fi
# Add Script
if [ "x$SKRIPT_FILES" != "x" ] ; then
COPY_AS_IS+=( "$SKRIPT_FILES" )
fi
fi
done

# Filter if Duplicate Librarys have been added
sorted_unique_LIBS=$(echo "${LIBS[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')
eval LIBS=${sorted_unique_LIBS[@]}
# Filter Duplicate Scripts
sorted_unique_COPY_AS_IS=$(echo "${COPY_AS_IS[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')
eval COPY_AS_IS=${sorted_unique_COPY_AS_IS}
fi
for name in $FILES ; do
# Libs ar often Links, Solve the Links
if [[ -f "$name" ]] || [[ -L "$name" ]] ; then
DATEI=$( readlink -f "$name" )
# Determinate if its a Lib
LIB=$( file $DATEI | grep "shared object" | cut -d \: -f 1 )
# Determinate if its a Script
SKRIPT_FILES=$( file $DATEI | grep "script," | cut -d \: -f 1 )
# Add the Lib
[ "x$LIB" != "x" ] && LIBS+=( "$name" )
# Add Script
[ "x$SKRIPT_FILES" != "x" ] && COPY_AS_IS+=( "$SKRIPT_FILES" )
fi
done

0 comments on commit 6d25fd1

Please sign in to comment.