[gnome-ostree] builddisks: Update for new ostree deploy syntax



commit 21f596ad6ff1baaa547e9bba9310e5e109fbcdef
Author: Colin Walters <walters verbum org>
Date:   Mon Jul 8 10:11:16 2013 -0400

    builddisks: Update for new ostree deploy syntax

 src/js/libqa.js                 |   21 +++++++++++++++++----
 src/js/tasks/task-builddisks.js |    8 ++------
 2 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/src/js/libqa.js b/src/js/libqa.js
index 3cb1972..1d7e289 100644
--- a/src/js/libqa.js
+++ b/src/js/libqa.js
@@ -272,7 +272,7 @@ function _findCurrentOstreeBootArg(mntdir, cancellable) {
     throw new Error("Failed to find ostree= kernel argument");
 }
 
-function pullDeploy(mntdir, srcrepo, osname, target, revision, cancellable) {
+function pullDeploy(mntdir, srcrepo, osname, target, revision, originRepoUrl, cancellable) {
     let ostreedir = mntdir.get_child('ostree');
     let ostreeOsdir = ostreedir.resolve_relative_path('deploy/' + osname);
 
@@ -313,15 +313,28 @@ function pullDeploy(mntdir, srcrepo, osname, target, revision, cancellable) {
     // will clean up disks that were using the old ostree model.
     GSystem.shutil_rm_rf(ostreeOsdir, cancellable);
     
+    let repoPath = ostreedir.get_child('repo');
+    let repoArg = '--repo=' + repoPath.get_path();
     ProcUtil.runSync(adminCmd.concat(['os-init', osname]), cancellable,
                      {logInitiation: true, env: adminEnv});
-    ProcUtil.runSync(['ostree', '--repo=' + ostreedir.get_child('repo').get_path(),
-                      'pull-local', srcrepo.get_path(), revOrTarget], cancellable,
+    if (originRepoUrl)
+        ProcUtil.runSync(['ostree', repoArg,
+                          'remote', 'add', osname, originRepoUrl, target],
+                         cancellable, { logInitiation: true });
+    
+    ProcUtil.runSync(['ostree', repoArg,
+                      'pull-local', '--remote=' + osname, srcrepo.get_path(), revOrTarget], cancellable,
                      {logInitiation: true, env: adminEnv});
 
+    let origin = GLib.KeyFile.new();
+    origin.set_string('origin', 'refspec', osname + ':' + target);
+    let [originData, len] = origin.to_data();
+    let tmpOrigin = Gio.File.new_for_path('origin.tmp');
+    tmpOrigin.replace_contents(originData, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, 
cancellable);
+
     let rootArg = 'root=LABEL=gnostree-root';
     ProcUtil.runSync(adminCmd.concat(['deploy', '--karg=' + rootArg, '--karg=quiet', '--karg=splash',
-                                     osname, revOrTarget]), cancellable,
+                                     '--os=' + osname, '--origin-file=' + tmpOrigin.get_path(), 
revOrTarget]), cancellable,
                      {logInitiation: true, env: adminEnv});
 
     let defaultFstab = 'LABEL=gnostree-root / ext4 defaults 1 1\n\
diff --git a/src/js/tasks/task-builddisks.js b/src/js/tasks/task-builddisks.js
index 77c409b..be8f5c7 100644
--- a/src/js/tasks/task-builddisks.js
+++ b/src/js/tasks/task-builddisks.js
@@ -83,7 +83,7 @@ const TaskBuildDisks = new Lang.Class({
         let targets = buildData['targets'];
 
         let osname = buildData['snapshot']['osname'];
-        let repo = buildData['snapshot']['repo'];
+        let originRepoUrl = buildData['snapshot']['repo'];
 
         for (let targetName in targets) {
             let matched = false;
@@ -112,12 +112,8 @@ const TaskBuildDisks = new Lang.Class({
                                                              readWrite: true });
             gfmnt.mount(mntdir, cancellable);
             try {
-                LibQA.pullDeploy(mntdir, this.repo, osname, targetName, targetRevision,
+                LibQA.pullDeploy(mntdir, this.repo, osname, targetName, targetRevision, originRepoUrl,
                                  cancellable);
-                if (repo)
-                    ProcUtil.runSync(['ostree', '--repo=' + 
mntdir.resolve_relative_path('ostree/repo').get_path(),
-                                      'remote', 'add', osname, repo, targetName],
-                                     cancellable, { logInitiation: true });
             } finally {
                 gfmnt.umount(cancellable);
             }


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