From ebb9d2010c9dde4e2589bfe71a88c64c1653d169 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Wed, 7 Jun 2023 13:33:10 +0200 Subject: [PATCH] Add %specpartsdir to macros.in 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 --- build/build.c | 5 +++++ build/parsePrep.c | 15 ++++++++------- macros.in | 2 ++ tests/rpmspec.at | 3 ++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/build/build.c b/build/build.c index 8d0b9d0fd9..5bff9cc170 100644 --- a/build/build.c +++ b/build/build.c @@ -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); diff --git a/build/parsePrep.c b/build/parsePrep.c index ea8faa9531..ca32eea001 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -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); diff --git a/macros.in b/macros.in index 4dc6e3ca3b..f361b4b1aa 100644 --- a/macros.in +++ b/macros.in @@ -132,6 +132,8 @@ %_keyringpath %{_dbpath}/pubkeys/ +%specpartsdir %{_builddir}/%{buildsubdir}-SPECPARTS + # sysusers helper binary or script, uncomment to disable %__systemd_sysusers %{_bindir}/systemd-sysusers diff --git a/tests/rpmspec.at b/tests/rpmspec.at index 564479391a..431b7678e3 100644 --- a/tests/rpmspec.at +++ b/tests/rpmspec.at @@ -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