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
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
#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
SCD scd;
scd.read_only = false;
scd.description = description;
+ scd.userdata = userdata;
Snapshots::iterator snapshot = snapper.createSingleSnapshot(scd);
{ "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 }
};
string root_prefix = "/";
string default_subvolume_name;
string description;
+ map<string, string> userdata;
GetOpts getopts;
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")
/*
- * 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)
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);
}
}
}
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);
+-------------------------------------------------------------------
+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