Skip to content

Commit

Permalink
Add %specpartsdir to macros.in
Browse files Browse the repository at this point in the history
so it can be configured from the spec file

Also move the dir beside the %buildsubdir as %{buildsubdir}-SPECPARTS so
it doesn't pollute the %buildsubdir.

This patch is still missing adjustments to the dynamic_specs.md as we
might decide to keep the SPECPARTS in %buildsubdir
  • Loading branch information
ffesti committed Jun 7, 2023
1 parent 51c596a commit ebb9d20
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions build/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name,
fprintf(fp, "cd '%s'\n", buildSubdir);

if (what == RPMBUILD_RMBUILD) {
if (rpmMacroIsDefined(spec->macros, "specpartsdir")) {
char * buf = rpmExpand("%{specpartsdir}", NULL);
fprintf(fp, "rm -rf '%s'\n", buf);
free(buf);
}
if (buildSubdir[0] != '\0')
fprintf(fp, "rm -rf '%s' '%s.gemspec'\n",
buildSubdir, buildSubdir);
Expand Down
15 changes: 8 additions & 7 deletions build/parsePrep.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,14 @@ static int doSetupMacro(rpmSpec spec, const char *line)
}

/* mkdir for dynamic specparts */
buf = rpmExpand("%{__mkdir_p} SPECPARTS", NULL);
appendBuf(spec, buf, 1);
free(buf);

buf = rpmGenPath("%{_builddir}", "%{buildsubdir}", "SPECPARTS");
rpmPushMacro(spec->macros, "specpartsdir", NULL, buf, RMIL_SPEC);
free(buf);
if (rpmMacroIsDefined(spec->macros, "specpartsdir")) {
buf = rpmExpand("rm -rf '%{specpartsdir}'", NULL);
appendBuf(spec, buf, 1);
free(buf);
buf = rpmExpand("%{__mkdir_p} '%{specpartsdir}'", NULL);
appendBuf(spec, buf, 1);
free(buf);
}

appendBuf(spec, getStringBuf(after), 0);

Expand Down
2 changes: 2 additions & 0 deletions macros.in
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@

%_keyringpath %{_dbpath}/pubkeys/

%specpartsdir %{_builddir}/%{buildsubdir}-SPECPARTS

# sysusers helper binary or script, uncomment to disable
%__systemd_sysusers %{_bindir}/systemd-sysusers

Expand Down
3 changes: 2 additions & 1 deletion tests/rpmspec.at
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ if [ $STATUS -ne 0 ]; then
exit $STATUS
fi
cd 'hello-1.0'
/usr/bin/mkdir -p SPECPARTS
rm -rf '/build/BUILD/hello-1.0-SPECPARTS'
/usr/bin/mkdir -p '/build/BUILD/hello-1.0-SPECPARTS'
/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
echo "Patch #0 (hello-1.0-modernize.patch):"
/usr/bin/patch --no-backup-if-mismatch -f -p1 -b --suffix .modernize --fuzz=0 < /build/SOURCES/hello-1.0-modernize.patch
Expand Down

0 comments on commit ebb9d20

Please sign in to comment.