[gnome-ostree] build: Compute yocto build status inside build.js, not script



commit 031085573942815f41d49d19eb2539482432273a
Author: Colin Walters <walters verbum org>
Date:   Fri Dec 21 16:30:28 2012 -0500

    build: Compute yocto build status inside build.js, not script
    
    This is faster, and avoids us running either linux-user-chroot or the
    tar import again.

 src/ostbuild/js/build.js        |   14 ++++++++++++++
 src/ostbuild/ostree-build-yocto |   22 ----------------------
 2 files changed, 14 insertions(+), 22 deletions(-)
---
diff --git a/src/ostbuild/js/build.js b/src/ostbuild/js/build.js
index 0d64109..2c1a81d 100644
--- a/src/ostbuild/js/build.js
+++ b/src/ostbuild/js/build.js
@@ -582,6 +582,18 @@ const Build = new Lang.Class({
         let builddirName = Format.vprintf('build-%s-%s', [basemeta['name'], architecture]);
         let builddir = this.workdir.get_child(builddirName);
 
+	let builtRevisionPath = builddir.get_child('built-revision');
+	if (builtRevisionPath.query_exists(cancellable)) {
+	    let builtRevision = GSystem.file_load_contents_utf8(builtRevisionPath, cancellable);
+	    builtRevision = builtRevision.replace(/[ \n]/g, '');
+	    if (builtRevision == basemeta['revision']) {
+		print(Format.vprintf("Already built %s at %s", [builddirName, builtRevision]));
+		return;
+	    } else {
+		print(Format.vprintf("%s was %s, now at revision %s", [builddirName, builtRevision, basemeta['revision']]));
+	    }
+	} 
+
         // Just keep reusing the old working directory downloads and sstate
         let oldBuilddir = this.workdir.get_child('build-' + basemeta['name']);
         let sstateDir = oldBuilddir.get_child('sstate-cache');
@@ -611,6 +623,8 @@ const Build = new Lang.Class({
 			     {logInitiation: true});
 	    GSystem.file_unlink(tarPath, cancellable);
 	}
+
+	builtRevisionPath.replace_contents(basemeta['revision'], null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, cancellable);
     },
         
     execute: function(argv) {
diff --git a/src/ostbuild/ostree-build-yocto b/src/ostbuild/ostree-build-yocto
index e7d3199..095b04a 100644
--- a/src/ostbuild/ostree-build-yocto
+++ b/src/ostbuild/ostree-build-yocto
@@ -38,23 +38,6 @@ test -n "${architecture}" || (usage; exit 1)
 repo_path=$4
 test -n "${repo_path}" || (usage; exit 1)
 
-src_gitrev=$(cd ${srcdir} && git rev-parse HEAD)
-built_gitrev_path=${builddir}/built-revision
-if test -f ${built_gitrev_path}; then
-    built_gitrev=$(cat ${built_gitrev_path})
-else
-    built_gitrev=
-fi
-
-if test x${src_gitrev} = x${built_gitrev}; then
-    echo "Already built ${src_gitrev}"
-    exit 0
-else
-    if test -n "${built_gitrev}"; then
-	echo "Yocto build ${src_gitrev} differs from previous ${built_gitrev}"
-    fi
-fi
-
 . "${srcdir}/oe-init-build-env" "${builddir}"
 
 if ! grep -q meta-gnomeos ${builddir}/conf/bblayers.conf; then
@@ -92,13 +75,8 @@ IMAGEDIR=${builddir}/tmp-eglibc/deploy/images
 mkdir -p "${IMAGEDIR}"
 ln -sf ${repo_path} ${IMAGEDIR}/repo
 
-echo "Building ${src_gitrev}"
 bitbake gnomeos-contents-{runtime,devel}
 
 for basetype in runtime devel; do
     ln -sf ${builddir}/tmp-eglibc/deploy/images/gnomeos-contents-${basetype}-${MACHINE}.tar.gz gnomeos-contents-${basetype}-${architecture}.tar.gz
 done
-
-echo ${src_gitrev} > ${built_gitrev_path}.tmp
-mv ${built_gitrev_path}.tmp ${built_gitrev_path}
-exit 0



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