From 54e8b3a8bcef087fc459bd726a2c8da761ddcc4e Mon Sep 17 00:00:00 2001 From: Slava Barinov Date: Wed, 17 Apr 2024 12:22:50 +0300 Subject: [PATCH] Explicitly limit the maximal depth for find 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 --- packaging/gcc-force-options | 11 ++++++----- packaging/gcc-unforce-options | 5 ++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packaging/gcc-force-options b/packaging/gcc-force-options index c8004d5..46d0b56 100644 --- a/packaging/gcc-force-options +++ b/packaging/gcc-force-options @@ -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 - diff --git a/packaging/gcc-unforce-options b/packaging/gcc-unforce-options index 7e85b75..a65006d 100644 --- a/packaging/gcc-unforce-options +++ b/packaging/gcc-unforce-options @@ -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 - -- 2.7.4