[gnome-ostree] Only rebuild initramfs if certain components change
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree] Only rebuild initramfs if certain components change
- Date: Wed, 10 Apr 2013 10:49:37 +0000 (UTC)
commit 08f5ebb113199877815a9f2eb7dcc0563de21a02
Author: Colin Walters <walters verbum org>
Date: Sun Apr 7 15:47:14 2013 -0400
Only rebuild initramfs if certain components change
Beyond simple speed, this avoids a 15MB blob being stored per build,
and downloaded by every client on every update.
manifest.json | 4 ++++
src/js/tasks/task-build.js | 44 +++++++++++++++++++++++++++++++++++++++++---
2 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/manifest.json b/manifest.json
index 66e1339..75dab60 100644
--- a/manifest.json
+++ b/manifest.json
@@ -619,6 +619,7 @@
"config-args": ["--disable-tls-check"]},
{"src": "gnome:ostree",
+ "initramfs-depends": true,
"config-opts": ["--disable-documentation",
"--with-soup-gnome"]},
@@ -816,6 +817,7 @@
{"src": "git:git://git.kernel.org/pub/scm/boot/dracut/dracut.git",
"config-opts": ["--disable-documentation",
"--enable-systemd"],
+ "initramfs-depends": true,
"tag": "ae4758ce0d0ceeddabe4a78dd575c7b42c349a88",
"patches": ["dracut-Support-OSTree.patch",
"dracut-systemd-configure.patch"]},
@@ -847,6 +849,8 @@
{"src": "gnome:gnome-software"}
],
+
+ "initramfs-build-epoch": {"version": 0},
"build-epoch": {"version": 8,
"all": true,
diff --git a/src/js/tasks/task-build.js b/src/js/tasks/task-build.js
index dc6b2ca..94dce79 100644
--- a/src/js/tasks/task-build.js
+++ b/src/js/tasks/task-build.js
@@ -722,7 +722,7 @@ const TaskBuild = new Lang.Class({
return [treename, ostreeRevision];
},
- _generateInitramfs: function(architecture, composeRootdir, cancellable) {
+ _generateInitramfs: function(architecture, composeRootdir, initramfsDepends, cancellable) {
let e = composeRootdir.get_child('boot').enumerate_children('standard::*',
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, cancellable);
let info;
let kernelPath = null;
@@ -740,6 +740,31 @@ const TaskBuild = new Lang.Class({
let releaseIdx = kernelName.indexOf('-');
let kernelRelease = kernelName.substr(releaseIdx + 1);
+ let initramfsCachedir = this.cachedir.resolve_relative_path('initramfs/' + architecture);
+ GSystem.file_ensure_directory(initramfsCachedir, true, cancellable);
+
+ let initramfsEpoch = this._snapshot.data['initramfs-build-epoch'];
+ let initramfsEpochVersion = 0;
+ if (initramfsEpoch)
+ initramfsEpochVersion = initramfsEpoch['version'];
+ let fullInitramfsDependsString = 'epoch:' + initramfsEpochVersion +
+ ';kernel:' + kernelRelease + ';' +
+ initramfsDepends.join(';');
+ let dependsChecksum = GLib.compute_checksum_for_bytes(GLib.ChecksumType.SHA256,
+ GLib.Bytes.new(fullInitramfsDependsString));
+
+ let cachedInitramfsPath = initramfsCachedir.get_child(dependsChecksum);
+ if (cachedInitramfsPath.query_exists(null)) {
+ print("Reusing cached initramfs " + cachedInitramfsPath.get_path());
+ return [kernelRelease, cachedInitramfsPath];
+ } else {
+ print("No cached initramfs matching " + fullInitramfsDependsString);
+ }
+
+ // Clean out all old initramfs images
+ GSystem.shutil_rm_rf(initramfsCachedir, cancellable);
+ GSystem.file_ensure_directory(initramfsCachedir, true, cancellable);
+
let cwd = Gio.File.new_for_path('.');
let workdir = cwd.get_child('tmp-initramfs-' + architecture);
let varTmp = workdir.resolve_relative_path('var/tmp');
@@ -765,7 +790,9 @@ const TaskBuild = new Lang.Class({
GSystem.file_chmod(initramfsTmp, 420, cancellable);
- return [kernelRelease, initramfsTmp];
+ GSystem.file_rename(initramfsTmp, cachedInitramfsPath, cancellable);
+
+ return [kernelRelease, cachedInitramfsPath];
},
/* Build the Yocto base system. */
@@ -1065,9 +1092,20 @@ const TaskBuild = new Lang.Class({
let develTargetName = 'buildmaster/' + architecture + '-devel';
let develTarget = this._findTargetInList(develTargetName, targetsList);
+ // Gather a list of components upon which the initramfs depends
+ let initramfsDepends = [];
+ for (let j = 0; j < components.length; j++) {
+ let component = components[j];
+ if (!component['initramfs-depends'])
+ continue;
+ let archname = component['name'] + '/' + architecture;
+ let buildRev = componentBuildRevs[archname];
+ initramfsDepends.push(component['name'] + ':' + buildRev);
+ }
+
let [composeRootdir, relatedTmpPath] = this._checkoutOneTree(develTarget, componentBuildRevs,
cancellable);
- let [kernelRelease, initramfsPath] = this._generateInitramfs(architecture, composeRootdir,
cancellable);
+ let [kernelRelease, initramfsPath] = this._generateInitramfs(architecture, composeRootdir,
initramfsDepends, cancellable);
archInitramfsImages[architecture] = [kernelRelease, initramfsPath];
let initramfsTargetName = 'initramfs-' + kernelRelease + '.img';
let targetInitramfsPath =
composeRootdir.resolve_relative_path('boot').get_child(initramfsTargetName);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]