Mailinglist Archive: yast-commit (500 mails)

< Previous Next >
[yast-commit] r66316 - in /trunk/snapper: VERSION agent-snapper/src/SnapperAgent.cc agent-snapper/src/SnapperAgent.h package/yast2-snapper.changes src/Snapper.ycp src/dialogs.ycp
Author: jsuchome
Date: Fri Oct 7 11:16:40 2011
New Revision: 66316

URL: http://svn.opensuse.org/viewcvs/yast?rev=66316&view=rev
Log:
- support more snapper configurations (bnc#719482)
- show path to current subvolume above filesystem tree (bnc#719482)
- close the feedback window correctly (bnc#722477)
- 2.21.11


Modified:
trunk/snapper/VERSION
trunk/snapper/agent-snapper/src/SnapperAgent.cc
trunk/snapper/agent-snapper/src/SnapperAgent.h
trunk/snapper/package/yast2-snapper.changes
trunk/snapper/src/Snapper.ycp
trunk/snapper/src/dialogs.ycp

Modified: trunk/snapper/VERSION
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/VERSION?rev=66316&r1=66315&r2=66316&view=diff
==============================================================================
--- trunk/snapper/VERSION (original)
+++ trunk/snapper/VERSION Fri Oct 7 11:16:40 2011
@@ -1 +1 @@
-2.21.10
+2.21.11

Modified: trunk/snapper/agent-snapper/src/SnapperAgent.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/SnapperAgent.cc?rev=66316&r1=66315&r2=66316&view=diff
==============================================================================
--- trunk/snapper/agent-snapper/src/SnapperAgent.cc (original)
+++ trunk/snapper/agent-snapper/src/SnapperAgent.cc Fri Oct 7 11:16:40 2011
@@ -18,13 +18,13 @@
/*
* search the map for value of given key; both key and value have to be strings
*/
-string SnapperAgent::getValue (const YCPMap map, const string key)
+string SnapperAgent::getValue (const YCPMap map, const string key, string
deflt)
{
if (!map->value(YCPString(key)).isNull()
&& map->value(YCPString(key))->isString())
return map->value(YCPString(key))->asString()->value();
else
- return "";
+ return deflt;
}

/**
@@ -139,7 +139,7 @@
if (!arg.isNull() && arg->isMap())
argmap = arg->asMap();

- if (!snapper_initialized && PC(0) != "error") {
+ if (!snapper_initialized && PC(0) != "error" && PC(0) != "configs") {
y2error ("snapper not initialized: use Execute (.snapper) first!");
snapper_error = "not_initialized";
return YCPVoid();
@@ -147,6 +147,24 @@

if (path->length() == 1) {

+ if (PC(0) == "configs") {
+ YCPList retlist;
+
+ try {
+ list<ConfigInfo> configs = Snapper::getConfigs();
+ for (list<ConfigInfo>::const_iterator it = configs.begin(); it
!= configs.end(); ++it)
+ {
+ retlist->add (YCPString (it->config_name));
+ }
+ }
+ catch (const ListConfigsFailedException& e)
+ {
+ y2error ("sysconfig file not found.");
+ snapper_error = "sysconfig_not_found";
+ return YCPVoid();
+ }
+ return retlist;
+ }
/**
* Read (.snapper.error) -> returns last error message
*/
@@ -242,7 +260,10 @@

for (Files::const_iterator it = files.begin(); it != files.end();
++it)
{
- retmap->add (YCPString (it->getName()), YCPString
(statusToString (it->getPreToPostStatus())));
+ YCPMap file_map;
+ file_map->add (YCPString ("status"), YCPString (statusToString
(it->getPreToPostStatus())));
+ file_map->add (YCPString ("full_path"), YCPString
(it->getAbsolutePath (LOC_SYSTEM)));
+ retmap->add (YCPString (it->getName()), file_map);
}
return retmap;
}
@@ -317,9 +338,17 @@
* Execute (.snapper) call: Initialize snapper object
*/
if (path->length() == 0) {
+
+ snapper_initialized = false;
+ if (sh)
+ {
+ y2milestone ("deleting existing snapper object");
+ deleteSnapper(sh);
+ }

+ string config_name = getValue (argmap, "config", "root");
try {
- sh = createSnapper();
+ sh = createSnapper (config_name);
}
catch (const ConfigNotFoundException& e)
{

Modified: trunk/snapper/agent-snapper/src/SnapperAgent.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/SnapperAgent.h?rev=66316&r1=66315&r2=66316&view=diff
==============================================================================
--- trunk/snapper/agent-snapper/src/SnapperAgent.h (original)
+++ trunk/snapper/agent-snapper/src/SnapperAgent.h Fri Oct 7 11:16:40 2011
@@ -35,9 +35,9 @@

/**
* search the map for value of given key; both key and value have to be
strings
- * when key is not present, empty string is returned
+ * when key is not present, default value is returned
*/
- string getValue (const YCPMap map, const string key);
+ string getValue (const YCPMap map, const string key, string deflt);

/**
* Search the map for value of given key

Modified: trunk/snapper/package/yast2-snapper.changes
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/package/yast2-snapper.changes?rev=66316&r1=66315&r2=66316&view=diff
==============================================================================
--- trunk/snapper/package/yast2-snapper.changes (original)
+++ trunk/snapper/package/yast2-snapper.changes Fri Oct 7 11:16:40 2011
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Fri Oct 7 11:15:53 CEST 2011 - jsuchome@xxxxxxx
+
+- support more snapper configurations (bnc#719482)
+- show path to current subvolume above filesystem tree (bnc#719482)
+- close the feedback window correctly (bnc#722477)
+- 2.21.11
+
+-------------------------------------------------------------------
Wed Sep 28 23:04:59 CEST 2011 - visnov@xxxxxxx

- set dialog title

Modified: trunk/snapper/src/Snapper.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/Snapper.ycp?rev=66316&r1=66315&r2=66316&view=diff
==============================================================================
--- trunk/snapper/src/Snapper.ycp (original)
+++ trunk/snapper/src/Snapper.ycp Fri Oct 7 11:16:40 2011
@@ -51,12 +51,17 @@
// index to snapshots list
global integer selected_snapshot_index = 0;

+// list of configurations
+global list<string> configs = [ "root" ];
+
+global string current_config = "root";
+
/**
* Return map of files modified between given snapshots
* Return structure has just one level, and maps each modified file to it's
modification map
*/
-global map<string,string> ReadModifiedFilesIndex (integer from, integer to) {
- return (map<string,string>) SCR::Read (.snapper.diff_index, $[ "from" :
from, "to" : to]);
+global map<string,map> ReadModifiedFilesIndex (integer from, integer to) {
+ return (map<string,map>) SCR::Read (.snapper.diff_index, $[ "from" : from,
"to" : to]);
}

/**
@@ -82,6 +87,16 @@
}

/**
+ * Return the full path to the given file from currently selected
configuration (subvolume)
+ * @param file path, relatively to current config
+ * GetFileFullPath ("/testfile.txt") -> /abc/testfile.txt for /abc subvolume
+ */
+global string GetFileFullPath (string file) {
+
+ return
snapshots[selected_snapshot_index,"files_index",file,"full_path"]:file;
+}
+
+/**
* Describe what was done with given file between given snapshots
* - when new is 0, meaning is 'current system'
*/
@@ -89,10 +104,10 @@

map ret = $[];
string file1 = sformat ("%1%2", GetSnapshotPath (old), file);
- string file2 = file;
- if (new != 0)
+ string file2 = sformat ("%1%2", GetSnapshotPath (new), file);
+ if (new == 0)
{
- file2 = sformat ("%1%2", GetSnapshotPath (new), file);
+ file2 = GetFileFullPath (file);
}

y2milestone ("comparing '%1' and '%2'", file1, file2);
@@ -159,7 +174,7 @@
*/
global boolean ReadSnapshots () {

-
+ snapshots = [];
list<map> snapshot_maps = (list<map>) SCR::Read (.snapper.snapshots);
if (snapshot_maps == nil) snapshot_maps = [];
integer i = 0;
@@ -172,8 +187,6 @@
id2index[id] = i;
i = i + 1;
});
-
-
return true;
}

@@ -182,13 +195,28 @@
return (map) SCR::Read (.snapper.error);
}

+
+global list<string> ReadConfigs () {
+
+ configs = (list<string>) SCR::Read (.snapper.configs);
+ if (configs == nil)
+ {
+ // error popup
+ Report::Error (_("File /etc/sysconfig/snapper is not available"));
+ configs = [ "root" ];
+ }
+ return configs;
+}
+
+
+
/**
* Initialize snapper agent
* Return true on success
*/
-global boolean InitializeSnapper () {
+global boolean InitializeSnapper (string config) {

- boolean init = (boolean) SCR::Execute (.snapper);
+ boolean init = (boolean) SCR::Execute (.snapper, $[ "config" :
config ]);
if (!init)
{
map err_map = LastSnapperErrorMap ();
@@ -238,7 +266,9 @@

Progress::NextStage();

- if (!InitializeSnapper ())
+ ReadConfigs ();
+
+ if (!InitializeSnapper (current_config))
{
return false;
}
@@ -252,13 +282,10 @@
/**
* Return the given file mode as octal number
*/
-global integer GetFileMode (string file) {
+integer GetFileMode (string file) {

map out = (map) SCR::Execute (.target.bash_output, "/bin/stat --printf=%a
" + file);
- string mode = out["stdout"]:"";
- if (mode == nil || mode == "")
- return 644;
- return tointeger (mode);
+ return tointeger (out["stdout"]:"755");
}

/**
@@ -287,8 +314,9 @@
UI::ChangeWidget (`id (`progress ), `Value, progress);

string orig = GetSnapshotPath (snapshot_num) + file;
+ string full_path= GetFileFullPath (file);
+ string dir = substring (full_path, 0, findlastof (full_path, "/"));

- string dir = substring (file, 0, findlastof (file, "/"));
if (!FileUtils::Exists (orig))
{
// log entry (%1 is file name)
@@ -300,24 +328,24 @@
if (FileUtils::IsDirectory (orig) == true)
{
map stat = (map) SCR::Read (.target.stat, orig);
- if (!FileUtils::Exists (file))
+ if (!FileUtils::Exists (full_path))
{
- SCR::Execute (.target.mkdir, file);
+ SCR::Execute (.target.mkdir, full_path);
}
- SCR::Execute (.target.bash, sformat ("/bin/chown %1:%2 '%3'",
stat["uid"]:0, stat["gid"]:0, file));
- SCR::Execute (.target.bash, sformat ("/bin/chmod %1 '%2'",
GetFileMode (orig), file));
+ SCR::Execute (.target.bash, sformat ("/bin/chown %1:%2 '%3'",
stat["uid"]:0, stat["gid"]:0, full_path));
+ SCR::Execute (.target.bash, sformat ("/bin/chmod %1 '%2'",
GetFileMode (orig), full_path));
}
else
{
- SCR::Execute (.target.bash, sformat ("/bin/cp -a '%1' '%2'",
orig, file));
+ SCR::Execute (.target.bash, sformat ("/bin/cp -a '%1' '%2'",
orig, full_path));
}
- UI::ChangeWidget (`id (`log), `LastLine, file + "\n");
+ UI::ChangeWidget (`id (`log), `LastLine, full_path + "\n");
}
else
{
- y2milestone ("failed to copy file '%1' to '%2' (dir: %3)", orig,
file, dir);
+ y2milestone ("failed to copy file '%1' to '%2' (dir: %3)", orig,
full_path, dir);
// log entry (%1 is file name)
- UI::ChangeWidget (`id (`log), `LastLine, sformat (_("%1
skipped\n"), file));
+ UI::ChangeWidget (`id (`log), `LastLine, sformat (_("%1
skipped\n"), full_path));
}
sleep (100);
progress = progress + 1;

Modified: trunk/snapper/src/dialogs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/dialogs.ycp?rev=66316&r1=66315&r2=66316&view=diff
==============================================================================
--- trunk/snapper/src/dialogs.ycp (original)
+++ trunk/snapper/src/dialogs.ycp Fri Oct 7 11:16:40 2011
@@ -67,12 +67,16 @@
/* summary dialog caption */
string caption = _("Snapshots");

- list<map> snapshots = Snapper::snapshots;
- integer i = -1;
+ list<map> snapshots = Snapper::snapshots;
+ list<string> configs = Snapper::configs;

list snapshot_items = [];

- foreach (map s, snapshots, {
+ list get_snapshot_items () {
+
+ integer i = -1;
+ snapshot_items = [];
+ foreach (map s, snapshots, {
i = i + 1;

integer num = s["num"]:0;
@@ -103,13 +107,23 @@
{
y2milestone ("skipping pre snapshot: %1", num);
}
- });
+ });
+ return snapshot_items;
+ }

term contents = `VBox (
+ `HBox (
+ // combo box label
+ `Label (_("Current Configuration")),
+ `ComboBox (`id (`configs), `opt (`notify), "", maplist (string
config, configs, {
+ return `item (`id (config), config, config ==
Snapper::current_config);
+ })),
+ `HStretch ()
+ ),
`Table (`id (`snapshots_table), `opt(`notify, `keepSorting), `header (
// table header
_("ID"), _("Type"), _("Start Date"), _("End Date"),
_("Description")),
- snapshot_items
+ get_snapshot_items ()
),
`HBox (
`PushButton (`id (`show_c), `opt (`default), _("Show Changes")),
@@ -127,6 +141,7 @@
{
UI::ChangeWidget (`id (`show_c), `Enabled, false);
}
+ UI::ChangeWidget (`id (`configs), `Enabled, size (configs) > 1);

any ret = nil;
while(true) {
@@ -150,8 +165,25 @@
Snapper::selected_snapshot_index = selected;
break;
}
- else if(ret == `next) {
- // TODO check if something needs to be written (description)
+ else if (ret == `configs) {
+ string config = (string) UI::QueryWidget (`id (ret), `Value);
+ if (config != Snapper::current_config)
+ {
+ Snapper::current_config = config;
+
+ // busy popup message
+ Popup::ShowFeedback ("", _("Reading list of snapshots..."));
+
+ Snapper::InitializeSnapper (config);
+ Snapper::ReadSnapshots ();
+ snapshots = Snapper::snapshots;
+ Popup::ClearFeedback ();
+
+ UI::ChangeWidget (`id (`snapshots_table), `Items,
get_snapshot_items ());
+ continue;
+ }
+ }
+ else if (ret == `next) {
break;
}
else {
@@ -221,16 +253,16 @@
if (!haskey (snapshot, "tree_map"))
{
snapshot["tree_map"] = Snapper::ReadModifiedFilesMap (from, to);
- Popup::ClearFeedback ();
tree_map = snapshot["tree_map"]:$[];
}
// full paths of files marked as modified, mapping to changes string
- map<string,string> files_index = $[];
+ map<string,map> files_index = $[];
if (!haskey (snapshot, "files_index"))
{
snapshot["files_index"] = Snapper::ReadModifiedFilesIndex (from, to);
Snapper::snapshots[Snapper::selected_snapshot_index] = snapshot;
}
+ Popup::ClearFeedback ();
files_index = snapshot["files_index"]:$[];

// update the global snapshots list
@@ -242,12 +274,11 @@
map<string,boolean> selected_items = $[];

boolean file_was_created (string file) {
- return (substring (files_index[file]:"", 0, 1) == "+");
+ return (substring (files_index[file,"status"]:"", 0, 1) == "+");
}
boolean file_was_removed (string file) {
- return (substring (files_index[file]:"", 0, 1) == "-");
+ return (substring (files_index[file,"status"]:"", 0, 1) == "-");
}
-
// go through the map defining filesystem tree and create the widget items
list<term> generate_tree_items (string current_path, map<string,map>
current_branch) {

@@ -439,6 +470,10 @@
}

string tree_label = sformat ("%1 - %2", previous_num, snapshot_num);
+ // find out the path to current subvolume
+ string subtree_path = Snapper::GetSnapshotPath (snapshot_num);
+ subtree_path = substring (subtree_path, 0, find (subtree_path,
".snapshots/"));
+
term date_widget = `VBox (
`HBox (
// label, date string will follow at the end of line
@@ -465,9 +500,10 @@
`HWeight (1, `HBox (`VSpacing (20), `VBox (`HSpacing(70),
`HBox (
`HSpacing (),
- `ReplacePoint (`id (`reptree),
+ `ReplacePoint (`id (`reptree), `VBox (
+ `Left (`Label (subtree_path)),
`Tree (`id(`tree), tree_label, [])
- ),
+ )),
`HSpacing ()
),
`HBox (
@@ -505,9 +541,10 @@

if (size (tree_items) > 0)
{
- UI::ReplaceWidget (`id (`reptree),
+ UI::ReplaceWidget (`id (`reptree), `VBox (
+ `Left (`Label (subtree_path)),
`Tree (`id(`tree), `opt (`notify, `immediate, `multiSelection,
`recursiveSelection), tree_label, tree_items)
- );
+ ));
// no item is selected
UI::ChangeWidget (`tree, `CurrentItem, nil);
}
@@ -575,7 +612,7 @@

%1

-from snapshot '%2' to current system?", current_file, previous_num)))
+from snapshot '%2' to current system?", Snapper::GetFileFullPath
(current_file), previous_num)))
{
Snapper::RestoreFiles (previous_num, [current_file]);
}
@@ -587,7 +624,7 @@

%1

-from snapshot '%2' to current system?", current_file, snapshot_num)))
+from snapshot '%2' to current system?", Snapper::GetFileFullPath
(current_file), snapshot_num)))
{
Snapper::RestoreFiles (snapshot_num, [current_file]);
}
@@ -595,22 +632,30 @@
}
else if (ret == `next) {
list<string> files = (list<string>) UI::QueryWidget (`id (`tree),
`SelectedItems);
+ list<string> to_restore = [];
files = filter (string file, files, {
- return haskey (files_index, file);
+ if (haskey (files_index, file))
+ {
+ to_restore = add (to_restore, Snapper::GetFileFullPath
(file));
+ return true;
+ }
+ else
+ {
+ return false;
+ }
});

- if (files == [])
+ if (to_restore == [])
{
// popup message
Popup::Message (_("No file was selected for restoring"));
continue;
}
- // FIXME restore from PRE or POST? (PRE by default)
// popup headline
if (Popup::AnyQuestionRichText (_("Restoring files"),
// popup message, %1 is snapshot number, %2 list of files
sformat (_("These files will be copied from snapshot '%1' to
current system: <p>%2</p>Are you sure?"),
- previous_num, mergestring (files, "<br>")),
+ previous_num, mergestring (to_restore, "<br>")),
60, 20, Label::YesButton (), Label::NoButton (), `focus_no))
{
Snapper::RestoreFiles (previous_num, files);

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages