kiwix: refactor expression, push pugixml into its own derivation

This commit is contained in:
Jan Malakhovski 2016-09-03 13:45:00 +00:00
parent 4da420709d
commit 659fb3b757

View File

@ -1,9 +1,11 @@
{ stdenv, callPackage, overrideCC, fetchurl, makeWrapper, pkgconfig { stdenv, callPackage, overrideCC, fetchurl, makeWrapper, pkgconfig
, zip, python, zlib, which, icu, libmicrohttpd, lzma, ctpp2, aria2, wget, bc , zip, python, zlib, which, icu, libmicrohttpd, lzma, ctpp2, aria2, wget, bc
, libuuid, glibc, libX11, libXext, libXt, libXrender, glib, dbus, dbus_glib , libuuid, glibc, libX11, libXext, libXt, libXrender, glib, dbus, dbus_glib
, gtk2, gdk_pixbuf, pango, cairo , freetype, fontconfig, alsaLib, atk , gtk2, gdk_pixbuf, pango, cairo, freetype, fontconfig, alsaLib, atk, cmake
}: }:
with stdenv.lib;
let let
xulrunner64_tar = fetchurl { xulrunner64_tar = fetchurl {
url = http://download.kiwix.org/dev/xulrunner-29.0.en-US.linux-x86_64.tar.bz2; url = http://download.kiwix.org/dev/xulrunner-29.0.en-US.linux-x86_64.tar.bz2;
@ -22,18 +24,41 @@ let
sha256 = "1h9vcbvf8wgds6i2z20y7krpys0mqsqhv1ijyfljanp6vyll9fvi"; sha256 = "1h9vcbvf8wgds6i2z20y7krpys0mqsqhv1ijyfljanp6vyll9fvi";
}; };
xulrunner_tar = if stdenv.system == "x86_64-linux" then xulrunner64_tar else xulrunner32_tar; xulrunner = if stdenv.system == "x86_64-linux"
xulrunnersdk_tar = if stdenv.system == "x86_64-linux" then xulrunnersdk64_tar else xulrunnersdk32_tar; then { tar = xulrunner64_tar; sdk = xulrunnersdk64_tar; }
pugixml_tar = fetchurl { else { tar = xulrunner32_tar; sdk = xulrunnersdk32_tar; };
url = http://download.kiwix.org/dev/pugixml-1.2.tar.gz;
sha256 = "0sqk0vdwjq44jxbbkj1cy8qykrmafs1sickzldb2w2nshsnjshhg";
};
xapian = callPackage ../../../development/libraries/xapian { inherit stdenv; }; xapian = callPackage ../../../development/libraries/xapian { inherit stdenv; };
zimlib = callPackage ../../../development/libraries/zimlib { inherit stdenv; }; zimlib = callPackage ../../../development/libraries/zimlib { inherit stdenv; };
pugixml = stdenv.mkDerivation rec {
version = "1.2";
name = "pugixml-${version}";
src = fetchurl {
url = "http://download.kiwix.org/dev/${name}.tar.gz";
sha256 = "0sqk0vdwjq44jxbbkj1cy8qykrmafs1sickzldb2w2nshsnjshhg";
};
buildInputs = [ cmake ];
unpackPhase = ''
# not a nice src archive: all the files are in the root :(
mkdir ${name}
cd ${name}
tar -xf ${src}
# and the build scripts are in there :'(
cd scripts
'';
NIX_CFLAGS_COMPILE = "-fPIC";
};
in in
with stdenv.lib;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "kiwix-${version}"; name = "kiwix-${version}";
version = "0.9"; version = "0.9";
@ -60,41 +85,32 @@ stdenv.mkDerivation rec {
bc bc
libuuid libuuid
makeWrapper makeWrapper
pugixml
]; ];
postUnpack = '' postUnpack = ''
cd kiwix-* cd kiwix*
mkdir static mkdir static
cp Makefile.in static/ cp Makefile.in static/
cd src/dependencies cd src/dependencies
cp ${pugixml_tar} pugixml-1.2.tar.gz
tar -xf ${xulrunner_tar} tar -xf ${xulrunner.tar}
tar -xf ${xulrunnersdk_tar} tar -xf ${xulrunner.sdk}
cd ../../.. cd ../../..
''; '';
configurePhase = '' configureFlags = [
bash ./configure --disable-static --disable-dependency-tracking --prefix=$out --with-libpugixml=SELF "--disable-static"
''; "--disable-staticbins"
];
buildPhase = ''
cd src/dependencies
make pugixml-1.2/libpugixml.a
cd ../..
bash ./configure --disable-static --disable-dependency-tracking --prefix=$out --with-libpugixml=SELF
make
'';
installPhase = '' installPhase = ''
make install make install
cp -r src/dependencies/xulrunner $out/lib/kiwix cp -r src/dependencies/xulrunner $out/lib/kiwix
patchelf --set-interpreter ${glibc.out}/lib/ld-linux${optionalString (stdenv.system == "x86_64-linux") "-x86-64"}.so.2 $out/lib/kiwix/xulrunner/xulrunner patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/lib/kiwix/xulrunner/xulrunner
rm $out/bin/kiwix rm $out/bin/kiwix
makeWrapper $out/lib/kiwix/kiwix-launcher $out/bin/kiwix \ makeWrapper $out/lib/kiwix/kiwix-launcher $out/bin/kiwix \