2021-05-20 23:08:51 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, docbook-xsl-nons
|
2020-12-27 14:24:52 +00:00
|
|
|
, fetchurl
|
2024-02-29 20:09:43 +00:00
|
|
|
, fetchpatch
|
2020-12-27 14:24:52 +00:00
|
|
|
, glib
|
|
|
|
, gobject-introspection
|
|
|
|
, gtk-doc
|
|
|
|
, libgudev
|
2021-10-14 00:43:12 +00:00
|
|
|
, libpcap
|
2020-12-27 14:24:52 +00:00
|
|
|
, meson
|
2022-08-12 12:06:08 +00:00
|
|
|
, mesonEmulatorHook
|
2020-12-27 14:24:52 +00:00
|
|
|
, ninja
|
|
|
|
, pkg-config
|
|
|
|
, python3
|
2024-02-29 20:09:43 +00:00
|
|
|
, substituteAll
|
|
|
|
, systemdMinimal
|
2020-12-27 14:24:52 +00:00
|
|
|
, usbutils
|
|
|
|
, vala
|
|
|
|
, which
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "umockdev";
|
2023-08-22 20:05:09 +00:00
|
|
|
version = "0.17.18";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
outputs = [ "bin" "out" "dev" "devdoc" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2023-08-04 22:07:22 +00:00
|
|
|
url = "https://github.com/martinpitt/umockdev/releases/download/${finalAttrs.version}/umockdev-${finalAttrs.version}.tar.xz";
|
2023-08-22 20:05:09 +00:00
|
|
|
sha256 = "sha256-RmrT4McV5W9Q6mqWUWWCPQc6hBN6y4oeObZlc2SKmF8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
patches = [
|
|
|
|
# Hardcode absolute paths to libraries so that consumers
|
|
|
|
# do not need to set LD_LIBRARY_PATH themselves.
|
|
|
|
./hardcode-paths.patch
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
# 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";
|
|
|
|
})
|
|
|
|
|
|
|
|
(fetchpatch {
|
|
|
|
name = "musl.patch";
|
|
|
|
url = "https://github.com/martinpitt/umockdev/commit/d4efe24be59bd859b87473ea3d7efe8100bedc74.patch";
|
|
|
|
hash = "sha256-whf3p2e7FWN1xk5+HF9KsbMW74DPOQ0R0+FxBfCZTX0=";
|
|
|
|
})
|
2022-05-18 14:49:53 +00:00
|
|
|
];
|
|
|
|
|
2020-12-27 14:24:52 +00:00
|
|
|
nativeBuildInputs = [
|
2021-05-20 23:08:51 +00:00
|
|
|
docbook-xsl-nons
|
2020-12-27 14:24:52 +00:00
|
|
|
gobject-introspection
|
|
|
|
gtk-doc
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
vala
|
2022-08-12 12:06:08 +00:00
|
|
|
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
|
|
|
|
mesonEmulatorHook
|
2020-12-27 14:24:52 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
buildInputs = [
|
|
|
|
glib
|
2024-02-29 20:09:43 +00:00
|
|
|
systemdMinimal
|
2021-10-14 00:43:12 +00:00
|
|
|
libpcap
|
2021-05-20 23:08:51 +00:00
|
|
|
];
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
checkInputs = lib.optionals finalAttrs.passthru.withGudev [
|
|
|
|
libgudev
|
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2021-05-20 23:08:51 +00:00
|
|
|
python3
|
|
|
|
usbutils
|
2024-02-29 20:09:43 +00:00
|
|
|
which
|
2021-05-20 23:08:51 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
mesonFlags = [
|
|
|
|
"-Dgtk_doc=true"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
doCheck = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Substitute the path to this derivation in the patch we apply.
|
|
|
|
substituteInPlace src/umockdev-wrapper \
|
|
|
|
--subst-var-by 'LIBDIR' "''${!outputLib}/lib"
|
|
|
|
'';
|
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
# Our patch makes the path to the `LD_PRELOAD`ed library absolute.
|
|
|
|
# When running tests, the library is not yet installed, though,
|
|
|
|
# so we need to replace the absolute path with a local one during build.
|
|
|
|
# We are using a symlink that will be overridden during installation.
|
|
|
|
mkdir -p "$out/lib"
|
|
|
|
ln -s "$PWD/libumockdev-preload.so.0" "$out/lib/libumockdev-preload.so.0"
|
|
|
|
'';
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
passthru = {
|
|
|
|
# libgudev is needed for an optional test but it itself relies on umockdev for testing.
|
|
|
|
withGudev = false;
|
|
|
|
|
|
|
|
tests = {
|
|
|
|
withGudev = finalAttrs.finalPackage.overrideAttrs (attrs: {
|
|
|
|
passthru = attrs.passthru // {
|
|
|
|
withGudev = true;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2023-02-02 18:25:31 +00:00
|
|
|
homepage = "https://github.com/martinpitt/umockdev";
|
2023-08-04 22:07:22 +00:00
|
|
|
changelog = "https://github.com/martinpitt/umockdev/releases/tag/${finalAttrs.version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Mock hardware devices for creating unit tests";
|
2021-05-20 23:08:51 +00:00
|
|
|
license = licenses.lgpl21Plus;
|
2020-12-27 14:24:52 +00:00
|
|
|
maintainers = with maintainers; [ flokli ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = with platforms; linux;
|
|
|
|
};
|
2023-08-04 22:07:22 +00:00
|
|
|
})
|