[gnome-ostree] build: No-op if we've already built the source version



commit ef683f918eaca6fe916f27e33be8c53b1d006c6b
Author: Colin Walters <walters verbum org>
Date:   Tue Jan 29 15:08:53 2013 -0500

    build: No-op if we've already built the source version

 src/ostbuild/js/builtins/build.js |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/ostbuild/js/builtins/build.js b/src/ostbuild/js/builtins/build.js
index 1a7abd5..bc2dcb1 100644
--- a/src/ostbuild/js/builtins/build.js
+++ b/src/ostbuild/js/builtins/build.js
@@ -654,6 +654,24 @@ const Build = new Lang.Class({
 	this._initSnapshot(args.prefix, args.snapshot, cancellable);
 	this.args = args;
 
+	let buildresultDir = this.workdir.get_child('builds').get_child(this.prefix);
+	let builddb = new JsonDB.JsonDB(buildresultDir);
+
+	let targetSourceVersion = builddb.parseVersionStr(this._snapshot.path.get_basename())
+
+	let latestBuildPath = builddb.getLatestPath();
+	if (latestBuildPath != null) {
+	    let lastBuiltSourceData = builddb.loadFromPath(latestBuildPath, cancellable);
+	    let lastBuiltSourceVersion = builddb.parseVersionStr(lastBuiltSourceData['snapshotName']);
+	    if (lastBuiltSourceVersion == targetSourceVersion) {
+		print("Already built source snapshot " + lastBuiltSourceVersion);
+		return;
+	    } else {
+		print("Last successful build was " + lastBuiltSourceVersion);
+	    }
+	}
+	print("building " + targetSourceVersion);
+
 	this.repo = this.workdir.get_child('repo');
 
         GSystem.file_ensure_directory(this.repo, true, cancellable);
@@ -793,8 +811,6 @@ const Build = new Lang.Class({
 	    }
 	}
 
-	let buildresultDir = this.workdir.get_child('builds').get_child(prefix);
-	let builddb = new JsonDB.JsonDB(buildresultDir);
 	let targetRevisions = {};
 	let buildData = { snapshotName: this._snapshot.path.get_basename(),
 			  snapshot: this._snapshot.data,



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