diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/misc/xpdf')
5 files changed, 270 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..f5ec9b71503e --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/xpdf/default.nix @@ -0,0 +1,83 @@ +{ enableGUI ? true +, enablePDFtoPPM ? true +, enablePrinting ? true +, stdenv, fetchzip, cmake, makeDesktopItem +, zlib, libpng, cups ? null, freetype ? null +, qtbase ? null, qtsvg ? null, wrapQtAppsHook +}: + +assert enableGUI -> qtbase != null && qtsvg != null && freetype != null; +assert enablePDFtoPPM -> freetype != null; +assert enablePrinting -> cups != null; + +stdenv.mkDerivation rec { + pname = "xpdf"; + version = "4.02"; + + src = fetchzip { + url = "https://xpdfreader-dl.s3.amazonaws.com/${pname}-${version}.tar.gz"; + sha256 = "0dzwq6fnk013wa4l5mjpvm4mms2mh5hbrxv4rhk2ab5ljbzz7b2w"; + }; + + # 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 ] + ++ stdenv.lib.optional enableGUI wrapQtAppsHook; + + cmakeFlags = ["-DSYSTEM_XPDFRC=/etc/xpdfrc" "-DA4_PAPER=ON" "-DOPI_SUPPORT=ON"] + ++ stdenv.lib.optional (!enablePrinting) "-DXPDFWIDGET_PRINTING=OFF"; + + buildInputs = [ zlib libpng ] ++ + stdenv.lib.optional enableGUI qtbase ++ + stdenv.lib.optional enablePrinting cups ++ + stdenv.lib.optional enablePDFtoPPM freetype; + + hardeningDisable = [ "format" ]; + + desktopItem = makeDesktopItem { + name = "xpdf"; + desktopName = "Xpdf"; + comment = "Views Adobe PDF files"; + icon = "xpdf"; + exec = "xpdf %f"; + categories = "Office;"; + terminal = "false"; + }; + + postInstall = '' + install -Dm644 ${desktopItem}/share/applications/xpdf.desktop $out/share/applications/xpdf.desktop + install -Dm644 $src/xpdf-qt/xpdf-icon.svg $out/share/pixmaps/xpdf.svg + ''; + + meta = with stdenv.lib; { + homepage = "https://www.xpdfreader.com"; + description = "Viewer for Portable Document Format (PDF) files"; + longDescription = '' + XPDF includes multiple tools for viewing and processing PDF files. + xpdf: PDF viewer (with Graphical Interface) + pdftotext: converts PDF to text + pdftops: converts PDF to PostScript + pdftoppm: converts PDF pages to netpbm (PPM/PGM/PBM) image files + pdftopng: converts PDF pages to PNG image files + pdftohtml: converts PDF to HTML + pdfinfo: extracts PDF metadata + pdfimages: extracts raw images from PDF files + pdffonts: lists fonts used in PDF files + pdfdetach: extracts attached files from PDF files + ''; + license = with licenses; [ gpl2 gpl3 ]; + platforms = platforms.unix; + maintainers = with maintainers; [ sikmir ]; + knownVulnerabilities = [ + "CVE-2018-7453: loop in PDF objects" + "CVE-2018-16369: loop in PDF objects" + "CVE-2019-9587: loop in PDF objects" + "CVE-2019-9588: loop in PDF objects" + "CVE-2019-16088: loop in PDF objects" + ]; + }; +} diff --git a/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.nix b/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.nix new file mode 100644 index 000000000000..7b7d9051ada3 --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/xpdf/libxpdf.nix @@ -0,0 +1,53 @@ +{ 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 = with stdenv.lib; { + platforms = platforms.unix; + license = licenses.gpl2; + }; +} 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 ---- |