[v2,1/9] new recipe : host-systemd
diff mbox series

Message ID 20191111172443.6874-2-jeremy.rosen@smile.fr
State Changes Requested
Headers show
Series
  • use host-systemd to enable units
Related show

Commit Message

Jérémy ROSEN Nov. 11, 2019, 5:24 p.m. UTC
Add the infrastructure to build the host version of systemd
* disable all optional features, they can be re-added when needed
* systemd has creative way of dealing with cross compile
  we build a "normal" host systemd, but install it in $HOST_DIR
  we use systemctl --root to correctly act on TARGET_DIR
* we need to adjust RPATH using patchelf because meson can't do it
  correctly by itsel

Signed-off-by: Jérémy Rosen <jeremy.rosen@smile.fr>
---
 package/systemd/systemd.mk | 93 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)

Comments

Yann E. MORIN Dec. 5, 2019, 11:01 a.m. UTC | #1
Jérémy, All,

Here's a quick review, sorry for the delay...

On 2019-11-11 18:24 +0100, Jérémy Rosen spake thusly:
> Add the infrastructure to build the host version of systemd
> * disable all optional features, they can be re-added when needed
> * systemd has creative way of dealing with cross compile
>   we build a "normal" host systemd, but install it in $HOST_DIR
>   we use systemctl --root to correctly act on TARGET_DIR
> * we need to adjust RPATH using patchelf because meson can't do it
>   correctly by itsel
> 
> Signed-off-by: Jérémy Rosen <jeremy.rosen@smile.fr>
> ---
>  package/systemd/systemd.mk | 93 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 93 insertions(+)
> 
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index 92490eb86b..d1db60b5ef 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -551,3 +551,96 @@ SYSTEMD_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)
>  SYSTEMD_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
>  
>  $(eval $(meson-package))
> +
> +#
> +# Host-systemd configuration
> +#
[--SNIP--]
> +# Fix RPATH After installation
> +# * systemd provides a install_rpath instruction to meson because the binaries need to link with
> +#   libsystemd which is not in a standard path
> +# * meson can only replace the RPATH, not append to it
> +# * the original rpatch is thus lost.
> +# * the original path had been tweaked by buildroot vial LD_FLAGS to add $(HOST_DIR)/lib
> +# * thus re-tweak rpath after the installation for all binaries that need it

Thanks for the detailed comment. :-)

> +#buildroot detects incorrect RPATH, so adding new binaries should be safe (it won't compile
> +#unless properly integrated).
> +HOST_SYSTEMD_HOST_TOOLS = \
> +	systemd-analyze  systemd-mount systemctl
> +
> +define HOST_SYSTEMD_FIX_RPATH
> +	$(foreach f,$(HOST_SYSTEMD_HOST_TOOLS), \
> +		$(HOST_DIR)/bin/patchelf --set-rpath $(HOST_DIR)/lib:$(HOST_DIR)/lib/systemd $(HOST_DIR)/bin/$(f)
> +	)
> +endef
> +
> +HOST_SYSTEMD_POST_INSTALL_HOOKS +=  HOST_SYSTEMD_FIX_RPATH
> +HOST_SYSTEMD_NINJA_ENV = DESTDIR=$(HOST_DIR)
> +
> +$(eval $(host-meson-package))

So in my review of v1, I said that we did not need a visible option for
the host variant.

However, I think we still need the symbol; just it would not have a
prompt.

The underlying idea, is to decide where/when we actually call "systemctl
preset-all". In my mind, this should be called only once, after all
packages have instaleld their units and dropins, which is indeed what
you do in patch 2.

However, to ensure that host-systemd is built, you make it a build
dependency of systemd itself, which it is in fact not; we just need
host-systemd for target-finalize.

As such, I think we should do like we did for host-eudev: introduce a
blind symbol for the host variant, that the target variant selects, and
not introduce a build dependency. Since there would be a xymbol, the
package would actually be built, and this is guaranteed to happen before
target-finalize.

