From 0b60086215ac09e73bff4ad151c0f09fc61b2ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Fri, 10 May 2024 10:35:45 +0200 Subject: [PATCH] Fix parsing of sections and tags from RPM sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nikola Forró --- scripts/extract.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/extract.py b/scripts/extract.py index fdeee30..825a436 100755 --- a/scripts/extract.py +++ b/scripts/extract.py @@ -32,11 +32,12 @@ def extract_sections(filename: Path) -> List[str]: static const struct PartRec { int part; + int prebuildonly; size_t len; const char * token; } partList[] = { - { PART_PREAMBLE, LEN_AND_STR("%package")}, - { PART_PREP, LEN_AND_STR("%prep")}, + { PART_PREAMBLE, 0, LEN_AND_STR("%package")}, + { PART_PREP, 1, LEN_AND_STR("%prep")}, ... {0, 0, 0} }; @@ -50,7 +51,8 @@ def extract_sections(filename: Path) -> List[str]: constant = Word(srange("[A-Z_]")).suppress() name = dbl_quoted_string.set_parse_action(remove_quotes) macro = "LEN_AND_STR(" + name + ")" - item = "{" + Suppress(constant) + "," + macro + "}" + number = pyparsing_common.number + item = "{" + Suppress(constant) + "," + number.suppress() + "," + macro + "}" sentinel = Suppress("{" + delimited_list(Literal("0")) + "}") parser = ( Suppress("partList[]") + "=" + "{" + delimited_list(item) + "," + sentinel + "}" @@ -67,8 +69,8 @@ def extract_tags(filename: Path, with_args: bool = False) -> List[str]: Extracts tag names from a constant array looking like this: static struct PreambleRec_s const preambleList[] = { - {RPMTAG_NAME, 0, 0, 1, LEN_AND_STR("name")}, - {RPMTAG_VERSION, 0, 0, 1, LEN_AND_STR("version")}, + {RPMTAG_NAME, 0, 0, 1, 0, LEN_AND_STR("name")}, + {RPMTAG_VERSION, 0, 0, 1, 0, LEN_AND_STR("version")}, ... {0, 0, 0, 0} }; @@ -94,6 +96,8 @@ def extract_tags(filename: Path, with_args: bool = False) -> List[str]: + "," + number.suppress() + "," + + number.suppress() + + "," + macro + "}" )