public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jakub Jelen <jjelen@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/python-tpm2-pytss] rawhide: Backport patches to work with current tpm2-tss and python (#2504590)
Date: Mon, 27 Jul 2026 09:39:36 GMT [thread overview]
Message-ID: <178514517662.1.9424583337520237615.rpms-python-tpm2-pytss-79722390dc02@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/python-tpm2-pytss
Branch : rawhide
Commit : 79722390dc02ff1ef3e731d0184dd94c3eb1b5fc
Author : Jakub Jelen <jjelen@redhat.com>
Date : 2026-07-27T11:39:22+02:00
Stats : +363/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/python-tpm2-pytss/c/79722390dc02ff1ef3e731d0184dd94c3eb1b5fc?branch=rawhide
Log:
Backport patches to work with current tpm2-tss and python (#2504590)
---
diff --git a/python-tpm2-pytss-raw-regex.patch b/python-tpm2-pytss-raw-regex.patch
new file mode 100644
index 0000000..da25c81
--- /dev/null
+++ b/python-tpm2-pytss-raw-regex.patch
@@ -0,0 +1,358 @@
+From cd433019cf109986d523ab4dc644af723f6f0d59 Mon Sep 17 00:00:00 2001
+From: Erik Larsson <who+github@cnackers.org>
+Date: Sun, 14 Jul 2024 00:01:17 +0200
+Subject: [PATCH] scripts: fix regex for header preparation
+
+There are more upstream header file changes, so make sure we handle them correctly.
+
+Signed-off-by: Erik Larsson <who+github@cnackers.org>
+---
+ scripts/prepare_headers.py | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/scripts/prepare_headers.py b/scripts/prepare_headers.py
+index a7529b36..be34fee5 100644
+--- a/scripts/prepare_headers.py
++++ b/scripts/prepare_headers.py
+@@ -37,6 +37,7 @@ def remove_common_guards(s):
+ s = re.sub(
+ "(#define [A-Za-z0-9_]+) .*\n.*?.*\)\)", "\g<1>...", s, flags=re.MULTILINE
+ )
++ s = re.sub("(#define +[A-Za-z0-9_]+) +\((-?\d+)\)", "\g<1> \g<2>", s)
+ s = re.sub("(#define [A-Za-z0-9_]+) .*", "\g<1>...", s)
+
+ # Restructure structs and untions with ...
+
+From dba34b3a0af39122381d613a7beb3a0d46b7ae21 Mon Sep 17 00:00:00 2001
+From: Erik Larsson <who+github@cnackers.org>
+Date: Mon, 3 Feb 2025 09:56:17 +0100
+Subject: [PATCH] scripts: fix regexp for poll stuff
+
+Support for zephyr in tpm2-tss broke the removal of poll conditionals.
+So make the matching more flexible.
+
+Signed-off-by: Erik Larsson <who+github@cnackers.org>
+---
+ scripts/prepare_headers.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/prepare_headers.py b/scripts/prepare_headers.py
+index be34fee5..ecbe22fd 100644
+--- a/scripts/prepare_headers.py
++++ b/scripts/prepare_headers.py
+@@ -48,7 +48,7 @@ def remove_common_guards(s):
+
+ def remove_poll_stuff(s, poll_handle_type):
+
+- r = r"#if defined\(__linux__\) \|\| defined\(__unix__\) \|\| defined\(__APPLE__\) \|\| defined \(__QNXNTO__\) \|\| defined \(__VXWORKS__\)(\n.*)+#endif\n#endif"
++ r = r"#if defined\(__linux__\).*(\n.*)+#endif\n#endif"
+
+ s = re.sub(r, f"typedef struct pollfd {poll_handle_type};", s)
+ return s
+
+
+
+From 6e02235e03eaab003d0bb94fd70ea16c684e6ff4 Mon Sep 17 00:00:00 2001
+From: Erik Larsson <who+github@cnackers.org>
+Date: Sun, 9 Feb 2025 16:27:29 +0100
+Subject: [PATCH] scripts: use raw strings for regular expressions
+
+Use raw strings for all regular expressions.
+This fixes the related syntax warnings during the build process.
+
+Signed-off-by: Erik Larsson <who+github@cnackers.org>
+---
+ scripts/prepare_headers.py | 80 ++++++++++++++++++++------------------
+ 1 file changed, 43 insertions(+), 37 deletions(-)
+
+diff --git a/scripts/prepare_headers.py b/scripts/prepare_headers.py
+index ecbe22fd..792c8bb8 100644
+--- a/scripts/prepare_headers.py
++++ b/scripts/prepare_headers.py
+@@ -12,36 +12,36 @@
+ def remove_common_guards(s):
+
+ # Remove includes and guards
+- s = re.sub("#ifndef.*", "", s)
+- s = re.sub("#if .*", "", s)
+- s = re.sub("#define .*_H_*?\n", "", s)
+- s = re.sub("#endif.*", "", s)
+- s = re.sub("#error.*", "", s)
+- s = re.sub('#ifdef __cplusplus\nextern "C" {', "", s, flags=re.MULTILINE)
+- s = re.sub("#ifdef __cplusplus\n}", "", s, flags=re.MULTILINE)
+- s = re.sub("#include.*", "", s)
++ s = re.sub(r"#ifndef.*", r"", s)
++ s = re.sub(r"#if .*", r"", s)
++ s = re.sub(r"#define .*_H_*?\n", r"", s)
++ s = re.sub(r"#endif.*", r"", s)
++ s = re.sub(r"#error.*", r"", s)
++ s = re.sub(r'#ifdef __cplusplus\nextern "C" {', r"", s, flags=re.MULTILINE)
++ s = re.sub(r"#ifdef __cplusplus\n}", r"", s, flags=re.MULTILINE)
++ s = re.sub(r"#include.*", "", s)
+
+ # Remove certain macros
+- s = re.sub("#define TSS2_API_VERSION.*", "", s)
+- s = re.sub("#define TSS2_ABI_VERSION.*", "", s)
+- s = re.sub("#define TSS2_RC_LAYER\(level\).*", "", s)
+- s = re.sub("(#define.*)TSS2_RC_LAYER\(0xff\)", "\g<1>0xff0000", s)
++ s = re.sub(r"#define TSS2_API_VERSION.*", r"", s)
++ s = re.sub(r"#define TSS2_ABI_VERSION.*", r"", s)
++ s = re.sub(r"#define TSS2_RC_LAYER\(level\).*", r"", s)
++ s = re.sub(r"(#define.*)TSS2_RC_LAYER\(0xff\)", r"\g<1>0xff0000", s)
+
+ # Remove comments
+- s = re.sub("/\*.*?\*/", "", s, flags=re.MULTILINE)
++ s = re.sub(r"/\*.*?\*/", "", s, flags=re.MULTILINE)
+
+ # Restructure #defines with ...
+- s = re.sub("(#define [A-Za-z0-9_]+) +\(\(.*?\) \(.*?\)\)", "\g<1>...", s)
+- s = re.sub("(#define [A-Za-z0-9_]+) +\(\(\(.*?\) .*\)", "\g<1>...", s)
+- s = re.sub("(#define [A-Za-z0-9_]+) +\(\(.*?\).*?\) ", "\g<1>...", s)
++ s = re.sub(r"(#define [A-Za-z0-9_]+) +\(\(.*?\) \(.*?\)\)", r"\g<1>...", s)
++ s = re.sub(r"(#define [A-Za-z0-9_]+) +\(\(\(.*?\) .*\)", r"\g<1>...", s)
++ s = re.sub(r"(#define [A-Za-z0-9_]+) +\(\(.*?\).*?\) ", r"\g<1>...", s)
+ s = re.sub(
+- "(#define [A-Za-z0-9_]+) .*\n.*?.*\)\)", "\g<1>...", s, flags=re.MULTILINE
++ r"(#define [A-Za-z0-9_]+) .*\n.*?.*\)\)", r"\g<1>...", s, flags=re.MULTILINE
+ )
+- s = re.sub("(#define +[A-Za-z0-9_]+) +\((-?\d+)\)", "\g<1> \g<2>", s)
+- s = re.sub("(#define [A-Za-z0-9_]+) .*", "\g<1>...", s)
++ s = re.sub(r"(#define +[A-Za-z0-9_]+) +\((-?\d+)\)", r"\g<1> \g<2>", s)
++ s = re.sub(r"(#define [A-Za-z0-9_]+) .*", r"\g<1>...", s)
+
+ # Restructure structs and untions with ...
+- s = re.sub("\[.+?\]", "[...]", s)
++ s = re.sub(r"\[.+?\]", r"[...]", s)
+
+ return s
+
+@@ -50,7 +50,7 @@ def remove_poll_stuff(s, poll_handle_type):
+
+ r = r"#if defined\(__linux__\).*(\n.*)+#endif\n#endif"
+
+- s = re.sub(r, f"typedef struct pollfd {poll_handle_type};", s)
++ s = re.sub(r, rf"typedef struct pollfd {poll_handle_type};", s)
+ return s
+
+
+@@ -58,9 +58,9 @@ def remove_INTERNALBUILD(s):
+
+ r = r"#if\s+defined\(INTERNALBUILD\)(?:(?!endif).)*#endif"
+ s = re.sub(r, "", s, flags=re.MULTILINE | re.DOTALL)
+- s = re.sub(r"DEPRECATED", "", s)
++ s = re.sub(r"DEPRECATED", r"", s)
+
+- return re.sub(r"__attribute__\(\(deprecated\)\)", "", s)
++ return re.sub(r"__attribute__\(\(deprecated\)\)", r"", s)
+
+
+ def prepare_common(dirpath):
+@@ -76,8 +76,8 @@ def prepare_types(dirpath):
+
+ # Remove false define (workaround)
+ s = re.sub(
+- "#define TPM2_MAX_TAGGED_POLICIES.*\n.*TPMS_TAGGED_POLICY\)\)",
+- "",
++ r"#define TPM2_MAX_TAGGED_POLICIES.*\n.*TPMS_TAGGED_POLICY\)\)",
++ r"",
+ s,
+ flags=re.MULTILINE,
+ )
+@@ -85,11 +85,13 @@ def prepare_types(dirpath):
+ s = remove_INTERNALBUILD(s)
+
+ s = re.sub(
+- "typedef struct TPMS_ALGORITHM_DESCRIPTION TPMS_ALGORITHM_DESCRIPTION ;", "", s
++ r"typedef struct TPMS_ALGORITHM_DESCRIPTION TPMS_ALGORITHM_DESCRIPTION ;",
++ r"",
++ s,
+ )
+
+ s = re.sub(
+- r"struct TPMS_ALGORITHM_DESCRIPTION {\n.*\n.*\n} ;", "", s, flags=re.MULTILINE
++ r"struct TPMS_ALGORITHM_DESCRIPTION {\n.*\n.*\n} ;", r"", s, flags=re.MULTILINE
+ )
+
+ return remove_common_guards(s)
+@@ -99,12 +101,12 @@ def prepare_tcti(dirpath):
+
+ s = pathlib.Path(dirpath, "tss2_tcti.h").read_text(encoding="utf-8")
+
+- s = re.sub("#ifndef TSS2_API_VERSION.*\n.*\n#endif", "", s, flags=re.MULTILINE)
++ s = re.sub(r"#ifndef TSS2_API_VERSION.*\n.*\n#endif", r"", s, flags=re.MULTILINE)
+
+ s = remove_poll_stuff(s, "TSS2_TCTI_POLL_HANDLE")
+
+- s = re.sub(r"#define TSS2_TCTI_.*\n.*", "", s, flags=re.MULTILINE)
+- s = re.sub(r"^\s*#define Tss2_Tcti_(?:.*\\\r?\n)*.*$", "", s, flags=re.MULTILINE)
++ s = re.sub(r"#define TSS2_TCTI_.*\n.*", r"", s, flags=re.MULTILINE)
++ s = re.sub(r"^\s*#define Tss2_Tcti_(?:.*\\\r?\n)*.*$", r"", s, flags=re.MULTILINE)
+
+ s += """
+ struct pollfd {
+@@ -269,20 +271,24 @@ def prepare_mu(dirpath):
+ # At least tpm2-tss 3.0.3 have duplicated BYTE (un)marshal functions which break cffi
+ # So removing them is needed until 3.1.x has reached most distributions
+ n = re.findall(
+- "TSS2_RC\s+Tss2_MU_BYTE_Marshal\(.+?\);", s, re.DOTALL | re.MULTILINE
++ r"TSS2_RC\s+Tss2_MU_BYTE_Marshal\(.+?\);", s, re.DOTALL | re.MULTILINE
+ )
+ if len(n) > 1:
+ s = re.sub(
+- "TSS2_RC\s+Tss2_MU_BYTE_Marshal\(.+?\);", "", s, 1, re.DOTALL | re.MULTILINE
++ r"TSS2_RC\s+Tss2_MU_BYTE_Marshal\(.+?\);",
++ r"",
++ s,
++ 1,
++ re.DOTALL | re.MULTILINE,
+ )
+
+ n = re.findall(
+- "TSS2_RC\s+Tss2_MU_BYTE_Unmarshal\(.+?\);", s, re.DOTALL | re.MULTILINE
++ r"TSS2_RC\s+Tss2_MU_BYTE_Unmarshal\(.+?\);", s, re.DOTALL | re.MULTILINE
+ )
+ if len(n) > 1:
+ s = re.sub(
+- "TSS2_RC\s+Tss2_MU_BYTE_Unmarshal\(.+?\);",
+- "",
++ r"TSS2_RC\s+Tss2_MU_BYTE_Unmarshal\(.+?\);",
++ r"",
+ s,
+ 1,
+ re.DOTALL | re.MULTILINE,
+@@ -290,7 +296,7 @@ def prepare_mu(dirpath):
+
+ s = re.sub(
+ r"TSS2_RC\s+Tss2_MU_TPMS_ALGORITHM_DESCRIPTION_Marshal\(.+?\)\s+;",
+- "",
++ r"",
+ s,
+ 1,
+ re.DOTALL | re.MULTILINE,
+@@ -312,7 +318,7 @@ def prepare_policy(dirpath):
+ s = remove_common_guards(s)
+ # cparser complains if a typedef of an enum is before the definition of the enum
+ s = re.sub(
+- "typedef enum TSS2_POLICY_PCR_SELECTOR TSS2_POLICY_PCR_SELECTOR;", "", s, 1
++ r"typedef enum TSS2_POLICY_PCR_SELECTOR TSS2_POLICY_PCR_SELECTOR;", r"", s, 1
+ )
+ s = re.sub(
+ r"(enum TSS2_POLICY_PCR_SELECTOR.*?\};)",
+
+
+From 9cc11edbe174dc71cf77c841b5a99717a85b7471 Mon Sep 17 00:00:00 2001
+From: Erik Larsson <who+github@cnackers.org>
+Date: Wed, 12 Nov 2025 14:50:40 +0100
+Subject: [PATCH] scripts: update regex for current head of tpm2-tss
+
+There have some more changes to the tpm2-tss headers, so we need to update the regular expressions.
+Also cleaned up the code a bit and added comments.
+
+Signed-off-by: Erik Larsson <who+github@cnackers.org>
+---
+ scripts/prepare_headers.py | 42 +++++++++++++++++++++-----------------
+ 1 file changed, 23 insertions(+), 19 deletions(-)
+
+diff --git a/scripts/prepare_headers.py b/scripts/prepare_headers.py
+index 792c8bb8..2488ef03 100644
+--- a/scripts/prepare_headers.py
++++ b/scripts/prepare_headers.py
+@@ -10,6 +10,8 @@
+
+
+ def remove_common_guards(s):
++ # merge split lines
++ s = s.replace("\\\n", "")
+
+ # Remove includes and guards
+ s = re.sub(r"#ifndef.*", r"", s)
+@@ -28,18 +30,17 @@ def remove_common_guards(s):
+ s = re.sub(r"(#define.*)TSS2_RC_LAYER\(0xff\)", r"\g<1>0xff0000", s)
+
+ # Remove comments
+- s = re.sub(r"/\*.*?\*/", "", s, flags=re.MULTILINE)
++ s = re.sub(r"/\*.*\n*\*/", "", s, flags=re.MULTILINE)
+
+ # Restructure #defines with ...
+- s = re.sub(r"(#define [A-Za-z0-9_]+) +\(\(.*?\) \(.*?\)\)", r"\g<1>...", s)
+- s = re.sub(r"(#define [A-Za-z0-9_]+) +\(\(\(.*?\) .*\)", r"\g<1>...", s)
+- s = re.sub(r"(#define [A-Za-z0-9_]+) +\(\(.*?\).*?\) ", r"\g<1>...", s)
++ # handles ((TYPE)NUMBER)
+ s = re.sub(
+- r"(#define [A-Za-z0-9_]+) .*\n.*?.*\)\)", r"\g<1>...", s, flags=re.MULTILINE
++ r"(#define +[A-Za-z0-9_]+)\s+\(\(\w+\)([0-9A-Fa-fxX]+)\)\)*", r"\g<1> \g<2>", s
+ )
+- s = re.sub(r"(#define +[A-Za-z0-9_]+) +\((-?\d+)\)", r"\g<1> \g<2>", s)
+- s = re.sub(r"(#define [A-Za-z0-9_]+) .*", r"\g<1>...", s)
+-
++ # handles other defines
++ s = re.sub(r"(#define +[A-Za-z0-9_]+)\s+[^0-9\s].*", r"\g<1>...", s)
++ # remove macros
++ s = re.sub(r"(#define +[A-Za-z0-9_]+)\s*\(.*?\).*", r"", s)
+ # Restructure structs and untions with ...
+ s = re.sub(r"\[.+?\]", r"[...]", s)
+
+@@ -278,8 +279,8 @@ def prepare_mu(dirpath):
+ r"TSS2_RC\s+Tss2_MU_BYTE_Marshal\(.+?\);",
+ r"",
+ s,
+- 1,
+- re.DOTALL | re.MULTILINE,
++ count=1,
++ flags=re.DOTALL | re.MULTILINE,
+ )
+
+ n = re.findall(
+@@ -290,24 +291,24 @@ def prepare_mu(dirpath):
+ r"TSS2_RC\s+Tss2_MU_BYTE_Unmarshal\(.+?\);",
+ r"",
+ s,
+- 1,
+- re.DOTALL | re.MULTILINE,
++ count=1,
++ flags=re.DOTALL | re.MULTILINE,
+ )
+
+ s = re.sub(
+ r"TSS2_RC\s+Tss2_MU_TPMS_ALGORITHM_DESCRIPTION_Marshal\(.+?\)\s+;",
+ r"",
+ s,
+- 1,
+- re.DOTALL | re.MULTILINE,
++ count=1,
++ flags=re.DOTALL | re.MULTILINE,
+ )
+
+ s = re.sub(
+ r"TSS2_RC\s+Tss2_MU_TPMS_ALGORITHM_DESCRIPTION_Unmarshal\(.+?\)\s+;",
+ "",
+ s,
+- 1,
+- re.DOTALL | re.MULTILINE,
++ count=1,
++ flags=re.DOTALL | re.MULTILINE,
+ )
+
+ return s
+@@ -318,14 +319,17 @@ def prepare_policy(dirpath):
+ s = remove_common_guards(s)
+ # cparser complains if a typedef of an enum is before the definition of the enum
+ s = re.sub(
+- r"typedef enum TSS2_POLICY_PCR_SELECTOR TSS2_POLICY_PCR_SELECTOR;", r"", s, 1
++ r"typedef enum TSS2_POLICY_PCR_SELECTOR TSS2_POLICY_PCR_SELECTOR;",
++ r"",
++ s,
++ count=1,
+ )
+ s = re.sub(
+ r"(enum TSS2_POLICY_PCR_SELECTOR.*?\};)",
+ r"\1" + "\ntypedef enum TSS2_POLICY_PCR_SELECTOR TSS2_POLICY_PCR_SELECTOR;",
+ s,
+- 1,
+- re.DOTALL | re.MULTILINE,
++ count=1,
++ flags=re.DOTALL | re.MULTILINE,
+ )
+ s += """
+ extern "Python" TSS2_RC _policy_cb_calc_pcr(
+
diff --git a/python-tpm2-pytss.spec b/python-tpm2-pytss.spec
index 9137e69..47fa39d 100644
--- a/python-tpm2-pytss.spec
+++ b/python-tpm2-pytss.spec
@@ -26,6 +26,11 @@ Patch6: %{name}-cryptography-decrepit.patch
# Drop redundant BuildRequires for python3-wheel
# https://github.com/fedora-eln/eln/issues/284
Patch7: https://github.com/tpm2-software/tpm2-pytss/commit/3107f615.patch
+# cd433019cf109986d523ab4dc644af723f6f0d59
+# dba34b3a0af39122381d613a7beb3a0d46b7ae21
+# 6e02235e03eaab003d0bb94fd70ea16c684e6ff4
+# 9cc11edbe174dc71cf77c841b5a99717a85b7471
+Patch8: python-tpm2-pytss-raw-regex.patch
BuildRequires: python3-devel
BuildRequires: python3-pytest
reply other threads:[~2026-07-27 9:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178514517662.1.9424583337520237615.rpms-python-tpm2-pytss-79722390dc02@fedoraproject.org \
--to=jjelen@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox