chiark / gitweb /
hwdb: use $(localstatedir)/lib/udev/hwdb.bin for the binary database
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 Nov 2012 22:10:13 +0000 (23:10 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 Nov 2012 22:29:56 +0000 (23:29 +0100)
It's not configuration, so it doesn't belong in udev.

Also, remove the catalog when uninstalling udev.

Makefile.am
man/udevadm.xml
src/libudev/libudev-hwdb.c
src/udev/udevadm-hwdb.c

index f3bda0176b73e6690f7cccae1dfcf77b57dcc142..1f30ba8cb86b5ae34280a9f28ef089c7c6551de6 100644 (file)
@@ -65,6 +65,8 @@ sysvinitdir=$(SYSTEM_SYSVINIT_PATH)
 varlogdir=$(localstatedir)/log
 systemdstatedir=$(localstatedir)/lib/systemd
 catalogstatedir=$(systemdstatedir)/catalog
+udevstatedir=$(localstatedir)/lib/udev
+hwdb_bin=$(udevstatedir)/hwdb.bin
 
 # Our own, non-special dirs
 pkgsysconfdir=$(sysconfdir)/systemd
@@ -130,6 +132,7 @@ AM_CPPFLAGS = \
        -DUSER_CONFIG_UNIT_PATH=\"$(pkgsysconfdir)/user\" \
        -DUSER_DATA_UNIT_PATH=\"$(userunitdir)\" \
        -DCATALOG_PATH=\"$(catalogstatedir)\" \
+       -DHWDB_BIN=\"$(hwdb_bin)\" \
        -DSYSTEMD_CGROUP_AGENT_PATH=\"$(rootlibexecdir)/systemd-cgroups-agent\" \
        -DSYSTEMD_BINARY_PATH=\"$(rootlibexecdir)/systemd\" \
        -DSYSTEMD_SHUTDOWN_BINARY_PATH=\"$(rootlibexecdir)/systemd-shutdown\" \
@@ -1962,11 +1965,14 @@ udevadm_LDADD = \
 # Update hwdb on installation. Do not bother if installing
 # in DESTDIR, since this is likely for packaging purposes.
 hwdb-update-hook:
-       -test -n "$(DESTDIR)" || udevadm hwdb --update
+       -test -n "$(DESTDIR)" || $(bindir)/udevadm hwdb --update
 
 INSTALL_DATA_HOOKS += \
        hwdb-update-hook
 
+hwdb-remove-hook:
+       -test -n "$(DESTDIR)" || rm -f $(HWDB_BIN)
+
 # ------------------------------------------------------------------------------
 TESTS += \
        test/udev-test.pl \
index 015980a63b67b6315df234d33981645b79d2753c..43d2f5bcf609b90b799d34cc0e2590fdedbc186b 100644 (file)
     </refsect2>
 
     <refsect2><title>udevadm hwdb <optional>options</optional></title>
-      <para>Maintain the hardware database index in /etc/udev/hwdb.bin.</para>
+      <para>Maintain the hardware database index in <filename>$(localstatedir)/lib/udev/hwdb.bin</filename>.</para>
       <variablelist>
         <varlistentry>
           <term><option>--update</option></term>
           <listitem>
             <para>Compile the hardware dabase information located in /usr/lib/udev/hwdb.d/,
-            /etc/udev/hwdb.d/ and store it in /etc/udev/hwdb.bin. This should be done with
+            /etc/udev/hwdb.d/ and store it in <filename>$(localstatedir)/lib/udev/hwdb.bin</filename>. This should be done with
             any update to the source files, it will not be called automatically. The running
             udev daemon will detect a new database on its own and does not need to be
             notified about it.</para>
index 6779e45b4e5302e675c29b711be17b7fbb33769c..12c8214ec50ebebdc2274149a27c7de2472a4633 100644 (file)
@@ -271,30 +271,30 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
         hwdb->refcount = 1;
         udev_list_init(udev, &hwdb->properties_list, true);
 
-        hwdb->f = fopen("/etc/udev/hwdb.bin", "re");
+        hwdb->f = fopen(HWDB_BIN, "re");
         if (!hwdb->f) {
-                log_debug("error reading /etc/udev/hwdb.bin: %m");
+                log_debug("error reading %s: %m", HWDB_BIN);
                 udev_hwdb_unref(hwdb);
                 return NULL;
         }
 
         if (fstat(fileno(hwdb->f), &hwdb->st) < 0 ||
             (size_t)hwdb->st.st_size < offsetof(struct trie_header_f, strings_len) + 8) {
-                log_debug("error reading /etc/udev/hwdb.bin: %m");
+                log_debug("error reading %s: %m", HWDB_BIN);
                 udev_hwdb_unref(hwdb);
                 return NULL;
         }
 
         hwdb->map = mmap(0, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
         if (hwdb->map == MAP_FAILED) {
-                log_debug("error mapping /etc/udev/hwdb.bin: %m");
+                log_debug("error mapping %s: %m", HWDB_BIN);
                 udev_hwdb_unref(hwdb);
                 return NULL;
         }
 
         if (memcmp(hwdb->map, sig, sizeof(hwdb->head->signature)) != 0 ||
             (size_t)hwdb->st.st_size != le64toh(hwdb->head->file_size)) {
-                log_debug("error recognizing the format of /etc/udev/hwdb.bin");
+                log_debug("error recognizing the format of %s", HWDB_BIN);
                 udev_hwdb_unref(hwdb);
                 return NULL;
         }
index 02d8d01f8af2125c3d65ac3754a480a099ad86cd..fd288db1cb73d68cf162743b46c0ca807225e0b1 100644 (file)
@@ -565,10 +565,11 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
                 log_debug("strings dedup'ed: %8zu bytes (%8zu)\n",
                           trie->strings->dedup_len, trie->strings->dedup_count);
 
-                mkdir_parents("/etc/udev/hwdb.bin", 0755);
-                err = trie_store(trie, "/etc/udev/hwdb.bin");
+                mkdir_parents(HWDB_BIN, 0755);
+                err = trie_store(trie, HWDB_BIN);
                 if (err < 0) {
-                        log_error("Failure writing hardware database '%s': %s", "/etc/udev/hwdb.bin", strerror(-err));
+                        log_error("Failure writing hardware database '%s': %s",
+                                  HWDB_BIN, strerror(-err));
                         rc = EXIT_FAILURE;
                 }
         }