Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.gentoo.dev > #70478

[gentoo-dev] [PATCH 3/3] metadata/install-qa-check.d: add udev hwdb check

From Lukas Schmelting <lschmelting@posteo.com>
Newsgroups linux.gentoo.dev
Subject [gentoo-dev] [PATCH 3/3] metadata/install-qa-check.d: add udev hwdb check
Date 2026-04-29 20:00 +0200
Message-ID <MPhmx-1kDL-1@gated-at.bofh.it> (permalink)
References <MOVvI-166w-11@gated-at.bofh.it> <MPhmx-1kDL-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Extend existing logic to cover udev hardware database files, similarly
to udev rule handling.

Signed-off-by: Lukas Schmelting <lschmelting@posteo.com>
---
 metadata/install-qa-check.d/60udev-eclass | 36 +++++++++++++++++++++--
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/metadata/install-qa-check.d/60udev-eclass b/metadata/install-qa-check.d/60udev-eclass
index 42e4bde22505..0611b2af9a37 100644
--- a/metadata/install-qa-check.d/60udev-eclass
+++ b/metadata/install-qa-check.d/60udev-eclass
@@ -7,12 +7,15 @@
 # Implements the following checks:
 # 1) Installation to user-customization locations
 #    1a) /etc/udev/rules.d (udev rules files)
+#    1b) /etc/udev/hwdb.d  (udev hardware database files)
 # 2) Installation of udev files without inheriting udev.eclass, which provides
 #    helper functions used in pkg_postinst and pkg_postrm to update udev state.
 #    2a) /lib/udev/rules.d (udev rules files)
+#    2b) /lib/udev/hwdb.d  (udev hardware database files)
 # 3) Installation of udev files without triggering udev state updates in
 #    pkg_postinst and pkg_postrm via eclass helper functions.
 #    3a) udev_reload
+#    3b) udev_hwdb_update
 
 
 # Check whether a directory contains any non-hidden files (i.e avoid triggering
