summaryrefslogtreecommitdiff
path: root/rpmbuild.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-09-02 13:31:44 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-09-02 13:31:44 +0300
commitb7dae177471f317618c51d24f97631e9713e015c (patch)
tree8b89fdb2afdca7025a459e92f37ab811c23c227c /rpmbuild.c
parent9eb54732721d28b828d62c6da43c8522629387ee (diff)
downloadlibrpm-tizen-b7dae177471f317618c51d24f97631e9713e015c.tar.gz
librpm-tizen-b7dae177471f317618c51d24f97631e9713e015c.tar.bz2
librpm-tizen-b7dae177471f317618c51d24f97631e9713e015c.zip
Eliminate targets from rpmBuildArguments
- Targets are obviously relevant for building but not in the context of rpmSpecBuild which expects the environment to be set up already. If/when we add a higher level build interface to librpmbuild this comes relevant again, until then bury inside the cli-tool. - Simplify the target parsery by using argvSplit() and friends.
Diffstat (limited to 'rpmbuild.c')
-rw-r--r--rpmbuild.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/rpmbuild.c b/rpmbuild.c
index ad388831c..46552f078 100644
--- a/rpmbuild.c
+++ b/rpmbuild.c
@@ -53,6 +53,7 @@ static int noDeps = 0; /*!< from --nodeps */
static int shortCircuit = 0; /*!< from --short-circuit */
static char buildMode = 0; /*!< Build mode (one of "btBC") */
static char buildChar = 0; /*!< Build stage (one of "abcilps ") */
+static ARGV_t build_targets = NULL; /*!< Target platform(s) */
static void buildArgCallback( poptContext con,
enum poptCallbackReason reason,
@@ -100,7 +101,7 @@ static void buildArgCallback( poptContext con,
rba->buildRootOverride = xstrdup(arg);
break;
case POPT_TARGETPLATFORM:
- rstrscat(&rba->targets, rba->targets ? "," : "", arg, NULL);
+ argvSplit(&build_targets, arg, ",");
break;
case RPMCLI_POPT_NODIGEST:
@@ -500,9 +501,8 @@ exit:
static int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile)
{
- char *t, *te;
int rc = 0;
- char * targets = ba->targets;
+ char * targets = argvJoin(build_targets, ",");
#define buildCleanMask (RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)
int cleanFlags = ba->buildAmount & buildCleanMask;
rpmVSFlags vsflags, ovsflags;
@@ -516,7 +516,7 @@ static int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile)
vsflags |= RPMVSF_NOHDRCHK;
ovsflags = rpmtsSetVSFlags(ts, vsflags);
- if (targets == NULL) {
+ if (build_targets == NULL) {
rc = buildForTarget(ts, arg, ba);
goto exit;
}
@@ -526,25 +526,17 @@ static int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile)
printf(_("Building target platforms: %s\n"), targets);
ba->buildAmount &= ~buildCleanMask;
- for (t = targets; *t != '\0'; t = te) {
- char *target;
- if ((te = strchr(t, ',')) == NULL)
- te = t + strlen(t);
- target = xmalloc(te-t+1);
- strncpy(target, t, (te-t));
- target[te-t] = '\0';
- if (*te != '\0')
- te++;
- else /* XXX Perform clean-up after last target build. */
+ for (ARGV_const_t target = build_targets; target && *target; target++) {
+ /* Perform clean-up after last target build. */
+ if (*(target + 1) == NULL)
ba->buildAmount |= cleanFlags;
- printf(_("Building for target %s\n"), target);
+ printf(_("Building for target %s\n"), *target);
/* Read in configuration for target. */
rpmFreeMacros(NULL);
rpmFreeRpmrc();
- (void) rpmReadConfigFiles(rcfile, target);
- free(target);
+ (void) rpmReadConfigFiles(rcfile, *target);
rc = buildForTarget(ts, arg, ba);
if (rc)
break;
@@ -556,6 +548,7 @@ exit:
rpmFreeMacros(NULL);
rpmFreeRpmrc();
(void) rpmReadConfigFiles(rcfile, NULL);
+ free(targets);
return rc;
}
@@ -669,7 +662,7 @@ int main(int argc, char *argv[])
ts = rpmtsFree(ts);
finishPipe();
ba->buildRootOverride = _free(ba->buildRootOverride);
- ba->targets = _free(ba->targets);
+ build_targets = argvFree(build_targets);
rpmcliFini(optCon);