From 27633432b969df2bc626369b5fa7f43e1fb97f0c Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Mon, 9 Mar 2026 00:27:43 -0700 Subject: [PATCH] Fix fakeroot build by using od(1) to check 64-bit ELFs bin/package: - Use od(1) to check the ELF header if the file command fails. This allows ksh to build and install correctly in fakeroot environments without encountering bogus seccomp restrictions. Fixes https://github.com/ksh93/ksh/issues/919 --- bin/package | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/package b/bin/package index 0117c1989b33..1dc30805d96e 100755 --- a/bin/package +++ b/bin/package @@ -1506,7 +1506,16 @@ int b(void) { return 0; } echo 'int main(void) { return 0; }' > $tmp.a.c checkcc $cc $CCFLAGS -o $tmp.a.exe $tmp.a.c /dev/null 2>&1 - file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g" ) + file_result=$(file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g") || true + # Use od(1) to check the ELF header directly if file(1) failed + if test -z "$file_result" && test "$(uname -s | sed 's/-.*//')" != CYGWIN + then elfbyte=$(( $(od -An -t x1 -j 4 -N 1 $tmp.a.exe) )) + if test "$elfbyte" = 2 + then echo "ELF 64-bit" + else echo "ELF 32-bit" + fi + else echo "$file_result" + fi ) case $bits in *\ 64-bit* | *\ 64\ bit* | *\ 64bit*) bits=64 ;;