about summary refs log tree commit diff
path: root/pkgs/tools/archivers/rpm2targz/default.nix
blob: ac5b132d7ab434041dbed81a58f4323c7e67c522 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ bzip2
, coreutils
, cpio
, fetchurl
, gnutar
, gzip
, lib
, stdenv
, xz
, zstd
}:

let
  shdeps = [
    bzip2
    coreutils
    cpio
    gnutar
    gzip
    xz
    zstd
  ];

in stdenv.mkDerivation rec {
  pname = "rpm2targz";
  version = "2021.03.16";

  # git repo: https://gitweb.gentoo.org/proj/rpm2targz.git/
  src = fetchurl {
    url = "https://dev.gentoo.org/~vapier/dist/${pname}-${version}.tar.xz";
    hash = "sha256-rcV+o9V2wWKznqSW2rA8xgnpQ02kpK4te6mYvLRC5vQ=";
  };

  buildInputs = shdeps;

  postPatch = ''
    substituteInPlace rpm2targz --replace "=\"rpmoffset\"" "=\"$out/bin/rpmoffset\""
    # rpm2targz relies on the executable name
    # to guess what compressor it should use
    # this is more reliable than wrapProgram
    sed -i -e '2iexport PATH="${lib.makeBinPath shdeps}"' rpm2targz
  '';

  preBuild = ''
    makeFlagsArray+=(prefix=$out)
  '';

  meta = with lib; {
    description = "Convert a .rpm file to a .tar.gz archive";
    homepage = "http://slackware.com/config/packages.php";
    license = licenses.bsd1;
    maintainers = with maintainers; [ zseri ];
    platforms = platforms.all;
  };
}