[gnome-ostree] ostbuild: Differentiate between new snapshots and existing ones



commit 645781988252ece0cd94c08d9d30351459896640
Author: Colin Walters <walters verbum org>
Date:   Wed Jul 18 16:53:57 2012 -0400

    ostbuild: Differentiate between new snapshots and existing ones
    
    Also add a --stamp-file argument to resolve that we can use in a build
    loop to know when something changed.

 src/ostbuild/pyostbuild/builtin_import_tree.py |    7 +++++--
 src/ostbuild/pyostbuild/builtin_resolve.py     |   13 +++++++++++--
 src/ostbuild/pyostbuild/jsondb.py              |    4 ++--
 3 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/src/ostbuild/pyostbuild/builtin_import_tree.py b/src/ostbuild/pyostbuild/builtin_import_tree.py
index 9fed209..5fbedd1 100755
--- a/src/ostbuild/pyostbuild/builtin_import_tree.py
+++ b/src/ostbuild/pyostbuild/builtin_import_tree.py
@@ -87,7 +87,10 @@ class OstbuildImportTree(builtins.Builtin):
         self.prefix = target_prefix
 
         db = self.get_src_snapshot_db()
-        path = db.store(self.snapshot)
-        log("Source snapshot: %s" % (path, ))
+        (path, modified) = db.store(self.snapshot)
+        if modified:
+            log("New source snapshot: %s" % (path, ))
+        else:
+            log("Source snapshot unchanged: %s" % (path, ))
 
 builtins.register(OstbuildImportTree)
diff --git a/src/ostbuild/pyostbuild/builtin_resolve.py b/src/ostbuild/pyostbuild/builtin_resolve.py
index 5109fd1..36aa1f0 100755
--- a/src/ostbuild/pyostbuild/builtin_resolve.py
+++ b/src/ostbuild/pyostbuild/builtin_resolve.py
@@ -48,6 +48,8 @@ class OstbuildResolve(builtins.Builtin):
                             help="Git fetch the patches")
         parser.add_argument('--fetch', action='store_true',
                             help="Also perform a git fetch")
+        parser.add_argument('--stamp-file',
+                            help="If manifest changes, create this file")
         parser.add_argument('components', nargs='*',
                             help="List of component names to git fetch")
 
@@ -100,7 +102,14 @@ class OstbuildResolve(builtins.Builtin):
             component['revision'] = revision
 
         src_db = self.get_src_snapshot_db()
-        path = src_db.store(self.snapshot)
-        log("Source snapshot: %s" % (path, ))
+        (path, modified) = src_db.store(self.snapshot)
+        if modified:
+            log("New source snapshot: %s" % (path, ))
+            if args.stamp_file:
+                f = open(args.stamp_file, 'w')
+                f.write(path)
+                f.close()
+        else:
+            log("Source snapshot unchanged: %s" % (path, ))
         
 builtins.register(OstbuildResolve)
diff --git a/src/ostbuild/pyostbuild/jsondb.py b/src/ostbuild/pyostbuild/jsondb.py
index 810103d..35103b4 100644
--- a/src/ostbuild/pyostbuild/jsondb.py
+++ b/src/ostbuild/pyostbuild/jsondb.py
@@ -98,7 +98,7 @@ class JsonDB(object):
         if latest is not None:
             if digest == latest[2]:
                 os.unlink(tmppath)
-                return latest[3]
+                return (latest[3], False)
             latest_version = (latest[0], latest[1])
         else:
             latest_version = (current_time.tm_year, 0)
@@ -106,7 +106,7 @@ class JsonDB(object):
                                             latest_version[1] + 1, digest)
         target_path = os.path.join(self._dirpath, target_name)
         os.rename(tmppath, target_path)
-        return target_path
+        return (target_path, True)
                 
                 
         



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]