Mailinglist Archive: yast-commit (195 mails)

< Previous Next >
[yast-commit] r63520 - in /trunk/snapper: ./ agent-snapper/ agent-snapper/conf/ agent-snapper/doc/ agent-snapper/doc/autodocs/ agent-snapper/src/ doc/ doc/autodocs/ package/ src/ testsuite/ testsuite/tests/
Author: jsuchome
Date: Mon Mar 7 10:21:10 2011
New Revision: 63520

URL: http://svn.opensuse.org/viewcvs/yast?rev=63520&view=rev
Log:
- first release for Factory
- 2.21.0


Added:
trunk/snapper/
trunk/snapper/MAINTAINER
trunk/snapper/Makefile.cvs
trunk/snapper/RPMNAME
trunk/snapper/VERSION
trunk/snapper/_cvsignore
trunk/snapper/agent-snapper/
trunk/snapper/agent-snapper/Makefile.am
trunk/snapper/agent-snapper/conf/
trunk/snapper/agent-snapper/conf/Makefile.am
trunk/snapper/agent-snapper/conf/snapper.scr
trunk/snapper/agent-snapper/doc/
trunk/snapper/agent-snapper/doc/Makefile.am
trunk/snapper/agent-snapper/doc/autodocs/
trunk/snapper/agent-snapper/doc/autodocs/Makefile.am
trunk/snapper/agent-snapper/src/
trunk/snapper/agent-snapper/src/Makefile.am
trunk/snapper/agent-snapper/src/SnapperAgent.cc
trunk/snapper/agent-snapper/src/SnapperAgent.h
trunk/snapper/agent-snapper/src/Y2CCSnapperAgent.cc
trunk/snapper/configure.in.in
trunk/snapper/doc/
trunk/snapper/doc/Makefile.am
trunk/snapper/doc/_cvsignore
trunk/snapper/doc/autodocs/
trunk/snapper/doc/autodocs/Makefile.am
trunk/snapper/doc/autodocs/_cvsignore
trunk/snapper/package/
trunk/snapper/package/_cvsignore
trunk/snapper/package/yast2-snapper.changes
trunk/snapper/src/
trunk/snapper/src/Makefile.am
trunk/snapper/src/Snapper.ycp (with props)
trunk/snapper/src/_cvsignore
trunk/snapper/src/dialogs.ycp (with props)
trunk/snapper/src/helps.ycp (with props)
trunk/snapper/src/snapper.desktop
trunk/snapper/src/snapper.ycp (with props)
trunk/snapper/src/wizards.ycp (with props)
trunk/snapper/testsuite/
trunk/snapper/testsuite/Makefile.am
trunk/snapper/testsuite/_cvsignore
trunk/snapper/testsuite/tests/
trunk/snapper/testsuite/tests/_cvsignore
trunk/snapper/yast2-snapper.spec.in

Added: trunk/snapper/MAINTAINER
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/MAINTAINER?rev=63520&view=auto
==============================================================================
--- trunk/snapper/MAINTAINER (added)
+++ trunk/snapper/MAINTAINER Mon Mar 7 10:21:10 2011
@@ -0,0 +1 @@
+Jiri Suchomel <jsuchome@xxxxxxx>

Added: trunk/snapper/Makefile.cvs
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/Makefile.cvs?rev=63520&view=auto
==============================================================================
--- trunk/snapper/Makefile.cvs (added)
+++ trunk/snapper/Makefile.cvs Mon Mar 7 10:21:10 2011
@@ -0,0 +1,22 @@
+#
+# Makefile.cvs
+#
+PREFIX = /usr
+
+LIB = $(shell y2tool get-lib)
+
+configure: all
+ ./configure --prefix=$(PREFIX) --libdir=$(PREFIX)/$(LIB)
+
+all:
+ y2tool y2autoconf
+ y2tool y2automake
+ autoreconf --force --install
+
+install: configure
+ make
+ make install
+
+reconf: all
+ ./config.status --recheck
+ ./config.status

Added: trunk/snapper/RPMNAME
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/RPMNAME?rev=63520&view=auto
==============================================================================
--- trunk/snapper/RPMNAME (added)
+++ trunk/snapper/RPMNAME Mon Mar 7 10:21:10 2011
@@ -0,0 +1 @@
+yast2-snapper

Added: trunk/snapper/VERSION
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/VERSION?rev=63520&view=auto
==============================================================================
--- trunk/snapper/VERSION (added)
+++ trunk/snapper/VERSION Mon Mar 7 10:21:10 2011
@@ -0,0 +1 @@
+2.21.0

Added: trunk/snapper/_cvsignore
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/_cvsignore?rev=63520&view=auto
==============================================================================
--- trunk/snapper/_cvsignore (added)
+++ trunk/snapper/_cvsignore Mon Mar 7 10:21:10 2011
@@ -0,0 +1,20 @@
+Makefile
+Makefile.am
+Makefile.am.common
+Makefile.in
+aclocal.m4
+config.cache
+config.guess
+config.h.in
+config.log
+config.status
+config.sub
+configure
+configure.in
+depcomp
+install-sh
+missing
+mkinstalldirs
+stamp-h
+snapper.pot
+autom4te.cache

Added: trunk/snapper/agent-snapper/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/Makefile.am (added)
+++ trunk/snapper/agent-snapper/Makefile.am Mon Mar 7 10:21:10 2011
@@ -0,0 +1 @@
+SUBDIRS = conf doc src testsuite

Added: trunk/snapper/agent-snapper/conf/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/conf/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/conf/Makefile.am (added)
+++ trunk/snapper/agent-snapper/conf/Makefile.am Mon Mar 7 10:21:10 2011
@@ -0,0 +1,7 @@
+#
+# Makefile.am for .../agent-snapper/conf
+#
+
+scrconf_DATA = snapper.scr
+
+EXTRA_DIST = $(scrconf_DATA)

Added: trunk/snapper/agent-snapper/conf/snapper.scr
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/conf/snapper.scr?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/conf/snapper.scr (added)
+++ trunk/snapper/agent-snapper/conf/snapper.scr Mon Mar 7 10:21:10 2011
@@ -0,0 +1,14 @@
+/**
+ * File: snapper.scr
+ * Summary: snapper agent: access to snapper library
+ * Author: Jiri Suchomel <jsuchome@xxxxxxx>
+ * Access: read / write / execute
+ *
+ * Example:
+ *
+ */
+.snapper
+
+`ag_snapper(
+ `SnapperAgent()
+)

Added: trunk/snapper/agent-snapper/doc/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/doc/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/doc/Makefile.am (added)
+++ trunk/snapper/agent-snapper/doc/Makefile.am Mon Mar 7 10:21:10 2011
@@ -0,0 +1 @@
+SUBDIRS = autodocs

Added: trunk/snapper/agent-snapper/doc/autodocs/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/doc/autodocs/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/doc/autodocs/Makefile.am (added)
+++ trunk/snapper/agent-snapper/doc/autodocs/Makefile.am Mon Mar 7 10:21:10
2011
@@ -0,0 +1,6 @@
+#
+# Makefile.am for .../agent-snapper/doc/autodocs
+#
+
+AUTODOCS_SUBDIR=agent-snapper
+include $(top_srcdir)/autodocs-cc.ami

Added: trunk/snapper/agent-snapper/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/src/Makefile.am (added)
+++ trunk/snapper/agent-snapper/src/Makefile.am Mon Mar 7 10:21:10 2011
@@ -0,0 +1,24 @@
+
+# Makefile.am for .../agent-snapper/src
+#
+
+AM_CXXFLAGS = -DY2LOG=\"agent-snapper\" -Wall
+
+plugin_LTLIBRARIES = libpy2ag_snapper.la
+noinst_LTLIBRARIES = liby2ag_snapper.la
+
+liby2ag_snapper_la_SOURCES = \
+ SnapperAgent.cc \
+ SnapperAgent.h
+liby2ag_snapper_la_LDFLAGS = -version-info 2:0
+liby2ag_snapper_la_LIBADD = @AGENT_LIBADD@ -lsnapper
+
+
+libpy2ag_snapper_la_SOURCES = \
+ $(liby2ag_snapper_la_SOURCES) \
+ Y2CCSnapperAgent.cc
+libpy2ag_snapper_la_LDFLAGS = -version-info 2:0
+libpy2ag_snapper_la_LIBADD = @AGENT_LIBADD@ -lsnapper
+
+
+INCLUDES = -I$(includedir)

