| Message ID | 20250522051651.3711352-2-changqing.li@windriver.com |
|---|---|
| State | New |
| Headers | show |
| Series | *** A workaround for bug of file on fedora42 *** | expand |
On 22 May 2025, at 06:16, Changqing Li via lists.openembedded.org <changqing.li=windriver.com@lists.openembedded.org> wrote: > > From: Changqing Li <changqing.li@windriver.com> > > Fedora 42 has file 5.46 installed, but this version has an issue, setup > will failed with error "Setting it up...*** buffer overflow detected > ***: terminated", refer [1], has fixed in [2], but not in any release, > also not cherry picked by fedora, refer [3]. There is now traction on the Fedora bug, so I hope this will be fixed in Fedora shortly and we don’t need this workaround. Ross
> On 22 May 2025, at 13:35, Ross Burton <Ross.Burton@arm.com> wrote: > > On 22 May 2025, at 06:16, Changqing Li via lists.openembedded.org <changqing.li=windriver.com@lists.openembedded.org> wrote: >> >> From: Changqing Li <changqing.li@windriver.com> >> >> Fedora 42 has file 5.46 installed, but this version has an issue, setup >> will failed with error "Setting it up...*** buffer overflow detected >> ***: terminated", refer [1], has fixed in [2], but not in any release, >> also not cherry picked by fedora, refer [3]. > > There is now traction on the Fedora bug, so I hope this will be fixed in Fedora shortly and we don’t need this workaround. This has now been fixed in rawhide[1] and backporting is in progress for F42. Ross [1] https://src.fedoraproject.org/rpms/file/c/15a32b1b66cf27d58440913972050a0340e45fa1.patch
On 4 Jun 2025, at 11:36, Ross Burton <Ross.Burton@arm.com> wrote: > > >> On 22 May 2025, at 13:35, Ross Burton <Ross.Burton@arm.com> wrote: >> >> On 22 May 2025, at 06:16, Changqing Li via lists.openembedded.org <changqing.li=windriver.com@lists.openembedded.org> wrote: >>> >>> From: Changqing Li <changqing.li@windriver.com> >>> >>> Fedora 42 has file 5.46 installed, but this version has an issue, setup >>> will failed with error "Setting it up...*** buffer overflow detected >>> ***: terminated", refer [1], has fixed in [2], but not in any release, >>> also not cherry picked by fedora, refer [3]. >> >> There is now traction on the Fedora bug, so I hope this will be fixed in Fedora shortly and we don’t need this workaround. > > This has now been fixed in rawhide[1] and backporting is in progress for F42. The F42 update is in progress now: https://bodhi.fedoraproject.org/updates/FEDORA-2025-4fff4f41c4 Ross
diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh index 06934e5a9a..6149d6c2de 100644 --- a/meta/files/toolchain-shar-extract.sh +++ b/meta/files/toolchain-shar-extract.sh @@ -11,6 +11,16 @@ INIT_PYTHON=$(command -v python3 2>/dev/null ) [ -z "$INIT_PYTHON" ] && INIT_PYTHON=$(command -v python2 2>/dev/null) [ -z "$INIT_PYTHON" ] && echo "Error: The SDK needs a python installed" && exit 1 +file_version=$(file --version | head -n 1) +if [ "$file_version" = "file-5.46" ];then + if ! python3 -c "import magic" &> /dev/null; then + echo "Error: The SDK needs file command, but the version 5.46 on this host has an issue:" + echo "Error: https://bugs.astron.com/view.php?id=638, so please upgrade file to 5.46+ or" + echo "Error: install python3-magic as a replacement" + exit 1 + fi +fi + # Remove invalid PATH elements first (maybe from a previously setup toolchain now deleted PATH=`$INIT_PYTHON -c 'import os; print(":".join(e for e in os.environ["PATH"].split(":") if os.path.exists(e)))'` @@ -297,7 +307,7 @@ fi # delete the relocating script, so that user is forced to re-run the installer # if he/she wants another location for the sdk if [ $savescripts = 0 ] ; then - $SUDO_EXEC rm -f ${env_setup_script%/*}/relocate_sdk.py ${env_setup_script%/*}/relocate_sdk.sh + $SUDO_EXEC rm -f ${env_setup_script%/*}/relocate_sdk.py ${env_setup_script%/*}/relocate_sdk.sh ${env_setup_script%/*}/file.py fi # Execute post-relocation script diff --git a/meta/files/toolchain-shar-relocate.sh b/meta/files/toolchain-shar-relocate.sh index c7170349db..f4efcfc88c 100644 --- a/meta/files/toolchain-shar-relocate.sh +++ b/meta/files/toolchain-shar-relocate.sh @@ -57,9 +57,15 @@ fi # replace @SDKPATH@ with the new prefix in all text files: configs/scripts/etc. # replace the host perl with SDK perl. +file_version=$(file --version | head -n 1) +if [ "$file_version" = "file-5.46" ];then + file_cmd="$target_sdk_dir/file.py" +else + file_cmd="file" +fi for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do $SUDO_EXEC find $replace -type f -done | xargs -d '\n' -n100 file | \ +done | xargs -d '\n' -n100 $file_cmd | \ awk -F': ' '{if (match($2, ".*(ASCII|script|source).*text")) {printf "\"%s\"\n", $1}}' | \ grep -Fv -e "$target_sdk_dir/environment-setup-" \ -e "$target_sdk_dir/relocate_sdk" \ diff --git a/meta/recipes-core/meta/buildtools-tarball.bb b/meta/recipes-core/meta/buildtools-tarball.bb index 6fa6d93a3d..51a54af7e4 100644 --- a/meta/recipes-core/meta/buildtools-tarball.bb +++ b/meta/recipes-core/meta/buildtools-tarball.bb @@ -68,6 +68,8 @@ create_sdk_files:append () { rm -f ${SDK_OUTPUT}/${SDKPATH}/environment-setup-* rm -f ${SDK_OUTPUT}/${SDKPATH}/version-* + cp ${COREBASE}/scripts/file.py ${SDK_OUTPUT}/${SDKPATH}/ + # Generate new (mini) sdk-environment-setup file script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-${SDK_SYS}} touch $script diff --git a/scripts/file.py b/scripts/file.py new file mode 100755 index 0000000000..69c8cb3d6c --- /dev/null +++ b/scripts/file.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2025 Wind River Systems, Inc. +# +# SPDX-License-Identifier: MIT +# +# DESCRIPTION +# This script may be called by the SDK installer script. It is a replacement +# for file command, it has a bug in version 5.46. Refer: +# https://bugs.astron.com/view.php?id=638 + +from concurrent.futures import ThreadPoolExecutor +import sys +import magic + +def get_file_type(filename): + try: + with open(filename, 'rb') as f: + data = f.read(2048) + file_type = magic.from_buffer(data) + print(f"{filename}: {file_type}") + except Exception as e: + print(f"Error processing {filename}: {e}") + +def main(): + if len(sys.argv) < 2: + print("Usage: file.py <file1> <file2> ...") + return + + with ThreadPoolExecutor(max_workers=10) as executor: + executor.map(get_file_type, sys.argv[1:]) + +if __name__ == "__main__": + main()