diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/misc/xpdf')
5 files changed, 237 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/misc/xpdf/cmake_version.patch b/nixpkgs/pkgs/applications/misc/xpdf/cmake_version.patch new file mode 100644 index 000000000000..59a51f7506d5 --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/xpdf/cmake_version.patch @@ -0,0 +1,15 @@ + +Fix "No known features for CXX compiler", see +https://cmake.org/pipermail/cmake/2016-December/064733.html and the note at +https://cmake.org/cmake/help/v3.10/command/cmake_minimum_required.html +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,7 +8,7 @@ + # + #======================================================================== + +-cmake_minimum_required(VERSION 2.8.8) ++cmake_minimum_required(VERSION 3.1.0) + + project(xpdf) + diff --git a/nixpkgs/pkgs/applications/misc/xpdf/default.nix b/nixpkgs/pkgs/applications/misc/xpdf/default.nix new file mode 100644 index 000000000000..7e0369b277d3 --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/xpdf/default.nix @@ -0,0 +1,51 @@ +{ enableGUI ? true, enablePDFtoPPM ? true, useT1Lib ? false +, stdenv, fetchurl, zlib, libpng, freetype ? null, t1lib ? null +, cmake, qtbase ? null, qtsvg ? null, makeWrapper +}: + +assert enableGUI -> qtbase != null && qtsvg != null && freetype != null; +assert enablePDFtoPPM -> freetype != null; +assert useT1Lib -> t1lib != null; + +assert !useT1Lib; # t1lib has multiple unpatched security vulnerabilities + +stdenv.mkDerivation { + name = "xpdf-4.00"; + + src = fetchurl { + url = http://www.xpdfreader.com/dl/xpdf-4.00.tar.gz; + sha256 = "1mhn89738vjva14xr5gblc2zrdgzmpqbbjdflqdmpqv647294ggz"; + }; + + # Fix "No known features for CXX compiler", see + # https://cmake.org/pipermail/cmake/2016-December/064733.html and the note at + # https://cmake.org/cmake/help/v3.10/command/cmake_minimum_required.html + patches = stdenv.lib.optional stdenv.isDarwin ./cmake_version.patch; + + nativeBuildInputs = [ cmake makeWrapper ]; + + cmakeFlags = ["-DSYSTEM_XPDFRC=/etc/xpdfrc" "-DA4_PAPER=ON"]; + + buildInputs = [ zlib libpng ] ++ + stdenv.lib.optional enableGUI qtbase ++ + stdenv.lib.optional useT1Lib t1lib ++ + stdenv.lib.optional enablePDFtoPPM freetype; + + # Debian uses '-fpermissive' to bypass some errors on char* constantness. + CXXFLAGS = "-O2 -fpermissive"; + + hardeningDisable = [ "format" ]; + + postInstall = stdenv.lib.optionalString (stdenv.isDarwin && enableGUI) '' + wrapProgram $out/bin/xpdf \ + --set QT_PLUGIN_PATH ${qtbase.bin}/${qtbase.qtPluginPrefix}:${qtsvg.bin}/${qtbase.qtPluginPrefix} + ''; + + meta = with stdenv.lib; { + homepage = https://www.xpdfreader.com; + description = "Viewer for Portable Document Format (PDF) files"; + license = with licenses; [ gpl2 gpl3 ]; + platforms = platforms.unix; + maintainers = [ maintainers.peti ]; + }; +} diff --git a/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.nix b/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.nix new file mode 100644 index 000000000000..cf6f5f32ee2a --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.nix @@ -0,0 +1,52 @@ +{ stdenv, fetchurl +}: + +stdenv.mkDerivation { + name = "libxpdf-3.02pl4"; + + src = fetchurl { + url = ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02.tar.gz; + sha256 = "000zq4ddbwyxiki4vdwpmxbnw5n9hsg9hvwra2p33hslyib7sfmk"; + }; + + patches = [ + (fetchurl { + url = ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02pl1.patch; + sha256 = "1wxv9l0d2kkwi961ihpdwi75whdvk7cgqxkbfym8cjj11fq17xjq"; + }) + (fetchurl { + url = ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02pl2.patch; + sha256 = "1nfrgsh9xj0vryd8h65myzd94bjz117y89gq0hzji9dqn23xihfi"; + }) + (fetchurl { + url = ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02pl3.patch; + sha256 = "0jskkv8x6dqr9zj4azaglas8cziwqqrkbbnzrpm2kzrvsbxyhk2r"; + }) + (fetchurl { + url = ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02pl4.patch; + sha256 = "1c48h7aizx0ngmzlzw0mpja1w8vqyy3pg62hyxp7c60k86al715h"; + }) + ./xpdf-3.02-protection.patch + ./libxpdf.patch + ]; + + installPhase = '' + mkdir -p $out/lib/goo + mkdir -p $out/lib/fofi + mkdir -p $out/lib/xpdf + mkdir -p $out/include + + cp -v goo/libGoo.a $out/lib/goo + cp -v fofi/libfofi.a $out/lib/fofi + cp -v xpdf/libxpdf.a $out/lib/xpdf + + cp -v *.h $out/include + cp -v goo/*.h $out/include + cp -v fofi/*.h $out/include + cp -v xpdf/*.h $out/include + ''; + + meta = { + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.patch b/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.patch new file mode 100644 index 000000000000..606da76c7293 --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.patch @@ -0,0 +1,45 @@ +diff -rc xpdf-3.02/xpdf/Makefile.in xpdf-3.02-new/xpdf/Makefile.in +*** xpdf-3.02/xpdf/Makefile.in 2007-02-27 23:05:52.000000000 +0100 +--- xpdf-3.02-new/xpdf/Makefile.in 2010-08-25 14:54:14.000000000 +0200 +*************** +*** 110,116 **** + pdffonts$(EXE) pdftoppm$(EXE) pdfimages$(EXE) + + all-no-x: pdftops$(EXE) pdftotext$(EXE) pdfinfo$(EXE) pdffonts$(EXE) \ +! pdfimages$(EXE) + + #------------------------------------------------------------------------ + +--- 110,116 ---- + pdffonts$(EXE) pdftoppm$(EXE) pdfimages$(EXE) + + all-no-x: pdftops$(EXE) pdftotext$(EXE) pdfinfo$(EXE) pdffonts$(EXE) \ +! pdfimages$(EXE) libxpdf.a + + #------------------------------------------------------------------------ + +*************** +*** 248,253 **** +--- 248,269 ---- + + #------------------------------------------------------------------------ + ++ PDFTOEPDF_OBJS = \ ++ Array.o BuiltinFont.o BuiltinFontTables.o CMap.o \ ++ Catalog.o CharCodeToUnicode.o Decrypt.o Dict.o Error.o \ ++ FontEncodingTables.o Gfx.o GfxFont.o GfxState.o \ ++ GlobalParams.o JArithmeticDecoder.o JBIG2Stream.o JPXStream.o Lexer.o Link.o \ ++ NameToCharCode.o Object.o OutputDev.o Outline.o PDFDoc.o Page.o \ ++ Parser.o PDFDocEncoding.o Stream.o UnicodeMap.o XRef.o Function.o \ ++ PSTokenizer.o UnicodeTypeTable.o ++ ++ libxpdf.a: $(PDFTOEPDF_OBJS) ++ rm -f $@ ++ $(AR) $(ARFLAGS) $@ *.o ++ ranlib $@ ++ ++ #------------------------------------------------------------------------ ++ + depend: + $(CXX) $(CXXFLAGS) -MM $(CXX_SRC) >Makefile.dep + diff --git a/nixpkgs/pkgs/applications/misc/xpdf/xpdf-3.02-protection.patch b/nixpkgs/pkgs/applications/misc/xpdf/xpdf-3.02-protection.patch new file mode 100644 index 000000000000..598fc6dbd073 --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/xpdf/xpdf-3.02-protection.patch @@ -0,0 +1,74 @@ +diff -C 3 -r orig/xpdf/pdfimages.cc xpdf-3.02/xpdf/pdfimages.cc +*** orig/xpdf/pdfimages.cc 2007-02-27 23:05:52.000000000 +0100 +--- xpdf-3.02/xpdf/pdfimages.cc 2007-10-31 20:17:22.601449943 +0100 +*************** +*** 118,130 **** + goto err1; + } + +- // check for copy permission +- if (!doc->okToCopy()) { +- error(-1, "Copying of images from this document is not allowed."); +- exitCode = 3; +- goto err1; +- } +- + // get page range + if (firstPage < 1) + firstPage = 1; +--- 118,123 ---- +diff -C 3 -r orig/xpdf/pdftotext.cc xpdf-3.02/xpdf/pdftotext.cc +*** orig/xpdf/pdftotext.cc 2007-02-27 23:05:52.000000000 +0100 +--- xpdf-3.02/xpdf/pdftotext.cc 2007-10-31 20:17:34.392224196 +0100 +*************** +*** 160,172 **** + goto err2; + } + +- // check for copy permission +- if (!doc->okToCopy()) { +- error(-1, "Copying of text from this document is not allowed."); +- exitCode = 3; +- goto err2; +- } +- + // construct text file name + if (argc == 3) { + textFileName = new GString(argv[2]); +--- 160,165 ---- +diff -C 3 -r orig/xpdf/XPDFCore.cc xpdf-3.02/xpdf/XPDFCore.cc +*** orig/xpdf/XPDFCore.cc 2007-02-27 23:05:52.000000000 +0100 +--- xpdf-3.02/xpdf/XPDFCore.cc 2007-10-31 20:18:05.370494431 +0100 +*************** +*** 384,394 **** + #ifndef NO_TEXT_SELECT + if (selectULX != selectLRX && + selectULY != selectLRY) { +! if (doc->okToCopy()) { +! copySelection(); +! } else { +! error(-1, "Copying of text from this document is not allowed."); +! } + } + #endif + } +--- 384,390 ---- + #ifndef NO_TEXT_SELECT + if (selectULX != selectLRX && + selectULY != selectLRY) { +! copySelection(); + } + #endif + } +*************** +*** 407,415 **** + int pg; + double ulx, uly, lrx, lry; + +- if (!doc->okToCopy()) { +- return; +- } + if (getSelection(&pg, &ulx, &uly, &lrx, &lry)) { + //~ for multithreading: need a mutex here + if (currentSelection) { +--- 403,408 ---- |