Skip to content

Commit

Permalink
setup.py: use pkg-config for udev/rules path (#2137)
Browse files Browse the repository at this point in the history
Distributions other than RHEL also use /usr/lib/udev for the rules
path. Instead of hardcoding the udev rules path for RedHat, check
pkg-config for the proper location.
  • Loading branch information
dankm committed Apr 28, 2023
1 parent 7ffd0bc commit 5abf5f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def pkg_config_read(library, var):
"systemdsystemconfdir": "/etc/systemd/system",
"systemdsystemunitdir": "/lib/systemd/system",
"systemdsystemgeneratordir": "/lib/systemd/system-generators",
}
},
"udev": {
"udevdir": "/lib/udev",
},
}
cmd = ["pkg-config", "--variable=%s" % var, library]
try:
Expand Down Expand Up @@ -307,14 +310,13 @@ def finalize_options(self):
),
]
if not platform.system().endswith("BSD"):

RULES_PATH = LIB
if os.path.isfile("/etc/redhat-release"):
RULES_PATH = "/usr/lib"
RULES_PATH = pkg_config_read("udev", "udevdir")
if not in_virtualenv():
RULES_PATH = "/" + RULES_PATH

data_files.extend(
[
(RULES_PATH + "/udev/rules.d", [f for f in glob("udev/*.rules")]),
(RULES_PATH + "/rules.d", [f for f in glob("udev/*.rules")]),
(
ETC + "/systemd/system/sshd-keygen@.service.d/",
["systemd/disable-sshd-keygen-if-cloud-init-active.conf"],
Expand Down
1 change: 1 addition & 0 deletions tools/.github-cla-signers
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ cjp256
Conan-Kudo
cvstealth
dankenigsberg
dankm
david-caro
dbungert
ddymko
Expand Down

0 comments on commit 5abf5f5

Please sign in to comment.