Skip to content
Snippets Groups Projects
Commit 89772bbd authored by Sertonix's avatar Sertonix Committed by Natanael Copa
Browse files

community/jbig2enc: upgrade to 0.30

parent e8c37374
No related branches found
No related tags found
1 merge request!77663[3.21] community/jbig2enc: upgrade to 0.30
Pipeline #285686 skipped
Author: zvezdochiot
Summary: changes for Python 3
URL: https://github.com/agl/jbig2enc/issues/72
----
--- a/pdf.py
+++ b/pdf.py
@@ -70,11 +70,15 @@ class Obj:
s.append(str(self.d))
if self.stream is not None:
s.append('stream\n')
- s.append(self.stream)
+# s.append(self.stream)
+ if(type(self.stream)==str):
+ s.append(self.stream)
+ else:
+ s.append(self.stream.decode(encoding="cp437"))
s.append('\nendstream\n')
s.append('endobj\n')
- return ''.join(s)
+ return (''.join(s))
class Doc:
def __init__(self):
@@ -117,24 +121,24 @@ class Doc:
# sys.stderr.write(str(offsets) + "\n")
- return '\n'.join(a)
+ return ('\n'.join(a))
def ref(x):
- return '%d 0 R' % x
+ return ('%d 0 R' % x)
-def main(symboltable='symboltable', pagefiles=glob.glob('page-*')):
+def main(symboltable='symboltable', pagefiles=glob.glob('page-*'), out='out.pdf'):
doc = Doc()
doc.add_object(Obj({'Type' : '/Catalog', 'Outlines' : ref(2), 'Pages' : ref(3)}))
doc.add_object(Obj({'Type' : '/Outlines', 'Count': '0'}))
pages = Obj({'Type' : '/Pages'})
doc.add_object(pages)
- symd = doc.add_object(Obj({}, file(symboltable, 'rb').read()))
+ symd = doc.add_object(Obj({}, open(symboltable, 'rb').read()))
page_objs = []
pagefiles.sort()
for p in pagefiles:
try:
- contents = file(p, mode='rb').read()
+ contents = open(p, mode='rb').read()
except IOError:
sys.stderr.write("error reading page file %s\n"% p)
continue
@@ -162,8 +166,10 @@ def main(symboltable='symboltable', page
pages.d.d['Count'] = str(len(page_objs))
pages.d.d['Kids'] = '[' + ' '.join([ref(x.id) for x in page_objs]) + ']'
- print str(doc)
-
+# print(str(doc))
+ fout = open(out, mode='wb')
+ fout.write(str(doc).encode(encoding="cp437"))
+ fout.close()
def usage(script, msg):
if msg:
Author: Holger Jaekel <holger.jaekel@gmx.de>
Summary: fixes shebang for Python
----
--- a/pdf.py
+++ b/pdf.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# Copyright 2006 Google Inc.
# Author: agl@imperialviolet.org (Adam Langley)
#
From a614bdb580d65653dbfe5c9925940797a065deac Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/agl/jbig2enc/pull/78
From: Federico <19206300+quaqo@users.noreply.github.com>
Date: Sun, 8 Jan 2023 14:12:51 +0100
Subject: [PATCH 1/2] Fix build with Leptonica >=1.83
From leptonica 1.83 release notes:
* Use stdatomic.h to make cloning string safe. Remove all *GetRefcount() and *ChangeRefcount() accessors.
* Remove information about fields in many structs from the public interface allheaders.h, instead putting them in internal files pix_internal.h, array_internal.h and ccbord_internal.h.
---
src/jbig2.cc | 3 +++
src/jbig2enc.cc | 8 ++++++++
src/jbig2sym.cc | 4 ++++
3 files changed, 15 insertions(+)
diff --git a/src/jbig2.cc b/src/jbig2.cc
index 0bddb90..baf62ea 100644
--- a/src/jbig2.cc
+++ b/src/jbig2.cc
@@ -29,6 +29,9 @@
#endif
#include <leptonica/allheaders.h>
+#if (LIBLEPT_MAJOR_VERSION == 1 && LIBLEPT_MINOR_VERSION >= 83) || LIBLEPT_MAJOR_VERSION > 1
+#include "leptonica/pix_internal.h"
+#endif
#include "jbig2enc.h"
diff --git a/src/jbig2enc.cc b/src/jbig2enc.cc
index 7603696..524b26f 100644
--- a/src/jbig2enc.cc
+++ b/src/jbig2enc.cc
@@ -24,6 +24,10 @@
#include <string.h>
#include <leptonica/allheaders.h>
+#if (LIBLEPT_MAJOR_VERSION == 1 && LIBLEPT_MINOR_VERSION >= 83) || LIBLEPT_MAJOR_VERSION > 1
+#include "leptonica/pix_internal.h"
+#include "leptonica/array_internal.h"
+#endif
#include <math.h>
#if defined(sun)
@@ -206,7 +210,11 @@ unite_templates(struct jbig2ctx *ctx,
numaSetValue(ctx->classer->naclass, i, new_representant);
}
}
+#if (LIBLEPT_MAJOR_VERSION == 1 && LIBLEPT_MINOR_VERSION >= 83) || LIBLEPT_MAJOR_VERSION > 1
+ ctx->classer->pixat->pix[new_representant]->refcount += ctx->classer->pixat->pix[second_template]->refcount;
+#else
pixChangeRefcount(ctx->classer->pixat->pix[new_representant],pixGetRefcount(ctx->classer->pixat->pix[second_template]));
+#endif
}
return 0;
}
diff --git a/src/jbig2sym.cc b/src/jbig2sym.cc
index b419b71..43d2ff9 100644
--- a/src/jbig2sym.cc
+++ b/src/jbig2sym.cc
@@ -29,6 +29,10 @@
#include <stdio.h>
#include <leptonica/allheaders.h>
+#if (LIBLEPT_MAJOR_VERSION == 1 && LIBLEPT_MINOR_VERSION >= 83) || LIBLEPT_MAJOR_VERSION > 1
+#include "leptonica/pix_internal.h"
+#include "leptonica/array_internal.h"
+#endif
#include <math.h>
From d211d8c9c65fbc103594580484a3b7fa0249e160 Mon Sep 17 00:00:00 2001
From: Federico <19206300+quaqo@users.noreply.github.com>
Date: Sun, 8 Jan 2023 20:15:45 +0100
Subject: [PATCH 2/2] Fix autotools with leptonica >= 1.83
From leptonica 1.83 release notes:
* Rename the autotools generated libraries from liblept to libleptonica
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 3b8404b..b38f11e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,7 @@ AC_CONFIG_COMMANDS([libtool-rpath-patch],
fi],
[libtool_patch_use_rpath=$enable_rpath])
-AC_CHECK_LIB([lept], [findFileFormatStream], [], [
+AC_CHECK_LIB([leptonica], [findFileFormatStream], [], [
echo "Error! Leptonica not detected."
exit -1
])
# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=jbig2enc
pkgver=0.29
pkgrel=4
pkgver=0.30
pkgrel=0
pkgdesc="JBIG2 Encoder"
url="https://github.com/agl/jbig2enc"
arch="all"
......@@ -16,11 +16,11 @@ makedepends="
libtool
"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev"
source="jbig2enc-$pkgver.tar.gz::https://github.com/agl/jbig2enc/archive/$pkgver.tar.gz
10-python3.patch
20-shebang.patch
30-leptonica-183.patch
"
source="jbig2enc-$pkgver.tar.gz::https://github.com/agl/jbig2enc/archive/$pkgver.tar.gz"
# secfixes:
# 0.30-r0:
# - CVE-2018-11230
build() {
./autogen.sh
......@@ -43,8 +43,5 @@ package() {
}
sha512sums="
aa50cdaf61ef0ae473c8139d8da2a4c374450f8d0d31e2260031e8086dab9201c303c86d50cd51427135bef500718cbc3a53baabf2bf505f8908c22a3d361c51 jbig2enc-0.29.tar.gz
7b0813f6a9aee71925320fb080d78846092f3436328208062dbfc92dafe1c90c931b5d7e28d1915f210666ddb3444405ddcee1290d67112172515fa20e0e14a8 10-python3.patch
d87e9ce391d29385a8df6654935fcc5a9ef4ef320650e4060b233c7503b380aa2ea8b77eb2f8fbd9b85eaf66e198f8aae85cf1396f032995121f7a297fec1496 20-shebang.patch
dfb344420c187e1939c8db656fa4b16ca19d36aef91d7e10f374c7c0aa697567ae8ca802cbfab6fae955fc54cf583c1a3955bedf3d3b05ff9e1644fe0816cfea 30-leptonica-183.patch
d20f7d3b9e8f633bd1d72af426ba5dba2104903072fdcd6b998550b5abee92fa02fea5542bfb4366cf6d9bdea3d747b64e9de5eccd7ef4653549780a2d3f26c6 jbig2enc-0.30.tar.gz
"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment