When I want to use qemu-user-static for aarch64 in combination with chroot there are a problem to run shell-scripts.
/bin/sh: adduser: not found
But, when i remove the first line in /usr/sbin/adduser (#!/bin/sh)
the script runs perfectly.
But i think, this is not the solution for this problem.
I also write a test-script and this have the same behavior.
The problem happens in Version 2.11.50.g20180622 on FreeBSD 11.2-RELEASE and on
FreeBSD 12.0-CURRENT (r336134).
On Freebsd 11.2-RELEASE with qemu-user-static version 2.6.90.g20160728_1 there are not this problem.
I have the same setup here and everything works as expected (on 12-current)
How do you set up your chroot?
(In reply to mikael.urankar from comment #1)
First I copied /usr/local/bin/qemu-aarch64-static to /tmp/qemu_static in the chroot-environment (world_dir)
After this is run: chroot world_dir /tmp/qemu_static /bin/sh
But I found a function "is_target_shell_script" in bsd-user/freebsd/os-proc.c,
which only used in FreeBSD-versions smaller than 11:
#if defined(__FreeBSD_version) && __FreeBSD_version < 1100000
After made a simple patch which deletes this lines around the function-declaration and function-calls the shell-scripts works correctly.
(In reply to dornergd from comment #2)
I don't know why is_target_shell_script is needed on __FreeBSD_version < 1100000
Usually I do the following:
cp /usr/local/bin/qemu-aarch64-static /data/jails/12aarch64/usr/local/bin
service qemu_user_static start