Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

build-and-flash-initramfs: fix musl-linked binary lib detection

ldd fails on musl-linked binaries. Use readelf to find NEEDED libs
and copy musl dynamic linker (ld-musl-x86_64.so.1) into initramfs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+32 -3
+32 -3
fedac/native/scripts/build-and-flash-initramfs.sh
··· 272 272 # Copy shared libs (if dynamic build) 273 273 if file "${BUILD_DIR}/ac-native" | grep -q "dynamically linked"; then 274 274 log "Copying shared libraries for dynamic binary..." 275 - for lib in $(ldd "${BUILD_DIR}/ac-native" | grep -oP '/\S+'); do 276 - [ -f "$lib" ] && cp "$lib" "${INITRAMFS_DIR}/lib64/" 277 - done 275 + 276 + # Detect musl-linked binary (interpreter is ld-musl-*, ldd won't work) 277 + if file "${BUILD_DIR}/ac-native" | grep -q "ld-musl"; then 278 + log " musl-linked binary detected" 279 + # Copy musl dynamic linker 280 + MUSL_LD=$(find /usr/lib /lib -name "ld-musl-x86_64.so.1" -type f 2>/dev/null | head -1) 281 + if [ -n "${MUSL_LD}" ]; then 282 + cp "${MUSL_LD}" "${INITRAMFS_DIR}/lib64/" 283 + # Also symlink to /lib/ where the binary expects it 284 + mkdir -p "${INITRAMFS_DIR}/lib" 285 + ln -sf ../lib64/ld-musl-x86_64.so.1 "${INITRAMFS_DIR}/lib/ld-musl-x86_64.so.1" 286 + log " musl linker: ${MUSL_LD}" 287 + fi 288 + # Copy musl libc (the linker IS the libc for musl) 289 + # Also copy system libs the binary links against (readelf approach) 290 + if command -v readelf &>/dev/null; then 291 + for needed in $(readelf -d "${BUILD_DIR}/ac-native" 2>/dev/null | grep NEEDED | grep -oP '\[.*?\]' | tr -d '[]'); do 292 + # Search common lib paths 293 + for dir in /usr/lib/x86_64-linux-gnu /usr/lib64 /lib/x86_64-linux-gnu /lib64 /usr/lib; do 294 + if [ -f "${dir}/${needed}" ]; then 295 + cp -nL "${dir}/${needed}" "${INITRAMFS_DIR}/lib64/" 2>/dev/null 296 + break 297 + fi 298 + done 299 + done 300 + fi 301 + else 302 + # Standard glibc binary — ldd works 303 + for lib in $(ldd "${BUILD_DIR}/ac-native" | grep -oP '/\S+'); do 304 + [ -f "$lib" ] && cp "$lib" "${INITRAMFS_DIR}/lib64/" 305 + done 306 + fi 278 307 # Symlink /lib -> /lib64 (some lookups use /lib) 279 308 ln -sf lib64 "${INITRAMFS_DIR}/lib" 280 309 fi