packageWorkdir needs to be passed the commit to make a workdir from.
[invirt/packages/invirt-dev.git] / invirtibuilder
index 32744ae..e6bf214 100755 (executable)
@@ -212,7 +212,7 @@ def updateSuperproject(pocket, package, commit, principal):
 
 
 @contextlib.contextmanager
-def packageWorkdir(package):
+def packageWorkdir(package, commit):
     """Checkout the package in a temporary working directory.
 
     This context manager returns that working directory. The requested
@@ -300,7 +300,7 @@ def build():
             # do the build ourselves
             else:
                 db.failed_stage = 'checking out package source'
-                with packageWorkdir(package) as workdir:
+                with packageWorkdir(package, commit) as workdir:
                     db.failed_stage = 'preparing source package'
                     packagedir = os.path.join(workdir, package)
 
@@ -353,10 +353,10 @@ def build():
 
 class Invirtibuilder(pyinotify.ProcessEvent):
     """Process inotify triggers to build new packages."""
-    def process_IN_CREATE(self, event):
-        """Handle a created file or directory.
+    def process_default(self, event):
+        """Handle an inotify event.
 
-        When an IN_CREATE event comes in, trigger the builder.
+        When an inotify event comes in, trigger the builder.
         """
         build()
 
@@ -369,7 +369,8 @@ def main():
     invirtibuilder = Invirtibuilder()
     notifier = pyinotify.Notifier(watch_manager, invirtibuilder)
     watch_manager.add_watch(b._QUEUE_DIR,
-                            pyinotify.EventsCodes.ALL_FLAGS['IN_CREATE'])
+                            pyinotify.EventsCodes.ALL_FLAGS['IN_CREATE'] |
+                            pyinotify.EventsCodes.ALL_FLAGS['IN_MOVED_TO'])
 
     # Before inotifying, run any pending builds; otherwise we won't
     # get notified for them.