openwrt/tools/gnulib/patches/020-python-version.patch
Michael Pratt b07b8c8b43 tools/gnulib: update to branch stable-202407
Bump to the next stable branch with the May 2025 update.

Add a patch to compensate for gnulib-tool being further split up
into independent shell and python implementations
by using a non-hidden version of the main.py file.

Add a patch for the python implementation of gnulib-tool
in order to ignore the required version of autoconf in configure.ac
being lower than the required version of autoconf for gnulib
if the version that is being run exceeds the required version for both,
and adjust existing autoconf version shell script patch to new filename.

Backport a patch for a change in function naming convention
for forward compatibility with tool releases after this stable branch.

Added:
 - 020-python-version.patch
 - 021-python-main.patch
 - 500-acl-function-name.patch

Manually Adjusted:
 - 010-autoconf-version.patch
 - 160-flag-reallocarray.patch

Existing patches are automatically refreshed.

Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/16522
Signed-off-by: Robert Marko <robimarko@gmail.com>
2025-07-26 14:38:07 +02:00

48 lines
1.8 KiB
Diff

--- a/pygnulib/functions.py
+++ b/pygnulib/functions.py
@@ -16,6 +16,8 @@
from __future__ import annotations
import os.path
+import re
+import subprocess as sp
from .constants import substart
from .GLConfig import GLConfig
@@ -50,3 +52,15 @@ def rewrite_file_name(file_name: str, co
else: # file is not a special file
result = file_name
return os.path.normpath(result)
+
+def get_version(app: str) -> str:
+ result = sp.run([app, '--version'], capture_output=True, text=True)
+ version = re.sub(r".*[v ]([0-9])", r"\1", result.stdout)
+ version_lines = [line for line in version.splitlines() if re.search(r"^[0-9]", line)]
+ version = '\n'.join(version_lines) + "\n"
+ version = re.sub(r"[^.a-z0-9-\n].*", r"", version)
+ version = re.sub(r"^([0-9]*)[a-z-].*", r"\1", version, 1)
+ version = re.sub(r"\.0*([1-9])", r".\1", version)
+ version_lines = [line for line in version.splitlines() if line.strip()]
+ version = ''.join(version_lines[0]) + "\n"
+ return version.strip()
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -40,6 +40,7 @@ from .constants import (
rmtree,
)
from .functions import rewrite_file_name
+from .functions import get_version
from .GLError import GLError
from .GLConfig import GLConfig
from .GLModuleSystem import GLModuleTable
@@ -125,7 +126,8 @@ class GLImport:
for version in versions })
self.config.setAutoconfVersion(version)
if version < 2.64:
- raise GLError(4, version)
+ # If the version of autoconf in use is high enough, do not error.
+ if float(get_version('autoconf')) < 2.64: raise GLError(4, version)
# Get other cached variables.
path = joinpath(self.config['m4base'], 'gnulib-cache.m4')