Added: trunk/snapper/agent-snapper/src/SnapperAgent.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/SnapperAgent.cc?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/src/SnapperAgent.cc (added)
+++ trunk/snapper/agent-snapper/src/SnapperAgent.cc Mon Mar 7 10:21:10 2011
@@ -0,0 +1,227 @@
+/* SnapperAgent.cc
+ *
+ * An agent for accessing snapper library
+ *
+ * Authors: Jiri Suchomel <jsuchome@xxxxxxx>
+ *
+ * $Id: SnapperAgent.cc 63174 2011-01-13 10:50:42Z jsuchome $
+ */
+
+#include "SnapperAgent.h"
+#include <ctype.h>
+
+#define PC(n) (path->component_str(n))
+
+using namespace snapper;
+
+/*
+ * 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)
+{
+ if (!map->value(YCPString(key)).isNull()
+ && map->value(YCPString(key))->isString())
+ return map->value(YCPString(key))->asString()->value();
+ else
+ return "";
+}
+
+/**
+ * Search the map for value of given key
+ * @param map YCP Map to look in
+ * @param key key we are looking for
+ * @param deflt the default value to be returned if key is not found
+ */
+int SnapperAgent::getIntValue (const YCPMap map, const string key, int deflt)
+{
+ if (!map->value(YCPString(key)).isNull() &&
map->value(YCPString(key))->isInteger()) {
+ return map->value(YCPString(key))->asInteger()->value();
+ }
+ else if (!map->value(YCPString(key)).isNull() &&
+ map->value(YCPString(key))->isString()) {
+ YCPInteger i (map->value(YCPString(key))->asString()->value().c_str());
+ return i->value();
+ }
+ return deflt;
+}
+
+string statusToString(unsigned int status)
+{
+ string ret;
+
+ if (status & CREATED)
+ ret += "+";
+ else if (status & DELETED)
+ ret += "-";
+ else if (status & TYPE)
+ ret += "t";
+ else if (status & CONTENT)
+ ret += "c";
+ else
+ ret += ".";
+
+ ret += status & PERMISSIONS ? "p" : ".";
+ ret += status & USER ? "u" : ".";
+ ret += status & GROUP ? "g" : ".";
+
+ return ret;
+}
+
+/**
+ * Constructor
+ */
+SnapperAgent::SnapperAgent() : SCRAgent()
+{
+ sh = createSnapper();
+}
+
+/**
+ * Destructor
+ */
+SnapperAgent::~SnapperAgent()
+{
+ deleteSnapper(sh);
+}
+
+
+/**
+ * Dir
+ */
+YCPList SnapperAgent::Dir(const YCPPath& path)
+{
+ y2error("Wrong path '%s' in Read().", path->toString().c_str());
+ return YCPNull();
+}
+
+/**
+ * Read
+ */
+YCPValue SnapperAgent::Read(const YCPPath &path, const YCPValue& arg, const
YCPValue& opt) {
+
+ y2internal ("path in Read: '%s'.", path->toString().c_str());
+ YCPValue ret = YCPVoid();
+
+ YCPMap argmap;
+ if (!arg.isNull() && arg->isMap())
+ argmap = arg->asMap();
+
+ if (path->length() == 1) {
+
+ /**
+ * error: Read(.snapper.error) -> returns last error message
+ */
+ if (PC(0) == "error") {
+ YCPMap retmap;
+ return retmap;
+ }
+ /**
+ * Read(.snapper.snapshots) -> return list of snapshot description maps
+ */
+ if (PC(0) == "snapshots") {
+ YCPList retlist;
+ const Snapshots& snapshots = sh->getSnapshots();
+ for (Snapshots::const_iterator it = snapshots.begin(); it !=
snapshots.end(); ++it)
+ {
+ YCPMap s;
+
+ switch (it->getType())
+ {
+ case SINGLE: s->add (YCPString ("type"), YCPSymbol
("SINGLE")); break;
+ case PRE: s->add (YCPString ("type"), YCPSymbol ("PRE"));
break;
+ case POST: s->add (YCPString ("type"), YCPSymbol ("POST"));
break;
+ }
+
+ s->add (YCPString ("num"), YCPInteger (it->getNum()));
+ s->add (YCPString ("date"), YCPInteger (it->getDate()));
+
+ if (it->getType() == SINGLE || it->getType() == PRE)
+ {
+ s->add (YCPString ("description"), YCPString
(it->getDescription()));
+ if (it->getType() == PRE)
+ s->add (YCPString ("post_num"), YCPInteger
(snapshots.findPost (it)->getNum ()));
+ }
+ else if (it->getType() == POST)
+ {
+ s->add (YCPString ("pre_num"), YCPInteger
(it->getPreNum()));
+ }
+
+ y2internal ("snapshot %s", s.toString().c_str());
+ retlist->add (s);
+ }
+ return retlist;
+ }
+
+ /**
+ * Read(.snapper.diff) -> show difference between snapnots num1 and
num2.
+ */
+ if (PC(0) == "diff") {
+ YCPList retlist;
+ unsigned int num1 = getIntValue (argmap, "from", 0);
+ unsigned int num2 = getIntValue (argmap, "to", 0);
+
+ const Snapshots& snapshots = sh->getSnapshots();
+
+ const Comparison comparison(sh, snapshots.find(num1),
snapshots.find(num2));
+
+ const Files& files = comparison.getFiles();
+ for (Files::const_iterator it = files.begin(); it != files.end();
++it)
+ {
+ YCPMap filemap;
+ filemap->add (YCPString ("name"), YCPString (it->getName()));
+ // FIXME it's PreToPostStatus!
+ filemap->add (YCPString ("changes"), YCPString (statusToString
(it->getPreToPostStatus())));
+ retlist->add (filemap);
+ }
+ return retlist;
+ }
+ else {
+ y2error("Wrong path '%s' in Read().", path->toString().c_str());
+ }
+ }
+ else if (path->length() == 2) {
+
+ y2error("Wrong path '%s' in Read().", path->toString().c_str());
+ }
+ else {
+ y2error("Wrong path '%s' in Read().", path->toString().c_str());
+ }
+ return YCPVoid();
+}
+
+/**
+ * Write
+ */
+YCPBoolean SnapperAgent::Write(const YCPPath &path, const YCPValue& arg,
+ const YCPValue& arg2)
+{
+ y2internal ("path in Write: '%s'.", path->toString().c_str());
+
+ YCPBoolean ret = YCPBoolean(true);
+ return ret;
+}
+
+/**
+ * Execute
+ */
+YCPValue SnapperAgent::Execute(const YCPPath &path, const YCPValue& arg,
+ const YCPValue& arg2)
+{
+ y2internal ("path in Execute: '%s'.", path->toString().c_str());
+ YCPValue ret = YCPBoolean (true);
+ return ret;
+}
+
+/**
+ * otherCommand
+ */
+YCPValue SnapperAgent::otherCommand(const YCPTerm& term)
+{
+ string sym = term->name();
+
+ if (sym == "SnapperAgent") {
+ /* Your initialization */
+ return YCPVoid();
+ }
+
+ return YCPNull();
+}

