1{ stdenv, lib, fetchpatch, 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 name = "libgpg-error-${version}";
20 version = "1.28";
21
22 src = fetchurl {
23 url = "mirror://gnupg/libgpg-error/${name}.tar.bz2";
24 sha256 = "0jfsfnh9bxlxiwxws60yah4ybjw2hshmvqp31pri4m4h8ivrbnry";
25 };
26
27 patches = [
28 # Fix builds on ARM, AArch64
29 (fetchpatch {
30 url = "https://github.com/gpg/libgpg-error/commit/791177de023574223eddf7288eb7c5a0721ac623.patch";
31 sha256 = "0vqfw0ak1j37wf6sk9y9vmdyk3kxdxkldhs0bv2waa76s11cmdx0";
32 })
33 ];
34
35 postPatch = ''
36 sed '/BUILD_TIMESTAMP=/s/=.*/=1970-01-01T00:01+0000/' -i ./configure
37 '' + lib.optionalString stdenv.hostPlatform.isMusl ''
38 ln -s lock-obj-pub.x86_64-pc-linux-musl.h src/syscfg/lock-obj-pub.linux-musl.h
39 '';
40
41 outputs = [ "out" "dev" "info" ];
42 outputBin = "dev"; # deps want just the lib, most likely
43
44 # If architecture-dependent MO files aren't available, they're generated
45 # during build, so we need gettext for cross-builds.
46 depsBuildBuild = [ buildPackages.stdenv.cc ];
47 nativeBuildInputs = [ gettext ];
48
49 postConfigure =
50 lib.optionalString stdenv.isSunOS
51 # For some reason, /bin/sh on OpenIndiana leads to this at the end of the
52 # `config.status' run:
53 # ./config.status[1401]: shift: (null): bad number
54 # (See <http://hydra.nixos.org/build/2931046/nixlog/1/raw>.)
55 # Thus, re-run it with Bash.
56 "${stdenv.shell} config.status";
57
58 doCheck = true; # not cross
59
60 meta = with stdenv.lib; {
61 homepage = https://www.gnupg.org/related_software/libgpg-error/index.html;
62 description = "A small library that defines common error values for all GnuPG components";
63
64 longDescription = ''
65 Libgpg-error is a small library that defines common error values
66 for all GnuPG components. Among these are GPG, GPGSM, GPGME,
67 GPG-Agent, libgcrypt, Libksba, DirMngr, Pinentry, SmartCard
68 Daemon and possibly more in the future.
69 '';
70
71 license = licenses.lgpl2Plus;
72 platforms = platforms.all;
73 maintainers = [ maintainers.fuuzetsu maintainers.vrthra ];
74 };
75} // genPosixLockObjOnlyAttrs)