s = getenv("SNAPPER_ZYPP_PLUGIN_DBUS_SESSION");
if (s != nullptr) {
- bus = DBUS_BUS_SESSION;
- }
+ bus = DBUS_BUS_SESSION;
+ }
}
};
try {
cerr << "INFO:" << "creating pre snapshot" << endl;
pre_snapshot_num = command_create_pre_snapshot(
- dbus_conn, snapper_cfg,
- snapshot_description, cleanup_algorithm, userdata
- );
+ dbus_conn, snapper_cfg,
+ snapshot_description, cleanup_algorithm, userdata
+ );
cerr << "DEBUG:" << "created pre snapshot " << pre_snapshot_num << endl;
}
- catch (const DBus::ErrorException& ex) {
+ catch (const DBus::ErrorException& ex) {
SN_CAUGHT(ex);
cerr << "ERROR:" << error_description(ex) << endl;
}
modification_data.cleanup = cleanup_algorithm;
modification_data.userdata = userdata;
command_set_snapshot(
- dbus_conn, snapper_cfg,
- pre_snapshot_num, modification_data
- );
+ dbus_conn, snapper_cfg,
+ pre_snapshot_num, modification_data
+ );
}
catch (const DBus::ErrorException& ex) {
SN_CAUGHT(ex);
try {
cerr << "INFO:" << "creating post snapshot" << endl;
unsigned int post_snapshot_num = command_create_post_snapshot(
- dbus_conn, snapper_cfg,
- pre_snapshot_num, "", cleanup_algorithm, userdata
- );
+ dbus_conn, snapper_cfg,
+ pre_snapshot_num, "", cleanup_algorithm, userdata
+ );
cerr << "DEBUG:" << "created post snapshot " << post_snapshot_num << endl;
}
catch (const DBus::ErrorException& ex) {
auto it = msg.headers.find("userdata");
if (it != msg.headers.end()) {
const string& userdata_s = it->second;
- vector<string> key_values;
+ vector<string> key_values;
boost::split(key_values, userdata_s, boost::is_any_of(","));
for (auto kv: key_values) {
static const snapper::Regex rx_keyval("^([^=]*)=(.+)$");
// https://doc.opensuse.org/projects/libzypp/SLE12SP2/plugin-commit.html
json_object * steps = object_get(zypp, "TransactionStepList");
if (!steps)
- return result;
+ return result;
if (json_object_get_type(steps) == json_type_array) {
- size_t i, len = json_object_array_length(steps);
- printf("steps: %zu\n", len);
- for (i = 0; i < len; ++i) {
- json_object * step = json_object_array_get_idx(steps, i);
- bool have_type = json_object_object_get_ex(step, "type", NULL);
- bool have_stage = json_object_object_get_ex(step, "stage", NULL);
- if (have_type && (phase == Phase::BEFORE || have_stage)) {
- json_object * solvable = object_get(step, "solvable");
- if (!solvable) {
- cerr << "ERROR:" << "in item #" << i << endl;
- continue;
- }
- json_object * name = object_get(solvable, "n");
- if (!name) {
- cerr << "ERROR:" << "in item #" << i << endl;
- continue;
- }
- if (json_object_get_type(name) != json_type_string) {
- cerr << "ERROR:" << "\"n\" is not a string" << endl;
- cerr << "ERROR:" << "in item #" << i << endl;
- continue;
- }
- else {
- const char * prize = json_object_get_string(name);
+ size_t i, len = json_object_array_length(steps);
+ printf("steps: %zu\n", len);
+ for (i = 0; i < len; ++i) {
+ json_object * step = json_object_array_get_idx(steps, i);
+ bool have_type = json_object_object_get_ex(step, "type", NULL);
+ bool have_stage = json_object_object_get_ex(step, "stage", NULL);
+ if (have_type && (phase == Phase::BEFORE || have_stage)) {
+ json_object * solvable = object_get(step, "solvable");
+ if (!solvable) {
+ cerr << "ERROR:" << "in item #" << i << endl;
+ continue;
+ }
+ json_object * name = object_get(solvable, "n");
+ if (!name) {
+ cerr << "ERROR:" << "in item #" << i << endl;
+ continue;
+ }
+ if (json_object_get_type(name) != json_type_string) {
+ cerr << "ERROR:" << "\"n\" is not a string" << endl;
+ cerr << "ERROR:" << "in item #" << i << endl;
+ continue;
+ }
+ else {
+ const char * prize = json_object_get_string(name);
result.insert(prize);
- }
- }
- }
+ }
+ }
+ }
}
return result;
bool SolvableMatcher::match(const string& solvable) const {
log << "DEBUG:"
- << "match? " << solvable
- << " by " << ((kind == Kind::GLOB)? "GLOB '": "REGEX '")
- << pattern << '\'' << endl;
+ << "match? " << solvable
+ << " by " << ((kind == Kind::GLOB)? "GLOB '": "REGEX '")
+ << pattern << '\'' << endl;
bool res;
if (kind == Kind::GLOB) {
- static const int flags = 0;
- res = fnmatch(pattern.c_str(), solvable.c_str(), flags) == 0;
+ static const int flags = 0;
+ res = fnmatch(pattern.c_str(), solvable.c_str(), flags) == 0;
}
else {
- // POSIX Extended Regular Expression Syntax
+ // POSIX Extended Regular Expression Syntax
// The original Python implementation allows "foo" to match "foo-devel"
snapper::Regex rx_pattern("^" + pattern, REG_EXTENDED | REG_NOSUB);
- res = rx_pattern.match(solvable);
+ res = rx_pattern.match(solvable);
}
log << "DEBUG:" << "-> " << res << endl;
return res;
const xmlNode* solvables_n = getChildNode(root, "solvables");
const list<const xmlNode*> solvables_l = getChildNodes(solvables_n, "solvable");
for (auto node: solvables_l) {
- string pattern;
- Kind kind;
- bool important = false;
+ string pattern;
+ Kind kind;
+ bool important = false;
- getAttributeValue(node, "important", important);
- string kind_s;
- getAttributeValue(node, "match", kind_s);
- getValue(node, pattern);
- if (kind_s == "w") { // w for wildcard
- kind = Kind::GLOB;
- }
- else if (kind_s == "re") { // Regular Expression
- kind = Kind::REGEX;
- }
- else {
- log << "ERROR:" << "Unknown match attribute '" << kind_s << "', disregarding pattern '"<< pattern << "'" << endl;
- continue;
- }
+ getAttributeValue(node, "important", important);
+ string kind_s;
+ getAttributeValue(node, "match", kind_s);
+ getValue(node, pattern);
+ if (kind_s == "w") { // w for wildcard
+ kind = Kind::GLOB;
+ }
+ else if (kind_s == "re") { // Regular Expression
+ kind = Kind::REGEX;
+ }
+ else {
+ log << "ERROR:" << "Unknown match attribute '" << kind_s << "', disregarding pattern '"<< pattern << "'" << endl;
+ continue;
+ }
- result.emplace_back(SolvableMatcher(pattern, kind, important));
+ result.emplace_back(SolvableMatcher(pattern, kind, important));
}
return result;
}
-