Explicitly limit the maximal depth for find 54/309854/3
authorSlava Barinov <v.barinov@samsung.com>
Wed, 17 Apr 2024 09:22:50 +0000 (12:22 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Wed, 17 Apr 2024 10:58:38 +0000 (19:58 +0900)
MAXSYMLINKS is hardcoded to 40, but 30 should be a reasonable value for Tizen
build root, so gcc-force-options and gcc-unforce-options won't cause the "Too
many levels of symbolic links" error

Change-Id: I20b7824e503113135a5eaccbef130c8e0f8c8f2c
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
packaging/gcc-force-options
packaging/gcc-unforce-options

index c8004d5..46d0b56 100644 (file)
@@ -14,7 +14,9 @@ EOF
        exit 1
 fi
 
-if [ $(find $(dirname $0) -name \*-real | wc -l) -gt 0 ]; then
+find --help > /dev/null || (echo >&2 "find utility malfunction, please check your environment" && exit 1)
+
+if [ $(find $(dirname $0) -maxdepth 30 -name \*-real | wc -l) -gt 0 ]; then
        echo >&2 "$(basename $0): directory was already processed, aborting"
        exit 1
 fi
@@ -97,7 +99,7 @@ chmod +x $TMP
 # Match gcc|g++|c++ with optional cross- preffix and -version ([0-9] and .) # suffix
 GCC_REG='\b(gcc|g\+\+|c\+\+)([-\d\.]?)+'
 
-find -L $(dirname $0) -type f -a -perm -a=x | grep -E "($GCC_REG)$" | while read tool; do
+find -L $(dirname $0) -maxdepth 30 -type f -a -perm -a=x | grep -E "($GCC_REG)$" | while read tool; do
        mv $tool $tool-real
        cp $TMP $tool
 done
@@ -118,17 +120,16 @@ chmod +x $LD_TMP
 
 GCC_REG_EXTRA='collect2'
 
-find -L GCC_LIBSUBDIR -type f -a -perm -a=x -name "$GCC_REG_EXTRA" | while read tool; do
+find -L GCC_LIBSUBDIR -maxdepth 30 -type f -a -perm -a=x -name "$GCC_REG_EXTRA" | while read tool; do
        mv $tool $tool-real
        cp $LD_TMP $tool
 done
 
 if [ -d /emul ]; then
-       find -L /emul -type f -a -perm -a=x | grep -E "($GCC_REG|$GCC_REG_EXTRA)$" | while read tool; do
+       find -L /emul -maxdepth 30 -type f -a -perm -a=x | grep -E "($GCC_REG|$GCC_REG_EXTRA)$" | while read tool; do
                ln -sf $(basename $tool) $tool-real
        done
 fi
 
 rm $TMP
 rm $LD_TMP
-
index 7e85b75..a65006d 100644 (file)
@@ -7,13 +7,12 @@ if [ $# -gt 0 ]; then
        exit 1
 fi
 
-find $(dirname $0) /usr/*/gcc -name \*-real | while read tool_real; do
+find $(dirname $0) /usr/*/gcc -maxdepth 30 -name \*-real | while read tool_real; do
        tool=$(echo "$tool_real" | sed -e 's/-real$//')
        mv $tool_real $tool
 done
 if [ -d /emul ]; then
-       find /emul -name \*-real | while read tool_real; do
+       find /emul -maxdepth 30 -name \*-real | while read tool_real; do
                rm $tool_real
        done
 fi
-