Skip to content

Commit a6bbe38

Browse files
committed
chore: enhance build_musl.sh script for improved output handling and error checking
- Updated the script to use 'set -euo pipefail' for better error handling. - Added dynamic output directory detection from config.mak. - Implemented checks to ensure the output directory exists before proceeding with installation. - Improved the copying of output files to /opt/musl with error handling.
1 parent 842ed84 commit a6bbe38

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

common/build/deplib/build_musl.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
#!/bin/bash
22

3-
set -e
3+
set -euo pipefail
44
git clone --depth 1 https://github.com/25077667/musl-cross-make.git
55

66
cp ./config.mak musl-cross-make/config.mak
77

8-
cd musl-cross-make && make -j $(nproc) install && cp -r output /opt/musl
8+
OUTPUT_DIR="$(awk -F= '/^[[:space:]]*OUTPUT[[:space:]]*=/{print $2}' ./config.mak | xargs || true)"
9+
if [ -z "${OUTPUT_DIR}" ]; then
10+
OUTPUT_DIR="output"
11+
fi
12+
13+
cd musl-cross-make
14+
make -j "$(nproc)" install
15+
16+
OUTPUT_PATH="${OUTPUT_DIR}"
17+
18+
if [ ! -d "${OUTPUT_PATH}" ]; then
19+
echo "musl-cross-make output directory not found: ${OUTPUT_PATH}" >&2
20+
exit 1
21+
fi
22+
23+
mkdir -p /opt/musl
24+
cp -a "${OUTPUT_PATH}/." /opt/musl/
925
find /opt/musl -iname "*.la" -type f -exec sed -i "s/libdir='/libdir='\/opt\/musl/g" "{}" \;
1026
find /opt/musl -iname "*.la" -type f -exec sed -i "s/installed=yes/installed=no/g" "{}" \;

0 commit comments

Comments
 (0)