]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Add snapshots creation to installation helpers
authorImobach González Sosa <igonzalezsosa@suse.com>
Thu, 14 May 2015 14:26:10 +0000 (15:26 +0100)
committerImobach González Sosa <igonzalezsosa@suse.com>
Fri, 15 May 2015 07:57:53 +0000 (08:57 +0100)
client/installation-helper.cc

index 1bb0b46224a74323e8150bdacdfd3b36d0fcce30..84f186edb0dcdbffe333a5181d2e6d722c56764a 100644 (file)
@@ -195,6 +195,38 @@ step4()
     cout << "done" << endl;
 }
 
+void
+step5(const string& description)
+{
+    // step runs in chroot
+
+    // preconditions (maybe incomplete):
+    // snapper rpms installed in chroot
+
+    unsigned int num;
+
+    SCD scd;
+    scd.read_only = false;
+    scd.description = description;
+
+    Snapper snapper("root", "/");
+
+    try
+    {
+        Snapshots::iterator snapshot = snapper.createSingleSnapshot(scd);
+        num = snapshot->getNum();
+        snapper.getFilesystem()->setDefault(num);
+    }
+    catch (const runtime_error& e)
+    {
+        y2err("create snapshot failed, " << e.what());
+        exit(EXIT_FAILURE);
+    }
+
+    cout << num << endl;
+    exit(EXIT_SUCCESS);
+}
+
 
 void
 log_do(LogLevel level, const string& component, const char* file, const int line, const char* func,
@@ -270,4 +302,6 @@ main(int argc, char** argv)
        step3(root_prefix, default_subvolume_name);
     else if (step == "4")
        step4();
+    else if (step == "5")
+       step5(description);
 }