python312Packages.slack-sdk: 3.33.3 -> 3.33.4 (#358119)
[NixPkgs.git] / pkgs / tools / package-management / rpm / default.nix
blobc42bcca20c904bece0eaba33951426c61f208704
1 { stdenv
2 , lib
3 , pkg-config
4 , autoreconfHook
5 , pandoc
6 , fetchpatch2
7 , fetchurl
8 , cpio
9 , zlib
10 , bzip2
11 , file
12 , elfutils
13 , libbfd
14 , libgcrypt
15 , libarchive
16 , nspr
17 , nss
18 , popt
19 , db
20 , xz
21 , python
22 , lua
23 , llvmPackages
24 , sqlite
25 , zstd
26 , libcap
27 , apple-sdk_13
28 , darwinMinVersionHook
31 stdenv.mkDerivation rec {
32   pname = "rpm";
33   version = "4.18.1";
35   src = fetchurl {
36     url = "https://ftp.osuosl.org/pub/rpm/releases/rpm-${lib.versions.majorMinor version}.x/rpm-${version}.tar.bz2";
37     hash = "sha256-N/O0LAlmlB4q0/EP3jY5gkplkdBxl7qP0IacoHeeH1Y=";
38   };
40   patches = [
41     # Resolves `error: expected expression` on clang
42     # See: https://github.com/rpm-software-management/rpm/issues/2435.
43     (fetchpatch2 {
44       url = "https://github.com/rpm-software-management/rpm/commit/b960c0b43a080287a7c13533eeb2d9f288db1414.diff?full_index=1";
45       hash = "sha256-0f7YOL2xR07xgAEN32oRbOjPsAsVmKFVtTLXUOeFAa8=";
46     })
47     # Fix missing includes required to build on Darwin.
48     # See: https://github.com/rpm-software-management/rpm/pull/2571.
49     (fetchpatch2 {
50       url = "https://github.com/rpm-software-management/rpm/commit/f07875392a09228b1a25c1763a50bbbd0f6798c2.diff?full_index=1";
51       hash = "sha256-DLpzMApRCgI9zqheglFtqL8E1vq9X/aQa0HMnIAQgk8=";
52     })
53     (fetchpatch2 {
54       url = "https://github.com/rpm-software-management/rpm/commit/b2e67642fd8cb64d8cb1cca9e759396c1c10807d.diff?full_index=1";
55       hash = "sha256-q3fIBfiUJVmw6Vi2/Bo/zX6/cqTM7aFnskKfMVK3DlU=";
56     })
57   ];
59   outputs = [ "out" "dev" "man" ];
60   separateDebugInfo = true;
62   nativeBuildInputs = [ autoreconfHook pkg-config pandoc ];
63   buildInputs = [ cpio zlib zstd bzip2 file libarchive libgcrypt nspr nss db xz python lua sqlite ]
64     ++ lib.optional stdenv.cc.isClang llvmPackages.openmp
65     ++ lib.optional stdenv.hostPlatform.isLinux libcap
66     ++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_13 (darwinMinVersionHook "13.0") ];
68   # rpm/rpmlib.h includes popt.h, and then the pkg-config file mentions these as linkage requirements
69   propagatedBuildInputs = [ popt nss db bzip2 libarchive libbfd ]
70     ++ lib.optional (lib.meta.availableOn stdenv.hostPlatform elfutils) elfutils;
72   env.NIX_CFLAGS_COMPILE = "-I${nspr.dev}/include/nspr -I${nss.dev}/include/nss";
74   configureFlags = [
75     "--with-external-db"
76     "--with-lua"
77     "--enable-python"
78     "--enable-ndb"
79     "--enable-sqlite"
80     "--enable-zstd"
81     "--localstatedir=/var"
82     "--sharedstatedir=/com"
83   ] ++ lib.optional stdenv.hostPlatform.isLinux "--with-cap";
85   postPatch = ''
86     substituteInPlace Makefile.am --replace '@$(MKDIR_P) $(DESTDIR)$(localstatedir)/tmp' ""
87   '';
89   preFixup = ''
90     # Don't keep a reference to RPM headers or manpages
91     for f in $out/lib/rpm/platform/*/macros; do
92       substituteInPlace $f --replace "$dev" "/rpm-dev-path-was-here"
93       substituteInPlace $f --replace "$man" "/rpm-man-path-was-here"
94     done
96     # Avoid macros like '%__ld' pointing to absolute paths
97     for tool in ld nm objcopy objdump strip; do
98       sed -i $out/lib/rpm/macros -e "s/^%__$tool.*/%__$tool $tool/"
99     done
101     # Avoid helper scripts pointing to absolute paths
102     for tool in find-provides find-requires; do
103       sed -i $out/lib/rpm/$tool -e "s#/usr/lib/rpm/#$out/lib/rpm/#"
104     done
106     # symlinks produced by build are incorrect
107     ln -sf $out/bin/{rpm,rpmquery}
108     ln -sf $out/bin/{rpm,rpmverify}
109   '';
111   enableParallelBuilding = true;
113   meta = with lib; {
114     homepage = "https://www.rpm.org/";
115     license = with licenses; [ gpl2Plus lgpl21Plus ];
116     description = "RPM Package Manager";
117     maintainers = with maintainers; [ copumpkin ];
118     platforms = platforms.linux ++ platforms.darwin;
119   };