Skip to content

Commit

Permalink
hplip: Update to 3.21.10
Browse files Browse the repository at this point in the history
Update hplip to latest upstream version and patch to fix Python 3.10
compatibility.
  • Loading branch information
heindsight authored and ahesford committed Dec 8, 2021
1 parent e437bb3 commit 6f33e38
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 147 deletions.

This file was deleted.

13 changes: 13 additions & 0 deletions srcpkgs/hplip/patches/gzip_text.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Open gzipped PPD file in text mode, otherwise text regex search fails

--- a/setup.py 2021-10-18 18:37:49.795887272 +0100
+++ b/setup.py 2021-10-18 18:37:20.214898473 +0100
@@ -552,7 +552,7 @@
if os.path.exists(file_path) and os.path.isfile(file_path):

if file_path.endswith('.gz'):
- nickname = gzip.GzipFile(file_path, 'r').read(4096)
+ nickname = gzip.open(file_path, 'rt').read(4096)
else:
nickname = open(file_path, 'r').read(4096)

100 changes: 100 additions & 0 deletions srcpkgs/hplip/patches/pysizet_clean.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Based on patch by Zdenek Dohnal obtained from
https://bugs.launchpad.net/hplip/+bug/1933973

diff -pru hplip-3.21.8/io/mudext/hpmudext.c hplip-3.21.8-patched/io/mudext/hpmudext.c
--- hplip-3.21.8/io/mudext/hpmudext.c 2021-09-01 16:10:17.000000000 +0100
+++ hplip-3.21.8-patched/io/mudext/hpmudext.c 2021-10-22 08:30:38.600922861 +0100
@@ -24,6 +24,8 @@ Authors: Don Welch, David Suffield, Naga

\*****************************************************************************/

+#define PY_SSIZE_T_CLEAN
+
#include <Python.h>
#include <stdarg.h>
#include "hpmud.h"
@@ -187,14 +189,22 @@ static PyObject *write_channel(PyObject
HPMUD_CHANNEL cd;
int timeout = 30;
char * buf;
- int buf_size = 0;
+ Py_ssize_t buf_size = 0;
+ int buf_size_asInt = 0;
int bytes_written = 0;

if (!PyArg_ParseTuple(args, "iis#|i", &dd, &cd, &buf, &buf_size, &timeout))
return NULL;

+ if (buf_size < INT_MIN)
+ buf_size_asInt = INT_MIN;
+ else if (buf_size > INT_MAX)
+ buf_size_asInt = INT_MAX;
+ else
+ buf_size_asInt = (int)buf_size;
+
Py_BEGIN_ALLOW_THREADS
- result = hpmud_write_channel(dd, cd, buf, buf_size, timeout, &bytes_written);
+ result = hpmud_write_channel(dd, cd, buf, buf_size_asInt, timeout, &bytes_written);
Py_END_ALLOW_THREADS

return Py_BuildValue("(ii)", result, bytes_written);
@@ -231,14 +241,22 @@ static PyObject *set_pml(PyObject *self,
char * oid;
int type;
char * data;
- int data_size;
+ Py_ssize_t data_size = 0;
+ int data_size_asInt = 0;
int pml_result;

if (!PyArg_ParseTuple(args, "iisis#", &dd, &cd, &oid, &type, &data, &data_size))
return NULL;

+ if (data_size < INT_MIN)
+ data_size_asInt = INT_MIN;
+ else if (data_size > INT_MAX)
+ data_size_asInt = INT_MAX;
+ else
+ data_size_asInt = (int)data_size;
+
Py_BEGIN_ALLOW_THREADS
- result = hpmud_set_pml(dd, cd, oid, type, (void *)data, data_size, &pml_result);
+ result = hpmud_set_pml(dd, cd, oid, type, (void *)data, data_size_asInt, &pml_result);
Py_END_ALLOW_THREADS

return Py_BuildValue("(ii)", result, pml_result);
diff -pru hplip-3.21.8/pcard/pcardext/pcardext.c hplip-3.21.8-patched/pcard/pcardext/pcardext.c
--- hplip-3.21.8/pcard/pcardext/pcardext.c 2021-09-01 16:10:17.000000000 +0100
+++ hplip-3.21.8-patched/pcard/pcardext/pcardext.c 2021-10-22 08:24:11.010798381 +0100
@@ -24,6 +24,8 @@ Author: Don Welch

\*****************************************************************************/

+#define PY_SSIZE_T_CLEAN
+
#include <Python.h>
#include <structmember.h>
#include "../fat.h"
diff -pru hplip-3.21.8/prnt/cupsext/cupsext.c hplip-3.21.8-patched/prnt/cupsext/cupsext.c
--- hplip-3.21.8/prnt/cupsext/cupsext.c 2021-09-01 16:10:17.000000000 +0100
+++ hplip-3.21.8-patched/prnt/cupsext/cupsext.c 2021-10-22 08:26:30.975843330 +0100
@@ -73,6 +73,7 @@ Yashwant Kumar Sahu
Sanjay Kumar
*/

+#define PY_SSIZE_T_CLEAN

#include <Python.h>
#include <structmember.h>
diff -pru hplip-3.21.8/scan/scanext/scanext.c hplip-3.21.8-patched/scan/scanext/scanext.c
--- hplip-3.21.8/scan/scanext/scanext.c 2021-09-01 16:10:17.000000000 +0100
+++ hplip-3.21.8-patched/scan/scanext/scanext.c 2021-10-21 21:31:23.074739743 +0100
@@ -45,6 +45,8 @@ PERFORMANCE OF THIS SOFTWARE.
*******************************************************************/


+#define PY_SSIZE_T_CLEAN
+
/* _ScanDevice objects */

#include "Python.h"
37 changes: 37 additions & 0 deletions srcpkgs/hplip/patches/remove-imageprocessing-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--- a/Makefile.am
+++ b/Makefile.am
@@ -167,7 +167,7 @@
dist_hplip_SCRIPTS = hpssd.py __init__.py hpdio.py
endif #HPLIP_CLASS_DRIVER

-dist_noinst_DATA += prnt/drv/hpijs.drv.in.template prnt/drv/hpcups.drv.in.template prnt/hpcups/libImageProcessor-x86_64.so prnt/hpcups/libImageProcessor-x86_32.so
+dist_noinst_DATA += prnt/drv/hpijs.drv.in.template prnt/drv/hpcups.drv.in.template

dist_noinst_DATA += prnt/ipp-usb/HPLIP.conf
dist_noinst_SCRIPTS += dat2drv.py install.py hplip-install init-suse-firewall init-iptables-firewall class_rpm_build.sh hplipclassdriver.spec createPPD.sh Makefile_dat2drv hpijs-drv
@@ -597,7 +597,7 @@
prnt/hpcups/ImageProcessor.h

hpcups_CXXFLAGS = $(APDK_ENDIAN_FLAG) $(DBUS_CFLAGS)
-hpcups_LDADD = -L./prnt/hpcups/ -ljpeg -ldl -lImageProcessor -lcups -lcupsimage -lz $(DBUS_LIBS)
+hpcups_LDADD = -L./prnt/hpcups/ -ljpeg -ldl -lcups -lcupsimage -lz $(DBUS_LIBS)
#else
#hpcupsdir = $(cupsfilterdir)
#hpcups_PROGRAMS = hpcups
@@ -687,16 +687,6 @@

install-data-hook:
if HPLIP_BUILD
- if [ \( "$(UNAME)" = "x86_64" -a -d "$(libdir)/" \) ]; then \
- cp prnt/hpcups/libImageProcessor-x86_64.so $(libdir)/ ; \
- chmod 775 $(libdir)/libImageProcessor-x86_64.so ; \
- ln -sf $(libdir)/libImageProcessor-x86_64.so $(libdir)/libImageProcessor.so ; \
- fi; \
- if [ \( \( "$(UNAME)" = "i686" -o "$(UNAME)" = "i386" \) -a -d "$(libdir)/" \) ]; then \
- cp prnt/hpcups/libImageProcessor-x86_32.so $(libdir)/ ; \
- chmod 775 $(libdir)/libImageProcessor-x86_32.so ; \
- ln -sf $(libdir)/libImageProcessor-x86_32.so $(libdir)/libImageProcessor.so ; \
- fi
if [ -d "/usr/share/ipp-usb/quirks/" ]; then \
echo "ipp-usb directory exists"; \
cp prnt/ipp-usb/HPLIP.conf /usr/share/ipp-usb/quirks/ ; \
31 changes: 0 additions & 31 deletions srcpkgs/hplip/patches/sane.patch

This file was deleted.

8 changes: 5 additions & 3 deletions srcpkgs/hplip/template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Template file for 'hplip'
pkgname=hplip
version=3.20.9
revision=6
version=3.21.10
revision=1
build_style=gnu-configure
pycompile_dirs="usr/share/hplip"
# configure checks sys.version[:3] for Python versioning, so 3.10 becomes 3.1;
Expand All @@ -19,6 +19,7 @@ configure_args="
--enable-hpijs-install
--enable-foomatic-drv-install
--enable-pp-build
--disable-imageProcessor-build
--with-mimedir=/usr/share/cups/mime
am_cv_python_version=${py3_ver}"
conf_files="/etc/hp/hplip.conf"
Expand All @@ -33,8 +34,9 @@ short_desc="HP Linux Imaging and Printing"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-only, BSD-3-Clause, MIT"
homepage="https://developers.hp.com/hp-linux-imaging-and-printing"
changelog="https://developers.hp.com/hp-linux-imaging-and-printing/release_notes"
distfiles="${SOURCEFORGE_SITE}/hplip/hplip/${version}/hplip-${version}.tar.gz"
checksum=36251189aa9cc349f6a3eacbb7ac3c4fd26fc9f087c9f75cee051010c85d2ddf
checksum=de230e1fdd1e718fc718417265612e0c882949e08fe045ee56f9f9882e6b6a60
conflicts="hplip-gui"

CFLAGS="-I${XBPS_CROSS_BASE}/usr/include/libusb-1.0 -I${XBPS_CROSS_BASE}/${py3_inc}"
Expand Down

0 comments on commit 6f33e38

Please sign in to comment.