Added: trunk/snapper/agent-snapper/src/SnapperAgent.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/SnapperAgent.h?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/src/SnapperAgent.h (added)
+++ trunk/snapper/agent-snapper/src/SnapperAgent.h Mon Mar 7 10:21:10 2011
@@ -0,0 +1,96 @@
+/* SnapperAgent.h
+ *
+ * Snapper agent implementation
+ *
+ * Authors: Jiri Suchomel <jsuchome@xxxxxxx>
+ *
+ * $Id: SnapperAgent.h 63174 2011-01-13 10:50:42Z jsuchome $
+ */
+
+#ifndef _SnapperAgent_h
+#define _SnapperAgent_h
+
+#include <Y2.h>
+#include <scr/SCRAgent.h>
+
+#include <snapper/Snapper.h>
+#include <snapper/Factory.h>
+#include <snapper/Snapshot.h>
+#include <snapper/Comparison.h>
+#include <snapper/File.h>
+
+/**
+ * @short An interface class between YaST2 and Snapper Agent
+ */
+class SnapperAgent : public SCRAgent
+{
+private:
+ /**
+ * Agent private variables and methods
+ */
+
+ /**
+ * 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
+ */
+ string getValue (const YCPMap map, const string key);
+
+ /**
+ * Search the map for value of given key
+ * @param map YCP Map to look in
+ * @param key key we are looking for
+ * @param deflt the default value to be returned if key is not found
+ */
+ int getIntValue ( const YCPMap map, const string key, int deflt);
+
+public:
+ /**
+ * Default constructor.
+ */
+ SnapperAgent();
+
+ /**
+ * Destructor.
+ */
+ virtual ~SnapperAgent();
+
+ /**
+ * Provides SCR Read ().
+ * @param path Path that should be read.
+ * @param arg Additional parameter.
+ */
+ virtual YCPValue Read ( const YCPPath &path,
+ const YCPValue& arg = YCPNull(),
+ const YCPValue& opt = YCPNull());
+
+ /**
+ * Provides SCR Write ().
+ */
+ virtual YCPBoolean Write(const YCPPath &path,
+ const YCPValue& arg,
+ const YCPValue& arg2 = YCPNull());
+
+ /**
+ * Provides SCR Execute ().
+ */
+ virtual YCPValue Execute(const YCPPath &path,
+ const YCPValue& arg = YCPNull(),
+ const YCPValue& arg2 = YCPNull());
+
+ /**
+ * Provides SCR Dir ().
+ */
+ virtual YCPList Dir(const YCPPath& path);
+
+ /**
+ * Used for mounting the agent.
+ */
+ virtual YCPValue otherCommand(const YCPTerm& term);
+
+private:
+
+ snapper::Snapper* sh;
+
+};
+
+#endif /* _SnapperAgent_h */

Added: trunk/snapper/agent-snapper/src/Y2CCSnapperAgent.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/Y2CCSnapperAgent.cc?rev=63520&view=auto
==============================================================================
--- trunk/snapper/agent-snapper/src/Y2CCSnapperAgent.cc (added)
+++ trunk/snapper/agent-snapper/src/Y2CCSnapperAgent.cc Mon Mar 7 10:21:10 2011
@@ -0,0 +1,14 @@
+/* Y2CCSnapperAgent.cc
+ *
+ * Authors: Jiri Suchomel <jsuchome@xxxxxxx>
+ *
+ */
+
+#include <scr/Y2AgentComponent.h>
+#include <scr/Y2CCAgentComponent.h>
+
+#include "SnapperAgent.h"
+
+typedef Y2AgentComp <SnapperAgent> Y2SnapperAgentComp;
+
+Y2CCAgentComp <Y2SnapperAgentComp> g_y2ccag_snapper ("ag_snapper");

Added: trunk/snapper/configure.in.in
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/configure.in.in?rev=63520&view=auto
==============================================================================
--- trunk/snapper/configure.in.in (added)
+++ trunk/snapper/configure.in.in Mon Mar 7 10:21:10 2011
@@ -0,0 +1,15 @@
+## YCP module configure.in.in
+
+## Initialize
+@YAST2-INIT-COMMON@
+@YAST2-INIT-YCP@
+@YAST2-INIT-PROGRAM@
+
+## some common checks
+@YAST2-CHECKS-COMMON@
+@YAST2-CHECKS-YCP@
+@YAST2-CHECKS-PROGRAM@
+
+
+## and generate the output...
+@YAST2-OUTPUT@

Added: trunk/snapper/doc/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/doc/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/doc/Makefile.am (added)
+++ trunk/snapper/doc/Makefile.am Mon Mar 7 10:21:10 2011
@@ -0,0 +1,10 @@
+# Makefile.am for snapper/doc
+
+SUBDIRS = autodocs
+
+htmldir = $(docdir)
+
+doc_DATA =
+html_DATA =
+
+EXTRA_DIST = $(doc_DATA) $(html_DATA)

Added: trunk/snapper/doc/_cvsignore
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/doc/_cvsignore?rev=63520&view=auto
==============================================================================
--- trunk/snapper/doc/_cvsignore (added)
+++ trunk/snapper/doc/_cvsignore Mon Mar 7 10:21:10 2011
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in

Added: trunk/snapper/doc/autodocs/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/doc/autodocs/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/doc/autodocs/Makefile.am (added)
+++ trunk/snapper/doc/autodocs/Makefile.am Mon Mar 7 10:21:10 2011
@@ -0,0 +1,3 @@
+# Makefile.am for snapper/doc/autodocs
+
+include $(top_srcdir)/autodocs-ycp.ami

Added: trunk/snapper/doc/autodocs/_cvsignore
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/doc/autodocs/_cvsignore?rev=63520&view=auto
==============================================================================
--- trunk/snapper/doc/autodocs/_cvsignore (added)
+++ trunk/snapper/doc/autodocs/_cvsignore Mon Mar 7 10:21:10 2011
@@ -0,0 +1,3 @@
+Makefile
+Makefile.in
+*.html

Added: trunk/snapper/package/_cvsignore
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/package/_cvsignore?rev=63520&view=auto
==============================================================================
--- trunk/snapper/package/_cvsignore (added)
+++ trunk/snapper/package/_cvsignore Mon Mar 7 10:21:10 2011
@@ -0,0 +1,2 @@
+*.spec
+*.bz2

Added: trunk/snapper/package/yast2-snapper.changes
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/package/yast2-snapper.changes?rev=63520&view=auto
==============================================================================
--- trunk/snapper/package/yast2-snapper.changes (added)
+++ trunk/snapper/package/yast2-snapper.changes Mon Mar 7 10:21:10 2011
@@ -0,0 +1,32 @@
+-------------------------------------------------------------------
+Mon Mar 7 08:26:14 CET 2011 - jsuchome@xxxxxxx
+
+- first release for Factory
+- 2.21.0
+
+-------------------------------------------------------------------
+Thu Mar 3 15:03:55 CET 2011 - jsuchome@xxxxxxx
+
+- check selected file mode and ownership
+
+-------------------------------------------------------------------
+Mon Feb 28 10:37:40 CET 2011 - jsuchome@xxxxxxx
+
+- added option to compare with arbitrary snapshot
+
+-------------------------------------------------------------------
+Thu Feb 24 14:37:00 CET 2011 - jsuchome@xxxxxxx
+
+- tree handling in YCP
+- added restore function
+- show 3 possible ways to diff
+
+-------------------------------------------------------------------
+Wed Feb 2 15:55:03 CET 2011 - jsuchome@xxxxxxx
+
+- added scr agent to access snapper library
+
+-------------------------------------------------------------------
+Mon Dec 13 18:51:43 2010 - jsuchome@xxxxxxx
+
+- initial version

Added: trunk/snapper/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/src/Makefile.am (added)
+++ trunk/snapper/src/Makefile.am Mon Mar 7 10:21:10 2011
@@ -0,0 +1,26 @@
+# Makefile.am for snapper/src
+
+yncludedir = @yncludedir@/snapper
+
+client_DATA = \
+ snapper.ycp
+
+ynclude_DATA = \
+ helps.ycp \
+ wizards.ycp \
+ dialogs.ycp
+
+desktop_DATA = \
+ snapper.desktop
+
+module_DATA = \
+ Snapper.ycp
+
+# create a symlink for local build, #145327
+snapper:
+ ln -sf . $@
+ycpchook = snapper
+
+EXTRA_DIST = $(client_DATA) $(ynclude_DATA) $(module_DATA) $(desktop_DATA)
+
+include $(top_srcdir)/Makefile.am.common

