From a2d3ae028622ddb944206fa8c99e47c8fc341577 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Fri, 8 Nov 2024 16:21:05 -0800 Subject: [PATCH] rpm-sequoia: init at 1.7.0 --- pkgs/by-name/rp/rpm-sequoia/objdump.patch | 18 ++++++ pkgs/by-name/rp/rpm-sequoia/package.nix | 74 +++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 pkgs/by-name/rp/rpm-sequoia/objdump.patch create mode 100644 pkgs/by-name/rp/rpm-sequoia/package.nix diff --git a/pkgs/by-name/rp/rpm-sequoia/objdump.patch b/pkgs/by-name/rp/rpm-sequoia/objdump.patch new file mode 100644 index 000000000000..232190a9bc80 --- /dev/null +++ b/pkgs/by-name/rp/rpm-sequoia/objdump.patch @@ -0,0 +1,18 @@ +objdump may be prefixed on cross-compilation, read the path from $OBJDUMP instead + +diff --git a/tests/symbols.rs b/tests/symbols.rs +index 9375619..5f161fc 100644 +--- a/tests/symbols.rs ++++ b/tests/symbols.rs +@@ -27,7 +27,10 @@ fn symbols() -> anyhow::Result<()> { + } + }; + +- let cmd = Command::new("objdump") ++ let cmd = Command::new("bash") ++ .arg("-c") ++ .arg(r#"exec "$OBJDUMP" "$@""#) ++ .arg("--") + .arg("-T") + .arg(lib) + .unwrap(); diff --git a/pkgs/by-name/rp/rpm-sequoia/package.nix b/pkgs/by-name/rp/rpm-sequoia/package.nix new file mode 100644 index 000000000000..d3ecf9fa91f6 --- /dev/null +++ b/pkgs/by-name/rp/rpm-sequoia/package.nix @@ -0,0 +1,74 @@ +{ + stdenv, + fetchFromGitHub, + lib, + nettle, + nix-update-script, + rustPlatform, + pkg-config, + runCommand, +}: + +rustPlatform.buildRustPackage rec { + pname = "rpm-sequoia"; + version = "1.7.0"; + + src = fetchFromGitHub { + owner = "rpm-software-management"; + repo = "rpm-sequoia"; + rev = "v${version}"; + hash = "sha256-AZCsboUv4muKOw5El2Hw5O1cvAgD3JhBppacrQCJT2k="; + }; + + cargoHash = "sha256-0yO1+OAkXje/ir8i8URVhIcW8gwXleYx+XL1U4bjtXk="; + + patches = [ + ./objdump.patch + ]; + + nativeBuildInputs = [ + pkg-config + rustPlatform.bindgenHook + ]; + + propagatedBuildInputs = [ nettle ]; + + # Tests will parse the symbols, on darwin we have two issues: + # - library name is hardcoded to librpm_sequoia.so + # - The output of the objdump differs and the parsing logic needs to be adapted + doCheck = !stdenv.hostPlatform.isDarwin; + + outputs = [ + "out" + "dev" + ]; + + # Ensure the generated .pc file gets the correct prefix + env.PREFIX = placeholder "out"; + + # Install extra files, the same as this is done on fedora: + # https://src.fedoraproject.org/rpms/rust-rpm-sequoia/blob/f41/f/rust-rpm-sequoia.spec#_81 + preInstall = + # Install the generated pc file for consumption by the dependents + '' + install -Dm644 target/release/rpm-sequoia.pc -t $dev/lib/pkgconfig + '' + + + # Dependents will rely on the versioned symlinks + '' + install -d $out/lib + find target/release/ \ + -maxdepth 1 \ + -type l -name 'librpm_sequoia.*' \ + -exec cp --no-dereference {} $out/lib/ \; + ''; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "An OpenPGP backend for rpm using Sequoia PGP"; + homepage = "https://sequoia-pgp.org/"; + license = lib.licenses.gpl2Plus; + maintainers = with lib.maintainers; [ baloo ]; + }; +}