gdu
gdu copied to clipboard
Generate binaries for Android
Could you include distribution files for Android?
I tried adding an additional block on the Makefile build-all target, similar to the other cross-compile entries:
-CGO_ENABLED=0 gox \
-os="android" \
-arch="arm arm64" \
-output="dist/gdu_{{.OS}}_{{.Arch}}" \
-ldflags="$(LDFLAGS)" \
$(PACKAGE)/$(CMD_GDU)
but the only output is Number of parallel builds: 4
, nothing more.
If I manually invoke a single cross compilation for android/arm64:
CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -o "dist/gdu_android_arm64" -ldflags="-s -w -extldflags '-static' -X 'github.com/dundee/gdu/v5/build.Version=v5.15.0-5-gb2ec5f8' -X 'github.com/dundee/
gdu/v5/build.User=XYZ' -X 'github.com/dundee/gdu/v5/build.Time=XYZ'" github.com/dundee/gdu/v5/cmd/gdu
compilation does succeed and I obtain a statically linked gdu_android_arm64
that I can push and run on the adb terminal.
Problems I found so far:
- compiling for arm(32) and amd64 Android processors didn't work
Error is:
loadinternal: cannot find runtime/cgo
- the arm64 binary seems to be working apart from "b" for spawning a new shell when running as root which fails on my device
Error is
Error executing shell: fork/exec /system/bin/sh: permission denied
. The binary is there, has the right execution bits, and I even tried changing SELinux to non-enforcing mode. Still, this seems to be caused by a kernel protection on Samsung devices, as I see this on /proc/avc_msgs
enforcing=0 old_enforcing=1 auid=4294967295 ses=4294967295
...
pid=999 gpid=999 subj=u:r:kernel:s0 op="appraise_data" cint=0x0 pint=0x0 cause="no-cert" comm="sh" name="/data/local/tmp/gdu/gdu_android_arm64" dev="sda25" ino=328370 res=0
pid=999 gpid=999 subj=u:r:kernel:s0 op="bprm-check" cint=0x0 pint=0x0 cause="reset-integrity" comm="sh" name="/data/local/tmp/gdu/gdu_android_arm64" dev="sda25" ino=328370 res=0
IIRC, Samsung's kernel will prevent most processes from spawning the shell under UID 0, except for some whitelisted processes -> issue not related with gdu
All in all, if possible please include at least the binary for Android/arm64 even if you don't get to make the other architectures work.