lol
1{
2 stdenv,
3 lib,
4 buildPackages,
5 fetchurl,
6 gettext,
7 genPosixLockObjOnly ? false,
8}:
9let
10 genPosixLockObjOnlyAttrs = lib.optionalAttrs genPosixLockObjOnly {
11 buildPhase = ''
12 cd src
13 make gen-posix-lock-obj
14 '';
15
16 installPhase = ''
17 mkdir -p $out/bin
18 install -m755 gen-posix-lock-obj $out/bin
19 '';
20
21 outputs = [ "out" ];
22 outputBin = "out";
23 };
24in
25stdenv.mkDerivation (
26 rec {
27 pname = "libgpg-error";
28 version = "1.55";
29
30 src = fetchurl {
31 url = "mirror://gnupg/${pname}/${pname}-${version}.tar.bz2";
32 hash = "sha256-lbF4FIhj8H1F3wzqZ+iAp5ue9x9dIwut3ABxEoUW73g=";
33 };
34
35 postPatch = ''
36 sed '/BUILD_TIMESTAMP=/s/=.*/=1970-01-01T00:01+0000/' -i ./configure
37 '';
38
39 hardeningDisable = [ "strictflexarrays3" ];
40
41 configureFlags = [
42 # See https://dev.gnupg.org/T6257#164567
43 "--enable-install-gpg-error-config"
44 ];
45
46 outputs = [
47 "out"
48 "dev"
49 "info"
50 ];
51 outputBin = "dev"; # deps want just the lib, most likely
52
53 # If architecture-dependent MO files aren't available, they're generated
54 # during build, so we need gettext for cross-builds.
55 depsBuildBuild = [ buildPackages.stdenv.cc ];
56 nativeBuildInputs = [ gettext ];
57
58 postConfigure =
59 # For some reason, /bin/sh on OpenIndiana leads to this at the end of the
60 # `config.status' run:
61 # ./config.status[1401]: shift: (null): bad number
62 # (See <https://hydra.nixos.org/build/2931046/nixlog/1/raw>.)
63 # Thus, re-run it with Bash.
64 lib.optionalString stdenv.hostPlatform.isSunOS ''
65 ${stdenv.shell} config.status
66 ''
67 # ./configure erroneous decides to use weak symbols on pkgsStatic,
68 # which, together with other defines results in locking functions in
69 # src/posix-lock.c to be no-op, causing tests/t-lock.c to fail.
70 + lib.optionalString stdenv.hostPlatform.isStatic ''
71 sed '/USE_POSIX_THREADS_WEAK/ d' config.h
72 echo '#undef USE_POSIX_THREADS_WEAK' >> config.h
73 '';
74
75 doCheck = true; # not cross
76
77 meta = {
78 homepage = "https://www.gnupg.org/software/libgpg-error/index.html";
79 changelog = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgpg-error.git;a=blob;f=NEWS;hb=refs/tags/libgpg-error-${version}";
80 description = "Small library that defines common error values for all GnuPG components";
81 mainProgram = "gen-posix-lock-obj";
82
83 longDescription = ''
84 Libgpg-error is a small library that defines common error values
85 for all GnuPG components. Among these are GPG, GPGSM, GPGME,
86 GPG-Agent, libgcrypt, Libksba, DirMngr, Pinentry, SmartCard
87 Daemon and possibly more in the future.
88 '';
89
90 license = lib.licenses.lgpl2Plus;
91 platforms = lib.platforms.all;
92 maintainers = with lib.maintainers; [ ];
93 };
94 }
95 // genPosixLockObjOnlyAttrs
96)