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