@@ -34,6 +37,12 @@ udev_rules_check() {
 		eqawarn "udev rules files supplied by ebuilds must be installed to /lib/udev/rules.d/"
 	fi
 
+	# Check 1b: Scan image for files in /etc/udev/hwdb.d which is a forbidden location
+	if _dir_has_nonhidden_files "etc/udev/hwdb.d"; then
+		eqawarn "QA Notice: files installed to /etc/udev/hwdb.d found"
+		eqawarn "hwdb files supplied by ebuilds must be installed to /usr/lib/udev/hwdb.d/"
+	fi
+
 	# Check 2
     # Detect whether udev.eclass must be inherited which provides helper
     # functions for updating udev state
@@ -47,6 +56,7 @@ udev_rules_check() {
 	fi
 
     local need_udev_reload=0
+    local need_udev_hwdb_update=0
 
     # Check 2a: Check if udev rules must be updated
     if _dir_has_nonhidden_files "lib/udev/rules.d" \
@@ -54,16 +64,24 @@ udev_rules_check() {
         need_udev_reload=1
     fi
 
+    # Check 2b: Check if udev binary hardware database must be updated
+    if _dir_has_nonhidden_files "lib/udev/hwdb.d" \
+       || _dir_has_nonhidden_files "usr/lib/udev/hwdb.d"; then
+	    need_udev_hwdb_update=1
+    fi
+
     # No relevant files -> nothing to enforce
     if [[ ${need_udev_reload} -eq 0 ]]; then
 	    return
     fi
 
-    # If any udev rules or hwdb files are present, the eclass must be inherited
-    if [[ ${need_udev_reload} -eq 1 ]] && ! has udev ${INHERITED}; then
+    # If any udev feature is used, eclass must be inherited
+    if [[ ${need_udev_reload} -eq 1 || ${need_udev_hwdb_update} -eq 1 ]] \
+       && ! has udev ${INHERITED}; then
 	    eqawarn "QA Notice: package is installing udev-related files without inheriting"
         eqawarn "udev.eclass! Packages must inherit udev.eclass then call the respective"
-        eqawarn "eclass function (udev_reload) in pkg_postinst and pkg_postrm."
+        eqawarn "eclass function (udev_reload and udev_hwdb_update) in pkg_postinst and"
+        eqawarn "pkg_postrm."
 	    return
     fi
 
@@ -87,6 +105,18 @@ udev_rules_check() {
 		    eqawarn "udev_reload in pkg_postrm phase"
 	    fi
     fi
+
+    if [[ ${need_udev_hwdb_update} -eq 1 ]]; then
+	    if [[ ! ${pkg_postinst_body} == *udev_hwdb_update* ]]; then
+		    eqawarn "QA Notice: package is installing hwdb files without calling"
+		    eqawarn "udev_hwdb_update in pkg_postinst phase"
+	    fi
+
+	    if [[ ! ${pkg_postrm_body} == *udev_hwdb_update* ]]; then
+		    eqawarn "QA Notice: package is installing hwdb files without calling"
+		    eqawarn "udev_hwdb_update in pkg_postrm phase"
+	    fi
+    fi
 }
 
 udev_rules_check
-- 
2.53.0

Back to linux.gentoo.dev | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

[gentoo-dev] [PATCH 0/3] refactor and extend udev handling Lukas Schmelting <lschmelting@posteo.com> - 2026-04-28 20:20 +0200
  [gentoo-dev] [PATCH 2/3] udev.eclass: add udev_hwdb_reload function Lukas Schmelting <lschmelting@posteo.com> - 2026-04-28 20:30 +0200
    [gentoo-dev] Re: [PATCH 2/3] udev.eclass: add udev_hwdb_reload function Mike Gilbert <floppym@gentoo.org> - 2026-04-28 20:40 +0200
      [gentoo-dev] [PATCH v2 0/2] range-diff v1/v2 Lukas Schmelting <lschmelting@posteo.com> - 2026-04-29 00:10 +0200
        [gentoo-dev] [PATCH v2 3/3] metadata/install-qa-check.d: add udev hwdb check Lukas Schmelting <lschmelting@posteo.com> - 2026-04-29 00:20 +0200
        [gentoo-dev] [PATCH v2 2/3] udev.eclass: add udev_hwdb_update function Lukas Schmelting <lschmelting@posteo.com> - 2026-04-29 00:20 +0200
      [gentoo-dev] [PATCH 3/3] metadata/install-qa-check.d: add udev hwdb check Lukas Schmelting <lschmelting@posteo.com> - 2026-04-29 20:00 +0200
      [gentoo-dev] [PATCH 0/3] "bash -n" fixes and nits Lukas Schmelting <lschmelting@posteo.com> - 2026-04-29 20:00 +0200
        [gentoo-dev] [PATCH 1/3] metadata/install-qa-check.d: refactor 60udev-eclass Lukas Schmelting <lschmelting@posteo.com> - 2026-04-29 20:00 +0200
        [gentoo-dev] [PATCH 2/3] udev.eclass: add udev_hwdb_update function Lukas Schmelting <lschmelting@posteo.com> - 2026-04-29 20:00 +0200
          [gentoo-dev] Re: [PATCH 2/3] udev.eclass: add udev_hwdb_update function Mike Gilbert <floppym@gentoo.org> - 2026-04-29 20:40 +0200
            [gentoo-dev] Re: [PATCH 2/3] udev.eclass: add udev_hwdb_update function Lukas Schmelting <lschmelting@posteo.com> - 2026-04-29 21:40 +0200
  [gentoo-dev] [PATCH 1/3] metadata/install-qa-check.d: refactor 60udev-eclass Lukas Schmelting <lschmelting@posteo.com> - 2026-04-28 20:30 +0200
  [gentoo-dev] [PATCH 3/3] metadata/install-qa-check.d: add udev hwdb check Lukas Schmelting <lschmelting@posteo.com> - 2026-04-28 20:30 +0200

csiph-web