nixpkgs/pkgs/applications/misc/mupdf/default.nix

85 lines
2.7 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, fetchpatch, pkgconfig
, zlib, freetype, libjpeg, jbig2dec, openjpeg
, libX11, libXcursor, libXrandr, libXinerama, libXext, harfbuzz, mesa }:
2015-04-19 09:57:45 +03:00
stdenv.mkDerivation rec {
version = "1.9a";
name = "mupdf-${version}";
src = fetchurl {
2016-05-15 23:13:31 +03:00
url = "http://mupdf.com/downloads/archive/${name}-source.tar.gz";
sha256 = "1k64pdapyj8a336jw3j61fhn0rp4q6az7d0dqp9r5n3d9rgwa5c0";
};
patches = [
# http://www.openwall.com/lists/oss-security/2016/08/03/2
(fetchpatch {
name = "mupdf-fix-CVE-2016-6525.patch";
url = "http://git.ghostscript.com/?p=mupdf.git;a=commitdiff_plain;h=39b0f07dd960f34e7e6bf230ffc3d87c41ef0f2e;hp=fa1936405b6a84e5c9bb440912c23d532772f958";
sha256 = "1g9fkd1f5rx1z043vr9dj4934qf7i4nkvbwjc61my9azjrrc3jv7";
})
2016-08-18 15:12:07 +03:00
# Compatibility with new openjpeg
(fetchpatch {
name = "mupdf-1.5-openjpeg-2.1.0.patch";
url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/mupdf-1.5-openjpeg-2.1.0.patch?h=packages/mupdf&id=ca5e3ef6c7788ccfb6011d785078bc47762f19e5";
sha256 = "0f18793q9fd22h3lclm8wahvc8az4v08an6lzy8mczrkl8mcgm3k";
})
];
NIX_CFLAGS_COMPILE= [ "-fPIC" ];
2016-08-18 15:12:07 +03:00
makeFlags = [ "prefix=$(out)" ];
2015-11-25 18:28:57 +03:00
nativeBuildInputs = [ pkgconfig ];
2016-08-18 15:12:07 +03:00
buildInputs = [ zlib libX11 libXcursor libXext harfbuzz mesa libXrandr libXinerama freetype libjpeg jbig2dec openjpeg ];
2016-08-31 13:12:11 +03:00
outputs = [ "bin" "dev" "out" "doc" ];
2016-08-18 15:12:07 +03:00
preConfigure = ''
# Don't remove mujs because upstream version is incompatible
rm -rf thirdparty/{curl,freetype,glfw,harfbuzz,jbig2dec,jpeg,openjpeg,zlib}
'';
2014-05-17 16:14:42 +04:00
2016-08-18 15:12:07 +03:00
postInstall = ''
for i in $out/lib/*.a; do
so="''${i%.a}.so"
gcc -shared -o $so.${version} -Wl,--whole-archive $i -Wl,--no-whole-archive
ln -s $so.${version} $so
rm $i
done
2014-05-17 16:14:42 +04:00
mkdir -p "$out/lib/pkgconfig"
cat >"$out/lib/pkgconfig/mupdf.pc" <<EOF
prefix=$out
libdir=$out/lib
includedir=$out/include
Name: mupdf
Description: Library for rendering PDF documents
2015-11-25 17:58:12 +03:00
Version: ${version}
2016-08-18 15:12:07 +03:00
Libs: -L$out/lib -lmupdf -lmupdfthird
2016-08-31 13:12:11 +03:00
Cflags: -I$dev/include
2014-05-17 16:14:42 +04:00
EOF
2016-08-18 15:12:07 +03:00
moveToOutput "bin" "$bin"
mkdir -p $bin/share/applications
cat > $bin/share/applications/mupdf.desktop <<EOF
[Desktop Entry]
Type=Application
Version=1.0
Name=mupdf
Comment=PDF viewer
2016-08-18 15:12:07 +03:00
Exec=$bin/bin/mupdf-x11 %f
Terminal=false
EOF
'';
2016-08-18 15:12:07 +03:00
enableParallelBuilding = true;
meta = with stdenv.lib; {
homepage = http://mupdf.com;
2014-04-03 08:55:17 +04:00
repositories.git = git://git.ghostscript.com/mupdf.git;
description = "Lightweight PDF viewer and toolkit written in portable C";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ viric vrthra ];
platforms = platforms.linux;
};
}