Added: trunk/snapper/src/Snapper.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/Snapper.ycp?rev=63520&view=auto
==============================================================================
--- trunk/snapper/src/Snapper.ycp (added)
+++ trunk/snapper/src/Snapper.ycp Mon Mar 7 10:21:10 2011
@@ -0,0 +1,243 @@
+/*
------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
find
+ * current contact information at www.novell.com.
+ *
------------------------------------------------------------------------------
+ */
+
+/**
+ * File: modules/Snapper.ycp
+ * Summary: Snapper settings, input and output functions
+ * Authors: Jiri Suchomel <jsuchome@xxxxxxx>
+ *
+ * $Id$
+ *
+ * Representation of the configuration of snapper.
+ * Input and output routines.
+ */
+
+{
+
+module "Snapper";
+textdomain "snapper";
+
+import "FileUtils";
+import "Label";
+import "Progress";
+
+
+// global list of all snapshot
+global list<map> snapshots = [];
+
+global string snapshots_path = "/snapshots"; // FIXME
+
+global map selected_snapshot = $[];
+
+// mapping of snapshot number to index in snapshots list
+global map<integer,integer> id2index = $[];
+
+// index to snapshots list
+global integer selected_snapshot_index = 0;
+
+/**
+ * Return list of files modified between given snapshots
+ * File is a map with name (path) and some parameters
+ */
+global list<map> ReadModifiedFiles (integer from, integer to) {
+
+ return (list<map>) SCR::Read (.snapper.diff, $[ "from" : from, "to" : to]);
+}
+
+/**
+ * Describe what was done with given file between given snapshots
+ * - when new is 0, meaning is 'current system'
+ */
+global map GetFileModification (string file, integer old, integer new) {
+
+ map ret = $[];
+
+ string file1 = sformat ("%1/%2/snapshot%3", snapshots_path, old,
file);
+ string file2 = sformat ("%1/%2/snapshot%3", snapshots_path, new,
file);
+ if (new == 0)
+ file2 = file;
+
+ y2milestone ("comparing '%1' and '%2'", file1, file2);
+
+ if (FileUtils::Exists (file1) && FileUtils::Exists (file2))
+ {
+ list<string> status = [ "no_change" ];
+ map out = (map) SCR::Execute (.target.bash_output,
+ sformat ("/usr/bin/diff -u %1 %2", file1, file2));
+ if (out["stderr"]:"" != "")
+ {
+ y2warning ("out: %1", out);
+ ret["diff"] = out["stderr"]:"";
+ }
+ // the file diff
+ else if (out["stdout"]:nil != "")
+ {
+ status = ["diff"];
+ ret["diff"] = out["stdout"]:"";
+ }
+
+ // check mode and ownerships
+ out = (map) SCR::Execute (.target.bash_output,
+ sformat ("ls -l %1 %2 | cut -f 1,3,4 -d ' '", file1, file2));
+ list<string> parts = splitstring (out["stdout"]:""," \n");
+
+ if (parts[0]:"" != parts[3]:"")
+ {
+ status = add (status, "mode");
+ ret["mode1"] = parts[0]:"";
+ ret["mode2"] = parts[3]:"";
+ }
+ if (parts[1]:"" != parts[4]:"")
+ {
+ status = add (status, "user");
+ ret["user1"] = parts[1]:"";
+ ret["user2"] = parts[4]:"";
+ }
+ if (parts[2]:"" != parts[5]:"")
+ {
+ status = add (status, "group");
+ ret["group1"] = parts[2]:"";
+ ret["group2"] = parts[5]:"";
+ }
+ ret["status"] = status;
+ }
+ else if (FileUtils::Exists (file1))
+ {
+ ret["status"] = ["removed"];
+ }
+ else if (FileUtils::Exists (file2))
+ {
+ ret["status"] = ["created"];
+ }
+ else
+ {
+ ret["status"] = ["none"];
+ }
+ return ret;
+}
+
+/**
+ * Read the list of snapshots
+ */
+global boolean ReadSnapshots () {
+
+
+ list<map> snapshot_maps = (list<map>) SCR::Read (.snapper.snapshots);
+ if (snapshot_maps == nil) snapshot_maps = [];
+ integer i = 0;
+ foreach (map snapshot, snapshot_maps, {
+ integer id = snapshot["num"]:0;
+ if (id == 0) return; // ignore the 'current system'
+ snapshot["name"] = tostring (id);
+ y2debug ("snapshot data: %1", snapshot);
+ snapshots = add (snapshots, snapshot);
+ id2index[id] = i;
+ i = i + 1;
+ });
+
+
+ return true;
+}
+
+/**
+ * Read all snapper settings
+ * @return true on success
+ */
+global boolean Read() {
+
+ /* Snapper read dialog caption */
+ string caption = _("Initializing Snapper");
+
+ integer steps = 2;
+
+ // We do not set help text here, because it was set outside
+ Progress::New( caption, " ", steps, [
+ /* Progress stage 1/3 */
+ _("Read the list of snapshots"),
+ ], [
+ /* Progress step 1/3 */
+ _("Reading the database..."),
+ /* Progress finished */
+ _("Finished")
+ ],
+ ""
+ );
+
+ Progress::NextStage();
+ // read database
+
+ ReadSnapshots ();
+
+ Progress::NextStage();
+ return true;
+}
+
+/**
+ * Copy given files from selected snapshot to current filesystem
+ */
+global boolean RestoreFiles (integer snapshot_num, list<string> files) {
+
+ boolean ret = true;
+ y2milestone ("going to restore files %1", files);
+
+ UI::OpenDialog (`opt (`decorated), `HBox (`HSpacing(1.5), `VBox (
+ `HSpacing (60),
+ // label for log window
+ `LogView (`id (`log), _("Restoring Files..."), 8, 0),
+ `ProgressBar (`id (`progress), "", size (files), 0),
+ `PushButton (`id (`ok), Label::OKButton ())
+ ), `HSpacing (1.5)));
+
+ UI::ChangeWidget (`id (`ok), `Enabled, false);
+ integer progress = 0;
+ foreach (string file, files, {
+
+ UI::ChangeWidget (`id (`progress ), `Value, progress);
+
+ string orig = sformat ("%1/%2/snapshot%3", snapshots_path,
snapshot_num, file);
+
+ string dir = substring (file, 0, findlastof (file, "/"));
+ y2milestone ("copying file %1 to %2 (dir: %3)", orig, file, dir);
+ if (FileUtils::CheckAndCreatePath (dir))
+ {
+ SCR::Execute (.target.bash, sformat ("/bin/cp -a %1 %2", orig,
file));
+ UI::ChangeWidget (`id (`log), `LastLine, file + "\n");
+ }
+ else
+ {
+ // log entry (%1 is file name)
+ UI::ChangeWidget (`id (`log), `LastLine, sformat (_("%1
skipped\n"), file));
+ }
+ sleep (100);
+ progress = progress + 1;
+ });
+
+ UI::ChangeWidget (`id (`progress ), `Value, progress);
+ UI::ChangeWidget (`id (`ok), `Enabled, true);
+
+ UI::UserInput ();
+ UI::CloseDialog ();
+
+ return ret;
+}
+
+
+/* EOF */
+}

Added: trunk/snapper/src/_cvsignore
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/_cvsignore?rev=63520&view=auto
==============================================================================
--- trunk/snapper/src/_cvsignore (added)
+++ trunk/snapper/src/_cvsignore Mon Mar 7 10:21:10 2011
@@ -0,0 +1,4 @@
+Makefile
+Makefile.in
+*.ybc
+.dep

