Skip to content

Commit

Permalink
package: DEFPATH fix for Android/Termux (re: 0a0a32c)
Browse files Browse the repository at this point in the history
The standard utilities directory on Android is actually /bin (a
symlink to /system/bin). There lives sh (which is dash) and the
core utilities (from Toybox). In DEFPATH these should take
precedence over whatever is added by termux -- if only because /bin
is read-only and therefore more secure; termux utilities are
installed by and can be overwrittem by the regular user.
  • Loading branch information
McDutchie committed Mar 22, 2024
1 parent 2818dcc commit 0af4dc9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,15 @@ DEFPATH=$(
$CC $CCFLAGS $LDFLAGS -o "$t.exe" "$t.c" 2>/dev/null && "$t.exe"
}
) || DEFPATH=/bin:/usr/bin:/sbin:/usr/sbin
# Fix for Android/Termux. The /bin directory exists with standard
# utilities (sh, Toybox utils) but it is not included in _PATH_DEFPATH.
# It should come first because /bin is read-only.
if test -d /data/data/com.termux && test "$(/bin/uname -o 2>/dev/null)" = Android
then case ":$DEFPATH:" in
*:/bin:* ) ;;
* ) DEFPATH=/bin:$DEFPATH ;;
esac
fi
# Fix for NixOS. Not all POSIX standard utilities come with the default system,
# e.g. 'bc', 'file', 'vi'. The command that NixOS recommends to get missing
# utilities, e.g. 'nix-env -iA nixos.bc', installs them in a default profile
Expand Down

0 comments on commit 0af4dc9

Please sign in to comment.