Re: [systemd-devel] [PATCH v2] udev hwdb: Support shipping pre-compiled database in system images

2014-10-20 Thread Lennart Poettering
On Fri, 17.10.14 15:44, Martin Pitt (martin.p...@ubuntu.com) wrote:

 Hello again,
 
 the previous patch had a typo in the manpage (it said /lib/udev
 instead of /usr/lib/udev at one place), and also forgot to adjust
 systemd-udev-hwdb-update.service.in. Both done now.
 
 However, the latter currently has a gotcha:
 
   +ConditionPathExists=!@udevlibexecdir@/hwdb.bin
 
 This works correctly if you use this with the factory reset
 semantics, i. e. start with an empty /etc. But it would not work if
 you update /usr and have an already existing /etc/udev/hwdb.d/*. So
 ideally the condition would be
 
   ConditionPathExists=!@udevlibexecdir@/hwdb.bin OR
   ConditionDirectoryNotEmpty=/etc/udev/hwdb.d/
 
 but this isn't possible AFAIK. The alternative would be to change the
 Exec= to call hdwb --update --vendor iff /etc/udev/hwdb.d/ is
 empty.

Wouldn't the triggering syntax Condition...=| work for this?

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v2] udev hwdb: Support shipping pre-compiled database in system images

2014-10-20 Thread Lennart Poettering
On Sun, 19.10.14 14:13, Ivan Shapovalov (intelfx...@gmail.com) wrote:
 Ugh, I haven't seen your second message. There's something strange with
 mail delivery -- I could swear that I've fetched everything before replying...
 
 Sorry for the noise.

There's something really broken on fdo mail deliver currently. It
appears it drops quite a few messages without any warning or report
back. I am not entirely sure who to ping abou this though...

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v2] udev hwdb: Support shipping pre-compiled database in system images

2014-10-19 Thread Ivan Shapovalov
On Sunday 19 October 2014 at 05:42:28, Ivan Shapovalov wrote:   
 On Friday 17 October 2014 at 15:44:51, Martin Pitt wrote: 
  Hello again,
  
  the previous patch had a typo in the manpage (it said /lib/udev
  instead of /usr/lib/udev at one place), and also forgot to adjust
  systemd-udev-hwdb-update.service.in. Both done now.
  
  However, the latter currently has a gotcha:
  
+ConditionPathExists=!@udevlibexecdir@/hwdb.bin
  
  This works correctly if you use this with the factory reset
  semantics, i. e. start with an empty /etc. But it would not work if
  you update /usr and have an already existing /etc/udev/hwdb.d/*. So
  ideally the condition would be
  
ConditionPathExists=!@udevlibexecdir@/hwdb.bin OR
ConditionDirectoryNotEmpty=/etc/udev/hwdb.d/
 
  
  but this isn't possible AFAIK. The alternative would be to change the
  Exec= to call hdwb --update --vendor iff /etc/udev/hwdb.d/ is empty.
 
 I'm just an innocent bystander, but isn't it possible with these two
 lines?
 
 ConditionPathExists=|!@udevlibexecdir@/hwdb.bin
 ConditionDirectoryNotEmpty=|/etc/udev/hwdb.d/
 
 This will succeed if EITHER @udevlibexecdir@/hwdb.bin does not exist
 OR /etc/udev/hwdb.d/ is not empty.
 
 Or have I misunderstood you?

Ugh, I haven't seen your second message. There's something strange with
mail delivery -- I could swear that I've fetched everything before replying...

Sorry for the noise.
-- 
Ivan Shapovalov / intelfx /

signature.asc
Description: This is a digitally signed message part.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v2] udev hwdb: Support shipping pre-compiled database in system images

2014-10-19 Thread Martin Pitt
Hello Ivan,

Ivan Shapovalov [2014-10-19  5:42 +0400]:
  but this isn't possible AFAIK. The alternative would be to change the
  Exec= to call hdwb --update --vendor iff /etc/udev/hwdb.d/ is empty.
 
 I'm just an innocent bystander, but isn't it possible with these two
 lines?
 
 ConditionPathExists=|!@udevlibexecdir@/hwdb.bin
 ConditionDirectoryNotEmpty=|/etc/udev/hwdb.d/
 
 This will succeed if EITHER @udevlibexecdir@/hwdb.bin does not exist
 OR /etc/udev/hwdb.d/ is not empty.

Correct. That's indeed what got pointed out to me on IRC on Friday,
and I sent another followup to the list. For some unknown reason that
didn't actually hit the list though, so I bounced my reply again this
morning.

Thanks,

Martin
-- 
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)


signature.asc
Description: Digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v2] udev hwdb: Support shipping pre-compiled database in system images

2014-10-18 Thread Ivan Shapovalov
On Friday 17 October 2014 at 15:44:51, Martin Pitt wrote:   
 Hello again,
 
 the previous patch had a typo in the manpage (it said /lib/udev
 instead of /usr/lib/udev at one place), and also forgot to adjust
 systemd-udev-hwdb-update.service.in. Both done now.
 
 However, the latter currently has a gotcha:
 
   +ConditionPathExists=!@udevlibexecdir@/hwdb.bin
 
 This works correctly if you use this with the factory reset
 semantics, i. e. start with an empty /etc. But it would not work if
 you update /usr and have an already existing /etc/udev/hwdb.d/*. So
 ideally the condition would be
 
   ConditionPathExists=!@udevlibexecdir@/hwdb.bin OR
   ConditionDirectoryNotEmpty=/etc/udev/hwdb.d/

 
 but this isn't possible AFAIK. The alternative would be to change the
 Exec= to call hdwb --update --vendor iff /etc/udev/hwdb.d/ is empty.

I'm just an innocent bystander, but isn't it possible with these two
lines?

ConditionPathExists=|!@udevlibexecdir@/hwdb.bin
ConditionDirectoryNotEmpty=|/etc/udev/hwdb.d/

This will succeed if EITHER @udevlibexecdir@/hwdb.bin does not exist
OR /etc/udev/hwdb.d/ is not empty.

Or have I misunderstood you?

-- 
Ivan Shapovalov / intelfx /

signature.asc
Description: This is a digitally signed message part.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v2] udev hwdb: Support shipping pre-compiled database in system images

2014-10-18 Thread Martin Pitt
Martin Pitt [2014-10-17 15:44 +0200]:
 So ideally the condition would be
 
   ConditionPathExists=!@udevlibexecdir@/hwdb.bin OR
   ConditionDirectoryNotEmpty=/etc/udev/hwdb.d/
 
 but this isn't possible AFAIK.

Hah, I stand corrected. So this could be

  ConditionPathExists=|!@udevlibexecdir@/hwdb.bin
  ConditionPathExists=|/etc/udev/hwdb.bin
  ConditionDirectoryNotEmpty=|/etc/udev/hwdb.d/

for catching all the edge cases, if we want to go ahead with the
explicit --vendor option instead of putting this logic into hwdb
--update itself. (I'd otherwise just replicate the logic again in the
Debian/Ubuntu package trigger).

Thanks,

Martin
-- 
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)


signature.asc
Description: Digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH v2] udev hwdb: Support shipping pre-compiled database in system images

2014-10-17 Thread Martin Pitt
Hello again,

the previous patch had a typo in the manpage (it said /lib/udev
instead of /usr/lib/udev at one place), and also forgot to adjust
systemd-udev-hwdb-update.service.in. Both done now.

However, the latter currently has a gotcha:

  +ConditionPathExists=!@udevlibexecdir@/hwdb.bin

This works correctly if you use this with the factory reset
semantics, i. e. start with an empty /etc. But it would not work if
you update /usr and have an already existing /etc/udev/hwdb.d/*. So
ideally the condition would be

  ConditionPathExists=!@udevlibexecdir@/hwdb.bin OR
  ConditionDirectoryNotEmpty=/etc/udev/hwdb.d/

but this isn't possible AFAIK. The alternative would be to change the
Exec= to call hdwb --update --vendor iff /etc/udev/hwdb.d/ is empty.

An alternative that was discussed at Plumbers was to make hwdb
--update automatically use @udevlibexecdir@ if there is no
/etc/udev/hwdb.d/, which would avoid this problem, avoid introducing a
new option, and still generally DTRT. I'd prefer this, so if you think
that's easier/better, I'm happy to update the patch accordingly.

Thanks,

Martin
-- 
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
From 5c093f2552d7ebbafe079eafe9b0a9bada7615ad Mon Sep 17 00:00:00 2001
From: Martin Pitt martin.p...@ubuntu.com
Date: Fri, 17 Oct 2014 15:01:01 +0200
Subject: [PATCH] udev hwdb: Support shipping pre-compiled database in system
 images

In some cases it is preferable to ship system images with a pre-generated
binary hwdb database, to avoid having to build it at runtime, avoid shipping
the source hwdb files, or avoid storing large binary files in /etc.

So if hwdb.bin does not exist in /etc/udev/, fall back to looking for it in
UDEVLIBEXECDIR. This keeps the possibility to add files to /etc/udev/hwdb.d/
and re-generating the database which trumps the one in /usr/lib.

Add a new --vendor flag to udevadm hwdb --update which puts the database
into UDEVLIBEXECDIR.

Adjust systemd-udev-hwdb-update.service to not generate the file in /etc if we
already have it in /usr.
---
 man/udev.xml  |  4 +++-
 man/udevadm.xml   |  9 +
 src/libudev/libudev-hwdb.c| 20 ++--
 src/udev/udevadm-hwdb.c   | 10 --
 units/systemd-udev-hwdb-update.service.in |  1 +
 5 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/man/udev.xml b/man/udev.xml
index d77cbb0..87c16c7 100644
--- a/man/udev.xml
+++ b/man/udev.xml
@@ -766,7 +766,9 @@
 
   paraThe content of all hwdb files is read by
   citerefentryrefentrytitleudevadm/refentrytitlemanvolnum8/manvolnum/citerefentry
-  and compiled to a binary database located at filename/etc/udev/hwdb.bin/filename.
+  and compiled to a binary database located at filename/etc/udev/hwdb.bin/filename,
+  or alternatively filename/usr/lib/udev/hwdb.bin/filename if you want ship the compiled
+  database in an immutable image.
   During runtime only the binary database is used./para
   /refsect1
 
diff --git a/man/udevadm.xml b/man/udevadm.xml
index 749144d..571ef7d 100644
--- a/man/udevadm.xml
+++ b/man/udevadm.xml
@@ -494,6 +494,15 @@
   /listitem
 /varlistentry
 varlistentry
+  termoption--vendor/option/term
+  listitem
+paraPut the compiled database into filename/usr/lib/udev/hwdb.bin/filename instead.
+Use this if you want to ship a pre-compiled database in immutable system images, or
+don't use filename/etc/udev/hwdb.d/filename and want to avoid large binary files in
+filename/etc/filename./para
+  /listitem
+/varlistentry
+varlistentry
   termoption-t/option/term
   termoption--test=replaceablestring/replaceable/option/term
   listitem
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c
index 8fb7240..91c05e8 100644
--- a/src/libudev/libudev-hwdb.c
+++ b/src/libudev/libudev-hwdb.c
@@ -256,6 +256,13 @@ static int trie_search_f(struct udev_hwdb *hwdb, const char *search) {
 return 0;
 }
 
+static const char *get_hwdb_bin_path(void) {
+if (access(/etc/udev/hwdb.bin, F_OK) = 0)
+return /etc/udev/hwdb.bin;
+else
+return UDEVLIBEXECDIR /hwdb.bin;
+}
+
 /**
  * udev_hwdb_new:
  * @udev: udev library context
@@ -267,6 +274,7 @@ static int trie_search_f(struct udev_hwdb *hwdb, const char *search) {
 _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
 struct udev_hwdb *hwdb;
 const char sig[] = HWDB_SIG;
+const char *hwdb_bin_path = get_hwdb_bin_path();
 
 hwdb = new0(struct udev_hwdb, 1);
 if (!hwdb)
@@ -275,30 +283,30 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
 hwdb-refcount = 1;
 udev_list_init(udev, hwdb-properties_list, true);
 
-hwdb-f =