Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 137 lines 3.2 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchDebianPatch, 5 fetchpatch, 6 fetchurl, 7 pkg-config, 8 testers, 9 validatePkgConfig, 10 autoconf, 11 automake, 12 libtool, 13}: 14stdenv.mkDerivation (finalAttrs: { 15 pname = "liblzf"; 16 version = "3.6"; 17 18 src = fetchurl { 19 url = "http://dist.schmorp.de/liblzf/liblzf-${finalAttrs.version}.tar.gz"; 20 hash = "sha256-nF3gH3ucyuQMP2GdJqer7JmGwGw20mDBec7dBLiftGo="; 21 }; 22 23 patches = [ 24 (fetchDebianPatch { 25 inherit (finalAttrs) pname version; 26 debianRevision = "4"; 27 patch = "0001-Make-sure-that-the-library-is-linked-with-C-symbols.patch"; 28 hash = "sha256-Rgfp/TysRcEJaogOo/Xno+G4HZzj9Loa69DL43Bp1Ok="; 29 }) 30 ( 31 let 32 name = "liblzf-3.6-autoconf-20140314.patch"; 33 in 34 fetchpatch { 35 inherit name; 36 url = "https://src.fedoraproject.org/rpms/liblzf/raw/53da654eead51a24ac81a28e1b1c531eb1afab28/f/${name}"; 37 hash = "sha256-rkhI8w0HV3fGiDfHiXBzrnxqGDE/Yo5ntePrsscMiyg="; 38 } 39 ) 40 ]; 41 42 nativeBuildInputs = [ 43 autoconf 44 automake 45 libtool 46 pkg-config 47 validatePkgConfig 48 ]; 49 50 preConfigure = '' 51 sh ./bootstrap.sh 52 ''; 53 54 postInstall = '' 55 pushd $out/bin 56 ln -s lzf unlzf 57 popd 58 ''; 59 60 outputs = [ 61 "out" 62 "dev" 63 ]; 64 65 passthru.tests = { 66 pkgConfigTest = testers.hasPkgConfigModules { 67 package = finalAttrs.finalPackage; 68 version = "${finalAttrs.version}.0"; 69 versionCheck = true; 70 }; 71 72 exeTest = testers.runCommand { 73 name = "${finalAttrs.pname}-exe-test"; 74 buildInputs = [ finalAttrs.finalPackage ]; 75 script = '' 76 lzf -h 2> /dev/null 77 78 echo "LZFLZFLZFLZFLZFLZFLZFLZF" > test.txt 79 80 # unlzf writes to filename minus ".lzf" 81 cp test.txt test.txt.orig 82 83 lzf test.txt 84 unlzf test.txt.lzf 85 86 # Compare results 87 if ! cmp -s test.txt test.txt.orig; then 88 echo "Executable test failed: files don't match" 89 exit 1 90 fi 91 92 echo "Decompressed output matches test string (lzf & unlzf)" 93 94 touch $out 95 ''; 96 }; 97 98 shlibTest = testers.runCommand { 99 name = "${finalAttrs.pname}-shlib-test"; 100 inherit stdenv; # with CC 101 nativeBuildInputs = [ pkg-config ]; 102 buildInputs = [ 103 finalAttrs.finalPackage.dev 104 finalAttrs.finalPackage 105 ]; 106 # tests both the library and pkg-config file 107 script = '' 108 $CC -g ${./lib_test.c} -o lib_test \ 109 $(pkg-config --cflags --libs liblzf) 110 111 ./lib_test >/dev/null 112 113 echo "Built and tested file linked against liblzf using pkg-config" 114 touch $out 115 ''; 116 }; 117 }; 118 119 meta = { 120 changelog = 121 "http://cvs.schmorp.de/liblzf/Changes?pathrev=rel-" 122 + builtins.replaceStrings [ "." ] [ "_" ] finalAttrs.version; 123 description = "Small data compression library"; 124 downloadPage = "http://dist.schmorp.de/liblzf/"; 125 homepage = "http://software.schmorp.de/pkg/liblzf.html"; 126 license = with lib.licenses; [ 127 bsd2 128 gpl2Plus 129 ]; 130 mainProgram = "lzf"; 131 maintainers = with lib.maintainers; [ 132 tetov 133 ]; 134 platforms = lib.platforms.unix; 135 pkgConfigModules = [ "liblzf" ]; 136 }; 137})