1{lib, stdenv, fetchurl, gettext }:
2
3stdenv.mkDerivation rec {
4 pname = "checkinstall";
5 version = "1.6.2";
6
7 src = fetchurl {
8 url = "https://www.asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-${version}.tar.gz";
9 sha256 = "1x4kslyvfd6lm6zd1ylbq2pjxrafb77ydfjaqi16sa5qywn1jqfw";
10 };
11
12 patches = [
13 # Include empty directories created by the installation script in
14 # generated packages. (E.g., if a `make install' does `mkdir
15 # /var/lib/mystuff', then /var/lib/mystuff should be included in
16 # the package.)
17 ./empty-dirs.patch
18
19 # Implement the getxattr(), lgetxattr(), __open_2() and
20 # __open64_2() functions. Needed for doing builds on Ubuntu 8.10.
21 ./missing-functions.patch
22
23 # Don't include directories in the Debian `conffiles' file.
24 ./etc-dirs.patch
25
26 # Support Glibc >= 2.8.
27 ./glibc-check.patch
28
29 # Fix a `conflicting types for 'scandir'' error on Glibc 2.11.
30 ./scandir.patch
31
32 # Fix a `conflicting types for 'readlink'' error since Glibc 2.19
33 ./readlink-types.patch
34
35 # Fix BuildRoot handling in RPM builds.
36 ./set-buildroot.patch
37
38 (fetchurl {
39 url = "https://salsa.debian.org/debian/checkinstall/-/raw/7175ae9de0e45f42fdd7f185ab9a12043d5efeeb/debian/patches/0016-Define-_STAT_VER-_MKNOD_VER-locally-dropped-in-glibc.patch";
40 hash = "sha256-InodEfvVMuN708yjXPrVXb+q8aUcyFhCLx35PHls0Eo=";
41 })
42 ]
43
44 ++ lib.optional (stdenv.hostPlatform.system == "x86_64-linux")
45 # Force use of old memcpy so that installwatch works on Glibc <
46 # 2.14.
47 ./use-old-memcpy.patch;
48
49 buildInputs = [gettext];
50
51 hardeningDisable = [ "fortify" ];
52
53 preBuild = ''
54 makeFlagsArray=(PREFIX=$out)
55
56 substituteInPlace checkinstall --replace /usr/local/lib/checkinstall $out/lib/checkinstall
57 substituteInPlace checkinstallrc-dist --replace /usr/local $out
58
59 substituteInPlace installwatch/create-localdecls \
60 --replace /usr/include/unistd.h ${stdenv.cc.libc.dev}/include/unistd.h
61 '';
62
63 postInstall =
64 # Clear the RPATH, otherwise installwatch.so won't work properly
65 # as an LD_PRELOADed library on applications that load against a
66 # different Glibc.
67 ''
68 patchelf --set-rpath "" $out/lib/installwatch.so
69 '';
70
71 meta = {
72 homepage = "http://checkinstall.izto.org/";
73 description = "A tool for automatically generating Slackware, RPM or Debian packages when doing `make install'";
74 maintainers = [ lib.maintainers.eelco ];
75 platforms = lib.platforms.linux;
76 license = lib.licenses.gpl2;
77 knownVulnerabilities = [
78 "CVE-2020-25031"
79 ];
80 };
81}