Then the host variant registers a target-finalize hook, like we do for
eudev. IMHO, this host-systemd stuff is very akin to the eudev one.

For reference, see commits:
    c2fee90943 package/eudev: introduce a host variant
    cf9afa50e1 package/eudev: generate the hwdb.bin
    6feba7cba1 packagesystemd: generate the hwdb.bin

Regards,
Yann E. MORIN.

Patch
diff mbox series

diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index 92490eb86b..d1db60b5ef 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -551,3 +551,96 @@  SYSTEMD_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)
 SYSTEMD_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
 
 $(eval $(meson-package))
+
+#
+# Host-systemd configuration
+#
+#Options tweaked for buildroot
+HOST_SYSTEMD_CONF_OPTS= \
+	-Dsplit-bin=true \
+	-Dsplit-usr=false \
+	--prefix=/usr \
+	--libdir=lib \
+	--sysconfdir=/etc \
+	--localstatedir=/var
+
+#disable everything else
+HOST_SYSTEMD_CONF_OPTS+= \
+	-Dutmp=false \
+	-Dhibernate=false \
+	-Dldconfig=false \
+	-Dresolve=false \
+	-Defi=false \
+	-Dtpm=false \
+	-Denvironment-d=false \
+	-Dbinfmt=false \
+	-Dcoredump=false \
+	-Dpstore=false \
+	-Dlogind=false \
+	-Dhostnamed=false \
+	-Dlocaled=false \
+	-Dmachined=false \
+	-Dportabled=false \
+	-Dnetworkd=false \
+	-Dtimedated=false \
+	-Dtimesyncd=false \
+	-Dremote=false \
+	-Dcreate-log-dirs=false \
+	-Dnss-myhostname=false \
+	-Dnss-mymachines=false \
+	-Dnss-resolve=false \
+	-Dnss-systemd=false \
+	-Dfirstboot=false \
+	-Drandomseed=false \
+	-Dbacklight=false \
+	-Dvconsole=false \
+	-Dquotacheck=false \
+	-Dsysusers=false \
+	-Dtmpfiles=false \
+	-Dimportd=false \
+	-Dhwdb=false \
+	-Drfkill=false \
+	-Dman=false \
+	-Dhtml=false \
+	-Dsmack=false \
+	-Dpolkit=false \
+	-Dblkid=false \
+	-Didn=false \
+	-Dadm-group=false \
+	-Dwheel-group=false \
+	-Dzlib=false \
+	-Dgshadow=false \
+	-Dima=false \
+	-Dtests=false \
+	-Dglib=false \
+	-Dacl=false \
+	-Dsysvinit-path=''
+
+HOST_SYSTEMD_DEPENDENCIES = \
+	host-util-linux \
+	host-patchelf \
+	host-libcap \
+	host-gperf
+
+# Fix RPATH After installation
+# * systemd provides a install_rpath instruction to meson because the binaries need to link with
+#   libsystemd which is not in a standard path
+# * meson can only replace the RPATH, not append to it
+# * the original rpatch is thus lost.
+# * the original path had been tweaked by buildroot vial LD_FLAGS to add $(HOST_DIR)/lib
+# * thus re-tweak rpath after the installation for all binaries that need it
+#buildroot detects incorrect RPATH, so adding new binaries should be safe (it won't compile
+#unless properly integrated).
+HOST_SYSTEMD_HOST_TOOLS = \
+	systemd-analyze  systemd-mount systemctl
+
+define HOST_SYSTEMD_FIX_RPATH
+	$(foreach f,$(HOST_SYSTEMD_HOST_TOOLS), \
+		$(HOST_DIR)/bin/patchelf --set-rpath $(HOST_DIR)/lib:$(HOST_DIR)/lib/systemd $(HOST_DIR)/bin/$(f)
+	)
+endef
+
+HOST_SYSTEMD_POST_INSTALL_HOOKS +=  HOST_SYSTEMD_FIX_RPATH
+HOST_SYSTEMD_NINJA_ENV = DESTDIR=$(HOST_DIR)
+
+$(eval $(host-meson-package))