commit:     864b528b1db3f4e946a21c7badac1448f13feaea
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 12 16:27:11 2019 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sat Jan 12 20:07:04 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=864b528b

sci-libs/gdal: Fix build with poppler-0.71 and poppler-0.72

Bug: https://bugs.gentoo.org/674556
Package-Manager: Portage-2.3.55, Repoman-2.3.12
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../gdal/files/gdal-2.3.1-poppler-0.71.0.patch     | 82 ++++++++++++++++++++++
 .../gdal/files/gdal-2.3.1-poppler-0.72.0.patch     | 58 +++++++++++++++
 sci-libs/gdal/gdal-2.3.1.ebuild                    |  7 +-
 3 files changed, 146 insertions(+), 1 deletion(-)

diff --git a/sci-libs/gdal/files/gdal-2.3.1-poppler-0.71.0.patch 
b/sci-libs/gdal/files/gdal-2.3.1-poppler-0.71.0.patch
new file mode 100644
index 00000000000..90ee94d0621
--- /dev/null
+++ b/sci-libs/gdal/files/gdal-2.3.1-poppler-0.71.0.patch
@@ -0,0 +1,82 @@
+Description: Add support for Poppler 0.71.0.
+Author: Even Rouault <[email protected]>
+Origin: 
https://github.com/OSGeo/gdal/commit/4cc0215b8f2cef3582265cdfaf16589390697706
+Bug: https://github.com/OSGeo/gdal/issues/1121
+Bug-Debian: https://bugs.debian.org/915722
+
+--- a/frmts/pdf/pdfdataset.cpp
++++ b/frmts/pdf/pdfdataset.cpp
+@@ -2593,18 +2593,25 @@ static void PDFDatasetErrorFunctionCommo
+ }
+ 
+ #ifdef POPPLER_0_20_OR_LATER
+-static void PDFDatasetErrorFunction(CPL_UNUSED void* userData, CPL_UNUSED 
ErrorCategory eErrCategory,
++
++static void PDFDatasetErrorFunction(void* /* userData*/,
++                                    ErrorCategory /* eErrCategory */,
+ #ifdef POPPLER_0_23_OR_LATER
+                                     Goffset nPos,
+ #else
+                                     int nPos,
+ #endif
+-                                    char *pszMsg)
++#ifdef POPPLER_0_71_OR_LATER
++                                    const char *pszMsg
++#else
++                                    char *pszMsg
++#endif
++                                   )
+ {
+     CPLString osError;
+ 
+     if (nPos >= 0)
+-        osError.Printf("Pos = %d, ", (int)nPos);
++        osError.Printf("Pos = " CPL_FRMT_GUIB ", ", 
static_cast<GUIntBig>(nPos));
+     osError += pszMsg;
+     PDFDatasetErrorFunctionCommon(osError);
+ }
+@@ -4442,7 +4449,7 @@ GDALDataset *PDFDataset::Open( GDALOpenI
+ #ifdef HAVE_POPPLER
+     if (bUseLib.test(PDFLIB_POPPLER))
+     {
+-        PDFRectangle* psMediaBox = poPagePoppler->getMediaBox();
++        const auto* psMediaBox = poPagePoppler->getMediaBox();
+         dfX1 = psMediaBox->x1;
+         dfY1 = psMediaBox->y1;
+         dfX2 = psMediaBox->x2;
+@@ -4780,14 +4787,12 @@ GDALDataset *PDFDataset::Open( GDALOpenI
+     GooString* poMetadata = poCatalogPoppler->readMetadata();
+     if (poMetadata)
+     {
+-        char* pszContent = poMetadata->getCString();
++        const char* pszContent = poMetadata->getCString();
+         if (pszContent != nullptr &&
+             STARTS_WITH(pszContent, "<?xpacket begin="))
+         {
+-            char *apszMDList[2];
+-            apszMDList[0] = pszContent;
+-            apszMDList[1] = nullptr;
+-            poDS->SetMetadata(apszMDList, "xml:XMP");
++            const char * const apszMDList[2] = { pszContent, nullptr };
++            poDS->SetMetadata(const_cast<char**>(apszMDList), "xml:XMP");
+         }
+         delete poMetadata;
+     }
+--- a/frmts/pdf/pdfio.h
++++ b/frmts/pdf/pdfio.h
+@@ -58,6 +58,15 @@
+ #define makeSubStream_object_type Object*
+ #endif
+ 
++// Detect Poppler 0.71 that no longer defines GBool
++#ifdef POPPLER_0_69_OR_LATER
++#ifndef initObj
++#define POPPLER_0_71_OR_LATER
++#define GBool bool
++#define gFalse false
++#endif
++#endif
++
+ class VSIPDFFileStream: public BaseStream
+ {
+     public:

diff --git a/sci-libs/gdal/files/gdal-2.3.1-poppler-0.72.0.patch 
b/sci-libs/gdal/files/gdal-2.3.1-poppler-0.72.0.patch
new file mode 100644
index 00000000000..3302df9100d
--- /dev/null
+++ b/sci-libs/gdal/files/gdal-2.3.1-poppler-0.72.0.patch
@@ -0,0 +1,58 @@
+From b471814ef406582f2b1bc0aabbe430c0026608c7 Mon Sep 17 00:00:00 2001
+From: Andreas Sturmlechner <[email protected]>
+Date: Sat, 12 Jan 2019 17:21:54 +0100
+Subject: [PATCH] Fix build with poppler-0.72.0
+
+Non-upstreamable patch that breaks backward compatibility.
+---
+ frmts/pdf/pdfdataset.cpp | 4 ++--
+ frmts/pdf/pdfobject.cpp  | 4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/frmts/pdf/pdfdataset.cpp b/frmts/pdf/pdfdataset.cpp
+index 84fe1fe..38b8c30 100644
+--- a/frmts/pdf/pdfdataset.cpp
++++ b/frmts/pdf/pdfdataset.cpp
+@@ -3459,7 +3459,7 @@ void PDFDataset::FindLayersPoppler()
+ #endif
+             if( ocg != nullptr && ocg->getName() != nullptr )
+             {
+-                const char* pszLayerName = (const 
char*)ocg->getName()->getCString();
++                const char* pszLayerName = (const 
char*)ocg->getName()->c_str();
+                 AddLayer(pszLayerName);
+                 oLayerOCGMapPoppler[pszLayerName] = ocg;
+             }
+@@ -4787,7 +4787,7 @@ GDALDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo 
)
+     GooString* poMetadata = poCatalogPoppler->readMetadata();
+     if (poMetadata)
+     {
+-        const char* pszContent = poMetadata->getCString();
++        const char* pszContent = poMetadata->c_str();
+         if (pszContent != nullptr &&
+             STARTS_WITH(pszContent, "<?xpacket begin="))
+         {
+diff --git a/frmts/pdf/pdfobject.cpp b/frmts/pdf/pdfobject.cpp
+index 0a5f907..9bed6c1 100644
+--- a/frmts/pdf/pdfobject.cpp
++++ b/frmts/pdf/pdfobject.cpp
+@@ -1061,7 +1061,7 @@ const CPLString& GDALPDFObjectPoppler::GetString()
+ #else
+         GooString* gooString = m_po->getString();
+ #endif
+-        return (osStr = GDALPDFGetUTF8StringFromBytes(reinterpret_cast<const 
GByte*>(gooString->getCString()),
++        return (osStr = GDALPDFGetUTF8StringFromBytes(reinterpret_cast<const 
GByte*>(gooString->c_str()),
+                                                       
static_cast<int>(gooString->getLength())));
+     }
+     else
+@@ -1422,7 +1422,7 @@ char* GDALPDFStreamPoppler::GetBytes()
+         char* pszContent = (char*) VSIMalloc(m_nLength + 1);
+         if (pszContent)
+         {
+-            memcpy(pszContent, gstr->getCString(), m_nLength);
++            memcpy(pszContent, gstr->c_str(), m_nLength);
+             pszContent[m_nLength] = '\0';
+         }
+         delete gstr;
+-- 
+2.20.1
+

diff --git a/sci-libs/gdal/gdal-2.3.1.ebuild b/sci-libs/gdal/gdal-2.3.1.ebuild
index 317b386da9e..7af0dee0851 100644
--- a/sci-libs/gdal/gdal-2.3.1.ebuild
+++ b/sci-libs/gdal/gdal-2.3.1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -83,6 +83,7 @@ PATCHES=(
        "${FILESDIR}/${PN}-2.2.3-bashcomp-path.patch" # bug 641866
        "${FILESDIR}/${PN}-2.3.0-curl.patch" # bug 659840
        "${FILESDIR}/${PN}-2.3.1-poppler-0.69.0.patch"
+       "${FILESDIR}/${PN}-2.3.1-poppler-0.71.0.patch" # bug 674556
 )
 
 src_prepare() {
@@ -119,6 +120,9 @@ src_prepare() {
 
        default
 
+       # not upstreamable, not fixed in 2.4.0 or master as of 2019-01-12:
+       has_version ">=app-text/poppler-0.72.0" && eapply 
"${FILESDIR}/${PN}-2.3.1-poppler-0.72.0.patch"
+
        eautoreconf
 }
 
@@ -311,6 +315,7 @@ src_install() {
        fi
 
        doman "${S}"/man/man*/*
+       find "${ED}" -name '*.la' -delete || die
 }
 
 pkg_postinst() {

Reply via email to