diff mbox series

[1/2] systemd: Allow native build

Message ID 20230330134214.2772913-1-zboszor@gmail.com
State New
Headers show
Series [1/2] systemd: Allow native build | expand

Commit Message

Böszörményi Zoltán March 30, 2023, 1:42 p.m. UTC
systemd-native is a dependency for libgudev-native, which
in turn is a dependency for libfprint-native, which is needed
to build libfprint.

The native systemctl binary is removed so it doesn't conflict
with the script from systemd-systemctl-native.

TODO? The new natively built systemctl binary may replace
the script in systemd-systemctl-native, as it supports
more options and works better than the script. For example,
the current script does not create the symlinks in
/etc/systemd/system for WantedBy= and RequiredBy= settings
and does not support systemctl set-default some.target.

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
 meta/recipes-core/systemd/systemd_253.1.bb | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Alexander Kanavin March 30, 2023, 1:46 p.m. UTC | #1
Can you please point to what piece of libgudev actually requires systemd?

Alex

On Thu, 30 Mar 2023 at 15:42, Zoltan Boszormenyi <zboszor@gmail.com> wrote:
>
> systemd-native is a dependency for libgudev-native, which
> in turn is a dependency for libfprint-native, which is needed
> to build libfprint.
>
> The native systemctl binary is removed so it doesn't conflict
> with the script from systemd-systemctl-native.
>
> TODO? The new natively built systemctl binary may replace
> the script in systemd-systemctl-native, as it supports
> more options and works better than the script. For example,
> the current script does not create the symlinks in
> /etc/systemd/system for WantedBy= and RequiredBy= settings
> and does not support systemctl set-default some.target.
>
> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> ---
>  meta/recipes-core/systemd/systemd_253.1.bb | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-core/systemd/systemd_253.1.bb b/meta/recipes-core/systemd/systemd_253.1.bb
> index 9c2b96d3c1..c73b5e05b3 100644
> --- a/meta/recipes-core/systemd/systemd_253.1.bb
> +++ b/meta/recipes-core/systemd/systemd_253.1.bb
> @@ -6,6 +6,8 @@ PE = "1"
>
>  DEPENDS = "intltool-native gperf-native libcap util-linux python3-jinja2-native"
>
> +BBCLASSEXTEND = "native"
> +
>  SECTION = "base/shell"
>
>  inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives qemu systemd gettext bash-completion manpages features_check
> @@ -60,7 +62,7 @@ PAM_PLUGINS = " \
>      pam-plugin-namespace \
>  "
>
> -PACKAGECONFIG ??= " \
> +PACKAGECONFIG:class-target ??= " \
>      ${@bb.utils.filter('DISTRO_FEATURES', 'acl audit efi ldconfig pam selinux smack usrmerge polkit seccomp', d)} \
>      ${@bb.utils.contains('DISTRO_FEATURES', 'wifi', 'rfkill', '', d)} \
>      ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xkbcommon', '', d)} \
> @@ -197,7 +199,7 @@ PACKAGECONFIG[selinux] = "-Dselinux=true,-Dselinux=false,libselinux,initscripts-
>  PACKAGECONFIG[smack] = "-Dsmack=true,-Dsmack=false"
>  PACKAGECONFIG[sysext] = "-Dsysext=true, -Dsysext=false"
>  PACKAGECONFIG[sysusers] = "-Dsysusers=true,-Dsysusers=false"
> -PACKAGECONFIG[sysvinit] = "-Dsysvinit-path=${sysconfdir}/init.d -Dsysvrcnd-path=${sysconfdir},-Dsysvinit-path= -Dsysvrcnd-path=,,systemd-compat-units update-rc.d"
> +PACKAGECONFIG[sysvinit] = "-Dsysvinit-path=${sysconfdir}/init.d -Dsysvrcnd-path=${sysconfdir},-Dsysvinit-path= -Dsysvrcnd-path=,,${@'systemd-compat-units update-rc.d' if d.getVar('PN') == d.getVar('BPN') else ''}"
>  # When enabled use reproducble build timestamp if set as time epoch,
>  # or build time if not. When disabled, time epoch is unset.
>  def build_epoch(d):
> @@ -211,7 +213,7 @@ PACKAGECONFIG[sbinmerge] = "-Dsplit-bin=false,-Dsplit-bin=true"
>  PACKAGECONFIG[userdb] = "-Duserdb=true,-Duserdb=false"
>  PACKAGECONFIG[utmp] = "-Dutmp=true,-Dutmp=false"
>  PACKAGECONFIG[valgrind] = "-DVALGRIND=1,,valgrind"
> -PACKAGECONFIG[vconsole] = "-Dvconsole=true,-Dvconsole=false,,${PN}-vconsole-setup"
> +PACKAGECONFIG[vconsole] = "-Dvconsole=true,-Dvconsole=false,,${BPN}-vconsole-setup"
>  PACKAGECONFIG[wheel-group] = "-Dwheel-group=true, -Dwheel-group=false"
>  PACKAGECONFIG[xdg-autostart] = "-Dxdg-autostart=true,-Dxdg-autostart=false"
>  # Verify keymaps on locale change
> @@ -364,6 +366,12 @@ do_install() {
>      fi
>  }
>
> +do_install:append:class-native () {
> +    rm -f ${D}${bindir}/systemctl
> +       ln -sf ..${base_bindir_native}/udevadm ${D}${base_sbindir}/udevadm
> +       ln -sf ..${systemd_unitdir#${rootprefix}}/systemd-udevd ${D}${base_sbindir}/udevd
> +}
> +
>  python populate_packages:prepend (){
>      systemdlibdir = d.getVar("rootlibdir")
>      do_split_packages(d, systemdlibdir, r'^lib(.*)\.so\.*', 'lib%s', 'Systemd %s library', extra_depends='', allow_links=True)
> @@ -670,10 +678,10 @@ FILES:${PN} = " ${base_bindir}/* \
>  FILES:${PN}-dev += "${base_libdir}/security/*.la ${datadir}/dbus-1/interfaces/ ${sysconfdir}/rpm/macros.systemd"
>
>  RDEPENDS:${PN} += "kmod dbus util-linux-mount util-linux-umount udev (= ${EXTENDPKGV}) systemd-udev-rules util-linux-agetty util-linux-fsck"
> -RDEPENDS:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', '', 'systemd-serialgetty', d)}"
> -RDEPENDS:${PN} += "volatile-binds"
> +RDEPENDS:${PN}:class-target += "${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', '', 'systemd-serialgetty', d)}"
> +RDEPENDS:${PN}:class-target += "volatile-binds"
>
> -RRECOMMENDS:${PN} += "systemd-extra-utils \
> +RRECOMMENDS:${PN}:class-target += "systemd-extra-utils \
>                        udev-hwdb \
>                        e2fsprogs-e2fsck \
>                        kernel-module-autofs4 kernel-module-unix kernel-module-ipv6 kernel-module-sch-fq-codel \
> --
> 2.39.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#179321): https://lists.openembedded.org/g/openembedded-core/message/179321
> Mute This Topic: https://lists.openembedded.org/mt/97950749/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Richard Purdie March 30, 2023, 1:50 p.m. UTC | #2
On Thu, 2023-03-30 at 15:42 +0200, Zoltan Boszormenyi wrote:
> systemd-native is a dependency for libgudev-native, which
> in turn is a dependency for libfprint-native, which is needed
> to build libfprint.
> 
> The native systemctl binary is removed so it doesn't conflict
> with the script from systemd-systemctl-native.
> 
> TODO? The new natively built systemctl binary may replace
> the script in systemd-systemctl-native, as it supports
> more options and works better than the script. For example,
> the current script does not create the symlinks in
> /etc/systemd/system for WantedBy= and RequiredBy= settings
> and does not support systemctl set-default some.target.

Which piece of systemd is libfprint needing? 

We've had a request for systemd-native before and my opinion on it
hasn't changed, I'd much prefer not to have it.

Cheers,

Richard
Böszörményi Zoltán March 30, 2023, 2:04 p.m. UTC | #3
2023. 03. 30. 15:46 keltezéssel, Alexander Kanavin írta:
> Can you please point to what piece of libgudev actually requires systemd?

It's this line:

DEPENDS = "glib-2.0 udev"

udev is in systemd:

PROVIDES = "udev"

>
> Alex
>
> On Thu, 30 Mar 2023 at 15:42, Zoltan Boszormenyi <zboszor@gmail.com> wrote:
>> systemd-native is a dependency for libgudev-native, which
>> in turn is a dependency for libfprint-native, which is needed
>> to build libfprint.
>>
>> The native systemctl binary is removed so it doesn't conflict
>> with the script from systemd-systemctl-native.
>>
>> TODO? The new natively built systemctl binary may replace
>> the script in systemd-systemctl-native, as it supports
>> more options and works better than the script. For example,
>> the current script does not create the symlinks in
>> /etc/systemd/system for WantedBy= and RequiredBy= settings
>> and does not support systemctl set-default some.target.
>>
>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>> ---
>>   meta/recipes-core/systemd/systemd_253.1.bb | 20 ++++++++++++++------
>>   1 file changed, 14 insertions(+), 6 deletions(-)
>>
>> diff --git a/meta/recipes-core/systemd/systemd_253.1.bb b/meta/recipes-core/systemd/systemd_253.1.bb
>> index 9c2b96d3c1..c73b5e05b3 100644
>> --- a/meta/recipes-core/systemd/systemd_253.1.bb
>> +++ b/meta/recipes-core/systemd/systemd_253.1.bb
>> @@ -6,6 +6,8 @@ PE = "1"
>>
>>   DEPENDS = "intltool-native gperf-native libcap util-linux python3-jinja2-native"
>>
>> +BBCLASSEXTEND = "native"
>> +
>>   SECTION = "base/shell"
>>
>>   inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives qemu systemd gettext bash-completion manpages features_check
>> @@ -60,7 +62,7 @@ PAM_PLUGINS = " \
>>       pam-plugin-namespace \
>>   "
>>
>> -PACKAGECONFIG ??= " \
>> +PACKAGECONFIG:class-target ??= " \
>>       ${@bb.utils.filter('DISTRO_FEATURES', 'acl audit efi ldconfig pam selinux smack usrmerge polkit seccomp', d)} \
>>       ${@bb.utils.contains('DISTRO_FEATURES', 'wifi', 'rfkill', '', d)} \
>>       ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xkbcommon', '', d)} \
>> @@ -197,7 +199,7 @@ PACKAGECONFIG[selinux] = "-Dselinux=true,-Dselinux=false,libselinux,initscripts-
>>   PACKAGECONFIG[smack] = "-Dsmack=true,-Dsmack=false"
>>   PACKAGECONFIG[sysext] = "-Dsysext=true, -Dsysext=false"
>>   PACKAGECONFIG[sysusers] = "-Dsysusers=true,-Dsysusers=false"
>> -PACKAGECONFIG[sysvinit] = "-Dsysvinit-path=${sysconfdir}/init.d -Dsysvrcnd-path=${sysconfdir},-Dsysvinit-path= -Dsysvrcnd-path=,,systemd-compat-units update-rc.d"
>> +PACKAGECONFIG[sysvinit] = "-Dsysvinit-path=${sysconfdir}/init.d -Dsysvrcnd-path=${sysconfdir},-Dsysvinit-path= -Dsysvrcnd-path=,,${@'systemd-compat-units update-rc.d' if d.getVar('PN') == d.getVar('BPN') else ''}"
>>   # When enabled use reproducble build timestamp if set as time epoch,
>>   # or build time if not. When disabled, time epoch is unset.
>>   def build_epoch(d):
>> @@ -211,7 +213,7 @@ PACKAGECONFIG[sbinmerge] = "-Dsplit-bin=false,-Dsplit-bin=true"
>>   PACKAGECONFIG[userdb] = "-Duserdb=true,-Duserdb=false"
>>   PACKAGECONFIG[utmp] = "-Dutmp=true,-Dutmp=false"
>>   PACKAGECONFIG[valgrind] = "-DVALGRIND=1,,valgrind"
>> -PACKAGECONFIG[vconsole] = "-Dvconsole=true,-Dvconsole=false,,${PN}-vconsole-setup"
>> +PACKAGECONFIG[vconsole] = "-Dvconsole=true,-Dvconsole=false,,${BPN}-vconsole-setup"
>>   PACKAGECONFIG[wheel-group] = "-Dwheel-group=true, -Dwheel-group=false"
>>   PACKAGECONFIG[xdg-autostart] = "-Dxdg-autostart=true,-Dxdg-autostart=false"
>>   # Verify keymaps on locale change
>> @@ -364,6 +366,12 @@ do_install() {
>>       fi
>>   }
>>
>> +do_install:append:class-native () {
>> +    rm -f ${D}${bindir}/systemctl
>> +       ln -sf ..${base_bindir_native}/udevadm ${D}${base_sbindir}/udevadm
>> +       ln -sf ..${systemd_unitdir#${rootprefix}}/systemd-udevd ${D}${base_sbindir}/udevd
>> +}
>> +
>>   python populate_packages:prepend (){
>>       systemdlibdir = d.getVar("rootlibdir")
>>       do_split_packages(d, systemdlibdir, r'^lib(.*)\.so\.*', 'lib%s', 'Systemd %s library', extra_depends='', allow_links=True)
>> @@ -670,10 +678,10 @@ FILES:${PN} = " ${base_bindir}/* \
>>   FILES:${PN}-dev += "${base_libdir}/security/*.la ${datadir}/dbus-1/interfaces/ ${sysconfdir}/rpm/macros.systemd"
>>
>>   RDEPENDS:${PN} += "kmod dbus util-linux-mount util-linux-umount udev (= ${EXTENDPKGV}) systemd-udev-rules util-linux-agetty util-linux-fsck"
>> -RDEPENDS:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', '', 'systemd-serialgetty', d)}"
>> -RDEPENDS:${PN} += "volatile-binds"
>> +RDEPENDS:${PN}:class-target += "${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', '', 'systemd-serialgetty', d)}"
>> +RDEPENDS:${PN}:class-target += "volatile-binds"
>>
>> -RRECOMMENDS:${PN} += "systemd-extra-utils \
>> +RRECOMMENDS:${PN}:class-target += "systemd-extra-utils \
>>                         udev-hwdb \
>>                         e2fsprogs-e2fsck \
>>                         kernel-module-autofs4 kernel-module-unix kernel-module-ipv6 kernel-module-sch-fq-codel \
>> --
>> 2.39.2
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#179321): https://lists.openembedded.org/g/openembedded-core/message/179321
>> Mute This Topic: https://lists.openembedded.org/mt/97950749/1686489
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
Böszörményi Zoltán March 30, 2023, 2:08 p.m. UTC | #4
2023. 03. 30. 15:50 keltezéssel, Richard Purdie írta:
> On Thu, 2023-03-30 at 15:42 +0200, Zoltan Boszormenyi wrote:
>> systemd-native is a dependency for libgudev-native, which
>> in turn is a dependency for libfprint-native, which is needed
>> to build libfprint.
>>
>> The native systemctl binary is removed so it doesn't conflict
>> with the script from systemd-systemctl-native.
>>
>> TODO? The new natively built systemctl binary may replace
>> the script in systemd-systemctl-native, as it supports
>> more options and works better than the script. For example,
>> the current script does not create the symlinks in
>> /etc/systemd/system for WantedBy= and RequiredBy= settings
>> and does not support systemctl set-default some.target.
> Which piece of systemd is libfprint needing?

Please see the MR:
https://gitlab.freedesktop.org/libfprint/libfprint/-/merge_requests/431

udev (provided by systemd) -> libgudev -> libfprint
also:
udev-native -> libgudev-native -> libfprint-native -> libfprint

Also, please read the TODO part of the patch for systemd
and consider it.

Thanks.


>
> We've had a request for systemd-native before and my opinion on it
> hasn't changed, I'd much prefer not to have it.
>
> Cheers,
>
> Richard
Alexander Kanavin March 30, 2023, 2:10 p.m. UTC | #5
On Thu, 30 Mar 2023 at 16:08, Zoltan Boszormenyi <zboszor@gmail.com> wrote:
> Please see the MR:
> https://gitlab.freedesktop.org/libfprint/libfprint/-/merge_requests/431
>
> udev (provided by systemd) -> libgudev -> libfprint
> also:
> udev-native -> libgudev-native -> libfprint-native -> libfprint
>
> Also, please read the TODO part of the patch for systemd
> and consider it.

We can simply direct libfprint to run its own target pieces under qemu
usermode, and avoid all this nasty native stuff. Meson has direct
support for it, and even if it doesn't work, libfprint can be patched
to use a custom 'wrapper' for executing the binaries.

Alex
Böszörményi Zoltán March 30, 2023, 2:31 p.m. UTC | #6
2023. 03. 30. 16:10 keltezéssel, Alexander Kanavin írta:
> On Thu, 30 Mar 2023 at 16:08, Zoltan Boszormenyi <zboszor@gmail.com> wrote:
>> Please see the MR:
>> https://gitlab.freedesktop.org/libfprint/libfprint/-/merge_requests/431
>>
>> udev (provided by systemd) -> libgudev -> libfprint
>> also:
>> udev-native -> libgudev-native -> libfprint-native -> libfprint
>>
>> Also, please read the TODO part of the patch for systemd
>> and consider it.
> We can simply direct libfprint to run its own target pieces under qemu
> usermode

The mariadb change to use CROSSCOMPILING_EMULATOR
instead of building mariadb-native was reverted because
qemu is not ominpotent. The same applies to meson
running executables via qemu. No custom wrapper would help.

> , and avoid all this nasty native stuff. Meson has direct
> support for it, and even if it doesn't work, libfprint can be patched
> to use a custom 'wrapper' for executing the binaries.

You seem to have omitted reading a large part in the
commit message for the systemd change.

> TODO? The new natively built systemctl binary may replace
> the script in systemd-systemctl-native, as it supports
> more options and works better than the script. For example,
> the current script does not create the symlinks in
> /etc/systemd/system for WantedBy= and RequiredBy= settings
> and does not support systemctl set-default some.target.


This is not relevant to libfprint itself, it's a bug in
Yocto's systemctl replacement script.

----8<--- foo.service ----8<---
...
[Install]
WantedBy=bar.service
RequiredBy=baz.service
...
----8<--- foo.service ----8<---

The symlinks in /etc/systemd/system/bar.service.wants
and /etc/systemd/system/baz.service.requires are not
created for foo.service.

This command is also not supported by the Yocto replacement:

systemctl set-default custom.target

I have been bitten by both issues.
Alexander Kanavin March 30, 2023, 2:41 p.m. UTC | #7
On Thu, 30 Mar 2023 at 16:31, Böszörményi Zoltán <zboszor@gmail.com> wrote:
> The mariadb change to use CROSSCOMPILING_EMULATOR
> instead of building mariadb-native was reverted because
> qemu is not ominpotent. The same applies to meson
> running executables via qemu. No custom wrapper would help.

Mariadb's problem was that (for a specific target) it somehow included
CPU instructions that qemu usermode doesn't support, and no one looked
into what those instructions were and why they were produced in the
first place, preferring to revert the whole thing. There are lots of
counter-examples in core where qemu usermode works fine, and has been
working that way for many years, for example gobject introspection, or
all of the scripts in ../scripts/postinst-intercepts/ which run every
time you bake an image, including update_udev_hwdb by the way that
runs target udevadm. I am not maintaining oe-devel, and I do not keep
an eye on things like that, otherwise I would've asked for further
investigation into what crashes and why.

I do not want to add complex native dependency chains when usermode
would work. It's me who's going to fix them when they break, not you.

> You seem to have omitted reading a large part in the
> commit message for the systemd change.
>
> > TODO? The new natively built systemctl binary may replace
> > the script in systemd-systemctl-native, as it supports
> > more options and works better than the script. For example,
> > the current script does not create the symlinks in
> > /etc/systemd/system for WantedBy= and RequiredBy= settings
> > and does not support systemctl set-default some.target.

This is a separate concern, and needs to be proposed as such.

Alex
Böszörményi Zoltán March 30, 2023, 2:45 p.m. UTC | #8
2023. 03. 30. 16:31 keltezéssel, Zoltan Boszormenyi via lists.openembedded.org írta:
> 2023. 03. 30. 16:10 keltezéssel, Alexander Kanavin írta:
>> On Thu, 30 Mar 2023 at 16:08, Zoltan Boszormenyi <zboszor@gmail.com> wrote:
>>> Please see the MR:
>>> https://gitlab.freedesktop.org/libfprint/libfprint/-/merge_requests/431
>>>
>>> udev (provided by systemd) -> libgudev -> libfprint
>>> also:
>>> udev-native -> libgudev-native -> libfprint-native -> libfprint
>>>
>>> Also, please read the TODO part of the patch for systemd
>>> and consider it.
>> We can simply direct libfprint to run its own target pieces under qemu
>> usermode
>
> The mariadb change to use CROSSCOMPILING_EMULATOR
> instead of building mariadb-native was reverted because
> qemu is not ominpotent. The same applies to meson
> running executables via qemu. No custom wrapper would help.
>
>> , and avoid all this nasty native stuff. Meson has direct
>> support for it, and even if it doesn't work, libfprint can be patched
>> to use a custom 'wrapper' for executing the binaries.
>
> You seem to have omitted reading a large part in the
> commit message for the systemd change.
>
>> TODO? The new natively built systemctl binary may replace
>> the script in systemd-systemctl-native, as it supports
>> more options and works better than the script. For example,
>> the current script does not create the symlinks in
>> /etc/systemd/system for WantedBy= and RequiredBy= settings
>> and does not support systemctl set-default some.target.
>
>
> This is not relevant to libfprint itself, it's a bug in
> Yocto's systemctl replacement script.
>

Here's the fixed

----8<--- foo.service ----8<---
...
[Install]
WantedBy=bar.service bar2.service bar3.service
RequiredBy=baz.service baz2.service baz3.service
...
----8<--- foo.service ----8<---

> The symlinks in /etc/systemd/system/bar.service.wants
> and /etc/systemd/system/baz.service.requires are not
> created for foo.service.

Or not all of them. This command fixed them on the
installed system by creating all symlinks and not just the first:

systemctl reenable foo.service

but on a PXE booted image it's a bummer.

> This command is also not supported by the Yocto replacement:
>
> systemctl set-default custom.target
>
> I have been bitten by both issues.
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#179330): https://lists.openembedded.org/g/openembedded-core/message/179330
> Mute This Topic: https://lists.openembedded.org/mt/97950749/3617728
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [zboszor@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Böszörményi Zoltán March 30, 2023, 2:51 p.m. UTC | #9
2023. 03. 30. 16:41 keltezéssel, Alexander Kanavin írta:
> On Thu, 30 Mar 2023 at 16:31, Böszörményi Zoltán <zboszor@gmail.com> wrote:
>> The mariadb change to use CROSSCOMPILING_EMULATOR
>> instead of building mariadb-native was reverted because
>> qemu is not ominpotent. The same applies to meson
>> running executables via qemu. No custom wrapper would help.
> Mariadb's problem was that (for a specific target) it somehow included
> CPU instructions that qemu usermode doesn't support, and no one looked
> into what those instructions were and why they were produced in the
> first place, preferring to revert the whole thing. There are lots of
> counter-examples in core where qemu usermode works fine, and has been
> working that way for many years, for example gobject introspection, or
> all of the scripts in ../scripts/postinst-intercepts/ which run every
> time you bake an image, including update_udev_hwdb by the way that
> runs target udevadm. I am not maintaining oe-devel, and I do not keep
> an eye on things like that, otherwise I would've asked for further
> investigation into what crashes and why.
>
> I do not want to add complex native dependency chains when usermode
> would work. It's me who's going to fix them when they break, not you.
>
>> You seem to have omitted reading a large part in the
>> commit message for the systemd change.
>>
>>> TODO? The new natively built systemctl binary may replace
>>> the script in systemd-systemctl-native, as it supports
>>> more options and works better than the script. For example,
>>> the current script does not create the symlinks in
>>> /etc/systemd/system for WantedBy= and RequiredBy= settings
>>> and does not support systemctl set-default some.target.
> This is a separate concern, and needs to be proposed as such.

I can extend this patchset to remove systemd-systemctl-native.bb
and use the native build fixing these problems.

Then libfprint can just use that as an innocent bystander.
Alexander Kanavin March 30, 2023, 2:57 p.m. UTC | #10
On Thu, 30 Mar 2023 at 16:51, Böszörményi Zoltán <zboszor@gmail.com> wrote:

> >>> TODO? The new natively built systemctl binary may replace
> >>> the script in systemd-systemctl-native, as it supports
> >>> more options and works better than the script. For example,
> >>> the current script does not create the symlinks in
> >>> /etc/systemd/system for WantedBy= and RequiredBy= settings
> >>> and does not support systemctl set-default some.target.
> > This is a separate concern, and needs to be proposed as such.
>
> I can extend this patchset to remove systemd-systemctl-native.bb
> and use the native build fixing these problems.

That would make a stronger case for it. But you'd likely be asked to
make systemd-native really minimal, and ideally produce the systemctl
executable and nothing else.

Alex
Richard Purdie March 30, 2023, 4:39 p.m. UTC | #11
On Thu, 2023-03-30 at 16:10 +0200, Alexander Kanavin wrote:
> On Thu, 30 Mar 2023 at 16:08, Zoltan Boszormenyi <zboszor@gmail.com> wrote:
> > Please see the MR:
> > https://gitlab.freedesktop.org/libfprint/libfprint/-/merge_requests/431
> > 
> > udev (provided by systemd) -> libgudev -> libfprint
> > also:
> > udev-native -> libgudev-native -> libfprint-native -> libfprint
> > 
> > Also, please read the TODO part of the patch for systemd
> > and consider it.
> 
> We can simply direct libfprint to run its own target pieces under qemu
> usermode, and avoid all this nasty native stuff. Meson has direct
> support for it, and even if it doesn't work, libfprint can be patched
> to use a custom 'wrapper' for executing the binaries.

Before we jump to using qemu user mode, the first question has to be do
we really need a libgudev native to make libfprint-native work enough
to build libprintf.

I'd hope the answer is no, we don't as we don't want the build systems
udev setup/devices leaking into a target build.

We intentionally try and keep native dependencies minimal and needing
native udev/systemd versions of things sets of warnings in my mind and
in others since it often means we're doing things we shouldn't be or
don't actually need.

I appreciate there are issues with systemctl-native but those are
separate issues and should be addressed as such. Complicating the build
dependencies unnecessarily is bad and we should minimise them where
possible. it isn't that I didn't read that bit of the patch, I just
don't see it as a reason to have this dependency for libfprint.

So, I come back to the question of what libfprint needs from libfprint-
native and whether it really does need udev for that?

Cheers,

Richard
Böszörményi Zoltán March 31, 2023, 9:39 a.m. UTC | #12
2023. 03. 30. 18:39 keltezéssel, Richard Purdie írta:
> On Thu, 2023-03-30 at 16:10 +0200, Alexander Kanavin wrote:
>> On Thu, 30 Mar 2023 at 16:08, Zoltan Boszormenyi <zboszor@gmail.com> wrote:
>>> Please see the MR:
>>> https://gitlab.freedesktop.org/libfprint/libfprint/-/merge_requests/431
>>>
>>> udev (provided by systemd) -> libgudev -> libfprint
>>> also:
>>> udev-native -> libgudev-native -> libfprint-native -> libfprint
>>>
>>> Also, please read the TODO part of the patch for systemd
>>> and consider it.
>> We can simply direct libfprint to run its own target pieces under qemu
>> usermode, and avoid all this nasty native stuff. Meson has direct
>> support for it, and even if it doesn't work, libfprint can be patched
>> to use a custom 'wrapper' for executing the binaries.
> Before we jump to using qemu user mode, the first question has to be do
> we really need a libgudev native to make libfprint-native work enough
> to build libprintf.
>
> I'd hope the answer is no, we don't as we don't want the build systems
> udev setup/devices leaking into a target build.
>
> We intentionally try and keep native dependencies minimal and needing
> native udev/systemd versions of things sets of warnings in my mind and
> in others since it often means we're doing things we shouldn't be or
> don't actually need.
>
> I appreciate there are issues with systemctl-native but those are
> separate issues and should be addressed as such. Complicating the build
> dependencies unnecessarily is bad and we should minimise them where
> possible. it isn't that I didn't read that bit of the patch, I just
> don't see it as a reason to have this dependency for libfprint.
>
> So, I come back to the question of what libfprint needs from libfprint-
> native and whether it really does need udev for that?

libfprint needs two generator executables to create
a set of udev rules and another file called autosuspend.hwdb.

Both executables are linked with the complete libfprint library
which includes the complete set of drivers that are configured
and built. They seem to need this to deduce the list of supported
device USB IDs for the current build. Both executables use fpi_
prefixed functions to ask the libfprint library for their goals.

In turn, the libfprint library depend on libgudev and libgusb
for hotplug and device discovery purposes, respectively.

There is also a meson bug that Alexander Kanavin brought
to my attention where custom_target() doesn't run executables
using the exe_wrapper and I seem to be hitting this with
libfprint.

I am not a meson expert so if there's a way to replace
the executable()+custom_target(capture: true) combination
with something more cross-compiler friendly, please don't hold
this information back.

I couldn't fix this for libfprint 1.0 / fprintd 0.9.0 two years ago
and I cannot fix it for the 2.0 beta versions either.
In my current in-house solution there's a separate systemd-native.bb
recipe but I thought maybe cleaning it up for upstream and
modifying the systemd recipe may be acceptable.
Böszörményi Zoltán March 31, 2023, 9:46 a.m. UTC | #13
2023. 03. 31. 11:39 keltezéssel, Zoltan Boszormenyi via lists.openembedded.org írta:
> 2023. 03. 30. 18:39 keltezéssel, Richard Purdie írta:
>> On Thu, 2023-03-30 at 16:10 +0200, Alexander Kanavin wrote:
>>> On Thu, 30 Mar 2023 at 16:08, Zoltan Boszormenyi <zboszor@gmail.com> wrote:
>>>> Please see the MR:
>>>> https://gitlab.freedesktop.org/libfprint/libfprint/-/merge_requests/431
>>>>
>>>> udev (provided by systemd) -> libgudev -> libfprint
>>>> also:
>>>> udev-native -> libgudev-native -> libfprint-native -> libfprint
>>>>
>>>> Also, please read the TODO part of the patch for systemd
>>>> and consider it.
>>> We can simply direct libfprint to run its own target pieces under qemu
>>> usermode, and avoid all this nasty native stuff. Meson has direct
>>> support for it, and even if it doesn't work, libfprint can be patched
>>> to use a custom 'wrapper' for executing the binaries.
>> Before we jump to using qemu user mode, the first question has to be do
>> we really need a libgudev native to make libfprint-native work enough
>> to build libprintf.
>>
>> I'd hope the answer is no, we don't as we don't want the build systems
>> udev setup/devices leaking into a target build.
>>
>> We intentionally try and keep native dependencies minimal and needing
>> native udev/systemd versions of things sets of warnings in my mind and
>> in others since it often means we're doing things we shouldn't be or
>> don't actually need.
>>
>> I appreciate there are issues with systemctl-native but those are
>> separate issues and should be addressed as such. Complicating the build
>> dependencies unnecessarily is bad and we should minimise them where
>> possible. it isn't that I didn't read that bit of the patch, I just
>> don't see it as a reason to have this dependency for libfprint.
>>
>> So, I come back to the question of what libfprint needs from libfprint-
>> native and whether it really does need udev for that?
>
> libfprint needs two generator executables to create
> a set of udev rules and another file called autosuspend.hwdb.
>
> Both executables are linked with the complete libfprint library
> which includes the complete set of drivers that are configured
> and built. They seem to need this to deduce the list of supported
> device USB IDs for the current build. Both executables use fpi_
> prefixed functions to ask the libfprint library for their goals.
>
> In turn, the libfprint library depend on libgudev and libgusb
> for hotplug and device discovery purposes, respectively.
>
> There is also a meson bug that Alexander Kanavin brought
> to my attention where custom_target() doesn't run executables
> using the exe_wrapper and I seem to be hitting this with
> libfprint.
>
> I am not a meson expert so if there's a way to replace
> the executable()+custom_target(capture: true) combination
> with something more cross-compiler friendly, please don't hold
> this information back.
>
> I couldn't fix this for libfprint 1.0 / fprintd 0.9.0 two years ago
> and I cannot fix it for the 2.0 beta versions either.
> In my current in-house solution there's a separate systemd-native.bb
> recipe but I thought maybe cleaning it up for upstream and
> modifying the systemd recipe may be acceptable.

Regarding my attempts to fix this: I have looked into
making these executables use "native: true" but it
would need duplicating all the driver and library targets
with "native: true", too, and it seemed to be too intrusive.
Also, it doesn't eliminate the native dependency chain,
building these executables would still need systemd-native,
libgudev-native and libgusb-native.

>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#179406): https://lists.openembedded.org/g/openembedded-core/message/179406
> Mute This Topic: https://lists.openembedded.org/mt/97950749/3617728
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [zboszor@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Ross Burton April 3, 2023, 10:59 a.m. UTC | #14
On 31 Mar 2023, at 10:46, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
> Regarding my attempts to fix this: I have looked into
> making these executables use "native: true" but it
> would need duplicating all the driver and library targets
> with "native: true", too, and it seemed to be too intrusive.
> Also, it doesn't eliminate the native dependency chain,
> building these executables would still need systemd-native,
> libgudev-native and libgusb-native.

I’d say this is still the correct solution, although the ‘native’ libfprint would be as lean as possible and not the entire library.

Ross
Böszörményi Zoltán April 3, 2023, 1 p.m. UTC | #15
2023. 04. 03. 12:59 keltezéssel, Ross Burton írta:
> On 31 Mar 2023, at 10:46, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
>> Regarding my attempts to fix this: I have looked into
>> making these executables use "native: true" but it
>> would need duplicating all the driver and library targets
>> with "native: true", too, and it seemed to be too intrusive.
>> Also, it doesn't eliminate the native dependency chain,
>> building these executables would still need systemd-native,
>> libgudev-native and libgusb-native.
> I’d say this is still the correct solution, although the ‘native’ libfprint would be as lean as possible and not the entire library.

Hopefully someone can solve this bug soon:
https://github.com/mesonbuild/meson/issues/11029
FWIW, I commented about the problem but the meson
codebase is over my head so I can't fix it.

Then libfrint (and probably other meson bases recipes
in Yocto) won't need a native part.

Until then, please ignore this patchset and the other one
for meta-oe. I will stick to my in-house solution for now.
Ross Burton April 3, 2023, 7:52 p.m. UTC | #16
> On 3 Apr 2023, at 14:00, Böszörményi Zoltán <zboszor@gmail.com> wrote:
> 
> 2023. 04. 03. 12:59 keltezéssel, Ross Burton írta:
>> On 31 Mar 2023, at 10:46, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
>>> Regarding my attempts to fix this: I have looked into
>>> making these executables use "native: true" but it
>>> would need duplicating all the driver and library targets
>>> with "native: true", too, and it seemed to be too intrusive.
>>> Also, it doesn't eliminate the native dependency chain,
>>> building these executables would still need systemd-native,
>>> libgudev-native and libgusb-native.
>> I’d say this is still the correct solution, although the ‘native’ libfprint would be as lean as possible and not the entire library.
> 
> Hopefully someone can solve this bug soon:
> https://github.com/mesonbuild/meson/issues/11029
> FWIW, I commented about the problem but the meson
> codebase is over my head so I can't fix it.
> 
> Then libfrint (and probably other meson bases recipes
> in Yocto) won't need a native part.

FWIW I just took a stripped down copy of your libfprint recipe and it happily built using qemu’s exe wrapper in oe-core master.

So, yes, it would be good if the build used native instead of relying on qemu, but it’s not a hard blocker.  We should definitely be doing AB runs of poky with the exe wrapper disabled to exercise those codepaths.

Ross
Böszörményi Zoltán April 4, 2023, 8:31 a.m. UTC | #17
2023. 04. 03. 21:52 keltezéssel, Ross Burton írta:
>
>> On 3 Apr 2023, at 14:00, Böszörményi Zoltán <zboszor@gmail.com> wrote:
>>
>> 2023. 04. 03. 12:59 keltezéssel, Ross Burton írta:
>>> On 31 Mar 2023, at 10:46, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
>>>> Regarding my attempts to fix this: I have looked into
>>>> making these executables use "native: true" but it
>>>> would need duplicating all the driver and library targets
>>>> with "native: true", too, and it seemed to be too intrusive.
>>>> Also, it doesn't eliminate the native dependency chain,
>>>> building these executables would still need systemd-native,
>>>> libgudev-native and libgusb-native.
>>> I’d say this is still the correct solution, although the ‘native’ libfprint would be as lean as possible and not the entire library.
>> Hopefully someone can solve this bug soon:
>> https://github.com/mesonbuild/meson/issues/11029
>> FWIW, I commented about the problem but the meson
>> codebase is over my head so I can't fix it.
>>
>> Then libfrint (and probably other meson bases recipes
>> in Yocto) won't need a native part.
> FWIW I just took a stripped down copy of your libfprint recipe and it happily built using qemu’s exe wrapper in oe-core master.

After a fresh "repo sync" my libfprint build still fails with the
stripped down copy that doesn't want the native dependency.

Please share the changes of yours against the libfprint recipe
because clearly I am doing something wrong which is not
obvious to me.

Or there is something subtle going on. For example, does
this stripped down copy of the libfprint recipe still build
for you if meta-clang is also used?

> So, yes, it would be good if the build used native instead of relying on qemu, but it’s not a hard blocker.  We should definitely be doing AB runs of poky with the exe wrapper disabled to exercise those codepaths.
>
> Ross
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd_253.1.bb b/meta/recipes-core/systemd/systemd_253.1.bb
index 9c2b96d3c1..c73b5e05b3 100644
--- a/meta/recipes-core/systemd/systemd_253.1.bb
+++ b/meta/recipes-core/systemd/systemd_253.1.bb
@@ -6,6 +6,8 @@  PE = "1"
 
 DEPENDS = "intltool-native gperf-native libcap util-linux python3-jinja2-native"
 
+BBCLASSEXTEND = "native"
+
 SECTION = "base/shell"
 
 inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives qemu systemd gettext bash-completion manpages features_check
@@ -60,7 +62,7 @@  PAM_PLUGINS = " \
     pam-plugin-namespace \
 "
 
-PACKAGECONFIG ??= " \
+PACKAGECONFIG:class-target ??= " \
     ${@bb.utils.filter('DISTRO_FEATURES', 'acl audit efi ldconfig pam selinux smack usrmerge polkit seccomp', d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', 'wifi', 'rfkill', '', d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xkbcommon', '', d)} \
@@ -197,7 +199,7 @@  PACKAGECONFIG[selinux] = "-Dselinux=true,-Dselinux=false,libselinux,initscripts-
 PACKAGECONFIG[smack] = "-Dsmack=true,-Dsmack=false"
 PACKAGECONFIG[sysext] = "-Dsysext=true, -Dsysext=false"
 PACKAGECONFIG[sysusers] = "-Dsysusers=true,-Dsysusers=false"
-PACKAGECONFIG[sysvinit] = "-Dsysvinit-path=${sysconfdir}/init.d -Dsysvrcnd-path=${sysconfdir},-Dsysvinit-path= -Dsysvrcnd-path=,,systemd-compat-units update-rc.d"
+PACKAGECONFIG[sysvinit] = "-Dsysvinit-path=${sysconfdir}/init.d -Dsysvrcnd-path=${sysconfdir},-Dsysvinit-path= -Dsysvrcnd-path=,,${@'systemd-compat-units update-rc.d' if d.getVar('PN') == d.getVar('BPN') else ''}"
 # When enabled use reproducble build timestamp if set as time epoch,
 # or build time if not. When disabled, time epoch is unset.
 def build_epoch(d):
@@ -211,7 +213,7 @@  PACKAGECONFIG[sbinmerge] = "-Dsplit-bin=false,-Dsplit-bin=true"
 PACKAGECONFIG[userdb] = "-Duserdb=true,-Duserdb=false"
 PACKAGECONFIG[utmp] = "-Dutmp=true,-Dutmp=false"
 PACKAGECONFIG[valgrind] = "-DVALGRIND=1,,valgrind"
-PACKAGECONFIG[vconsole] = "-Dvconsole=true,-Dvconsole=false,,${PN}-vconsole-setup"
+PACKAGECONFIG[vconsole] = "-Dvconsole=true,-Dvconsole=false,,${BPN}-vconsole-setup"
 PACKAGECONFIG[wheel-group] = "-Dwheel-group=true, -Dwheel-group=false"
 PACKAGECONFIG[xdg-autostart] = "-Dxdg-autostart=true,-Dxdg-autostart=false"
 # Verify keymaps on locale change
@@ -364,6 +366,12 @@  do_install() {
     fi
 }
 
+do_install:append:class-native () {
+    rm -f ${D}${bindir}/systemctl
+	ln -sf ..${base_bindir_native}/udevadm ${D}${base_sbindir}/udevadm
+	ln -sf ..${systemd_unitdir#${rootprefix}}/systemd-udevd ${D}${base_sbindir}/udevd
+}
+
 python populate_packages:prepend (){
     systemdlibdir = d.getVar("rootlibdir")
     do_split_packages(d, systemdlibdir, r'^lib(.*)\.so\.*', 'lib%s', 'Systemd %s library', extra_depends='', allow_links=True)
@@ -670,10 +678,10 @@  FILES:${PN} = " ${base_bindir}/* \
 FILES:${PN}-dev += "${base_libdir}/security/*.la ${datadir}/dbus-1/interfaces/ ${sysconfdir}/rpm/macros.systemd"
 
 RDEPENDS:${PN} += "kmod dbus util-linux-mount util-linux-umount udev (= ${EXTENDPKGV}) systemd-udev-rules util-linux-agetty util-linux-fsck"
-RDEPENDS:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', '', 'systemd-serialgetty', d)}"
-RDEPENDS:${PN} += "volatile-binds"
+RDEPENDS:${PN}:class-target += "${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', '', 'systemd-serialgetty', d)}"
+RDEPENDS:${PN}:class-target += "volatile-binds"
 
-RRECOMMENDS:${PN} += "systemd-extra-utils \
+RRECOMMENDS:${PN}:class-target += "systemd-extra-utils \
                       udev-hwdb \
                       e2fsprogs-e2fsck \
                       kernel-module-autofs4 kernel-module-unix kernel-module-ipv6 kernel-module-sch-fq-codel \