Skip to content

Commit

Permalink
Convert a couple of rpmExpand() usages to the C++ versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatilai authored and dmnks committed Nov 4, 2024
1 parent 439a601 commit ac25837
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
24 changes: 13 additions & 11 deletions build/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
#include <rpm/rpmfileutil.h>
#include "rpmbuild_internal.hh"
#include "rpmbuild_misc.hh"
#include "rpmmacro_internal.hh"

#include "debug.h"

using namespace rpm;

static rpm_time_t getBuildTime(void)
{
rpm_time_t buildTime = 0;
Expand Down Expand Up @@ -321,28 +324,27 @@ static int doCheckBuildRequires(rpmts ts, rpmSpec spec, int test)

static rpmRC doBuildDir(rpmSpec spec, int test, int inPlace, StringBuf *sbp)
{
char *doDir = rpmExpand("test -d '", spec->buildDir, "' && ",
"%{_fixperms} '", spec->buildDir, "'\n",
"%{__rm} -rf '", spec->buildDir, "'\n",
"%{__mkdir_p} '", spec->buildDir, "'\n",
"%{__mkdir_p} '%{specpartsdir}'\n",
NULL);
auto [ ign, doDir ] = macros().expand({
"test -d '", spec->buildDir, "' && ",
"%{_fixperms} '", spec->buildDir, "'\n",
"%{__rm} -rf '", spec->buildDir, "'\n",
"%{__mkdir_p} '", spec->buildDir, "'\n",
"%{__mkdir_p} '%{specpartsdir}'\n",
});

if (inPlace) {
/* note that pwd needs to be from parse, not build time */
char *buf = rpmExpand("%{__ln} -s %(pwd) %{builddir}/%{buildsubdir}", NULL);
doDir = rstrcat(&doDir, buf);
free(buf);
auto [ ign, buf ] = macros().expand("%{__ln} -s %(pwd) %{builddir}/%{buildsubdir}");
doDir += buf;
}

rpmRC rc = doScript(spec, RPMBUILD_MKBUILDDIR, "%mkbuilddir",
doDir, test, sbp);
doDir.c_str(), test, sbp);
if (rc) {
rpmlog(RPMLOG_ERR,
_("failed to create package build directory %s: %s\n"),
spec->buildDir, strerror(errno));
}
free(doDir);
return rc;
}

Expand Down
7 changes: 4 additions & 3 deletions build/rpmfc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@

#include "rpmfi_internal.hh" /* rpmfiles stuff for now */
#include "rpmbuild_internal.hh"
#include "rpmmacro_internal.hh"

#include "debug.h"

using std::string;
using std::vector;
using namespace rpm;

struct matchRule {
regex_t *path;
Expand Down Expand Up @@ -239,9 +241,8 @@ static rpmds rpmdsSingleNS(rpmstrPool pool,
{
rpmds ds = NULL;
if (namespc) {
char *NSN = rpmExpand(namespc, "(", N, ")", NULL);
ds = rpmdsSinglePool(pool, tagN, NSN, EVR, Flags);
free(NSN);
auto [ ign, NSN ] = macros().expand({namespc, "(", N, ")",});
ds = rpmdsSinglePool(pool, tagN, NSN.c_str(), EVR, Flags);
} else {
ds = rpmdsSinglePool(pool, tagN, N, EVR, Flags);
}
Expand Down

0 comments on commit ac25837

Please sign in to comment.