All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/3] udev providers: compile the hwdb at build time (branch yem/host-eudev)
@ 2019-10-28 22:54 Yann E. MORIN
  2019-10-28 22:54 ` [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant Yann E. MORIN
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Yann E. MORIN @ 2019-10-28 22:54 UTC (permalink / raw)
  To: buildroot

Hello All!

The *.hwdb files installed by eudev or systemd are "source" files; they
need to be compiled into a binary form to be useful.

This needs udevadm to be available, so we introduce a eudev host variant
to provide it, and use that from both eudev and systemd to compile the
database during target-finalize.


Regards,
Yann E. MORIN.


The following changes since commit 658388138ceba022c0db7ddb30a453140911f994

  package/libsigrok: fix libftdi support (2019-10-28 23:37:58 +0100)


are available in the git repository at:

  git://git.buildroot.org/~ymorin/git/buildroot.git

for you to fetch changes up to 371d42c6636c11fe7ad280c28ca67aa9e2d9f3ba

  package/systemd: generate hwdb.bin (2019-10-28 23:54:09 +0100)


----------------------------------------------------------------
Yann E. MORIN (3):
      package/eudev: introduce a host variant
      package/eudev: generate hwdb.bin
      package/systemd: generate hwdb.bin

 package/Config.in.host       |  1 +
 package/eudev/Config.in      |  3 ++-
 package/eudev/Config.in.host |  3 +++
 package/eudev/eudev.mk       | 36 ++++++++++++++++++++++++++++++++++++
 package/systemd/Config.in    |  1 +
 package/systemd/systemd.mk   | 23 +++++++++++++++++++++++
 6 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 package/eudev/Config.in.host

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant
  2019-10-28 22:54 [Buildroot] [PATCH 0/3] udev providers: compile the hwdb at build time (branch yem/host-eudev) Yann E. MORIN
@ 2019-10-28 22:54 ` Yann E. MORIN
  2019-10-29  2:54   ` Carlos Santos
  2019-10-28 22:54 ` [Buildroot] [PATCH 2/3] package/eudev: generate hwdb.bin Yann E. MORIN
  2019-10-28 22:54 ` [Buildroot] [PATCH 3/3] package/systemd: " Yann E. MORIN
  2 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2019-10-28 22:54 UTC (permalink / raw)
  To: buildroot

eudev and systemd provide a hardware database (hwdb) as a set of
multiple files. Various other utilities may also use that database.

Those files have to be "compiled" into a binary to be useful; libudev
(and thus all utilities based on it) only use the compiled hwdb.

Compiling the hwdb is done with udevadm, using the hwdb sub-command:
    udevadm hwdb --update

Provide a simple host-variant of eudev, so that we can call udevadm at
build time.

This host udevadm will read files from $(HOST_DIR)/etc/udev/hwdb.d/*.hwdb
and write the compiled hwdb to $(HOST_DIR)/etc/udev/hwdb.bin.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Carlos Santos <unixmania@gmail.com>
---
 package/Config.in.host       |  1 +
 package/eudev/Config.in.host |  3 +++
 package/eudev/eudev.mk       | 14 ++++++++++++++
 3 files changed, 18 insertions(+)
 create mode 100644 package/eudev/Config.in.host

diff --git a/package/Config.in.host b/package/Config.in.host
index 914491e210..c0ac4fbbcc 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -17,6 +17,7 @@ menu "Host utilities"
 	source "package/dtc/Config.in.host"
 	source "package/e2fsprogs/Config.in.host"
 	source "package/e2tools/Config.in.host"
+	source "package/eudev/Config.in.host"
 	source "package/f2fs-tools/Config.in.host"
 	source "package/faketime/Config.in.host"
 	source "package/fatcat/Config.in.host"
diff --git a/package/eudev/Config.in.host b/package/eudev/Config.in.host
new file mode 100644
index 0000000000..87dfc43912
--- /dev/null
+++ b/package/eudev/Config.in.host
@@ -0,0 +1,3 @@
+# Select this if you need host eudev tools (e.g. udevadm)
+config BR2_PACKAGE_HOST_EUDEV
+	bool
diff --git a/package/eudev/eudev.mk b/package/eudev/eudev.mk
index 2a3adb849c..12568a6645 100644
--- a/package/eudev/eudev.mk
+++ b/package/eudev/eudev.mk
@@ -55,4 +55,18 @@ define EUDEV_USERS
 	- - kvm -1 * - - - kvm nodes
 endef
 
+HOST_EUDEV_DEPENDENCIES = host-gperf host-pkgconf
+HOST_EUDEV_CONF_OPTS = \
+	--disable-manpages \
+	--sbindir=$(HOST_DIR)/sbin \
+	--libexecdir=$(HOST_DIR)/lib \
+	--with-rootlibdir=$(HOST_DIR)/lib \
+	--disable-introspection \
+	--disable-kmod \
+	--disable-blkid \
+	--disable-rule-generator \
+	--enable-hwdb \
+	--disable-selinux
+
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 2/3] package/eudev: generate hwdb.bin
  2019-10-28 22:54 [Buildroot] [PATCH 0/3] udev providers: compile the hwdb at build time (branch yem/host-eudev) Yann E. MORIN
  2019-10-28 22:54 ` [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant Yann E. MORIN
@ 2019-10-28 22:54 ` Yann E. MORIN
  2019-10-29  2:56   ` Carlos Santos
  2019-10-28 22:54 ` [Buildroot] [PATCH 3/3] package/systemd: " Yann E. MORIN
  2 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2019-10-28 22:54 UTC (permalink / raw)
  To: buildroot

For the hwdb installed by eudev to be useful, it has to be compiled
into a binary form.

This is a bit tricky:
  - the .hwdb files (the source) are installed in TARGET_DIR,
  - HOST_DIR/bin/udevadm only looks in HOST_DIR

So, we copy the .hwdb files for the target from TARGET_DIR and into
HOST_DIR, run udevadm, and copy the generated hwdb.bin back to
TARGET_DIR.

Various packages may install their .hwdb files, so we can only generate
hwdb.bin after all packages have been installed, that is as a
target-finalize hook.

Finally, the .hwdb files take as much space as the generated hwdb.bin
(in the order of 8MiB currently), so we remove them for target.

However, to still support iterative builds (e.g. make foo-reinstall), we
still want to have the .hwdb in target/. So we remove them as a
pre-rootfs hook.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Carlos Santos <unixmania@gmail.com>
---
 package/eudev/Config.in |  3 ++-
 package/eudev/eudev.mk  | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/package/eudev/Config.in b/package/eudev/Config.in
index 2220265a55..b1d2f37a72 100644
--- a/package/eudev/Config.in
+++ b/package/eudev/Config.in
@@ -29,8 +29,9 @@ config BR2_PACKAGE_EUDEV_RULES_GEN
 config BR2_PACKAGE_EUDEV_ENABLE_HWDB
 	bool "enable hwdb installation"
 	default y
+	select BR2_PACKAGE_HOST_EUDEV # for udevadm, during target-finalize
 	help
-	  Enables hardware database installation to /etc/udev/hwdb.d
+	  Enables hardware database installation to /etc/udev/hwdb.bin
 
 endif
 
diff --git a/package/eudev/eudev.mk b/package/eudev/eudev.mk
index 12568a6645..9bb96714f0 100644
--- a/package/eudev/eudev.mk
+++ b/package/eudev/eudev.mk
@@ -33,6 +33,28 @@ endif
 
 ifeq ($(BR2_PACKAGE_EUDEV_ENABLE_HWDB),y)
 EUDEV_CONF_OPTS += --enable-hwdb
+
+# "udevadm hwdb" was configured with its prefix set to HOST_DIR (it is
+# from a host package), so it can only look in there to find .hwdb files.
+# Remove existing .hwdb files (they are from the host variant or a
+# previous run), and replace them with those from target.
+define EUDEV_BUILD_HWDB
+	rm -rf $(HOST_DIR)/etc/udev/hwdb.d
+	cp -a $(TARGET_DIR)/etc/udev/hwdb.d $(HOST_DIR)/etc/udev/hwdb.d
+	$(HOST_DIR)/bin/udevadm hwdb --update
+	$(INSTALL) -D -m 0644 $(HOST_DIR)/etc/udev/hwdb.bin \
+		$(TARGET_DIR)/etc/udev/hwdb.bin
+endef
+EUDEV_TARGET_FINALIZE_HOOKS += EUDEV_BUILD_HWDB
+
+# Note: this will run in the filesystem context, so will use a copy
+# of tharget/, not the real one, so the files are still available on
+# re-builds (foo-rebuild, etc...)
+define EUDEV_RM_HWDB_SRC
+	rm -rf $(TARGET_DIR)/etc/udev/hwdb.d/
+endef
+EUDEV_ROOTFS_PRE_CMD_HOOKS += EUDEV_RM_HWDB_SRC
+
 else
 EUDEV_CONF_OPTS += --disable-hwdb
 endif
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 3/3] package/systemd: generate hwdb.bin
  2019-10-28 22:54 [Buildroot] [PATCH 0/3] udev providers: compile the hwdb at build time (branch yem/host-eudev) Yann E. MORIN
  2019-10-28 22:54 ` [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant Yann E. MORIN
  2019-10-28 22:54 ` [Buildroot] [PATCH 2/3] package/eudev: generate hwdb.bin Yann E. MORIN
@ 2019-10-28 22:54 ` Yann E. MORIN
  2019-10-29  2:57   ` Carlos Santos
  2 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2019-10-28 22:54 UTC (permalink / raw)
  To: buildroot

For the hwdb installed by systemd to be useful, it has to be compiled
into a binary form.

This is a bit tricky:
  - the .hwdb files (the source) are installed in TARGET_DIR,
  - HOST_DIR/bin/udevadm only looks in HOST_DIR

So, we copy the .hwdb files for the target from TARGET_DIR and into
HOST_DIR, run udevadm, and copy the generated hwdb.bin back to
TARGET_DIR.

Various packages may install their .hwdb files, so we can only generate
hwdb.bin after all packages have been installed, that is as a
target-finalize hook.

Finally, the .hwdb files take as much space as the generated hwdb.bin
(in the order of 8MiB currently), so we remove them for target.

However, to still support iterative builds (e.g. make foo-reinstall), we
still want to have the .hwdb in target/. So we remove them as a
pre-rootfs hook.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Carlos Santos <unixmania@gmail.com>
---
 package/systemd/Config.in  |  1 +
 package/systemd/systemd.mk | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/package/systemd/Config.in b/package/systemd/Config.in
index 601398bf96..aef39abe27 100644
--- a/package/systemd/Config.in
+++ b/package/systemd/Config.in
@@ -199,6 +199,7 @@ config BR2_PACKAGE_SYSTEMD_HOSTNAMED
 config BR2_PACKAGE_SYSTEMD_HWDB
 	bool "enable hwdb installation"
 	default y
+	select BR2_PACKAGE_HOST_EUDEV # for udevadm, during target-finalize
 	help
 	  Enables hardware database installation to /usr/lib/udev/hwdb.d
 
diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index df40961fee..4e8db8fd31 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -203,6 +203,29 @@ endif
 
 ifeq ($(BR2_PACKAGE_SYSTEMD_HWDB),y)
 SYSTEMD_CONF_OPTS += -Dhwdb=true
+
+# "udevadm hwdb" was configured with its prefix set to HOST_DIR (it is
+# from a host package), so it can only look in there to find .hwdb files.
+# Remove existing .hwdb files (they are from the host variant or a
+# previous run), and replace them with those from target.
+# Note that systemd and eudev put their files in diffeernt locations.
+define SYSTEMD_BUILD_HWDB
+	rm -rf $(HOST_DIR)/etc/udev/hwdb.d
+	cp -a $(TARGET_DIR)/usr/lib/udev/hwdb.d $(HOST_DIR)/etc/udev/hwdb.d
+	$(HOST_DIR)/bin/udevadm hwdb --update
+	$(INSTALL) -D -m 0644 $(HOST_DIR)/etc/udev/hwdb.bin \
+		$(TARGET_DIR)/usr/lib/udev/hwdb.bin
+endef
+SYSTEMD_TARGET_FINALIZE_HOOKS += SYSTEMD_BUILD_HWDB
+
+# Note: this will run in the filesystem context, so will use a copy
+# of tharget/, not the real one, so the files are still available on
+# re-builds (foo-rebuild, etc...)
+define SYSTEMD_RM_HWDB_SRC
+	rm -rf $(TARGET_DIR)/usr/lib/udev/hwdb.d/
+endef
+SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_RM_HWDB_SRC
+
 else
 SYSTEMD_CONF_OPTS += -Dhwdb=false
 endif
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant
  2019-10-28 22:54 ` [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant Yann E. MORIN
@ 2019-10-29  2:54   ` Carlos Santos
  2019-10-29  9:22     ` Peter Korsgaard
  0 siblings, 1 reply; 9+ messages in thread
From: Carlos Santos @ 2019-10-29  2:54 UTC (permalink / raw)
  To: buildroot

On Mon, Oct 28, 2019 at 7:54 PM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> eudev and systemd provide a hardware database (hwdb) as a set of
> multiple files. Various other utilities may also use that database.
>
> Those files have to be "compiled" into a binary to be useful; libudev
> (and thus all utilities based on it) only use the compiled hwdb.
>
> Compiling the hwdb is done with udevadm, using the hwdb sub-command:
>     udevadm hwdb --update
>
> Provide a simple host-variant of eudev, so that we can call udevadm at
> build time.
>
> This host udevadm will read files from $(HOST_DIR)/etc/udev/hwdb.d/*.hwdb
> and write the compiled hwdb to $(HOST_DIR)/etc/udev/hwdb.bin.
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Peter Korsgaard <peter@korsgaard.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: Carlos Santos <unixmania@gmail.com>
> ---
>  package/Config.in.host       |  1 +
>  package/eudev/Config.in.host |  3 +++
>  package/eudev/eudev.mk       | 14 ++++++++++++++
>  3 files changed, 18 insertions(+)
>  create mode 100644 package/eudev/Config.in.host
>
> diff --git a/package/Config.in.host b/package/Config.in.host
> index 914491e210..c0ac4fbbcc 100644
> --- a/package/Config.in.host
> +++ b/package/Config.in.host
> @@ -17,6 +17,7 @@ menu "Host utilities"
>         source "package/dtc/Config.in.host"
>         source "package/e2fsprogs/Config.in.host"
>         source "package/e2tools/Config.in.host"
> +       source "package/eudev/Config.in.host"
>         source "package/f2fs-tools/Config.in.host"
>         source "package/faketime/Config.in.host"
>         source "package/fatcat/Config.in.host"
> diff --git a/package/eudev/Config.in.host b/package/eudev/Config.in.host
> new file mode 100644
> index 0000000000..87dfc43912
> --- /dev/null
> +++ b/package/eudev/Config.in.host
> @@ -0,0 +1,3 @@
> +# Select this if you need host eudev tools (e.g. udevadm)
> +config BR2_PACKAGE_HOST_EUDEV
> +       bool
> diff --git a/package/eudev/eudev.mk b/package/eudev/eudev.mk
> index 2a3adb849c..12568a6645 100644
> --- a/package/eudev/eudev.mk
> +++ b/package/eudev/eudev.mk
> @@ -55,4 +55,18 @@ define EUDEV_USERS
>         - - kvm -1 * - - - kvm nodes
>  endef
>
> +HOST_EUDEV_DEPENDENCIES = host-gperf host-pkgconf
> +HOST_EUDEV_CONF_OPTS = \
> +       --disable-manpages \
> +       --sbindir=$(HOST_DIR)/sbin \
> +       --libexecdir=$(HOST_DIR)/lib \
> +       --with-rootlibdir=$(HOST_DIR)/lib \
> +       --disable-introspection \
> +       --disable-kmod \
> +       --disable-blkid \
> +       --disable-rule-generator \
> +       --enable-hwdb \
> +       --disable-selinux

This uses the default --prefix=$(HOST_DIR), which ruins the --rut
argument of udevadm and is r=teh reason why the file copies are
required in the following patches. Use this, instead:

# Use custom configuration commands because the default --prefix="$(HOST_DIR)"
# argument ruins the "udevadm hwdb --update --root <path>" command, making the
# root be $(HOST_DIR)/<path>. We also customize sysconfdir to create hwdb.bin
# at /usr/lib/udev if systemd is selected.
define HOST_EUDEV_CONFIGURE_CMDS
    (cd $(@D); rm -rf config.cache; \
    $(HOST_CONFIGURE_OPTS) \
    ./configure \
        --enable-shared --disable-static \
        --disable-manpages \
        --sysconfdir=$(if $(BR2_PACKAGE_SYSTEMD),/usr/lib,/etc) \
        --sbindir=/sbin \
        --libexecdir=/lib \
        --with-rootlibdir=/lib \
        --disable-introspection \
        --disable-kmod \
        --disable-blkid \
        --disable-rule-generator \
        --enable-hwdb \
        --disable-selinux \
    )
endef

# We just want udevadm
define HOST_EUDEV_INSTALL_CMDS
    $(INSTALL) -D -m 0755 $(@D)/src/udev/udevadm \
        $(HOST_DIR)/bin/udevadm
endef

>  $(eval $(autotools-package))
> +$(eval $(host-autotools-package))
> --
> 2.20.1
>


-- 
Carlos Santos <unixmania@gmail.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 2/3] package/eudev: generate hwdb.bin
  2019-10-28 22:54 ` [Buildroot] [PATCH 2/3] package/eudev: generate hwdb.bin Yann E. MORIN
@ 2019-10-29  2:56   ` Carlos Santos
  0 siblings, 0 replies; 9+ messages in thread
From: Carlos Santos @ 2019-10-29  2:56 UTC (permalink / raw)
  To: buildroot

On Mon, Oct 28, 2019 at 7:54 PM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> For the hwdb installed by eudev to be useful, it has to be compiled
> into a binary form.
>
> This is a bit tricky:
>   - the .hwdb files (the source) are installed in TARGET_DIR,
>   - HOST_DIR/bin/udevadm only looks in HOST_DIR
>
> So, we copy the .hwdb files for the target from TARGET_DIR and into
> HOST_DIR, run udevadm, and copy the generated hwdb.bin back to
> TARGET_DIR.
>
> Various packages may install their .hwdb files, so we can only generate
> hwdb.bin after all packages have been installed, that is as a
> target-finalize hook.
>
> Finally, the .hwdb files take as much space as the generated hwdb.bin
> (in the order of 8MiB currently), so we remove them for target.
>
> However, to still support iterative builds (e.g. make foo-reinstall), we
> still want to have the .hwdb in target/. So we remove them as a
> pre-rootfs hook.
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Peter Korsgaard <peter@korsgaard.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: Carlos Santos <unixmania@gmail.com>
> ---
>  package/eudev/Config.in |  3 ++-
>  package/eudev/eudev.mk  | 22 ++++++++++++++++++++++
>  2 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/package/eudev/Config.in b/package/eudev/Config.in
> index 2220265a55..b1d2f37a72 100644
> --- a/package/eudev/Config.in
> +++ b/package/eudev/Config.in
> @@ -29,8 +29,9 @@ config BR2_PACKAGE_EUDEV_RULES_GEN
>  config BR2_PACKAGE_EUDEV_ENABLE_HWDB
>         bool "enable hwdb installation"
>         default y
> +       select BR2_PACKAGE_HOST_EUDEV # for udevadm, during target-finalize
>         help
> -         Enables hardware database installation to /etc/udev/hwdb.d
> +         Enables hardware database installation to /etc/udev/hwdb.bin
>
>  endif
>
> diff --git a/package/eudev/eudev.mk b/package/eudev/eudev.mk
> index 12568a6645..9bb96714f0 100644
> --- a/package/eudev/eudev.mk
> +++ b/package/eudev/eudev.mk
> @@ -33,6 +33,28 @@ endif
>
>  ifeq ($(BR2_PACKAGE_EUDEV_ENABLE_HWDB),y)
>  EUDEV_CONF_OPTS += --enable-hwdb
> +
> +# "udevadm hwdb" was configured with its prefix set to HOST_DIR (it is
> +# from a host package), so it can only look in there to find .hwdb files.
> +# Remove existing .hwdb files (they are from the host variant or a
> +# previous run), and replace them with those from target.
> +define EUDEV_BUILD_HWDB
> +       rm -rf $(HOST_DIR)/etc/udev/hwdb.d
> +       cp -a $(TARGET_DIR)/etc/udev/hwdb.d $(HOST_DIR)/etc/udev/hwdb.d
> +       $(HOST_DIR)/bin/udevadm hwdb --update
> +       $(INSTALL) -D -m 0644 $(HOST_DIR)/etc/udev/hwdb.bin \
> +               $(TARGET_DIR)/etc/udev/hwdb.bin

Use

    $(HOST_DIR)/bin/udevadm hwdb --update --root $(TARGET_DIR)

> +endef
> +EUDEV_TARGET_FINALIZE_HOOKS += EUDEV_BUILD_HWDB
> +
> +# Note: this will run in the filesystem context, so will use a copy
> +# of tharget/, not the real one, so the files are still available on
> +# re-builds (foo-rebuild, etc...)
> +define EUDEV_RM_HWDB_SRC
> +       rm -rf $(TARGET_DIR)/etc/udev/hwdb.d/
> +endef
> +EUDEV_ROOTFS_PRE_CMD_HOOKS += EUDEV_RM_HWDB_SRC
> +
>  else
>  EUDEV_CONF_OPTS += --disable-hwdb
>  endif
> --
> 2.20.1
>


-- 
Carlos Santos <unixmania@gmail.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 3/3] package/systemd: generate hwdb.bin
  2019-10-28 22:54 ` [Buildroot] [PATCH 3/3] package/systemd: " Yann E. MORIN
@ 2019-10-29  2:57   ` Carlos Santos
  0 siblings, 0 replies; 9+ messages in thread
From: Carlos Santos @ 2019-10-29  2:57 UTC (permalink / raw)
  To: buildroot

On Mon, Oct 28, 2019 at 7:54 PM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> For the hwdb installed by systemd to be useful, it has to be compiled
> into a binary form.
>
> This is a bit tricky:
>   - the .hwdb files (the source) are installed in TARGET_DIR,
>   - HOST_DIR/bin/udevadm only looks in HOST_DIR
>
> So, we copy the .hwdb files for the target from TARGET_DIR and into
> HOST_DIR, run udevadm, and copy the generated hwdb.bin back to
> TARGET_DIR.
>
> Various packages may install their .hwdb files, so we can only generate
> hwdb.bin after all packages have been installed, that is as a
> target-finalize hook.
>
> Finally, the .hwdb files take as much space as the generated hwdb.bin
> (in the order of 8MiB currently), so we remove them for target.
>
> However, to still support iterative builds (e.g. make foo-reinstall), we
> still want to have the .hwdb in target/. So we remove them as a
> pre-rootfs hook.
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Peter Korsgaard <peter@korsgaard.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: Carlos Santos <unixmania@gmail.com>
> ---
>  package/systemd/Config.in  |  1 +
>  package/systemd/systemd.mk | 23 +++++++++++++++++++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index 601398bf96..aef39abe27 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -199,6 +199,7 @@ config BR2_PACKAGE_SYSTEMD_HOSTNAMED
>  config BR2_PACKAGE_SYSTEMD_HWDB
>         bool "enable hwdb installation"
>         default y
> +       select BR2_PACKAGE_HOST_EUDEV # for udevadm, during target-finalize
>         help
>           Enables hardware database installation to /usr/lib/udev/hwdb.d
>
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index df40961fee..4e8db8fd31 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -203,6 +203,29 @@ endif
>
>  ifeq ($(BR2_PACKAGE_SYSTEMD_HWDB),y)
>  SYSTEMD_CONF_OPTS += -Dhwdb=true
> +
> +# "udevadm hwdb" was configured with its prefix set to HOST_DIR (it is
> +# from a host package), so it can only look in there to find .hwdb files.
> +# Remove existing .hwdb files (they are from the host variant or a
> +# previous run), and replace them with those from target.
> +# Note that systemd and eudev put their files in diffeernt locations.
> +define SYSTEMD_BUILD_HWDB
> +       rm -rf $(HOST_DIR)/etc/udev/hwdb.d
> +       cp -a $(TARGET_DIR)/usr/lib/udev/hwdb.d $(HOST_DIR)/etc/udev/hwdb.d
> +       $(HOST_DIR)/bin/udevadm hwdb --update
> +       $(INSTALL) -D -m 0644 $(HOST_DIR)/etc/udev/hwdb.bin \
> +               $(TARGET_DIR)/usr/lib/udev/hwdb.bin

Use

        $(HOST_DIR)/bin/udevadm hwdb --update --root $(TARGET_DIR)

> +endef
> +SYSTEMD_TARGET_FINALIZE_HOOKS += SYSTEMD_BUILD_HWDB
> +
> +# Note: this will run in the filesystem context, so will use a copy
> +# of tharget/, not the real one, so the files are still available on
> +# re-builds (foo-rebuild, etc...)
> +define SYSTEMD_RM_HWDB_SRC
> +       rm -rf $(TARGET_DIR)/usr/lib/udev/hwdb.d/
> +endef
> +SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_RM_HWDB_SRC
> +
>  else
>  SYSTEMD_CONF_OPTS += -Dhwdb=false
>  endif
> --
> 2.20.1
>


-- 
Carlos Santos <unixmania@gmail.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant
  2019-10-29  2:54   ` Carlos Santos
@ 2019-10-29  9:22     ` Peter Korsgaard
  2019-10-29 22:23       ` Carlos Santos
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Korsgaard @ 2019-10-29  9:22 UTC (permalink / raw)
  To: buildroot

>>>>> "Carlos" == Carlos Santos <unixmania@gmail.com> writes:

Hi,

 >> +HOST_EUDEV_DEPENDENCIES = host-gperf host-pkgconf
 >> +HOST_EUDEV_CONF_OPTS = \
 >> +       --disable-manpages \
 >> +       --sbindir=$(HOST_DIR)/sbin \
 >> +       --libexecdir=$(HOST_DIR)/lib \
 >> +       --with-rootlibdir=$(HOST_DIR)/lib \
 >> +       --disable-introspection \
 >> +       --disable-kmod \
 >> +       --disable-blkid \
 >> +       --disable-rule-generator \
 >> +       --enable-hwdb \
 >> +       --disable-selinux

 > This uses the default --prefix=$(HOST_DIR), which ruins the --rut
 > argument of udevadm and is r=teh reason why the file copies are
 > required in the following patches. Use this, instead:

 > # Use custom configuration commands because the default --prefix="$(HOST_DIR)"
 > # argument ruins the "udevadm hwdb --update --root <path>" command, making the
 > # root be $(HOST_DIR)/<path>. We also customize sysconfdir to create hwdb.bin
 > # at /usr/lib/udev if systemd is selected.
 > define HOST_EUDEV_CONFIGURE_CMDS
 >     (cd $(@D); rm -rf config.cache; \
 >     $(HOST_CONFIGURE_OPTS) \
 >     ./configure \
 >         --enable-shared --disable-static \
 >         --disable-manpages \
 >         --sysconfdir=$(if $(BR2_PACKAGE_SYSTEMD),/usr/lib,/etc) \
 >         --sbindir=/sbin \
 >         --libexecdir=/lib \
 >         --with-rootlibdir=/lib \
 >         --disable-introspection \
 >         --disable-kmod \
 >         --disable-blkid \
 >         --disable-rule-generator \
 >         --enable-hwdb \
 >         --disable-selinux \
 >     )
 > endef

 > # We just want udevadm
 > define HOST_EUDEV_INSTALL_CMDS
 >     $(INSTALL) -D -m 0755 $(@D)/src/udev/udevadm \
 >         $(HOST_DIR)/bin/udevadm
 > endef

As long as this is the only reason for having host-eudev, this is indeed
simpler and means that we can have a single TARGET_FINALIZE hook.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant
  2019-10-29  9:22     ` Peter Korsgaard
@ 2019-10-29 22:23       ` Carlos Santos
  0 siblings, 0 replies; 9+ messages in thread
From: Carlos Santos @ 2019-10-29 22:23 UTC (permalink / raw)
  To: buildroot

On Tue, Oct 29, 2019 at 6:22 AM Peter Korsgaard <peter@korsgaard.com> wrote:
>
> >>>>> "Carlos" == Carlos Santos <unixmania@gmail.com> writes:
>
> Hi,
>
>  >> +HOST_EUDEV_DEPENDENCIES = host-gperf host-pkgconf
>  >> +HOST_EUDEV_CONF_OPTS = \
>  >> +       --disable-manpages \
>  >> +       --sbindir=$(HOST_DIR)/sbin \
>  >> +       --libexecdir=$(HOST_DIR)/lib \
>  >> +       --with-rootlibdir=$(HOST_DIR)/lib \
>  >> +       --disable-introspection \
>  >> +       --disable-kmod \
>  >> +       --disable-blkid \
>  >> +       --disable-rule-generator \
>  >> +       --enable-hwdb \
>  >> +       --disable-selinux
>
>  > This uses the default --prefix=$(HOST_DIR), which ruins the --rut
>  > argument of udevadm and is r=teh reason why the file copies are
>  > required in the following patches. Use this, instead:
>
>  > # Use custom configuration commands because the default --prefix="$(HOST_DIR)"
>  > # argument ruins the "udevadm hwdb --update --root <path>" command, making the
>  > # root be $(HOST_DIR)/<path>. We also customize sysconfdir to create hwdb.bin
>  > # at /usr/lib/udev if systemd is selected.
>  > define HOST_EUDEV_CONFIGURE_CMDS
>  >     (cd $(@D); rm -rf config.cache; \
>  >     $(HOST_CONFIGURE_OPTS) \
>  >     ./configure \
>  >         --enable-shared --disable-static \
>  >         --disable-manpages \
>  >         --sysconfdir=$(if $(BR2_PACKAGE_SYSTEMD),/usr/lib,/etc) \
>  >         --sbindir=/sbin \
>  >         --libexecdir=/lib \
>  >         --with-rootlibdir=/lib \
>  >         --disable-introspection \
>  >         --disable-kmod \
>  >         --disable-blkid \
>  >         --disable-rule-generator \
>  >         --enable-hwdb \
>  >         --disable-selinux \
>  >     )
>  > endef
>
>  > # We just want udevadm
>  > define HOST_EUDEV_INSTALL_CMDS
>  >     $(INSTALL) -D -m 0755 $(@D)/src/udev/udevadm \
>  >         $(HOST_DIR)/bin/udevadm
>  > endef
>
> As long as this is the only reason for having host-eudev, this is indeed
> simpler and means that we can have a single TARGET_FINALIZE hook.
>
> --
> Bye, Peter Korsgaard

I just noticed that eudev by default looks for .hwdb files in
/usr/lib/udev/hwdb.d/ and /etc/udev/hwdb.d/ an that systemd looks for
hwdb.bin at /etc/udev/ too.

So we could simplify the the patches by omitting the --sysconfdir
argument and removing both hwdb.d directories in the rootfs-pre-cmd
hooks.

We could also make the removal optional (default yes) for the cases in
which the user wants to rebuild the database at run-time (e.g. after
adding .hwdb files). I'm not a fan of feature provisioning but  it
would be much harder to do this otherwise.

Finally, the hooks could be moved to a single location instead of
repeated in package/eudev.mk and package/systemd.mk. package/udev.mk
would be the ideal location but virtual packages can't have hooks.

Anyway, these are just optional improvements that can be made later.

-- 
Carlos Santos <unixmania@gmail.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-10-29 22:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28 22:54 [Buildroot] [PATCH 0/3] udev providers: compile the hwdb at build time (branch yem/host-eudev) Yann E. MORIN
2019-10-28 22:54 ` [Buildroot] [PATCH 1/3] package/eudev: introduce a host variant Yann E. MORIN
2019-10-29  2:54   ` Carlos Santos
2019-10-29  9:22     ` Peter Korsgaard
2019-10-29 22:23       ` Carlos Santos
2019-10-28 22:54 ` [Buildroot] [PATCH 2/3] package/eudev: generate hwdb.bin Yann E. MORIN
2019-10-29  2:56   ` Carlos Santos
2019-10-28 22:54 ` [Buildroot] [PATCH 3/3] package/systemd: " Yann E. MORIN
2019-10-29  2:57   ` Carlos Santos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.