RPi-Distro / pi-gen

Tool used to create the official Raspberry Pi OS images
BSD 3-Clause "New" or "Revised" License
2.51k stars 1.59k forks source link

adduser: command not found #721

Open JoelLinn opened 8 months ago

JoelLinn commented 8 months ago

With FIRST_USER_NAME being set, /bin/bash: line 2: adduser: command not found is raised here https://github.com/RPi-Distro/pi-gen/blob/d9668973950853ce3dc026246cad24fcbb5dbcfa/stage1/01-sys-tweaks/00-run.sh#L8-L10 because /usr/sbin is not in PATH. Possible fix is to add export PATH=$PATH:/usr/sbin inside the branch.

JoelLinn commented 8 months ago

I suspect this might be because /usr/sbin is not in PATH on Arch Linux, maybe there should be a global check added or the PATH overwritten on chroot.

XECDesign commented 8 months ago

Isn't that a configuration issues with the host OS then?

https://man.archlinux.org/man/file-hierarchy.7#COMPATIBILITY_SYMLINKS

JoelLinn commented 8 months ago

Isn't that a configuration issues with the host OS then?

No since one can theoretically craft a Unix/Posix OS which has its binaries in /beehive or whatever, but if the corresponding PATH is not overwritten when chrooting, it will fail the pi-gen build.

https://man.archlinux.org/man/file-hierarchy.7#COMPATIBILITY_SYMLINKS

Even if that symlink may exists, it may not be in path by default on the host

XECDesign commented 8 months ago

Oh right, yeah that makes sense. I didn't realise chroot inherited the host's PATH variable. I wouldn't be against a PR that sets PATH to something sensible when entering the chroot environment