Re: Building a Linuxulator userland from source

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Fri, 25 Aug 2023 06:23:45 UTC
Felix Palmen wrote on 2023/08/21 18:30:
> * Tatsuki Makino <tatsuki_makino@hotmail.com> [20230821 17:40]:

>> If we try to use it directly, the command not found if bash is not installed.
> 
> Installing a FreeBSD bash won't help either, this script expects
> /bin/bash which will never exist on FreeBSD (it's installed in
> /usr/local/bin/bash).

This I added after "if" without trying :)
I was only doing /compat...bin/bash /compat...bin/ldd /something/about/escpr2.

>> we want poudriere to mount real devfs to /compat/linux/dev as well,
>> since linux binary behaves like chroot to /compat/linux.
> 
> Well, first /compat/linux is *not* a chroot or jail, but actually just
> some kind of "filesystem overlay", which is the great thing about it. It
> means Linux binaries can access *all* files of the FreeBSD system, as
> long as they are not "shadowed" by something below /compat/linux.

I was also trying this in jail of poudriere and made the mistake of thinking it was a chroot because I couldn't find the file that should have been there.
However, I will learn about more appropriate words :)

> And indeed, to support building native Linux software using poudriere,
> it *should* mount devfs on /compat/linux/dev.
> 
>> Alternatively, pkg-plist in emulators/linux_base-c7 is creating dummy
>> /compat/linux/dev, and removing it seems to be a workaround.
> 
> In a live system, there's no issue. /etc/rc.d/linux will mount all
> necessary pseudo filesystems:
> 
> | if checkyesno linux_mounts_enable; then
> |         linux_mount linprocfs "${_emul_path}/proc" -o nocover
> |         linux_mount linsysfs "${_emul_path}/sys" -o nocover
> |         linux_mount devfs "${_emul_path}/dev" -o nocover
> |         linux_mount fdescfs "${_emul_path}/dev/fd" -o nocover,linrdlnk
> |         linux_mount tmpfs "${_emul_path}/dev/shm" -o nocover,mode=1777
> | fi

Does this nocover mean that the files that exist in the directory that will be the mount point will remain visible?
This will be a feature that will remain non-existent in 12.x and await end of support.

> So far, poudriere doesn't mount anything on /compat/linux/dev for its
> building jails, although it *does* mount /compat/linux/proc.
> 
> For now, I found that a simple symlink to the real /dev also does the
> trick, which I can add with some hackery in the port Makefile itself, by
> adding some extra prerequisite for "build-depends" when a poudriere
> build is detected. In the long run, poudriere should mount a real devfs
> though.

In addition, variable JAIL_PARAMS (and JAIL_NET_PARAMS) exist in poudriere and are used to append to something defined somewhere.
It may be possible to use this to allow mount inside the jail.
But I don't know how to configure the jail that way :)

Regards.