Modify eu-strip option to perform strip in post script of rpm package & add option...
[platform/upstream/rpm.git] / rpmbuild.c
index 975364e..4fb4289 100644 (file)
@@ -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 rpmBuildFlags nobuildAmount = 0;        /*!< Build stage disablers */
 static ARGV_t build_targets = NULL;    /*!< Target platform(s) */
 
 static void buildArgCallback( poptContext con,
@@ -182,6 +183,11 @@ static struct poptOption rpmBuildPoptTable[] = {
        N_("generate package header(s) compatible with (legacy) rpm v3 packaging"),
        NULL},
 
+ { "noclean", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_CLEAN,
+       N_("do not execute %clean stage of the build"), NULL },
+ { "nocheck", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_CHECK,
+       N_("do not execute %check stage of the build"), NULL },
+
  { "nolang", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOLANG,
        N_("do not accept i18N msgstr's from specfile"), NULL},
  { "rmsource", '\0', 0, 0, POPT_RMSOURCE,
@@ -232,7 +238,7 @@ static int checkSpec(rpmts ts, rpmSpec spec)
        rpmpsPrint(NULL, ps);
     }
     rc = (ps != NULL);
-    ps = rpmpsFree(ps);
+    rpmpsFree(ps);
     return rc;
 }
 
@@ -245,7 +251,7 @@ static int isSpecFile(const char * specfile)
     int checking;
 
     f = fopen(specfile, "r");
-    if (f == NULL || ferror(f)) {
+    if (f == NULL) {
        rpmlog(RPMLOG_ERR, _("Unable to open spec file %s: %s\n"),
                specfile, strerror(errno));
        return 0;
@@ -289,7 +295,7 @@ static char * getTarSpec(const char *arg)
     char *specDir;
     char *specBase;
     char *tmpSpecFile;
-    const char **try;
+    const char **spec;
     char tarbuf[BUFSIZ];
     int gotspec = 0, res;
     static const char *tryspec[] = { "Specfile", "\\*.spec", NULL };
@@ -299,12 +305,12 @@ static char * getTarSpec(const char *arg)
 
     (void) close(mkstemp(tmpSpecFile));
 
-    for (try = tryspec; *try != NULL; try++) {
+    for (spec = tryspec; *spec != NULL; spec++) {
        FILE *fp;
        char *cmd;
 
        cmd = rpmExpand("%{uncompress: ", arg, "} | ",
-                       "%{__tar} xOvf - --wildcards ", *try,
+                       "%{__tar} xOvf - --wildcards ", *spec,
                        " 2>&1 > ", tmpSpecFile, NULL);
 
        if (!(fp = popen(cmd, "r"))) {
@@ -367,10 +373,6 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
     int justRm = ((buildAmount & ~(RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)) == 0);
     rpmSpecFlags specFlags = spec_flags;
 
-#ifndef        DYING
-    rpmSetTables(RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS);
-#endif
-
     if (ba->buildRootOverride)
        buildRootURL = rpmGenPath(NULL, ba->buildRootOverride, NULL);
 
@@ -406,7 +408,7 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
     if (*specFile != '/') {
        char *cwd = rpmGetCwd();
        char *s = NULL;
-       rasprintf(&s, "%s/%s", cwd, arg);
+       rasprintf(&s, "%s/%s", cwd, specFile);
        free(cwd);
        free(specFile);
        specFile = s;
@@ -511,7 +513,7 @@ static int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile)
     }
 
 exit:
-    vsflags = rpmtsSetVSFlags(ts, ovsflags);
+    rpmtsSetVSFlags(ts, ovsflags);
     /* Restore original configuration. */
     rpmFreeMacros(NULL);
     rpmFreeRpmrc();
@@ -567,6 +569,7 @@ int main(int argc, char *argv[])
            ba->buildAmount |= RPMBUILD_CLEAN;
            ba->buildAmount |= RPMBUILD_RMBUILD;
        }
+       ba->buildAmount &= ~(nobuildAmount);
 
        while ((pkg = poptGetArg(optCon))) {
            char * specFile = NULL;
@@ -614,6 +617,7 @@ int main(int argc, char *argv[])
            ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
            break;
        }
+       ba->buildAmount &= ~(nobuildAmount);
 
        while ((pkg = poptGetArg(optCon))) {
            ba->rootdir = rpmcliRootDir;
@@ -627,10 +631,11 @@ int main(int argc, char *argv[])
        break;
     }
 
-    ts = rpmtsFree(ts);
-    finishPipe();
-    ba->buildRootOverride = _free(ba->buildRootOverride);
-    build_targets = argvFree(build_targets);
+    rpmtsFree(ts);
+    if (finishPipe())
+       ec = EXIT_FAILURE;
+    free(ba->buildRootOverride);
+    argvFree(build_targets);
 
     rpmcliFini(optCon);