2016-06-12 05:34:57 +02:00
|
|
|
{ stdenv, fetchurl, fetchpatch, pkgconfig
|
|
|
|
, zlib, freetype, libjpeg, jbig2dec, openjpeg
|
|
|
|
, libX11, libXcursor, libXrandr, libXinerama, libXext, harfbuzz, mesa }:
|
2015-04-19 08:57:45 +02:00
|
|
|
|
2010-08-09 22:59:38 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2016-08-03 14:07:50 +02:00
|
|
|
version = "1.9a";
|
2014-06-13 11:29:52 +02:00
|
|
|
name = "mupdf-${version}";
|
2010-08-09 22:59:38 +02:00
|
|
|
|
|
|
|
src = fetchurl {
|
2016-05-15 22:13:31 +02:00
|
|
|
url = "http://mupdf.com/downloads/archive/${name}-source.tar.gz";
|
2016-08-03 14:07:50 +02:00
|
|
|
sha256 = "1k64pdapyj8a336jw3j61fhn0rp4q6az7d0dqp9r5n3d9rgwa5c0";
|
2010-08-09 22:59:38 +02:00
|
|
|
};
|
|
|
|
|
2016-08-03 14:07:50 +02:00
|
|
|
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-09-26 15:53:40 +02:00
|
|
|
(fetchpatch {
|
|
|
|
name = "mupdf-696941-fix-use-after-free.patch";
|
|
|
|
url = "http://git.ghostscript.com/?p=mupdf.git;a=patch;h=fa1936405b6a84e5c9bb440912c23d532772f958";
|
|
|
|
sha256 = "02j9b6my1h3rb0sz9yp6gi7c4ldi3mz0z9s5i8g9cl0arxyzys5h";
|
|
|
|
})
|
2016-08-18 14:12:07 +02:00
|
|
|
# Compatibility with new openjpeg
|
|
|
|
(fetchpatch {
|
2016-09-26 15:53:40 +02:00
|
|
|
name = "mupdf-1.9a-openjpeg-2.1.1.patch";
|
|
|
|
url = "https://git.archlinux.org/svntogit/community.git/plain/mupdf/trunk/0001-mupdf-openjpeg.patch?id=9083dac2a398bfe694d31a0c6a0a839c5a756e53";
|
|
|
|
sha256 = "14ndgy3w1sl25km9bcc2zfcxrcihqjw1sdzkpcw5g1mi7gcgxp3g";
|
2016-08-18 14:12:07 +02:00
|
|
|
})
|
2016-08-03 14:07:50 +02:00
|
|
|
];
|
|
|
|
|
2016-08-18 14:12:07 +02:00
|
|
|
makeFlags = [ "prefix=$(out)" ];
|
2015-11-25 16:28:57 +01:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
2016-08-18 14:12:07 +02:00
|
|
|
buildInputs = [ zlib libX11 libXcursor libXext harfbuzz mesa libXrandr libXinerama freetype libjpeg jbig2dec openjpeg ];
|
2016-08-31 12:12:11 +02:00
|
|
|
outputs = [ "bin" "dev" "out" "doc" ];
|
2010-08-09 22:59:38 +02:00
|
|
|
|
2016-08-18 14:12:07 +02: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 14:14:42 +02:00
|
|
|
|
2016-08-18 14:12:07 +02: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 14:14:42 +02: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 15:58:12 +01:00
|
|
|
Version: ${version}
|
2016-08-18 14:12:07 +02:00
|
|
|
Libs: -L$out/lib -lmupdf -lmupdfthird
|
2016-08-31 12:12:11 +02:00
|
|
|
Cflags: -I$dev/include
|
2014-05-17 14:14:42 +02:00
|
|
|
EOF
|
|
|
|
|
2016-08-18 14:12:07 +02:00
|
|
|
moveToOutput "bin" "$bin"
|
|
|
|
mkdir -p $bin/share/applications
|
|
|
|
cat > $bin/share/applications/mupdf.desktop <<EOF
|
2013-08-29 19:29:22 +02:00
|
|
|
[Desktop Entry]
|
|
|
|
Type=Application
|
|
|
|
Version=1.0
|
|
|
|
Name=mupdf
|
|
|
|
Comment=PDF viewer
|
2016-08-18 14:12:07 +02:00
|
|
|
Exec=$bin/bin/mupdf-x11 %f
|
2013-08-29 19:29:22 +02:00
|
|
|
Terminal=false
|
|
|
|
EOF
|
|
|
|
'';
|
2016-08-18 14:12:07 +02:00
|
|
|
|
2016-06-12 05:34:57 +02:00
|
|
|
enableParallelBuilding = true;
|
2013-08-29 19:29:22 +02:00
|
|
|
|
2016-06-12 05:34:57 +02:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = http://mupdf.com;
|
2014-04-03 06:55:17 +02:00
|
|
|
repositories.git = git://git.ghostscript.com/mupdf.git;
|
2010-08-09 22:59:38 +02:00
|
|
|
description = "Lightweight PDF viewer and toolkit written in portable C";
|
2016-06-12 05:34:57 +02:00
|
|
|
license = licenses.gpl3Plus;
|
2016-09-26 15:53:40 +02:00
|
|
|
maintainers = with maintainers; [ viric vrthra fpletz ];
|
2016-06-12 05:34:57 +02:00
|
|
|
platforms = platforms.linux;
|
2010-08-09 22:59:38 +02:00
|
|
|
};
|
|
|
|
}
|