Don't check package BuildRequires when doing --rmsource (rhbz#452477)
authorJindrich Novy <jnovy@redhat.com>
Sun, 11 Jan 2009 15:54:07 +0000 (16:54 +0100)
committerJindrich Novy <jnovy@redhat.com>
Sun, 11 Jan 2009 15:54:07 +0000 (16:54 +0100)
- export doRmSource() and make it more consistent with the API

build.c
build/build.c
build/rpmbuild.h

diff --git a/build.c b/build.c
index 3891b2a..48e579d 100644 (file)
--- a/build.c
+++ b/build.c
@@ -259,6 +259,13 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
        goto exit;
     }
 
+    if ( ba->buildAmount&RPMBUILD_RMSOURCE && !(ba->buildAmount&~(RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)) ) {
+       rc = doRmSource(spec);
+       if ( rc == RPMRC_OK && ba->buildAmount&RPMBUILD_RMSPEC )
+           rc = unlink(specFile);
+       goto exit;
+    }
+
     /* Assemble source header from parsed components */
     initSourceHeader(spec);
 
index 45e9b10..a4a271a 100644 (file)
@@ -15,17 +15,18 @@ static int _build_debug = 0;
 
 /**
  */
-static void doRmSource(rpmSpec spec)
+rpmRC doRmSource(rpmSpec spec)
 {
     struct Source *p;
     Package pkg;
-    int rc;
+    int rc = 0;
     
     for (p = spec->sources; p != NULL; p = p->next) {
        if (! (p->flags & RPMBUILD_ISNO)) {
            char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
            rc = unlink(fn);
            fn = _free(fn);
+           if (rc) goto exit;
        }
     }
 
@@ -35,9 +36,12 @@ static void doRmSource(rpmSpec spec)
                char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
                rc = unlink(fn);
                fn = _free(fn);
+               if (rc) goto exit;
            }
        }
     }
+exit:
+    return !rc ? RPMRC_OK : RPMRC_FAIL;
 }
 
 /*
index 0ba3c7e..acea095 100644 (file)
@@ -273,6 +273,13 @@ int parseExpressionBoolean(rpmSpec spec, const char * expr);
 char * parseExpressionString(rpmSpec spec, const char * expr);
 
 /** \ingroup rpmbuild
+ * Remove all sources assigned to spec file.
+ *
+ * @param spec         spec file control structure
+ * @return             RPMRC_OK on success
+ */
+rpmRC doRmSource(rpmSpec spec);
+/** \ingroup rpmbuild
  * Run a build script, assembled from spec file scriptlet section.
  *
  * @param spec         spec file control structure