#13 build.sh fails on Adelie Linux due to missing which(1)
Opened 2 months ago by sskras. Modified 2 months ago

Adelie-BA34AA ~/midipix_build # ./build.sh -a nt64 -b release -D zipdist -P -v
==> 2024/07/06 14:00:09 Error: Error: missing prerequisite package(s): awk bunzip2 bzip2 cat chmod cmake cp date find flock g++ gcc git grep gunzip gzip hostname id install kill ln lzip make mkdir mkfifo mktemp mv paste patch perl pgrep pkill printf readlink rm sed sha256sum sort stat tail tar test touch tr uniq wget xz zip

These seemingly are names of the binaries. I copied all of them and rAn through a shell check to see if any of them is missing. I also added a bogus fake-bin just to be sure my check works:

Adelie-BA34AA ~ # echo; echo 'fake-bin awk bunzip2 bzip2 cat chmod cmake cp date find flock g++ gcc git grep gunzip gzip hostname id install kill ln lzip make mkdir mkfifo mktemp mv paste patch perl pgrep pkill printf readlink rm sed sha256sum sort stat tail tar test touch tr uniq wget xz zip' | fmt -w1 | while read BINARY; do type -p $BINARY >/dev/null || echo Not found: $BINARY; done

Not found: fake-bin

And no, all they seems to be present on disk (except for that bogus name).


To test that I ran two things in advance:

# apk update
# apk add build-tools
# apk list binutils bison bzip2 cmake coreutils curl findutils g++ gawk gcc git grep gzip libc-dev linux-headers lzip m4 make musl-dev net-tools patch perl perl-xml-parser procps sed tar util-linux util-linux-dev wget xz zip | awk '!/installed/ {gsub(/[{}]/, "", $3); print $3}' | xargs apk add

The last monstrous shell composite:
- gets Alpine package names from README in the stdin
- finds which of these names are not installed
- passes the resulting names to apk add ...

Narrowed the scope down to this: https://dev.midipix.org/build/midipix_build/blob/6ecff4/f/subr.rtl/rtl_platform.subr#_18-22

And this is what I found:

Adelie-BA34AA ~/midipix_build # if ! which id ; then echo BAD; else echo OK; fi
-bash: which: command not found
BAD

So the script relies on an optional binary which, which could be easily replaced with POSIX defined shell builtin command -v.

Log in to comment on this ticket.

Metadata