Hello community, here is the log from the commit of package yast2-snapper for openSUSE:Factory checked in at 2012-09-12 07:15:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-snapper (Old) and /work/SRC/openSUSE:Factory/.yast2-snapper.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-snapper", Maintainer is "[email protected]" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-snapper/yast2-snapper.changes 2012-06-13 22:47:01.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-snapper.new/yast2-snapper.changes 2012-09-12 07:15:59.000000000 +0200 @@ -1,0 +2,15 @@ +Tue Sep 11 14:24:18 CEST 2012 - [email protected] + +- enable deleting snapshots +- enable editing lonely pre snapshots +- read, show and edit cleanup algorithm +- 2.22.7 + +------------------------------------------------------------------- +Wed Sep 5 12:33:23 CEST 2012 - [email protected] + +- added support for creating and modifying snapshots (fate#313041) +- show and enable editing of userdata +- 2.22.6 + +------------------------------------------------------------------- Old: ---- yast2-snapper-2.22.5.tar.bz2 New: ---- yast2-snapper-2.22.7.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-snapper.spec ++++++ --- /var/tmp/diff_new_pack.Uvwaxu/_old 2012-09-12 07:16:01.000000000 +0200 +++ /var/tmp/diff_new_pack.Uvwaxu/_new 2012-09-12 07:16:01.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-snapper -Version: 2.22.5 +Version: 2.22.7 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-snapper-2.22.5.tar.bz2 -> yast2-snapper-2.22.7.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/COPYING new/yast2-snapper-2.22.7/COPYING --- old/yast2-snapper-2.22.5/COPYING 2012-06-13 14:01:48.000000000 +0200 +++ new/yast2-snapper-2.22.7/COPYING 2012-09-11 14:26:39.000000000 +0200 @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -15,7 +15,7 @@ General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to +the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not @@ -55,8 +55,8 @@ The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE + + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -110,7 +110,7 @@ License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -168,7 +168,7 @@ access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -225,7 +225,7 @@ This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -255,7 +255,7 @@ of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -277,9 +277,9 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -303,16 +303,17 @@ 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -335,5 +336,5 @@ This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General +library. If this is what you want to do, use the GNU Library General Public License instead of this License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/Makefile.am.common new/yast2-snapper-2.22.7/Makefile.am.common --- old/yast2-snapper-2.22.5/Makefile.am.common 2012-06-13 14:00:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/Makefile.am.common 2012-09-11 14:26:19.000000000 +0200 @@ -30,7 +30,7 @@ dist-hook: check-syntax CHECK_SYNTAX = true -check-syntax: $(client_DATA) $(ycpchook) $(ybcfiles) +check-syntax: $(client_DATA) $(ycpchook) @if test "$(client_DATA)"; then \ if $(CHECK_SYNTAX); then \ TO_CHECK="$(filter %.ycp,$^)"; \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/VERSION new/yast2-snapper-2.22.7/VERSION --- old/yast2-snapper-2.22.5/VERSION 2012-06-13 13:58:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/VERSION 2012-09-11 14:24:49.000000000 +0200 @@ -1 +1 @@ -2.22.5 +2.22.7 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/agent-snapper/doc/autodocs/Makefile.in new/yast2-snapper-2.22.7/agent-snapper/doc/autodocs/Makefile.in --- old/yast2-snapper-2.22.5/agent-snapper/doc/autodocs/Makefile.in 2012-06-13 14:00:27.000000000 +0200 +++ new/yast2-snapper-2.22.7/agent-snapper/doc/autodocs/Makefile.in 2012-09-11 14:26:29.000000000 +0200 @@ -20,7 +20,7 @@ # # -*- makefile -*- Automake include file -# $Id$ +# $Id: autodocs-cc.ami 28248 2006-02-21 14:14:07Z mvidner $ # Builds source documentation for C++ sources. # Builds and installs by default, intended for base packages where the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/agent-snapper/src/SnapperAgent.cc new/yast2-snapper-2.22.7/agent-snapper/src/SnapperAgent.cc --- old/yast2-snapper-2.22.5/agent-snapper/src/SnapperAgent.cc 2012-06-13 13:58:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/agent-snapper/src/SnapperAgent.cc 2012-09-11 13:53:30.000000000 +0200 @@ -59,6 +59,40 @@ return YCPList(); } +/** + * Search the map for value of given key; + * key is string and value is YCPMap + */ +YCPMap SnapperAgent::getMapValue (const YCPMap &map, const YCPString &key) +{ + YCPValue val = map->value(key); + if (!val.isNull() && val->isMap()) + return val->asMap(); + else + return YCPMap(); +} + +YCPMap map2ycpmap (const map<string, string>& userdata) +{ + YCPMap m; + for (map<string, string>::const_iterator it = userdata.begin(); it != userdata.end(); ++it) + { + m->add (YCPString (it->first), YCPString (it->second)); + } + return m; +} + +map<string, string> ycpmap2stringmap (const YCPMap &ycp_map) +{ + map<string, string> m; + + for (YCPMapIterator i = ycp_map->begin(); i != ycp_map->end(); i++) { + string key = i->first->asString()->value(); + m[key] = i->second->asString()->value(); + } + return m; +} + void log_do(LogLevel level, const string& component, const char* file, const int line, const char* func, @@ -99,7 +133,8 @@ { if (sh) { - deleteSnapper(sh); + delete sh; + sh = 0; } } @@ -208,17 +243,22 @@ s->add (YCPString ("num"), YCPInteger (it->getNum())); s->add (YCPString ("date"), YCPInteger (it->getDate())); + s->add (YCPString ("description"), YCPString (it->getDescription())); - if (it->getType() == SINGLE || it->getType() == PRE) + if (it->getType() == PRE) { - s->add (YCPString ("description"), YCPString (it->getDescription())); - if (it->getType() == PRE) - s->add (YCPString ("post_num"), YCPInteger (snapshots.findPost (it)->getNum ())); + Snapshots::const_iterator it2 = snapshots.findPost(it); + if (it2 != snapshots.end()) + { + s->add (YCPString ("post_num"), YCPInteger (it2->getNum ())); + } } else if (it->getType() == POST) { s->add (YCPString ("pre_num"), YCPInteger (it->getPreNum())); } + s->add (YCPString ("userdata"), YCPMap (map2ycpmap (it->getUserdata()))); + s->add (YCPString ("cleanup"), YCPString (it->getCleanup ())); y2debug ("snapshot %s", s.toString().c_str()); retlist->add (s); @@ -344,11 +384,13 @@ if (sh) { y2milestone ("deleting existing snapper object"); - deleteSnapper(sh); + delete sh; + sh = 0; } string config_name = getValue (argmap, YCPString ("config"), "root"); - try { - sh = createSnapper (config_name); + try + { + sh = new Snapper(config_name); } catch (const ConfigNotFoundException& e) { @@ -376,10 +418,103 @@ if (path->length() == 1) { + if (PC(0) == "create") { + + string description = getValue (argmap, YCPString ("description"), ""); + string cleanup = getValue (argmap, YCPString ("cleanup"), ""); + string type = getValue (argmap, YCPString ("type"), "single"); + YCPMap userdata = getMapValue (argmap, YCPString ("userdata")); + + const Snapshots& snapshots = sh->getSnapshots(); + Snapshots::iterator snap; + + if (type == "single") { + snap = sh->createSingleSnapshot(description); + } + else if (type == "pre") { + snap = sh->createPreSnapshot(description); + } + else if (type == "post") { + // check if pre was given! + int pre = getIntValue (argmap, YCPString ("pre"), -1); + if (pre == -1) + { + snapper_error = "pre_not_given"; + return YCPBoolean (false); + } + else + { + Snapshots::const_iterator snap1 = snapshots.find (pre); + if (snap1 == snapshots.end()) + { + snapper_error = "pre_not_found"; + return YCPBoolean (false); + } + else + { + snap = sh->createPostSnapshot(description, snap1); + } + } + } + else { + snapper_error = "wrong_snapshot_type"; + return YCPBoolean (false); + } + + snap->setCleanup (cleanup); + snap->setUserdata (ycpmap2stringmap (userdata)); + snap->flushInfo(); + return ret; + } + else if (PC(0) == "modify") { + + int num = getIntValue (argmap, YCPString ("num"), 0); + + Snapshots& snapshots = sh->getSnapshots(); + Snapshots::iterator snap = snapshots.find(num); + if (snap == snapshots.end()) + { + y2error ("snapshot '%d' not found", num); + snapper_error = "snapshot_not_found"; + return YCPBoolean (false); + } + + if (argmap->hasKey(YCPString ("description"))) + { + snap->setDescription (getValue (argmap, YCPString ("description"), "")); + } + if (argmap->hasKey(YCPString ("cleanup"))) + { + snap->setCleanup (getValue (argmap, YCPString ("cleanup"), "")); + } + if (argmap->hasKey(YCPString ("userdata"))) + { + snap->setUserdata (ycpmap2stringmap (getMapValue (argmap, YCPString ("userdata")))); + } + snap->flushInfo(); + return ret; + } + else if (PC(0) == "delete") { + + int num = getIntValue (argmap, YCPString ("num"), 0); + + Snapshots& snapshots = sh->getSnapshots(); + Snapshots::iterator snap = snapshots.find(num); + + if (snap == snapshots.end()) + { + snapper_error = "not_found"; + return YCPBoolean (false); + } + + sh->deleteSnapshot(snap); + return ret; + } + /** * Rollback the list of given files from snapshot num1 to num2 (system by default) */ - if (PC(0) == "rollback") { + else if (PC(0) == "rollback") { unsigned int num1 = getIntValue (argmap, YCPString ("from"), 0); unsigned int num2 = getIntValue (argmap, YCPString ("to"), 0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/agent-snapper/src/SnapperAgent.h new/yast2-snapper-2.22.7/agent-snapper/src/SnapperAgent.h --- old/yast2-snapper-2.22.5/agent-snapper/src/SnapperAgent.h 2012-06-13 13:58:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/agent-snapper/src/SnapperAgent.h 2012-09-11 10:52:27.000000000 +0200 @@ -14,7 +14,6 @@ #include <scr/SCRAgent.h> #include <snapper/Snapper.h> -#include <snapper/Factory.h> #include <snapper/Snapshot.h> #include <snapper/Comparison.h> #include <snapper/File.h> @@ -54,6 +53,12 @@ */ YCPList getListValue (const YCPMap &map, const YCPString &key); + /** + * Search the map for value of given key; + * key is string and value is YCPMap + */ + YCPMap getMapValue (const YCPMap &map, const YCPString &key); + public: /** * Default constructor. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/autodocs-cc.ami new/yast2-snapper-2.22.7/autodocs-cc.ami --- old/yast2-snapper-2.22.5/autodocs-cc.ami 2012-06-13 14:00:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/autodocs-cc.ami 2012-09-11 14:26:19.000000000 +0200 @@ -1,5 +1,5 @@ # -*- makefile -*- Automake include file -# $Id$ +# $Id: autodocs-cc.ami 28248 2006-02-21 14:14:07Z mvidner $ # Builds source documentation for C++ sources. # Builds and installs by default, intended for base packages where the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/autodocs-ycp.ami new/yast2-snapper-2.22.7/autodocs-ycp.ami --- old/yast2-snapper-2.22.5/autodocs-ycp.ami 2012-06-13 14:00:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/autodocs-ycp.ami 2012-09-11 14:26:19.000000000 +0200 @@ -1,5 +1,5 @@ # -*- makefile -*- Automake include file -# $Id$ +# $Id: autodocs-ycp.ami 57644 2009-06-19 08:38:11Z mvidner $ # Builds source documentation for YCP sources # Uses ycpdoc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/configure new/yast2-snapper-2.22.7/configure --- old/yast2-snapper-2.22.5/configure 2012-06-13 14:00:26.000000000 +0200 +++ new/yast2-snapper-2.22.7/configure 2012-09-11 14:26:28.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for yast2-snapper 2.22.5. +# Generated by GNU Autoconf 2.68 for yast2-snapper 2.22.7. # # Report bugs to <http://bugs.opensuse.org/>. # @@ -570,8 +570,8 @@ # Identity of this package. PACKAGE_NAME='yast2-snapper' PACKAGE_TARNAME='yast2-snapper' -PACKAGE_VERSION='2.22.5' -PACKAGE_STRING='yast2-snapper 2.22.5' +PACKAGE_VERSION='2.22.7' +PACKAGE_STRING='yast2-snapper 2.22.7' PACKAGE_BUGREPORT='http://bugs.opensuse.org/' PACKAGE_URL='' @@ -1354,7 +1354,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures yast2-snapper 2.22.5 to adapt to many kinds of systems. +\`configure' configures yast2-snapper 2.22.7 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1425,7 +1425,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of yast2-snapper 2.22.5:";; + short | recursive ) echo "Configuration of yast2-snapper 2.22.7:";; esac cat <<\_ACEOF @@ -1541,7 +1541,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -yast2-snapper configure 2.22.5 +yast2-snapper configure 2.22.7 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1994,7 +1994,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by yast2-snapper $as_me 2.22.5, which was +It was created by yast2-snapper $as_me 2.22.7, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2924,7 +2924,7 @@ # Define the identity of the package. PACKAGE='yast2-snapper' - VERSION='2.22.5' + VERSION='2.22.7' cat >>confdefs.h <<_ACEOF @@ -3046,7 +3046,7 @@ -VERSION="2.22.5" +VERSION="2.22.7" RPMNAME="yast2-snapper" MAINTAINER="Jiri Suchomel <[email protected]>" @@ -5232,7 +5232,7 @@ fi -CFLAGS="${CFLAGS} -Wall -Wformat=2 -Wmissing-prototypes" +CFLAGS="${CFLAGS} ${Y2CORE_CFLAGS} -Wall -Wformat=2 -Wmissing-prototypes" CXXFLAGS="${CXXFLAGS} ${Y2CORE_CFLAGS} -Wall -Wformat=2" : ${AGENT_LIBADD:='-L$(libdir) -lscr'} @@ -16615,7 +16615,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by yast2-snapper $as_me 2.22.5, which was +This file was extended by yast2-snapper $as_me 2.22.7, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16681,7 +16681,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -yast2-snapper config.status 2.22.5 +yast2-snapper config.status 2.22.7 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/configure.in new/yast2-snapper-2.22.7/configure.in --- old/yast2-snapper-2.22.5/configure.in 2012-06-13 14:00:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/configure.in 2012-09-11 14:26:19.000000000 +0200 @@ -1,9 +1,9 @@ dnl configure.in for yast2-snapper dnl -dnl -- This file is generated by y2autoconf 2.21.9 - DO NOT EDIT! -- +dnl -- This file is generated by y2autoconf 2.21.8 - DO NOT EDIT! -- dnl (edit configure.in.in instead) -AC_INIT(yast2-snapper, 2.22.5, http://bugs.opensuse.org/, yast2-snapper) +AC_INIT(yast2-snapper, 2.22.7, http://bugs.opensuse.org/, yast2-snapper) dnl Check for presence of file 'RPMNAME' AC_CONFIG_SRCDIR([RPMNAME]) @@ -18,7 +18,7 @@ AM_INIT_AUTOMAKE(tar-ustar -Wno-portability) dnl Important YaST2 variables -VERSION="2.22.5" +VERSION="2.22.7" RPMNAME="yast2-snapper" MAINTAINER="Jiri Suchomel <[email protected]>" @@ -169,7 +169,7 @@ PKG_CHECK_MODULES(Y2CORE, yast2-core) ]) -CFLAGS="${CFLAGS} -Wall -Wformat=2 -Wmissing-prototypes" +CFLAGS="${CFLAGS} ${Y2CORE_CFLAGS} -Wall -Wformat=2 -Wmissing-prototypes" CXXFLAGS="${CXXFLAGS} ${Y2CORE_CFLAGS} -Wall -Wformat=2" : ${AGENT_LIBADD:='-L$(libdir) -lscr'} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/doc/autodocs/Makefile.in new/yast2-snapper-2.22.7/doc/autodocs/Makefile.in --- old/yast2-snapper-2.22.5/doc/autodocs/Makefile.in 2012-06-13 14:00:28.000000000 +0200 +++ new/yast2-snapper-2.22.7/doc/autodocs/Makefile.in 2012-09-11 14:26:29.000000000 +0200 @@ -18,7 +18,7 @@ # Makefile.am for snapper/doc/autodocs # -*- makefile -*- Automake include file -# $Id$ +# $Id: autodocs-ycp.ami 57644 2009-06-19 08:38:11Z mvidner $ # Builds source documentation for YCP sources # Uses ycpdoc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/src/Makefile.in new/yast2-snapper-2.22.7/src/Makefile.in --- old/yast2-snapper-2.22.5/src/Makefile.in 2012-06-13 14:00:28.000000000 +0200 +++ new/yast2-snapper-2.22.7/src/Makefile.in 2012-09-11 14:26:29.000000000 +0200 @@ -598,7 +598,7 @@ rm ${NEWDEP} dist-hook: check-syntax -check-syntax: $(client_DATA) $(ycpchook) $(ybcfiles) +check-syntax: $(client_DATA) $(ycpchook) @if test "$(client_DATA)"; then \ if $(CHECK_SYNTAX); then \ TO_CHECK="$(filter %.ycp,$^)"; \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/src/Snapper.ycp new/yast2-snapper-2.22.7/src/Snapper.ycp --- old/yast2-snapper-2.22.5/src/Snapper.ycp 2012-06-13 13:58:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/src/Snapper.ycp 2012-09-11 13:53:30.000000000 +0200 @@ -246,6 +246,86 @@ } /** + * Delete existing snapshot + * Return true on success + */ +global boolean DeleteSnapshot (map args) { + + boolean success = (boolean) SCR::Execute (.snapper.delete, args); + if (!success) + { + map err_map = LastSnapperErrorMap (); + string type = err_map["type"]:""; + string details = _("Reason not known."); + + if (type == "not_found") + { + details = _("Snapshot was not found."); + } + + y2warning ("deleting failed with '%1'", err_map); + // error popup + Report::Error (sformat (_("Failed to delete snapshot: +%1"), details)); + } + return success; +} +/** + * Modify existing snapshot + * Return true on success + */ +global boolean ModifySnapshot (map args) { + + boolean success = (boolean) SCR::Execute (.snapper.modify, args); + if (!success) + { + map err_map = LastSnapperErrorMap (); + string type = err_map["type"]:""; + string details = _("Reason not known."); + + y2warning ("modification failed with '%1'", err_map); + // error popup + Report::Error (sformat (_("Failed to modify snapshot: +%1"), details)); + } + return success; +} + +/** + * Create new snapshot + * Return true on success + */ +global boolean CreateSnapshot (map args) { + + boolean success = (boolean) SCR::Execute (.snapper.create, args); + if (!success) + { + map err_map = LastSnapperErrorMap (); + string type = err_map["type"]:""; + string details = _("Reason not known."); + + if (type == "wrong_snapshot_type") + { + details = _("Wrong snapshot type given."); + } + else if (type == "pre_not_given") + { + details = _("'Pre' snapshot was not given."); + } + else if (type == "pre_not_found") + { + details = _("Given 'Pre' snapshot was not found."); + } + + y2warning ("creating failed with '%1'", err_map); + // error popup + Report::Error (sformat (_("Failed to create new snapshot: +%1"), details)); + } + return success; +} + +/** * Read all snapper settings * @return true on success */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-snapper-2.22.5/src/dialogs.ycp new/yast2-snapper-2.22.7/src/dialogs.ycp --- old/yast2-snapper-2.22.5/src/dialogs.ycp 2012-06-13 13:58:21.000000000 +0200 +++ new/yast2-snapper-2.22.7/src/dialogs.ycp 2012-09-11 13:57:05.000000000 +0200 @@ -60,6 +60,249 @@ } /** + * convert map of userdata to string + * $[ "a" : "b", "1" : "2" ] -> "a=b,1=2" + */ +string userdata2string (map<string,string> userdata) { + + return mergestring ( + maplist (string key, string val, userdata, { + return sformat ("%1=%2", key, val); + }), + "," + ); +} + +// transform userdata from widget to map +map get_userdata (string id) { + + map u = $[]; + string user_s = (string) UI::QueryWidget (`id (id), `Value); + foreach (string line, splitstring (user_s, ","), { + list<string> split = splitstring (line, "="); + if (size (split) > 1) + { + u[split[0]:""] = split[1]:""; + } + }); + return u; +} + +// generate list of items for Cleanup combo box +list<term> cleanup_items (string current) { + + return maplist (string cleanup, [ "timeline", "number", "" ], { + return `item (`id (cleanup), cleanup, cleanup == current); + }); +} + +// compare editable parts of snapshot maps +boolean snapshot_modified (map orig, map new) { + + boolean ret = false; + foreach (string key, any value, (map<string,any>) new, { + ret = ret || (orig[key]:nil != value); + }); + return ret; +} + +/** + * Popup for modification of existing snapshot + * @return true if new snapshot was created + */ +boolean ModifySnapshotPopup (map snapshot) { + + boolean modified = false; + integer num = snapshot["num"]:0; + integer previous_num = snapshot["pre_num"]:num; + symbol type = snapshot["type"]:`none; + + integer pre_index = Snapper::id2index[previous_num]:0; + map pre_snapshot = Snapper::snapshots[pre_index]:$[]; + + term snapshot_term (string prefix, map data) { + return `HBox (`HSpacing (), `Frame ("", `HBox (`HSpacing (0.4), `VBox ( + // text entry label + `TextEntry (`id (prefix + "description"), _("Description"), + data["description"]:""), + // text entry label + `TextEntry (`id (prefix + "userdata"), _("User data"), + userdata2string (data["userdata"]:$[])), + `Left (`ComboBox (`id (prefix + "cleanup"), `opt (`editable, `hstretch), + // combo box label + _("Cleanup algorithm"), cleanup_items (data["cleanup"]:"")) + ) + ), `HSpacing (0.4))), `HSpacing ()); + } + + term cont = `VBox ( + // popup label, %1 is number + `Label (sformat (_("Modify Snapshot %1"), num)), + snapshot_term ("", snapshot) + ); + + if (type == `POST) + { + cont = `VBox ( + // popup label, %1, %2 are numbers (range) + `Label (sformat (_("Modify Snapshots %1 - %2"), previous_num, num)), + // label + `Left (`Label (sformat (_("Pre (%1)"), previous_num))), + snapshot_term ("pre_", pre_snapshot), + `VSpacing (), + // label + `Left (`Label (sformat (_("Post (%1)"), num))), + snapshot_term ("", snapshot) + ); + } + + UI::OpenDialog (`opt (`decorated), `HBox (`HSpacing (1), `VBox( + `VSpacing (0.5), + `HSpacing (65), + cont, + `VSpacing (0.5), + `ButtonBox ( + `PushButton (`id(`ok), Label::OKButton()), + `PushButton (`id(`cancel), Label::CancelButton()) + ), + `VSpacing (0.5)), `HSpacing (1)) + ); + + any ret = nil; + map args = $[]; + map pre_args= $[]; + + while (true) + { + ret = UI::UserInput (); + args = $[ + "num" : num, + "description" : UI::QueryWidget (`id ("description"), `Value), + "cleanup" : UI::QueryWidget (`id ("cleanup"), `Value), + "userdata" : get_userdata ("userdata") + ]; + if (type == `POST) + { + pre_args = $[ + "num" : previous_num, + "description" : UI::QueryWidget (`id ("pre_description"), `Value), + "cleanup" : UI::QueryWidget (`id ("pre_cleanup"), `Value), + "userdata" : get_userdata ("pre_userdata") + ]; + } + if (ret == `ok || ret == `cancel) + { + break; + } + } + UI::CloseDialog (); + if (ret == `ok) + { + if (snapshot_modified (snapshot, args)) + { + modified = Snapper::ModifySnapshot (args); + } + if (type == `POST && snapshot_modified (pre_snapshot, pre_args)) + { + modified = Snapper::ModifySnapshot (pre_args) || modified; + } + } + + return modified; +} + +/** + * Popup for creating new snapshot + * @return true if new snapshot was created + */ +boolean CreateSnapshotPopup (list<integer> pre_snapshots) { + + boolean created = false; + list pre_items = maplist (integer s, pre_snapshots, { + return `item (`id (s), tostring (s)); + }); + + UI::OpenDialog (`opt (`decorated), `HBox (`HSpacing (1), `VBox( + `VSpacing (0.5), + `HSpacing (65), + // popup label + `Label (_("Create New Snapshot")), + // text entry label + `TextEntry (`id ("description"), _("Description"), ""), + `RadioButtonGroup (`id(`rb_type), `Left (`HVSquash (`VBox ( + `Left (`RadioButton (`id ("single"), `opt (`notify), + // radio button label + _("Single snapshot"), true)), + `Left (`RadioButton (`id ("pre"), `opt (`notify), + // radio button label + _("Pre"), false)), + `VBox ( + `Left (`RadioButton (`id ("post"), `opt (`notify), + // radio button label, snapshot selection will follow + _("Post, paired with:"), false) + ), + `HBox ( + `HSpacing (2), + `Left (`ComboBox (`id (`pre_list), `opt (`notify), "", pre_items)) + ) + ) + )))), + // text entry label + `TextEntry (`id ("userdata"), _("User data"), ""), + // text entry label + `ComboBox (`id ("cleanup"), `opt (`editable, `hstretch), _("Cleanup algorithm"), + cleanup_items ("")), + `VSpacing (0.5), + `ButtonBox ( + `PushButton (`id(`ok), Label::OKButton()), + `PushButton (`id(`cancel), Label::CancelButton()) + ), + `VSpacing (0.5)), `HSpacing (1)) + ); + + UI::ChangeWidget (`id ("post"), `Enabled, size (pre_items) > 0); + UI::ChangeWidget (`id (`pre_list), `Enabled, size (pre_items) > 0); + + any ret = nil; + map args = $[]; + while (true) + { + ret = UI::UserInput (); + args = $[ + "type" : UI::QueryWidget (`id (`rb_type), `Value), + "description" : UI::QueryWidget (`id ("description"), `Value), + "pre" : UI::QueryWidget (`id (`pre_list), `Value), + "cleanup" : UI::QueryWidget (`id ("cleanup"), `Value), + "userdata" : get_userdata ("userdata") + ]; + if (ret == `ok || ret == `cancel) + { + break; + } + } + UI::CloseDialog (); + if (ret == `ok) + { + created = Snapper::CreateSnapshot (args); + } + return created; +} + +/** + * Popup for deleting existing snapshot + * @return true if snapshot was deleted + */ +boolean DeleteSnapshotPopup (map snapshot) { + + // yes/no popup question + if (Popup::YesNo (sformat (_("Really delete snapshot '%1'?"), snapshot["num"]:0))) + { + return Snapper::DeleteSnapshot (snapshot); + } + return false; +} + +/** * Summary dialog * @return dialog result */ @@ -72,64 +315,102 @@ list<string> configs = Snapper::configs; list snapshot_items = []; + // lonely pre snapshots + list<integer> pre_snapshots = []; + // generate list of snapshot table items list get_snapshot_items () { integer i = -1; snapshot_items = []; + pre_snapshots = []; + foreach (map s, snapshots, { - i = i + 1; + 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); - } + integer num = s["num"]:0; + string date = ""; + if (num != 0) + date = timestring ("%c", s["date"]:0, false); + + string userdata = userdata2string (s["userdata"]:$[]); + + if (s["type"]:`none == `SINGLE) + { + snapshot_items = add (snapshot_items, + `item (`id (i), num, _("Single"), date, "", s["description"]:"", userdata)); + } + 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, userdata)); + } + else + { + integer post = s["post_num"]:0; // 0 means there's no post + if (post == 0) + { + y2milestone ("pre snappshot %1 does not have post", num); + snapshot_items = add (snapshot_items, + `item (`id (i), num, _("Pre"), date, "", s["description"]:"", userdata)); + pre_snapshots = add (pre_snapshots, num); + } + else + { + y2milestone ("skipping pre snapshot: %1", num); + } + } }); return snapshot_items; } + // update list of snapshots + void update_snapshots () { + + // busy popup message + Popup::ShowFeedback ("", _("Reading list of snapshots...")); + + Snapper::InitializeSnapper (Snapper::current_config); + Snapper::ReadSnapshots (); + snapshots = Snapper::snapshots; + Popup::ClearFeedback (); + + UI::ChangeWidget (`id (`snapshots_table), `Items, get_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")), - get_snapshot_items () - ), - `HBox ( - `PushButton (`id (`show_c), `opt (`default), _("Show Changes")), - `HStretch () - ) + `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"), _("User Data")), + get_snapshot_items () + ), + `HBox ( + // button label + `PushButton (`id (`show), `opt (`default), _("Show Changes")), + `PushButton (`id (`create), Label::CreateButton ()), + // button label + `PushButton (`id (`modify), _("Modify")), + `PushButton (`id (`delete), Label::DeleteButton ()), + `HStretch () + ) ); Wizard::SetContentsButtons(caption, contents, HELPS["summary"]:"", @@ -147,43 +428,57 @@ any ret = nil; while(true) { - ret = UI::UserInput(); + ret = UI::UserInput(); - integer selected = 0; + integer selected = (integer) UI::QueryWidget (`id (`snapshots_table), `CurrentItem); - 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; - } + 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; + if (snapshots[selected,"type"]:nil == `PRE) + { + // popup message + Popup::Message (_("This 'Pre' snapshot is not paired with any 'Post' one yet. +Showing differences is not possible.")); + continue; + } + // `POST snapshot is selected from the couple + Snapper::selected_snapshot = snapshots[selected]:$[]; + Snapper::selected_snapshot_index = selected; break; } 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; + Snapper::current_config = config; + update_snapshots (); + continue; } } + else if (ret == `create) { + if (CreateSnapshotPopup (pre_snapshots)) + { + update_snapshots (); + continue; + } + } + else if (ret == `modify) { + if (ModifySnapshotPopup (snapshots[selected]:$[])) + { + update_snapshots (); + continue; + } + } + else if (ret == `delete) { + if (DeleteSnapshotPopup (snapshots[selected]:$[])) + { + update_snapshots (); + continue; + } + } else if (ret == `next) { break; } -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
