Package: python3-grpc-tools Version: 1.14.1-7 Tags: patch
The current code assume the result from readlink() will always fit in a buffer of size PATH_MAX, which is not true for all file systems. It also break the build on Hurd. This patch solve the problem. Also, setup.py fail to understand that Hurd support pthreads. This patch solve this problem too. diff --git a/debian/patches/1010-hurd-no-path-max.patch b/debian/patches/1010-hurd-no-path-max.patch new file mode 100644 index 0000000..fff39b3 --- /dev/null +++ b/debian/patches/1010-hurd-no-path-max.patch @@ -0,0 +1,65 @@ +Description: Stopped assuming readlink() result fit in PATH_MAX. + This avoid assuming something that might not be true for all file + systems, and get the code building on Hurd. +Author: Petter Reinholdtsen <p...@hungry.com> +Forwarded: no +Last-Update: 2025-04-21 +--- +Index: python-grpc-tools-salsa/third_party/protobuf/src/google/protobuf/compiler/command_line_interface.cc +=================================================================== +--- python-grpc-tools-salsa.orig/third_party/protobuf/src/google/protobuf/compiler/command_line_interface.cc 2025-04-21 15:55:06.384235266 +0200 ++++ python-grpc-tools-salsa/third_party/protobuf/src/google/protobuf/compiler/command_line_interface.cc 2025-04-21 15:55:30.052490544 +0200 +@@ -189,6 +189,33 @@ + return true; + } + ++/* from ++ * <URL:https://buildsecurityin.us-cert.gov/bsi/articles/knowledge/coding/806-BSI.html>. ++ * via ++ * <URL:https://www.gnu.org/software/hurd//user/tlecarrour/porting_guide_for_dummies.html> ++*/ ++static char *readlink_malloc(const char *filename) ++{ ++ int size = 100; ++ ++ while (1) { ++ char *buff = (char*)malloc(size); ++ if (buff == NULL) ++ return NULL; ++ int nchars = readlink(filename, buff, size); ++ if (nchars < 0) { ++ free(buff); ++ return NULL; ++ } ++ if (nchars < size) { ++ buff[nchars] = '\0'; ++ return buff; ++ } ++ free (buff); ++ size *= 2; ++ } ++} ++ + // Get the absolute path of this protoc binary. + bool GetProtocAbsolutePath(string* path) { + #ifdef _WIN32 +@@ -205,11 +232,17 @@ + len = strlen(buffer); + } + #else +- char buffer[PATH_MAX]; +- int len = readlink("/proc/self/exe", buffer, PATH_MAX); ++ char *buffer = readlink_malloc("/proc/self/exe"); ++ int len; ++ if (buffer) ++ len = strlen(buffer); + #endif + if (len > 0) { + path->assign(buffer, len); ++#if !defined(_WIN32) && !defined(__APPLE__) ++ free(buffer); ++ buffer = NULL; ++#endif /* !defined(_WIN32) && !defined(__APPLE__) */ + return true; + } else { + return false; diff --git a/debian/patches/1020-hurd-pthreads.patch b/debian/patches/1020-hurd-pthreads.patch new file mode 100644 index 0000000..6c1b534 --- /dev/null +++ b/debian/patches/1020-hurd-pthreads.patch @@ -0,0 +1,42 @@ +Description: <short summary of the patch> + TODO: Put a short summary on the line above and replace this paragraph + with a longer explanation of this change. Complete the meta-information + with other relevant fields (see below for details). To make it easier, the + information below has been extracted from the changelog. Adjust it or drop + it. + . + python-grpc-tools (1.14.1-7) unstable; urgency=medium + . + * Team upload. + * Clean grpc_tools/_protoc_compiler.cpp, generated by cython. + (Closes: #1069374) +Author: Andreas Beckmann <a...@debian.org> +Bug-Debian: https://bugs.debian.org/1069374 + +--- +The information above should follow the Patch Tagging Guidelines, please +checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here +are templates for supplementary fields that you might want to add: + +Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>) +Bug: <upstream-bugtracker-url> +Bug-Debian: https://bugs.debian.org/<bugnumber> +Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> +Forwarded: (no|not-needed|<patch-forwarded-url>) +Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>) +Reviewed-By: <name and email of someone who approved/reviewed the patch> +Last-Update: 2025-04-21 + +Index: python-grpc-tools-salsa/setup.py +=================================================================== +--- python-grpc-tools-salsa.orig/setup.py 2025-04-21 16:39:49.137706024 +0200 ++++ python-grpc-tools-salsa/setup.py 2025-04-21 16:41:03.618588970 +0200 +@@ -113,7 +113,7 @@ + DEFINE_MACROS += (('WIN32_LEAN_AND_MEAN', 1),) + if '64bit' in platform.architecture()[0]: + DEFINE_MACROS += (('MS_WIN64', 1),) +-elif "linux" in sys.platform or "darwin" in sys.platform: ++elif "linux" in sys.platform or "gnu0" in sys.platform or "darwin" in sys.platform: + DEFINE_MACROS += (('HAVE_PTHREAD', 1),) + + # By default, Python3 distutils enforces compatibility of diff --git a/debian/patches/series b/debian/patches/series index 55b107a..b3813c1 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,3 +2,5 @@ setuptools-60 cython-0.29.32 0020-generic-64-compareandswap.patch replace-pkg_resources-with-importlib-and-packaging.patch +1010-hurd-no-path-max.patch +1020-hurd-pthreads.patch -- Happy hacking Petter Reinholdtsen