import-srpm: return 2 if patch import fails
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 9 Nov 2012 06:40:36 +0000 (08:40 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 7 Jan 2014 14:21:29 +0000 (16:21 +0200)
A new return value for failed patch import. If the patch import fails
the repo is left in clean and buildable state so one might want to
distinguish that from other failures.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/import_srpm.py

index 70a1da1f52f3cadfdb036cdf8f99d4cca83a95b4..8071ece95bd002446810d89fb40e3733845121ed 100755 (executable)
@@ -58,6 +58,10 @@ class SkipImport(Exception):
     """Nothing imported"""
     pass
 
+class PatchImportError(Exception):
+    """Patch import failed"""
+    pass
+
 
 def download_source(pkg, dirs):
     """Download package from a remote location"""
@@ -134,8 +138,8 @@ def import_spec_patches(repo, spec, dirs):
             apply_and_commit_patch(repo, patch, packager)
         except (GbpError, GitRepositoryError):
             repo.force_head(orig_head, hard=True)
-            raise GbpError, "Couldn't import patches, you need to apply and "\
-                            "commit manually"
+            raise PatchImportError("Patch(es) didn't apply, you need apply "
+                                   "and commit manually")
 
     # Remove patches from spec and packaging directory
     gbp.log.info("Removing imported patch files from spec and packaging dir")
@@ -145,8 +149,8 @@ def import_spec_patches(repo, spec, dirs):
         spec.write_spec_file()
     except GbpError:
         repo.force_head('HEAD', hard=True)
-        raise GbpError("Unable to update spec file, you need to edit and "
-                       "commit it  manually")
+        raise PatchImportError("Unable to update spec file, you need to edit"
+                               "and commit it  manually")
     repo.commit_all(msg=PATCH_AUTODELETE_COMMIT_MSG %
                         os.path.basename(spec.specfile))
 
@@ -480,6 +484,9 @@ def main(argv):
     except NoSpecError as err:
         gbp.log.err("Failed determine spec file: %s" % err)
         ret = 1
+    except PatchImportError as err:
+        gbp.log.err(err)
+        ret = 2
     except SkipImport:
         skipped = True
     finally: