]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- allow to set userdata for snapshots created by helper programs 156/head
authorArvin Schnell <aschnell@suse.de>
Tue, 3 Mar 2015 09:23:57 +0000 (10:23 +0100)
committerArvin Schnell <aschnell@suse.de>
Tue, 3 Mar 2015 09:23:57 +0000 (10:23 +0100)
client/Makefile.am
client/installation-helper.cc
client/systemd-helper.cc
package/snapper.changes

index dabca854423a76f804c23af9ec41832de6356bac..aecddbdeab65d7ce4abcc13001c2d11234e32706 100644 (file)
@@ -23,7 +23,8 @@ libexecdir = /usr/lib/snapper
 libexec_PROGRAMS = installation-helper systemd-helper
 
 installation_helper_SOURCES =          \
-       installation-helper.cc
+       installation-helper.cc          \
+       misc.cc         misc.h
 
 installation_helper_LDADD = ../snapper/libsnapper.la utils/libutils.la
 
@@ -32,6 +33,7 @@ systemd_helper_SOURCES =              \
        types.cc        types.h         \
        commands.cc     commands.h      \
        cleanup.cc      cleanup.h       \
+       misc.cc         misc.h          \
        errors.cc       errors.h
 
 systemd_helper_LDADD = ../snapper/libsnapper.la utils/libutils.la ../dbus/libdbus.la
index 8e80976b91c3ca0ffa8b51544d01aec88c564ab4..1bb0b46224a74323e8150bdacdfd3b36d0fcce30 100644 (file)
 
 #include "utils/GetOpts.h"
 
+#include "misc.h"
+
 
 using namespace snapper;
 using namespace std;
 
 
 void
-step1(const string& device, const string& description)
+step1(const string& device, const string& description, const map<string, string>& userdata)
 {
     // step runs in inst-sys
 
@@ -94,6 +96,7 @@ step1(const string& device, const string& description)
     SCD scd;
     scd.read_only = false;
     scd.description = description;
+    scd.userdata = userdata;
 
     Snapshots::iterator snapshot = snapper.createSingleSnapshot(scd);
 
@@ -222,6 +225,7 @@ main(int argc, char** argv)
        { "root-prefix",                required_argument,      0,      0 },
        { "default-subvolume-name",     required_argument,      0,      0 },
        { "description",                required_argument,      0,      0 },
+       { "userdata",                   required_argument,      0,      'u' },
        { 0, 0, 0, 0 }
     };
 
@@ -230,6 +234,7 @@ main(int argc, char** argv)
     string root_prefix = "/";
     string default_subvolume_name;
     string description;
+    map<string, string> userdata;
 
     GetOpts getopts;
 
@@ -254,8 +259,11 @@ main(int argc, char** argv)
     if ((opt = opts.find("description")) != opts.end())
        description = opt->second;
 
+    if ((opt = opts.find("userdata")) != opts.end())
+       userdata = read_userdata(opt->second);
+
     if (step == "1")
-       step1(device, description);
+       step1(device, description, userdata);
     else if (step == "2")
        step2(device, root_prefix, default_subvolume_name);
     else if (step == "3")
index e7830dc38f64fae7ab1f51b692c4e4cefbd8c2c5..db0a6687501c40e749a7f2c55c083766c84957f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Novell, Inc.
+ * Copyright (c) [2014-2015] Novell, Inc.
  *
  * All Rights Reserved.
  *
 #include "commands.h"
 #include "cleanup.h"
 #include "errors.h"
+#include "misc.h"
 
 
 using namespace snapper;
 using namespace std;
 
 
-GetOpts getopts;
-
 bool do_timeline = false;
 bool do_cleanup = false;
 
 
 void
-timeline(DBus::Connection* conn)
+timeline(DBus::Connection* conn, const map<string, string>& userdata)
 {
     list<XConfigInfo> config_infos = command_list_xconfigs(*conn);
     for (const XConfigInfo& config_info : config_infos)
@@ -53,7 +52,7 @@ timeline(DBus::Connection* conn)
        if (pos1 != config_info.raw.end() && pos1->second == "yes")
        {
            command_create_single_xsnapshot(*conn, config_info.config_name, "timeline",
-                                           "timeline", map<string, string>());
+                                           "timeline", userdata);
        }
     }
 }
@@ -94,25 +93,35 @@ main(int argc, char** argv)
     const struct option options[] = {
        { "timeline",           no_argument,            0,      0 },
        { "cleanup",            no_argument,            0,      0 },
+       { "userdata",           required_argument,      0,      'u' },
        { 0, 0, 0, 0 }
     };
 
+    map<string, string> userdata;
+
+    GetOpts getopts;
+
     getopts.init(argc, argv);
 
     GetOpts::parsed_opts opts = getopts.parse(options);
 
+    GetOpts::parsed_opts::const_iterator opt;
+
     if (opts.find("timeline") != opts.end())
        do_timeline = true;
 
     if (opts.find("cleanup") != opts.end())
        do_cleanup = true;
 
+    if ((opt = opts.find("userdata")) != opts.end())
+       userdata = read_userdata(opt->second);
+
     try
     {
        DBus::Connection conn(DBUS_BUS_SYSTEM);
 
        if (do_timeline)
-           timeline(&conn);
+           timeline(&conn, userdata);
 
        if (do_cleanup)
            cleanup(&conn);
index ef5531b93b403c02d4490cf780d37be78e1829a2..ff7da09dacec8f6ff7421c76e9490d07f6d9725c 100644 (file)
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Tue Mar 03 10:22:28 CET 2015 - aschnell@suse.de
+
+- allow to set userdata for snapshots created by helper programs
+
 -------------------------------------------------------------------
 Mon Mar 02 17:30:06 CET 2015 - aschnell@suse.de