[gnome-continuous] libqa: Drop use of 'current' symbolic link



commit 4bff74ac900145466a9fcec4b70f7ef90706133c
Author: Colin Walters <walters verbum org>
Date:   Tue Oct 1 10:15:20 2013 -0400

    libqa: Drop use of 'current' symbolic link
    
    A long while ago I added a hack to ostree to create a 'current'
    symbolic link so that this code could easily find the most recent
    deployment.  Since now OSTree has an introspectable sysroot API,
    that's no longer needed.

 src/js/libqa.js |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/js/libqa.js b/src/js/libqa.js
index 2620a1e..faef912 100644
--- a/src/js/libqa.js
+++ b/src/js/libqa.js
@@ -18,6 +18,7 @@
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Lang = imports.lang;
+const OSTree = imports.gi.OSTree;
 
 const GSystem = imports.gi.GSystem;
 const Params = imports.params;
@@ -147,10 +148,22 @@ function copyDisk(srcpath, destpath, cancellable) {
                      destpath.get_path()], cancellable);
 }
 
+function getSysrootAndCurrentDeployment(mntdir, osname) {
+    let sysroot = OSTree.Sysroot.new(mntdir);
+    sysroot.load(null);
+    let deployments = sysroot.get_deployments().filter(function (deployment) {
+       return deployment.get_osname() == osname;
+    });
+    if (deployments.length == 0)
+       throw new Error("No deployments for " + osname + " in " + mntdir.get_path());
+    let current = deployments[0];
+    return [sysroot, current];
+}
+
 function getDeployDirs(mntdir, osname) {
-    let basedir = mntdir.resolve_relative_path('ostree/deploy/' + osname);
-    return [basedir.get_child('current'),
-           basedir.get_child('current/etc')];
+    let [sysroot, current] = getSysrootAndCurrentDeployment(mntdir, osname);
+    let deployDir = sysroot.get_deployment_directory(current);
+    return [deployDir, deployDir.get_child('etc')];
 }
 
 function modifyBootloaderAppendKernelArgs(mntdir, kernelArgs, cancellable) {
@@ -247,7 +260,8 @@ function _findFirstFileMatching(dir, prefix, cancellable) {
 } 
 
 function _findCurrentKernel(mntdir, osname, cancellable) {
-    let deployBootdir = mntdir.resolve_relative_path('ostree/deploy/' + osname + '/current/boot');
+    let [sysroot, current] = getSysrootAndCurrentDeployment(mntdir, osname);
+    let deployBootdir = sysroot.get_deployment_directory(current).resolve_relative_path('boot');
     return [_findFirstFileMatching(deployBootdir, 'vmlinuz-', cancellable),
            _findFirstFileMatching(deployBootdir, 'initramfs-', cancellable)];
 };


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