Added: trunk/snapper/src/dialogs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/dialogs.ycp?rev=63520&view=auto
==============================================================================
--- trunk/snapper/src/dialogs.ycp (added)
+++ trunk/snapper/src/dialogs.ycp Mon Mar 7 10:21:10 2011
@@ -0,0 +1,679 @@
+/*
------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
find
+ * current contact information at www.novell.com.
+ *
------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/snapper/dialogs.ycp
+ * Package: Configuration of snapper
+ * Summary: Dialogs definitions
+ * Authors: Jiri Suchomel <jsuchome@xxxxxxx>
+ *
+ * $Id$
+ */
+
+{
+
+textdomain "snapper";
+
+import "Confirm";
+import "Label";
+import "Popup";
+import "Wizard";
+import "Snapper";
+
+include "snapper/helps.ycp";
+
+boolean ReallyAbort() {
+ return Popup::ReallyAbort(true);
+}
+
+/**
+ * Read settings dialog
+ * @return `abort if aborted and `next otherwise
+ */
+symbol ReadDialog() {
+
+ if (! Confirm::MustBeRoot ())
+ return `abort;
+
+ Wizard::RestoreHelp(HELPS["read"]:"");
+ boolean ret = Snapper::Read();
+ return ret ? `next : `abort;
+}
+
+/**
+ * Summary dialog
+ * @return dialog result
+ */
+any SummaryDialog() {
+
+ /* summary dialog caption */
+ string caption = _("Snapshots");
+
+ list<map> snapshots = Snapper::snapshots;
+ integer i = -1;
+
+ list snapshot_items = [];
+
+ foreach (map s, snapshots, {
+ i = i + 1;
+
+ integer num = s["num"]:0;
+ string date = "";
+ if (num != 0)
+ date = timestring ("%c", s["date"]:0, false);
+
+ if (s["type"]:`none == `SINGLE)
+ {
+ snapshot_items = add (snapshot_items,
+ `item (`id (i), num, _("Single"), date, "",
s["description"]:""));
+ }
+ else if (s["type"]:`none == `POST)
+ {
+ integer pre = s["pre_num"]:0; // pre canot be 0
+ integer index = Snapper::id2index[pre]:-1;
+ if (pre == 0 || index == -1)
+ {
+ y2warning ("something wrong - pre:%1, index:%2", pre, index);
+ continue;
+ }
+ string desc = Snapper::snapshots[index,"description"]:"";
+ string pre_date = timestring ("%c",
Snapper::snapshots[index,"date"]:0, false);
+ snapshot_items = add (snapshot_items,
+ `item (`id (i), sformat ("%1 - %2", pre, num), _("Pre & Post"),
pre_date, date, desc));
+ }
+ else
+ {
+ y2milestone ("skipping pre snapshot: %1", num);
+ }
+ });
+
+ term contents = `VBox (
+ `Table (`id (`snapshots_table), `opt(`notify, `keepSorting), `header (
+ // table header
+ _("ID"), _("Type"), _("Start Date"), _("End Date"),
_("Description")),
+ snapshot_items
+ ),
+ `HBox (
+ `PushButton (`id (`show_c), `opt (`default), _("Show Changes")),
+ `HStretch ()
+ )
+ );
+
+ Wizard::SetContentsButtons(caption, contents, HELPS["summary"]:"",
+ Label::BackButton(), Label::CloseButton());
+ Wizard::HideBackButton ();
+ Wizard::HideAbortButton ();
+
+ UI::SetFocus (`id (`snapshots_table));
+
+ any ret = nil;
+ while(true) {
+
+ ret = UI::UserInput();
+
+ integer selected = 0;
+
+ if (ret == `show_c || ret == `snapshots_table) {
+ selected = (integer) UI::QueryWidget (`id (`snapshots_table),
`CurrentItem);
+ ret = `show;
+ }
+
+ if(ret == `abort || ret == `cancel || ret == `back) {
+ if(ReallyAbort()) break;
+ else continue;
+ }
+ else if (ret == `show) {
+ // `POST snapshot is selected from the couple
+ Snapper::selected_snapshot = snapshots[selected]:$[];
+ Snapper::selected_snapshot_index = selected;
+ break;
+ }
+ else if(ret == `next) {
+ // TODO check if something needs to be written (description)
+ break;
+ }
+ else {
+ y2error("unexpected retcode: %1", ret);
+ continue;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * @return dialog result
+ */
+any ShowDialog () {
+
+ // dialog caption
+ string caption = _("Selected Snapshot Overview");
+
+ map display_info = UI::GetDisplayInfo ();
+ boolean textmode = display_info["TextMode"]:false;
+ string previous_file= "";
+ string current_file = "";
+
+ // map of already read files
+ map<string,boolean> files = $[];
+ // currently read subtree
+ list<string> subtree = [];
+ list<term> tree_items = [];
+ map open_items = $[];
+
+ map snapshot = Snapper::selected_snapshot;
+ integer snapshot_num = snapshot["num"]:0;
+ list<map> file_list = snapshot["files"]:[];
+ integer previous_num = snapshot["pre_num"]:snapshot_num;
+
+ integer pre_index = Snapper::id2index[previous_num]:0;
+ string description =
Snapper::snapshots[pre_index,"description"]:"";
+ string pre_date = timestring ("%c",
Snapper::snapshots[pre_index,"date"]:0, false);
+ string date = timestring ("%c", snapshot["date"]:0,
false);
+ symbol type = snapshot["type"]:`NONE;
+ list<term> combo_items = [];
+ foreach (map s, Snapper::snapshots, {
+ integer id = s["num"]:0;
+ if (id != snapshot_num)
+ {
+ // '%1: %2' means 'ID: description', adapt the order if necessary
+ combo_items = add (combo_items, `item (`id (id), sformat (_("%1:
%2"), id, s["description"]:"")));
+ }
+ });
+
+ if (!haskey (snapshot, "files"))
+ {
+ integer from = snapshot_num;
+ integer to = 0; // current system
+ if (snapshot["type"]:`NONE == `POST)
+ {
+ from = snapshot["pre_num"]:0;
+ to = snapshot_num;
+ }
+ else if (snapshot["type"]:`NONE == `PRE)
+ {
+ to = snapshot["post_num"]:0;
+ }
+ // busy popup message
+ Popup::ShowFeedback ("", _("Calculating changed files..."));
+ snapshot["files"] = Snapper::ReadModifiedFiles (from, to);
+ Popup::ClearFeedback ();
+ file_list = snapshot["files"]:[];
+ // update the global snapshots list
+ Snapper::snapshots[Snapper::selected_snapshot_index] = snapshot;
+ }
+
+ string snapshot_name = tostring (snapshot_num);
+
+ // map of tree (recursive)
+ map<string,map> tree_map = $[];
+
+ // map of all items in tree (just one level)
+ map<string,boolean> selected_items = $[];
+
+ // helper function: update the global map with directory tree structure
+ map<string,map> update_tree_map (map<string,map> current_map, list<string>
path_list)
+ {
+ string first = path_list[0]:"";
+
+ if (current_map[first]:nil == nil)
+ {
+ current_map[first] = $[];
+ }
+ if (size (path_list) > 1)
+ {
+ current_map[first] =
+ update_tree_map ((map<string,map>)current_map[first]:$[],
+ (list<string>) remove (path_list, 0)
+ );
+ }
+ return current_map;
+ }
+
+ // save full paths of files marked as modified
+ map<string,map> files_index = $[];
+
+ // 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) {
+
+ list<term> ret = [];
+ foreach (string node, map branch, current_branch, {
+ string new_path = current_path + "/" + node;
+ if (files_index[new_path]:$[] != $[])
+ {
+ string changes = files_index[new_path,"changes"]:"";
+ string icon_f = "16x16/apps/gdu-smart-unknown.png";
+ if (substring (changes, 0, 1) == "+")
+ {
+ icon_f = "16x16/apps/gdu-smart-healthy.png";
+ }
+ else if (substring (changes, 0, 1) == "-")
+ {
+ icon_f = "16x16/apps/gdu-smart-failing.png";
+ }
+ ret = add (ret,
+ `item (`id(new_path), `icon (icon_f), node, false,
+ generate_tree_items (new_path, (map<string,map>)
branch))
+ );
+ }
+ else
+ {
+ ret = add (ret, `item (`id(new_path), node, false,
+ generate_tree_items (new_path, (map<string,map>) branch))
+ );
+ }
+ });
+ return ret;
+ }
+
+ // helper function: show the specific modification between snapshots
+ void show_file_modification (string file, integer from, integer to) {
+
+ term content = `VBox ();
+ // busy popup message
+ Popup::ShowFeedback ("", _("Calculating file modifications..."));
+ map modification = Snapper::GetFileModification (file, from, to);
+ Popup::ClearFeedback ();
+ list<string> status = modification["status"]:[];
+ if (contains (status, "created"))
+ {
+ // label
+ content = add (content, `Left (`Label ("New file was
created.")));
+ }
+ else if (contains (status, "removed"))
+ {
+ // label
+ content = add (content, `Left (`Label ("File was removed.")));
+ }
+ else if (contains (status, "no_change"))
+ {
+ // label
+ content = add (content, `Left (`Label ("File content was not
changed.")));
+ }
+ else if (contains (status, "none"))
+ {
+ // label
+ content = add (content, `Left (`Label ("File does not exist in
either snapshot.")));
+ }
+ else if (contains (status, "diff"))
+ {
+ // label
+ content = add (content, `Left (`Label ("File content was
modified.")));
+ }
+ if (contains (status, "mode"))
+ {
+ content = add (content, `Left (`Label (
+ // text label, %1, %2 are file modes (like '-rw-r--r--')
+ sformat (_("File mode was changed from '%1' to '%2'."),
+ modification["mode1"]:"", modification["mode2"]:"")
+ )));
+ }
+ if (contains (status, "user"))
+ {
+ content = add (content, `Left (`Label (
+ // text label, %1, %2 are user names
+ sformat (_("File user ownership was changed from '%1' to
'%2'."),
+ modification["user1"]:"", modification["user2"]:"")
+ )));
+ }
+ if (contains (status, "group"))
+ {
+ // label
+ content = add (content, `Left (`Label (
+ // text label, %1, %2 are group names
+ sformat (_("File group ownership was changed from '%1' to
'%2'."),
+ modification["group1"]:"", modification["group2"]:"")
+ )));
+ }
+
+ if (haskey (modification, "diff"))
+ {
+ string diff = modification["diff"]:"";
+ diff = mergestring (splitstring (diff, "\n"), "<br>");
+ content = add (content, `RichText (`id (`diff), diff));
+ }
+ else
+ {
+ content = add (content, `VStretch ());
+ }
+
+ UI::ReplaceWidget (`id (`diff_content), `HBox (`HSpacing (0.5), `VBox (
+ content,
+ `VSquash (`HBox (
+ `HStretch (),
+ type == `SINGLE ? `Empty () : `PushButton (`id (`restore_pre),
_("Restore From First")),
+ // button label
+ `PushButton (`id (`restore), type == `SINGLE ? _("Restore") :
_("Restore From Second"))
+ ))
+ ), `HSpacing (0.5))
+ );
+ }
+
+
+ // create the term for selected file
+ void set_entry_term () {
+ if (current_file != "" && files_index[current_file]:$[] != $[])
+ {
+ if (type == `SINGLE)
+ {
+ UI::ReplaceWidget (`id (`diff_chooser), `HBox (`HSpacing (0.5),
`VBox (
+ `VSpacing (0.2),
+ `RadioButtonGroup (`id(`rd), `Left (`HVSquash (`VBox (
+ `Left (`RadioButton (`id(`diff_snapshot), `opt
(`notify),
+ // radio button label
+ _("Show the difference between snapshot and current
system"), true)),
+ `VBox (
+ `Left (`RadioButton (`id (`diff_arbitrary), `opt
(`notify),
+ // radio button label, snapshot selection will
follow
+ _("Show the difference between current and
selected snapshot:"), false)
+ ),
+ `HBox (
+ `HSpacing (2),
+ // FIXME without label, there's no shortcut!
+ `Left (`ComboBox (`id (`selection_snapshots),
`opt (`notify), "", combo_items))
+ )
+ )
+ )))),
+ `VSpacing ()
+ ), `HSpacing (0.5)));
+ show_file_modification (current_file, snapshot_num, 0);
+ UI::ChangeWidget (`id (`selection_snapshots), `Enabled, false);
+ }
+ else
+ {
+ UI::ReplaceWidget (`id (`diff_chooser), `HBox (`HSpacing (0.5),
`VBox (
+ `VSpacing (0.2),
+ `RadioButtonGroup (`id(`rd), `Left (`HVSquash (`VBox (
+ `Left (`RadioButton (`id(`diff_snapshot), `opt
(`notify),
+ // radio button label
+ _("Show the difference between first and second
snapshot"), true)),
+ `Left(`RadioButton (`id (`diff_pre_current), `opt
(`notify),
+ // radio button label
+ _("Show the difference between first snapshot and
current system"), false)),
+ `Left(`RadioButton (`id (`diff_post_current), `opt
(`notify),
+ // radio button label
+ _("Show the difference between second snapshot and
current system"), false))
+ )))),
+ `VSpacing ()
+ ), `HSpacing (0.5)));
+ show_file_modification (current_file, previous_num,
snapshot_num);
+ }
+ }
+ else
+ {
+ UI::ReplaceWidget (`id (`diff_chooser), `VBox (`VStretch ()));
+ UI::ReplaceWidget (`id (`diff_content), `HBox (`HStretch ()));
+ }
+ }
+
+ string tree_label = sformat ("%1 - %2", previous_num, snapshot_num);
+ term date_widget = `VBox (
+ `HBox (
+ // label, date string will follow at the end of line
+ `Label (`id (`pre_date), _("Time of taking the first
snapshot:")),
+ `Right (`Label (pre_date))
+ ),
+ `HBox (
+ // label, date string will follow at the end of line
+ `Label (`id (`post_date), _("Time of taking the second
snapshot:")),
+ `Right (`Label (date))
+ )
+ );
+ if (type == `SINGLE)
+ {
+ tree_label = tostring (snapshot_num);
+ date_widget = `HBox (
+ // label, date string will follow at the end of line
+ `Label (`id (`date), _("Time of taking the snapshot:")),
+ `Right (`Label (date))
+ );
+ }
+
+ term contents = `HBox (
+ `HWeight (1, `HBox (`VSpacing (20), `VBox (`HSpacing(70),
+ `HBox (
+ `HSpacing (),
+ `ReplacePoint (`id (`reptree),
+ `Tree (`id(`tree), tree_label, [])
+ ),
+ `HSpacing ()
+ ),
+ `HBox (
+ `HSpacing (1.5),
+ `HStretch (),
+ textmode ?
+ // button label
+ `PushButton (`id (`open), `opt (`key_F6),_("&Open")):
+ `Empty (),
+ `HSpacing (1.5)
+ )
+ ))),
+ `HWeight (2, `VBox (
+ `Left (`Label (`id (`desc), description)),
+ date_widget,
+ `Frame ("", `HBox (
+ `HSpacing (0.5), `VBox (
+ `VSpacing (0.5),
+ `VWeight (1, `ReplacePoint (`id (`diff_chooser), `VBox
(`VStretch ()))),
+ `VWeight (4, `ReplacePoint (`id (`diff_content), `HBox
(`HStretch ()))),
+ `VSpacing (0.5)
+ ),
+ `HSpacing (0.5)
+ ))
+ ))
+ );
+
+ // show the dialog contents with empty tree, compute items later
+ Wizard::SetContentsButtons (caption, contents,
+ type == `SINGLE ? HELPS["show_single"]:"" : HELPS["show_couple"]:"",
+ // button label
+ Label::CancelButton(), _("Restore Selected"));
+
+ // generate the map with directory tree structure
+ foreach (map file, file_list, {
+ string full_path = file["name"]:"";
+ list<string> path_l = splitstring (full_path, "/");
+ if (path_l[0]:"" == "")
+ path_l = remove (path_l, 0);
+ tree_map = update_tree_map (tree_map, path_l);
+ files_index[full_path] = $[
+ "changes" : file["changes"]:""
+ ];
+ });
+
+ tree_items = generate_tree_items ("", tree_map);
+
+ if (size (tree_items) > 0)
+ {
+ UI::ReplaceWidget (`id (`reptree),
+ `Tree (`id(`tree), `opt (`notify, `immediate, `multiSelection),
tree_label, tree_items)
+ );
+ // no item is selected
+ UI::ChangeWidget (`tree, `CurrentItem, nil);
+ }
+
+ current_file = "";
+
+ set_entry_term ();
+
+ if (textmode)
+ UI::SetFocus (`id(`tree));
+
+ any ret = nil;
+ while(true) {
+
+ map event = UI::WaitForEvent ();
+ ret = (symbol) event["ID"]:nil;
+
+ previous_file = current_file;
+ current_file = (string) UI::QueryWidget (`id(`tree),`CurrentItem);
+ if (current_file == nil) current_file = "";
+
+ // tree checkbox clicked
+ if (ret == `tree && event["EventReason"]:"" == "ValueChanged")
+ {
+ // non-tracked file (so, it should be directory)
+ if (current_file != "" && files_index[current_file]:$[] == $[])
+ {
+ void select_items (map<string,map> current_map, string prefix) {
+ selected_items[prefix] = !
selected_items[prefix]:false;
+ foreach (string key, map submap, current_map, {
+ string new_path = prefix + "/" + key;
+ if (submap != $[])
+ {
+ select_items ((map<string,map>) submap, new_path);
+ }
+ else
+ {
+ selected_items[new_path] = !
selected_items[new_path]:false;
+ }
+ });
+ }
+ void update_selection (map<string,map> current_map,
list<string> path_list)
+ {
+ string first = path_list[0]:"";
+ if (size (path_list) == 0)
+ {
+ select_items (current_map, current_file);
+ }
+ else if (haskey (current_map, first))
+ {
+ update_selection
((map<string,map>)current_map[first]:$[],
+ (list<string>) remove (path_list, 0)
+ );
+ }
+ }
+ list<string> path_l = splitstring (current_file, "/");
+ if (path_l[0]:"" == "")
+ path_l = remove (path_l, 0);
+
+ update_selection (tree_map, path_l);
+
+ list<string> selection = [];
+ foreach (string key, boolean val, selected_items, {
+ if (val)
+ selection = add (selection, key);
+ });
+ UI::ChangeWidget (`tree, `SelectedItems, selection);
+ }
+
+ }
+ // other tree events
+ else if (ret == `tree)
+ {
+ // seems like tree widget emits 2 SelectionChanged events
+ if (current_file != previous_file)
+ {
+ set_entry_term ();
+ if (textmode)
+ UI::SetFocus (`id(`tree));
+ }
+ }
+ else if (ret == `diff_snapshot)
+ {
+ if (type == `SINGLE)
+ {
+ UI::ChangeWidget (`id (`selection_snapshots), `Enabled, false);
+ show_file_modification (current_file, snapshot_num, 0);
+ }
+ else
+ {
+ show_file_modification (current_file, previous_num,
snapshot_num);
+ }
+ }
+ else if (ret == `diff_arbitrary || ret == `selection_snapshots)
+ {
+ UI::ChangeWidget (`id (`selection_snapshots), `Enabled, true);
+ integer selected_num = (integer) UI::QueryWidget (`id
(`selection_snapshots), `Value);
+ show_file_modification (current_file, previous_num, selected_num);
+ }
+ else if (ret == `diff_pre_current)
+ {
+ show_file_modification (current_file, previous_num, 0);
+ }
+ else if (ret == `diff_post_current)
+ {
+ show_file_modification (current_file, snapshot_num, 0);
+ }
+ else if (ret == `abort || ret == `cancel || ret == `back) {
+ break;
+ }
+ else if (ret == `restore_pre) {
+ // yes/no question, %1 is file name, %2 is number
+ if (Popup::YesNo (sformat ("Do you want to copy the file
+
+%1
+
+from snapshot '%2' to current system?", current_file, previous_num)))
+ {
+ Snapper::RestoreFiles (previous_num, [current_file]);
+ }
+ continue;
+ }
+ else if (ret == `restore) {
+ // yes/no question, %1 is file name, %2 is number
+ if (Popup::YesNo (sformat ("Do you want to copy the file
+
+%1
+
+from snapshot '%2' to current system?", current_file, snapshot_num)))
+ {
+ Snapper::RestoreFiles (snapshot_num, [current_file]);
+ }
+ continue;
+ }
+ else if (ret == `next) {
+ list<string> files = (list<string>) UI::QueryWidget (`id (`tree),
`SelectedItems);
+ files = filter (string file, files, {
+ return haskey (files_index, file);
+ });
+
+ if (files == [])
+ {
+ // 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>")),
+ 60, 20, Label::YesButton (), Label::NoButton (), `focus_no))
+ {
+ Snapper::RestoreFiles (previous_num, files);
+ break;
+ }
+ continue;
+ }
+ else {
+ y2error("unexpected retcode: %1", ret);
+ continue;
+ }
+ }
+
+ return ret;
+}
+
+
+
+/* EOF */
+}

Added: trunk/snapper/src/helps.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/helps.ycp?rev=63520&view=auto
==============================================================================
--- trunk/snapper/src/helps.ycp (added)
+++ trunk/snapper/src/helps.ycp Mon Mar 7 10:21:10 2011
@@ -0,0 +1,71 @@
+/*
------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
find
+ * current contact information at www.novell.com.
+ *
------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/snapper/helps.ycp
+ * Package: Configuration of snapper
+ * Summary: Help texts of all the dialogs
+ * Authors: Jiri Suchomel <jsuchome@xxxxxxx>
+ *
+ * $Id$
+ */
+
+{
+
+textdomain "snapper";
+
+/**
+ * All helps are here
+ */
+map HELPS = $[
+
+ /* Read dialog help */
+ "read" : _("<p><b><big>Reading the list of snapshots</big></b><br>
+Please wait...<br></p>
+"),
+
+ /* Summary dialog help: */
+ "summary" : _("<p><b><big>Snapshots Configuration</big></b><p>
+<p>The table shows a list of root filesystem snapshots. There are three types
of snapshots, <b>single</b>, <b>pre</b> and <b>post</b>. Single snapshots are
used for storing file system state in certain time, while Pre and Post are used
to define the changes done by special operation proceeded between taking those
two snapshots. Pre and Post snapshots are coupled together in the table.</p>
+<p>Select a snapshot or snapshot couple and click <b>Show Changes</b> to see
the file system changes new in specified snapshot.</p>
+"),
+
+ /* Show snapshot dialog help */
+ "show_couple" : _("<p><b><big>Snapshot Overview</big></b><p>
+<p>
+The tree shows all the files that were modified between creating first ('pre')
and second ('post') snapshot. On the right side, you can see the description
generated when the first snapshot was created and the time of creation for both
snapshots.
+</p>
+<p>
+When file is selected in the tree, you can see the changes done to it. By
default, changes between selected coupled snapshots are shown, but it is
possible to compare the file with different versions.
+</p>"),
+
+ /* Show snapshot dialog help, alternative for single snapshots */
+ "show_single" : _("<p><b><big>Snapshot Overview</big></b><p>
+<p>
+The tree shows all the files that are different between selected snapshot and
current system. On the right side, you can see the snapshot description and
time of its creation.
+</p>
+<p>
+When file is selected in the tree, you can see the its difference between
snapshot version and current system.
+</p>"),
+
+];
+
+/* EOF */
+}

Added: trunk/snapper/src/snapper.desktop
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/snapper.desktop?rev=63520&view=auto
==============================================================================
--- trunk/snapper/src/snapper.desktop (added)
+++ trunk/snapper/src/snapper.desktop Mon Mar 7 10:21:10 2011
@@ -0,0 +1,25 @@
+[Desktop Entry]
+Type=Application
+Categories=Settings;System;Qt;X-SuSE-YaST;X-SuSE-YaST-Misc;
+
+X-KDE-ModuleType=Library
+X-KDE-RootOnly=true
+X-KDE-HasReadOnlyMode=true
+X-KDE-Library=yast2
+X-SuSE-YaST-Call=snapper
+
+X-SuSE-YaST-Group=Misc
+X-SuSE-YaST-Argument=
+X-SuSE-YaST-RootOnly=true
+X-SuSE-YaST-AutoInst=
+X-SuSE-YaST-Geometry=
+X-SuSE-YaST-SortKey=
+X-SuSE-YaST-AutoInstResource=snapper
+
+Icon=yast-snapper
+Exec=/sbin/yast2 snapper
+
+Name=Snapper
+GenericName=snapper
+X-KDE-SubstituteUID=true
+StartupNotify=true

Added: trunk/snapper/src/snapper.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/snapper.ycp?rev=63520&view=auto
==============================================================================
--- trunk/snapper/src/snapper.ycp (added)
+++ trunk/snapper/src/snapper.ycp Mon Mar 7 10:21:10 2011
@@ -0,0 +1,68 @@
+/*
------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
find
+ * current contact information at www.novell.com.
+ *
------------------------------------------------------------------------------
+ */
+
+/**
+ * File: clients/snapper.ycp
+ * Package: Configuration of snapper
+ * Summary: Main file
+ * Authors: Jiri Suchomel <jsuchome@xxxxxxx>
+ *
+ * $Id$
+ *
+ * Main file for snapper configuration. Uses all other files.
+ */
+
+{
+
+/***
+ * <h3>Configuration of snapper</h3>
+ */
+
+textdomain "snapper";
+
+/* The main () */
+y2milestone ("----------------------------------------");
+y2milestone ("Snapper module started");
+
+import "Progress";
+import "Report";
+import "Summary";
+
+import "CommandLine";
+include "snapper/wizards.ycp";
+
+map cmdline_description = $[
+ "id" : "snapper",
+ "help" : _("Configuration of system snapshots"),
+ "guihandler": SnapperSequence,
+];
+
+/* main ui function */
+any ret = CommandLine::Run(cmdline_description);
+y2debug("ret=%1", ret);
+
+/* Finish */
+y2milestone("Snapper module finished");
+y2milestone("----------------------------------------");
+
+return ret;
+
+/* EOF */
+}

Added: trunk/snapper/src/wizards.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/wizards.ycp?rev=63520&view=auto
==============================================================================
--- trunk/snapper/src/wizards.ycp (added)
+++ trunk/snapper/src/wizards.ycp Mon Mar 7 10:21:10 2011
@@ -0,0 +1,102 @@
+/*
------------------------------------------------------------------------------
+ * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
find
+ * current contact information at www.novell.com.
+ *
------------------------------------------------------------------------------
+ */
+
+/**
+ * File: include/snapper/wizards.ycp
+ * Package: Configuration of snapper
+ * Summary: Wizards definitions
+ * Authors: Jiri Suchomel <jsuchome@xxxxxxx>
+ *
+ * $Id$
+ */
+
+{
+
+textdomain "snapper";
+
+import "Sequencer";
+import "Wizard";
+
+include "snapper/dialogs.ycp";
+
+
+/**
+ * Main workflow of the snapper configuration
+ * @return sequence result
+ */
+any MainSequence() {
+
+ map aliases = $[
+ "summary" : ``( SummaryDialog() ),
+ "show" : ``( ShowDialog() ),
+ ];
+
+ map sequence = $[
+ "ws_start" : "summary",
+ "summary" : $[
+ `abort : `abort,
+ `next : `next,
+ `show : "show",
+ ],
+ "show" : $[
+ `abort : `abort,
+ `next : "summary",
+ ],
+ ];
+
+ any ret = Sequencer::Run(aliases, sequence);
+
+ return ret;
+}
+
+/**
+ * Whole configuration of snapper
+ * @return sequence result
+ */
+any SnapperSequence() {
+
+ map aliases = $[
+ "read" : [ ``( ReadDialog() ), true ],
+ "main" : ``( MainSequence() ),
+ ];
+
+ map sequence = $[
+ "ws_start" : "read",
+ "read" : $[
+ `abort : `abort,
+ `next : "main"
+ ],
+ "main" : $[
+ `abort : `abort,
+ `next : `next
+ ],
+ ];
+
+ Wizard::CreateDialog ();
+
+ any ret = Sequencer::Run(aliases, sequence);
+
+ UI::CloseDialog();
+ return ret;
+}
+
+
+/* EOF */
+}

Added: trunk/snapper/testsuite/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/testsuite/Makefile.am?rev=63520&view=auto
==============================================================================
--- trunk/snapper/testsuite/Makefile.am (added)
+++ trunk/snapper/testsuite/Makefile.am Mon Mar 7 10:21:10 2011
@@ -0,0 +1,21 @@
+#
+# Makefile.am for .../testsuite
+#
+# Do not edit this file (Makefile.am) as it will be overwritten!
+#
+
+AUTOMAKE_OPTIONS = dejagnu
+EXTRA_DIST = $(wildcard tests/*.out) $(wildcard tests/*.err) $(wildcard
tests/*.ycp) $(wildcard tests/*.yh)
+
+testsuite_prepare = @ydatadir@/testsuite/Makefile.testsuite
+
+all-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir)
+
+clean-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) clean
+
+check-local: $(testsuite_prepare)
+ make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) check
+
+# EOF

Added: trunk/snapper/testsuite/_cvsignore
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/testsuite/_cvsignore?rev=63520&view=auto
==============================================================================
--- trunk/snapper/testsuite/_cvsignore (added)
+++ trunk/snapper/testsuite/_cvsignore Mon Mar 7 10:21:10 2011
@@ -0,0 +1,11 @@
+Makefile
+Makefile.in
+site.exp
+*.sum
+*.log
+tmp.out*
+tmp.err*
+tmp.log*
+config
+run
+*.test

Added: trunk/snapper/testsuite/tests/_cvsignore
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/testsuite/tests/_cvsignore?rev=63520&view=auto
==============================================================================
(empty)

Added: trunk/snapper/yast2-snapper.spec.in
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/snapper/yast2-snapper.spec.in?rev=63520&view=auto
==============================================================================
--- trunk/snapper/yast2-snapper.spec.in (added)
+++ trunk/snapper/yast2-snapper.spec.in Mon Mar 7 10:21:10 2011
@@ -0,0 +1,29 @@
+@HEADER-COMMENT@
+
+@HEADER@
+Requires: yast2
+BuildRequires: update-desktop-files yast2 yast2-devtools yast2-testsuite
libsnapper libsnapper-devel doxygen yast2-core-devel gcc-c++ perl-XML-Writer
+
+Summary: System snapshots configuration
+
+%description
+YaST module for accessing and managing btrfs system snapshots
+
+@PREP@
+
+@BUILD@
+
+@INSTALL@
+
+@CLEAN@
+
+%files
+%defattr(-,root,root)
+%dir @yncludedir@/snapper
+@yncludedir@/snapper/*
+@clientdir@/snapper.ycp
+@moduledir@/Snapper.*
+@desktopdir@/snapper.desktop
+@scrconfdir@/*.scr
+@plugindir@/libpy2ag_snapper*
+%doc @docdir@

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

< Previous Next >
This Thread
  • No further messages