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

No build directives in generated spec parts #2917

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

ffesti
Copy link
Contributor

@ffesti ffesti commented Feb 19, 2024

Many things need to be known before the build can be started. Make
declaring these sections or directives an error when encountered parsing
the generated Spec parts.

Resolves: #2693

build/parsePreamble.c Outdated Show resolved Hide resolved
build/rpmbuild_internal.h Outdated Show resolved Hide resolved
build/parseSpec.c Outdated Show resolved Hide resolved
build/parsePreamble.c Outdated Show resolved Hide resolved
return p->beforebuildonly;
}
}
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd combine these two into findPart() that returns a pointer to the struct, whose values you can then just use directly in the caller.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still this one 😇

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote above this is not quite as simple as it looks and I ma not that interested in refactoring the whole parting code. Yes, it looks wasteful and over complicated but I'd rather not change a whole bunch of functions just to pass a new pointer around.

Copy link
Member

@pmatilai pmatilai Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see you mentioned this below. isPart() is a different matter, but ..

Once you have

static const struct PartRec * getPart(int part)
{   
    const struct PartRec *p;
    
    for (p = partList; p->token != NULL; p++) {
        if (p->part == part) {
            return p;
        }
    }   
    return NULL;
}   

...the check becomes something like:

        if (stage == PARSE_GENERATED) {
            const struct PartRec *p = getPart(parsePart);
            if (p && p->prebuildonly) {
                rpmlog(RPMLOG_ERR,
                        _("Section %s is not allowed after build is done!\n"),
                        p->token);
                goto errxit;
            }
        }   

...and at that point you realize this whole if belongs into a separate helper function that checks whether the tag was legitimate for use here. parseSpecSection() is big enough as it is.

It's not exactly a huge refactoring job 😅 I mean, if you like, just stick the whole logic into one function you call from parseSpecSection(). But having two separate lookup functions just for this is a bit silly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the new code is that more readable. But whatever...

build/parsePreamble.c Outdated Show resolved Hide resolved
build/parsePreamble.c Outdated Show resolved Hide resolved
@pmatilai pmatilai self-assigned this Mar 6, 2024
As we now have three different sources of spec content we need a proper
enum to tell them apart and get rid of the seconday bool parameter.

No functional change but is needed for the next patch
@pmatilai
Copy link
Member

pmatilai commented Mar 6, 2024

Oh and for whatever reason, there's some po/ submodule update in here:

diff --git a/po b/po
index d5cc5d368e..eee506492f 160000
--- a/po
+++ b/po
@@ -1 +1 @@
-Subproject commit d5cc5d368e2cbb639156b3f6ceb824a8815fdeba
+Subproject commit eee506492f5fe2f4fe8940c5e5b088b42167b790

(also visible in the changed files tab)

Many things need to be known before the build can be started. Make
declaring these sections or directives an error when encountered parsing
the generated Spec parts.

Resolves: rpm-software-management#2693
Copy link
Member

@pmatilai pmatilai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually meant you could just as well inline the whole lookup in what you're calling checkPart() since there are no other users for this in sight, but works for me.

@pmatilai pmatilai merged commit 1296ea9 into rpm-software-management:master Mar 7, 2024
1 check passed
@ffesti ffesti deleted the 2693 branch March 19, 2024 08:57
@dmnks dmnks added the cleanup label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent Dynamic Spec part to create things needed earlier
3 participants