Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of sections and tags from RPM sources #375

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading