Skip to content

Commit

Permalink
Refactor the processing logic out of parseGeneratedSpecs() for reuse
Browse files Browse the repository at this point in the history
We'll need this on other paths than specpartsdir in the next commits.
No functional changes.
  • Loading branch information
pmatilai committed Oct 27, 2023
1 parent 283935b commit ed59d17
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions build/parseSpec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,17 +1184,15 @@ rpmSpec rpmSpecParse(const char *specFile, rpmSpecFlags flags,
return spec;
}

rpmRC parseGeneratedSpecs(rpmSpec spec)
static rpmRC parseSpecParts(rpmSpec spec, const char *pattern)
{
ARGV_t argv = NULL;
int argc = 0;
int i;
rpmRC rc = RPMRC_OK;

char * specPattern = rpmGenPath("%{specpartsdir}", NULL, "*.specpart");
/* rpmGlob returns files sorted */
if (rpmGlob(specPattern, &argc, &argv) == 0) {
for (i = 0; i < argc; i++) {
if (rpmGlob(pattern, &argc, &argv) == 0) {
for (int i = 0; i < argc; i++) {
rpmlog(RPMLOG_NOTICE, "Reading %s\n", argv[i]);
pushOFI(spec, argv[i]);
snprintf(spec->fileStack->readBuf, spec->fileStack->readBufLen,
Expand All @@ -1207,6 +1205,13 @@ rpmRC parseGeneratedSpecs(rpmSpec spec)
}
argvFree(argv);
}
return rc;
}

rpmRC parseGeneratedSpecs(rpmSpec spec)
{
char * specPattern = rpmGenPath("%{specpartsdir}", NULL, "*.specpart");
rpmRC rc = parseSpecParts(spec, specPattern);
free(specPattern);
if (!rc) {
rc = finalizeSpec(spec);
Expand Down

0 comments on commit ed59d17

Please sign in to comment.