Skip to content

Commit

Permalink
umockev: hardcode udevadm
Browse files Browse the repository at this point in the history
Replace references to udevadm with an absolute paths, so programs using
umockdev will just work without having to provide it in their test
environment $PATH.

This allows us removing systemdMinimal from nativeCheckInputs ourselves.
It's still needed in buildInputs, as the build queries for it via
pkg-config.
  • Loading branch information
flokli committed Jan 24, 2024
1 parent 5876256 commit ded8c86
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkgs/development/libraries/umockdev/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
, ninja
, pkg-config
, python3
, substituteAll
, systemdMinimal
, usbutils
, vala
Expand All @@ -33,6 +34,14 @@ stdenv.mkDerivation (finalAttrs: {
# Hardcode absolute paths to libraries so that consumers
# do not need to set LD_LIBRARY_PATH themselves.
./hardcode-paths.patch

# Replace references to udevadm with an absolute paths, so programs using
# umockdev will just work without having to provide it in their test environment
# $PATH.
(substituteAll {
src = ./substitute-udevadm.patch;
udevadm = "${systemdMinimal}/bin/udevadm";
})
];

nativeBuildInputs = [
Expand All @@ -59,7 +68,6 @@ stdenv.mkDerivation (finalAttrs: {

nativeCheckInputs = [
python3
systemdMinimal
usbutils
which
];
Expand Down
41 changes: 41 additions & 0 deletions pkgs/development/libraries/umockdev/substitute-udevadm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 09efbe8090f501c60975d5467fb587ed633d6a01 Mon Sep 17 00:00:00 2001
From: Florian Klink <[email protected]>
Date: Wed, 24 Jan 2024 14:29:28 +0200
Subject: [PATCH] substitute udevadm

---
src/umockdev-record.vala | 2 +-
tests/test-umockdev-run.vala | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/umockdev-record.vala b/src/umockdev-record.vala
index 2d49bc8..272f25e 100644
--- a/src/umockdev-record.vala
+++ b/src/umockdev-record.vala
@@ -223,7 +223,7 @@ record_device(string dev)
int exitcode;
try {
Process.spawn_sync(null,
- {"udevadm", "info", "--query=all", "--path", dev},
+ {"@udevadm@", "info", "--query=all", "--path", dev},
null,
SpawnFlags.SEARCH_PATH,
null,
diff --git a/tests/test-umockdev-run.vala b/tests/test-umockdev-run.vala
index cd00a08..94616cb 100644
--- a/tests/test-umockdev-run.vala
+++ b/tests/test-umockdev-run.vala
@@ -199,8 +199,8 @@ A: size=1048576\n

// unfortunately the udevadm output between distros is not entirely constant
assert (get_program_out (
- "udevadm",
- umockdev_run_command + "-d " + umockdev_file + " -- udevadm info --query=all --name=/dev/loop23",
+ "@udevadm@",
+ umockdev_run_command + "-d " + umockdev_file + " -- @udevadm@ info --query=all --name=/dev/loop23",
out sout, out serr, out exit));

assert_cmpstr (serr, CompareOperator.EQ, "");
--
2.43.0

0 comments on commit ded8c86

Please sign in to comment.