Fix %prep parse error to abort build
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 24 May 2011 13:55:31 +0000 (16:55 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 24 May 2011 13:55:31 +0000 (16:55 +0300)
- Previously in some cases parse error in %prep could emit an error msg
  but still continue building due to error code bogosity. Clean up
  the mess a bit: assume failure and actually return the res(ult) we
  calculated instead of nextPart.

build/parsePrep.c

index 9e61dde..be908b0 100644 (file)
@@ -475,7 +475,7 @@ exit:
 
 int parsePrep(rpmSpec spec)
 {
-    int nextPart, res, rc;
+    int nextPart, rc, res = PART_ERROR;
     ARGV_t saveLines = NULL;
 
     if (spec->prep != NULL) {
@@ -505,17 +505,15 @@ int parsePrep(rpmSpec spec)
     }
 
     for (ARGV_const_t lines = saveLines; lines && *lines; lines++) {
-       res = 0;
+       rc = RPMRC_OK;
        if (rstreqn(*lines, "%setup", sizeof("%setup")-1)) {
-           res = doSetupMacro(spec, *lines);
+           rc = doSetupMacro(spec, *lines);
        } else if (rstreqn(*lines, "%patch", sizeof("%patch")-1)) {
-           res = doPatchMacro(spec, *lines);
+           rc = doPatchMacro(spec, *lines);
        } else {
            appendStringBuf(spec->prep, *lines);
        }
-       if (res && !(spec->flags & RPMSPEC_FORCE)) {
-           /* fixup from RPMRC_FAIL do*Macro() codes for now */
-           nextPart = PART_ERROR; 
+       if (rc != RPMRC_OK && !(spec->flags & RPMSPEC_FORCE)) {
            goto exit;
        }
     }
@@ -524,5 +522,5 @@ int parsePrep(rpmSpec spec)
 exit:
     argvFree(saveLines);
 
-    return nextPart;
+    return res;
 }