lol
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.42";
21
22 src = fetchurl {
23 url = "mirror://gnupg/${pname}/${pname}-${version}.tar.bz2";
24 sha256 = "sha256-/AfnD2xhX4xPWQqON6m43S4soelAj45gRZxnRSuSXiM=";
25 };
26
27 # 1.42 breaks (some?) cross-compilation (e.g. x86_64 -> aarch64).
28 # Backporting this fix (merged in upstream master but no release cut) by David Michael <fedora.dm0@gmail.com> https://dev.gnupg.org/rE33593864cd54143db594c4237bba41e14179061c
29 patches = [ ./fix-1.42-cross-compilation.patch ];
30
31 postPatch = ''
32 sed '/BUILD_TIMESTAMP=/s/=.*/=1970-01-01T00:01+0000/' -i ./configure
33 '' + lib.optionalString (stdenv.hostPlatform.isAarch32 && stdenv.buildPlatform != stdenv.hostPlatform) ''
34 ln -s lock-obj-pub.arm-unknown-linux-gnueabi.h src/syscfg/lock-obj-pub.linux-gnueabihf.h
35 ln -s lock-obj-pub.arm-unknown-linux-gnueabi.h src/syscfg/lock-obj-pub.linux-gnueabi.h
36 '' + lib.optionalString (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform.isMusl) ''
37 ln -s lock-obj-pub.x86_64-pc-linux-musl.h src/syscfg/lock-obj-pub.linux-musl.h
38 '' + lib.optionalString (stdenv.hostPlatform.isi686 && stdenv.hostPlatform.isMusl) ''
39 ln -s lock-obj-pub.i686-unknown-linux-gnu.h src/syscfg/lock-obj-pub.linux-musl.h
40 '' + lib.optionalString (stdenv.hostPlatform.isAarch32 && stdenv.hostPlatform.isMusl) ''
41 ln -s src/syscfg/lock-obj-pub.arm-unknown-linux-gnueabi.h src/syscfg/lock-obj-pub.arm-unknown-linux-musleabihf.h
42 ln -s src/syscfg/lock-obj-pub.arm-unknown-linux-gnueabi.h src/syscfg/lock-obj-pub.linux-musleabihf.h
43 '';
44
45 outputs = [ "out" "dev" "info" ];
46 outputBin = "dev"; # deps want just the lib, most likely
47
48 # If architecture-dependent MO files aren't available, they're generated
49 # during build, so we need gettext for cross-builds.
50 depsBuildBuild = [ buildPackages.stdenv.cc ];
51 nativeBuildInputs = [ gettext ];
52
53 postConfigure =
54 lib.optionalString stdenv.isSunOS
55 # For some reason, /bin/sh on OpenIndiana leads to this at the end of the
56 # `config.status' run:
57 # ./config.status[1401]: shift: (null): bad number
58 # (See <https://hydra.nixos.org/build/2931046/nixlog/1/raw>.)
59 # Thus, re-run it with Bash.
60 "${stdenv.shell} config.status";
61
62 doCheck = true; # not cross
63
64 meta = with lib; {
65 homepage = "https://www.gnupg.org/software/libgpg-error/index.html";
66 changelog = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgpg-error.git;a=blob;f=NEWS;hb=refs/tags/libgpg-error-${version}";
67 description = "A small library that defines common error values for all GnuPG components";
68
69 longDescription = ''
70 Libgpg-error is a small library that defines common error values
71 for all GnuPG components. Among these are GPG, GPGSM, GPGME,
72 GPG-Agent, libgcrypt, Libksba, DirMngr, Pinentry, SmartCard
73 Daemon and possibly more in the future.
74 '';
75
76 license = licenses.lgpl2Plus;
77 platforms = platforms.all;
78 maintainers = [ maintainers.vrthra ];
79 };
80} // genPosixLockObjOnlyAttrs)