@@ -33,7 +33,7 @@ if [ ! -d "$TOOLCHAIN_DIR" ]; then
3333
3434 # 1c. Download (silent and follow redirects) and pipe directly to tar for extraction
3535 # 'xjf' is used: 'x' extract, 'j' for bzip2, 'f' for file/stream
36- if ! curl -L -s " $DOWNLOAD_URL " | tar xjf; then
36+ if ! curl -L -# " $DOWNLOAD_URL " | tar - xjf - ; then
3737 echo " ========================================================================="
3838 echo " ERROR: Failed to download or extract the ARM toolchain."
3939 echo " Please check if 'curl' and 'tar' are installed and the URL is still valid."
@@ -53,7 +53,8 @@ echo "Setting up PATH..."
5353
5454# Export the new PATH variable, using 'pwd' to ensure we get the absolute path
5555# to the toolchain's bin directory regardless of where the script is called from.
56- export PATH=" $PATH :$( pwd) /$TOOLCHAIN_DIR /bin"
56+ TOOLCHAIN_BIN_PATH=" $( pwd) /$TOOLCHAIN_DIR /bin"
57+ export PATH=" $PATH :$TOOLCHAIN_BIN_PATH "
5758
5859echo " Executing build script with: python make.py -C -T F3"
5960
8485# Looks for the line, and prints the third field (the number).
8586FIRMWARE_VERSION=$( grep ' #define FIRMWARE_VERSION' " $VERSION_FILE " | awk ' {print $3}' )
8687
87- # Basic validation for the extracted version.
88- # POSIX-compliant check using 'case' to ensure the variable is non-empty and contains only digits.
89- case " $FIRMWARE_VERSION " in
90- ' ' |* [!0-9]* )
91- echo " Error: Could not extract a valid numerical FIRMWARE_VERSION from '$VERSION_FILE '."
92- exit 1
93- ;;
94- * )
95- # Validation passed
96- ;;
97- esac
88+ # Basic validation: ensure extracted version is a non-empty decimal number
89+ if [ -z " $FIRMWARE_VERSION " ] || ! expr " $FIRMWARE_VERSION " : ' ^[0-9]\+$' > /dev/null; then
90+ echo " Error: Could not extract a valid numerical FIRMWARE_VERSION from '$VERSION_FILE '."
91+ exit 1
92+ fi
9893
9994echo " Extracted Firmware Version: $FIRMWARE_VERSION "
10095
@@ -107,7 +102,12 @@ if [ ! -f "$BUILD_OUTPUT_FILE" ]; then
107102 exit 1
108103fi
109104
110- # 3e. Copy the binary, preserving modification time, access time, and modes (-p)
105+ # 3e. Ensure output directory exists for the versioned binary
106+ if [ ! -d " output" ]; then
107+ mkdir -p output
108+ fi
109+
110+ # 3f. Copy the binary, preserving modification time, access time, and modes (-p)
111111echo " Copying '$BUILD_OUTPUT_FILE ' to '$DEST_FILE '..."
112112if cp -p " $BUILD_OUTPUT_FILE " " $DEST_FILE " ; then
113113 echo " =========================================================="
0 commit comments