Allow a backtracking branch to upload any package version
[invirt/packages/invirt-dev.git] / invirtibuilder
index ca12398..e1c3d80 100755 (executable)
@@ -166,13 +166,19 @@ def updateSubmoduleBranch(pocket, package, commit):
 
 def uploadBuild(pocket, workdir):
     """Upload all build products in the work directory."""
 
 def uploadBuild(pocket, workdir):
     """Upload all build products in the work directory."""
+    force = config.build.pockets[pocket].get('allow_backtracking', False)
     apt = b.pocketToApt(pocket)
     for changes in glob.glob(os.path.join(workdir, '*.changes')):
     apt = b.pocketToApt(pocket)
     for changes in glob.glob(os.path.join(workdir, '*.changes')):
-        c.captureOutput(['reprepro-env',
-                       '--ignore=wrongdistribution',
-                       'include',
-                       apt,
-                       changes])
+        upload = ['reprepro-env', '--ignore=wrongdistribution',
+                  'include', apt, changes]
+        try:
+            c.captureOutput(upload)
+        except subprocess.CalledProcessError, e:
+            if not force:
+                raise
+            package = deb822.Changes(open(changes).read())['Binary']
+            c.captureOutput(['reprepro-env', 'remove', apt, package])
+            c.captureOutput(upload)
 
 
 def updateSuperproject(pocket, package, commit, principal, version, env):
 
 
 def updateSuperproject(pocket, package, commit, principal, version, env):