[packages/libimobiledevice] - python3 fixes from git
qboosh
qboosh at pld-linux.org
Sat Apr 12 21:17:37 CEST 2025
commit 32d342e163278d6bd134499e140fbd1f293ef562
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Sat Apr 12 21:08:52 2025 +0200
- python3 fixes from git
libimobiledevice-python3.patch | 276 +++++++++++++++++++++++++++++++++++++++++
libimobiledevice.spec | 2 +
2 files changed, 278 insertions(+)
---
diff --git a/libimobiledevice.spec b/libimobiledevice.spec
index c5e7fcb..33fce44 100644
--- a/libimobiledevice.spec
+++ b/libimobiledevice.spec
@@ -24,6 +24,7 @@ Source0: https://github.com/libimobiledevice/libimobiledevice/releases/download/
# Source0-md5: c50a3a32acf33dc8c9ec88137ad12ec4
Patch0: %{name}-cython.patch
Patch1: %{name}-libplist.patch
+Patch2: %{name}-python3.patch
URL: https://libimobiledevice.org/
BuildRequires: autoconf >= 2.64
BuildRequires: automake
@@ -134,6 +135,7 @@ Wiązania libimobiledevice dla Pythona 3.
%setup -q
%patch -P 0 -p1
%patch -P 1 -p1
+%patch -P 2 -p1
%build
%{__libtoolize}
diff --git a/libimobiledevice-python3.patch b/libimobiledevice-python3.patch
new file mode 100644
index 0000000..1eb5a9d
--- /dev/null
+++ b/libimobiledevice-python3.patch
@@ -0,0 +1,276 @@
+From 7044571b4f243d2fda4dd3aa491f2f279787ee19 Mon Sep 17 00:00:00 2001
+From: wendyisgr33n <wendyisgr33n at gmail.com>
+Date: Mon, 30 Jul 2018 10:43:57 -0700
+Subject: [PATCH] Fixed AFC afc.pxi definitions for Python2/3 compatibility.
+ Added missing public method 'remove_path_and_contents'
+
+---
+ cython/afc.pxi | 28 ++++++++++++++++------------
+ 1 file changed, 16 insertions(+), 12 deletions(-)
+
+diff --git a/cython/afc.pxi b/cython/afc.pxi
+index e34588f96..6bd81824d 100644
+--- a/cython/afc.pxi
++++ b/cython/afc.pxi
+@@ -52,6 +52,7 @@ cdef extern from "libimobiledevice/afc.h":
+ afc_error_t afc_read_directory(afc_client_t client, char *dir, char ***list)
+ afc_error_t afc_get_file_info(afc_client_t client, char *filename, char ***infolist)
+ afc_error_t afc_remove_path(afc_client_t client, char *path)
++ afc_error_t afc_remove_path_and_contents(afc_client_t client, char *path)
+ afc_error_t afc_rename_path(afc_client_t client, char *f, char *to)
+ afc_error_t afc_make_directory(afc_client_t client, char *dir)
+ afc_error_t afc_truncate(afc_client_t client, char *path, uint64_t newsize)
+@@ -235,17 +236,17 @@ cdef class AfcClient(BaseService):
+ afc_file_mode_t c_mode
+ uint64_t handle
+ AfcFile f
+- if mode == <bytes>'r':
++ if mode == b'r':
+ c_mode = AFC_FOPEN_RDONLY
+- elif mode == <bytes>'r+':
++ elif mode == b'r+':
+ c_mode = AFC_FOPEN_RW
+- elif mode == <bytes>'w':
++ elif mode == b'w':
+ c_mode = AFC_FOPEN_WRONLY
+- elif mode == <bytes>'w+':
++ elif mode == b'w+':
+ c_mode = AFC_FOPEN_WR
+- elif mode == <bytes>'a':
++ elif mode == b'a':
+ c_mode = AFC_FOPEN_APPEND
+- elif mode == <bytes>'a+':
++ elif mode == b'a+':
+ c_mode = AFC_FOPEN_RDAPPEND
+ else:
+ raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'")
+@@ -282,6 +283,9 @@ cdef class AfcClient(BaseService):
+ cpdef remove_path(self, bytes path):
+ self.handle_error(afc_remove_path(self._c_client, path))
+
++ cpdef remove_path_and_contents(self, bytes path):
++ self.handle_error(afc_remove_path_and_contents(self._c_client, path))
++
+ cpdef rename_path(self, bytes f, bytes t):
+ self.handle_error(afc_rename_path(self._c_client, f, t))
+
+@@ -308,17 +312,17 @@ cdef class Afc2Client(AfcClient):
+ afc_file_mode_t c_mode
+ uint64_t handle
+ AfcFile f
+- if mode == <bytes>'r':
++ if mode == b'r':
+ c_mode = AFC_FOPEN_RDONLY
+- elif mode == <bytes>'r+':
++ elif mode == b'r+':
+ c_mode = AFC_FOPEN_RW
+- elif mode == <bytes>'w':
++ elif mode == b'w':
+ c_mode = AFC_FOPEN_WRONLY
+- elif mode == <bytes>'w+':
++ elif mode == b'w+':
+ c_mode = AFC_FOPEN_WR
+- elif mode == <bytes>'a':
++ elif mode == b'a':
+ c_mode = AFC_FOPEN_APPEND
+- elif mode == <bytes>'a+':
++ elif mode == b'a+':
+ c_mode = AFC_FOPEN_RDAPPEND
+ else:
+ raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'")
+From 1df0e4bfe86fde89772bf54d06c4546af85e303c Mon Sep 17 00:00:00 2001
+From: wendyisgr33n <wendyisgr33n at gmail.com>
+Date: Mon, 30 Jul 2018 10:44:40 -0700
+Subject: [PATCH] Fixed debugserver.pxi PyString_AsString compatibility with
+ Python3
+
+---
+ cython/debugserver.pxi | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/cython/debugserver.pxi b/cython/debugserver.pxi
+index 4ecb9e1a1..a3b7d1e53 100644
+--- a/cython/debugserver.pxi
++++ b/cython/debugserver.pxi
+@@ -44,7 +44,12 @@ cdef class DebugServerError(BaseError):
+
+
+ # from http://stackoverflow.com/a/17511714
+-from cpython.string cimport PyString_AsString
++# https://github.com/libimobiledevice/libimobiledevice/pull/198
++from cpython cimport PY_MAJOR_VERSION
++if PY_MAJOR_VERSION <= 2:
++ from cpython.string cimport PyString_AsString
++else:
++ from cpython.bytes cimport PyBytes_AsString as PyString_AsString
+ cdef char ** to_cstring_array(list_str):
+ if not list_str:
+ return NULL
+From 88ea0e3b553c26bddb7e49ec2aac6197c84aab25 Mon Sep 17 00:00:00 2001
+From: wendyisgr33n <wendyisgr33n at gmail.com>
+Date: Mon, 30 Jul 2018 10:45:22 -0700
+Subject: [PATCH] Fixed bytes/strings check in imobiledevice.pyx for
+ compatibility with Python2/3
+
+---
+ cython/imobiledevice.pyx | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx
+index aac4fdbc5..2a125aa18 100644
+--- a/cython/imobiledevice.pyx
++++ b/cython/imobiledevice.pyx
+@@ -176,7 +176,7 @@ from libc.stdlib cimport *
+ cdef class iDevice(Base):
+ def __cinit__(self, object udid=None, *args, **kwargs):
+ cdef char* c_udid = NULL
+- if isinstance(udid, basestring):
++ if isinstance(udid, (str, bytes)):
+ c_udid = <bytes>udid
+ elif udid is not None:
+ raise TypeError("iDevice's constructor takes a string or None as the udid argument")
+From 652dfdb12ebcdec64dba066550d893de17839365 Mon Sep 17 00:00:00 2001
+From: wendyisgr33n <wendyisgr33n at gmail.com>
+Date: Mon, 30 Jul 2018 10:45:55 -0700
+Subject: [PATCH] Fixed bytes/strings checks in lockdown.pxi for compatibility
+ with Python2/3
+
+---
+ cython/lockdown.pxi | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/cython/lockdown.pxi b/cython/lockdown.pxi
+index f24904974..1bf7072e1 100644
+--- a/cython/lockdown.pxi
++++ b/cython/lockdown.pxi
+@@ -230,9 +230,9 @@ cdef class LockdownClient(PropertyListService):
+
+ if issubclass(service, BaseService) and \
+ service.__service_name__ is not None \
+- and isinstance(service.__service_name__, basestring):
++ and isinstance(service.__service_name__, (str, bytes)):
+ c_service_name = <bytes>service.__service_name__
+- elif isinstance(service, basestring):
++ elif isinstance(service, (str, bytes)):
+ c_service_name = <bytes>service
+ else:
+ raise TypeError("LockdownClient.start_service() takes a BaseService or string as its first argument")
+@@ -253,7 +253,7 @@ cdef class LockdownClient(PropertyListService):
+
+ if not hasattr(service_class, '__service_name__') and \
+ not service_class.__service_name__ is not None \
+- and not isinstance(service_class.__service_name__, basestring):
++ and not isinstance(service_class.__service_name__, (str, bytes)):
+ raise TypeError("LockdownClient.get_service_client() takes a BaseService as its first argument")
+
+ descriptor = self.start_service(service_class)
+From 12d3a070717ad734b1048b1dcacffae5b903f190 Mon Sep 17 00:00:00 2001
+From: wendyisgr33n <wendyisgr33n at gmail.com>
+Date: Mon, 30 Jul 2018 10:47:48 -0700
+Subject: [PATCH] Fixed method visibility in mobilebackup2.pxi API
+
+---
+ cython/mobilebackup2.pxi | 31 ++++++++++++++++++-------------
+ 1 file changed, 18 insertions(+), 13 deletions(-)
+
+diff --git a/cython/mobilebackup2.pxi b/cython/mobilebackup2.pxi
+index 4eccae6c0..4b47e5b6f 100644
+--- a/cython/mobilebackup2.pxi
++++ b/cython/mobilebackup2.pxi
+@@ -58,10 +58,10 @@ cdef class MobileBackup2Client(PropertyListService):
+ cdef inline BaseError _error(self, int16_t ret):
+ return MobileBackup2Error(ret)
+
+- cdef send_message(self, bytes message, plist.Node options):
++ cpdef send_message(self, bytes message, plist.Node options):
+ self.handle_error(mobilebackup2_send_message(self._c_client, message, options._c_node))
+
+- cdef tuple receive_message(self):
++ cpdef tuple receive_message(self):
+ cdef:
+ char* dlmessage = NULL
+ plist.plist_t c_node = NULL
+@@ -77,29 +77,34 @@ cdef class MobileBackup2Client(PropertyListService):
+ free(dlmessage)
+ raise
+
+- cdef int send_raw(self, bytes data, int length):
++ cpdef int send_raw(self, bytes data, int length):
+ cdef:
+- uint32_t bytes = 0
++ uint32_t bytes_recvd = 0
+ mobilebackup2_error_t err
+- err = mobilebackup2_send_raw(self._c_client, data, length, &bytes)
++ err = mobilebackup2_send_raw(self._c_client, data, length, &bytes_recvd)
+ try:
+ self.handle_error(err)
+- return <bint>bytes
++ return <bint>bytes_recvd
+ except BaseError, e:
+ raise
+
+- cdef int receive_raw(self, bytes data, int length):
++ cpdef int receive_raw(self, bytearray data, int length):
+ cdef:
+- uint32_t bytes = 0
++ uint32_t bytes_recvd = 0
+ mobilebackup2_error_t err
+- err = mobilebackup2_receive_raw(self._c_client, data, length, &bytes)
++ err = mobilebackup2_receive_raw(self._c_client, data, length, &bytes_recvd)
++
++ # Throwing an exception when we test if theres more data to read is excessive
++ if err == -1 and bytes_recvd == 0:
++ return 0
++
+ try:
+ self.handle_error(err)
+- return <bint>bytes
++ return <bint>bytes_recvd
+ except BaseError, e:
+ raise
+
+- cdef float version_exchange(self, double[::1] local_versions):
++ cpdef float version_exchange(self, double[::1] local_versions):
+ cdef:
+ double[::1] temp = None
+ double remote_version = 0.0
+@@ -111,8 +116,8 @@ cdef class MobileBackup2Client(PropertyListService):
+ except BaseError, e:
+ raise
+
+- cdef send_request(self, bytes request, bytes target_identifier, bytes source_identifier, plist.Node options):
++ cpdef send_request(self, bytes request, bytes target_identifier, bytes source_identifier, plist.Node options):
+ self.handle_error(mobilebackup2_send_request(self._c_client, request, target_identifier, source_identifier, options._c_node))
+
+- cdef send_status_response(self, int status_code, bytes status1, plist.Node status2):
++ cpdef send_status_response(self, int status_code, bytes status1, plist.Node status2):
+ self.handle_error(mobilebackup2_send_status_response(self._c_client, status_code, status1, status2._c_node))
+From a7f993d45cf1516a2ed6c82fcddd9677984a65c8 Mon Sep 17 00:00:00 2001
+From: Dave Nicolson <david.nicolson at gmail.com>
+Date: Thu, 23 Nov 2023 22:28:49 +0100
+Subject: [PATCH] cython: Fix Python 3 LockdownClient exception
+
+Fixes #1110
+---
+ cython/lockdown.pxi | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/cython/lockdown.pxi b/cython/lockdown.pxi
+index 1bf7072e1..6b88f9d82 100644
+--- a/cython/lockdown.pxi
++++ b/cython/lockdown.pxi
+@@ -231,11 +231,12 @@ cdef class LockdownClient(PropertyListService):
+ if issubclass(service, BaseService) and \
+ service.__service_name__ is not None \
+ and isinstance(service.__service_name__, (str, bytes)):
+- c_service_name = <bytes>service.__service_name__
++ c_service_name_str = service.__service_name__.encode('utf-8')
+ elif isinstance(service, (str, bytes)):
+- c_service_name = <bytes>service
++ c_service_name_str = service.encode('utf-8')
+ else:
+ raise TypeError("LockdownClient.start_service() takes a BaseService or string as its first argument")
++ c_service_name = c_service_name_str
+
+ try:
+ self.handle_error(lockdownd_start_service(self._c_client, c_service_name, &c_descriptor))
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/libimobiledevice.git/commitdiff/32d342e163278d6bd134499e140fbd1f293ef562
More information about the pld-cvs-commit
mailing list