Skip to content

Commit

Permalink
Fix parsing of sections and tags from RPM sources (#375)
Browse files Browse the repository at this point in the history
Fix parsing of sections and tags from RPM sources

The definitions have been changed in rpm-software-management/rpm@1296ea9.

Reviewed-by: Laura Barcziová
  • Loading branch information
softwarefactory-project-zuul[bot] authored May 15, 2024
2 parents 0e46977 + 80743a7 commit 9f26a94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plans/packit-integration.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ prepare:
copr: packit/packit-dev
# make sure the Copr repo has higher priority than TF Tag Repository
- how: shell
script: dnf -y config-manager --save --setopt="*:packit:packit-dev.priority=5"
script: sed -i -n '/^priority=/!p;$apriority=5' /etc/yum.repos.d/*:packit:packit-dev.repo

adjust:
- when: "how == integration"
Expand Down
14 changes: 9 additions & 5 deletions scripts/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
};
Expand All @@ -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 + "}"
Expand All @@ -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}
};
Expand All @@ -94,6 +96,8 @@ def extract_tags(filename: Path, with_args: bool = False) -> List[str]:
+ ","
+ number.suppress()
+ ","
+ number.suppress()
+ ","
+ macro
+ "}"
)
Expand Down

0 comments on commit 9f26a94

Please sign in to comment.