Hello community,
here is the log from the commit of package yast2-ncurses
checked in at Wed Jan 10 18:16:41 CET 2007.
--------
--- yast2-ncurses/yast2-ncurses.changes 2007-01-04 13:34:07.000000000 +0100
+++ /mounts/work_src_done/STABLE/yast2-ncurses/yast2-ncurses.changes 2007-01-10 17:51:51.910044000 +0100
@@ -1,0 +2,7 @@
+Wed Jan 10 17:46:18 CET 2007 - kmachalkova@suse.cz
+
+- Added functionality to export/import list of all packages and
+ patterns to xml file (FaTE #300729)
+- 2.15.4
+
+-------------------------------------------------------------------
Old:
----
yast2-ncurses-2.15.3.tar.bz2
New:
----
yast2-ncurses-2.15.4.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-ncurses.spec ++++++
--- /var/tmp/diff_new_pack.B19701/_old 2007-01-10 18:14:00.000000000 +0100
+++ /var/tmp/diff_new_pack.B19701/_new 2007-01-10 18:14:00.000000000 +0100
@@ -1,5 +1,5 @@
#
-# spec file for package yast2-ncurses (Version 2.15.3)
+# spec file for package yast2-ncurses (Version 2.15.4)
#
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -11,12 +11,12 @@
# norootforbuild
Name: yast2-ncurses
-Version: 2.15.3
+Version: 2.15.4
Release: 1
License: GNU General Public License (GPL)
Group: System/YaST
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-Source0: yast2-ncurses-2.15.3.tar.bz2
+Source0: yast2-ncurses-2.15.4.tar.bz2
prefix: /usr
BuildRequires: doxygen gcc-c++ libzypp-devel yast2-core-devel yast2-devtools
BuildRequires: blocxx-devel libxcrypt-devel
@@ -32,8 +32,8 @@
Provides: y2curses
Obsoletes: y2curses
Requires: glibc-locale
-#zypp::ui::PatternContents
-Requires: libzypp >= 2.7.0
+#zypp::syscontent::Reader/Writer
+Requires: libzypp >= 2.10.0
# UI builtins
Requires: yast2-core >= 2.15.1
@@ -44,7 +44,7 @@
%prep
-%setup -n yast2-ncurses-2.15.3
+%setup -n yast2-ncurses-2.15.4
%build
%{prefix}/bin/y2tool y2autoconf
@@ -77,6 +77,10 @@
%doc %{prefix}/share/doc/packages/yast2-ncurses
%changelog -n yast2-ncurses
+* Wed Jan 10 2007 - kmachalkova@suse.cz
+- Added functionality to export/import list of all packages and
+ patterns to xml file (FaTE #300729)
+- 2.15.4
* Thu Jan 04 2007 - kmachalkova@suse.cz
- Added functionality to update list of pkgs if newer version is
available (#227043)
++++++ yast2-ncurses-2.15.3.tar.bz2 -> yast2-ncurses-2.15.4.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/yast2-ncurses-2.15.3/src/PackageSelector.cc new/yast2-ncurses-2.15.4/src/PackageSelector.cc
--- old/yast2-ncurses-2.15.3/src/PackageSelector.cc 2007-01-04 12:52:36.000000000 +0100
+++ new/yast2-ncurses-2.15.4/src/PackageSelector.cc 2007-01-10 17:27:18.000000000 +0100
@@ -36,8 +36,11 @@
#include "NCPopupFile.h"
#include "PackageSelector.h"
#include "YSelectionBox.h"
+#include "YNCursesUI.h"
#include "NCi18n.h"
+#include
+#include <fstream>
#include <iomanip>
#include <list>
#include <string>
@@ -46,17 +49,24 @@
#include "YQZypp.h" // tryCastToZyppPkg(), tryCastToZyppPatch()
#include
#include
+#include
typedef zypp::ui::PatchContents ZyppPatchContents;
typedef zypp::ui::PatchContents::const_iterator ZyppPatchContentsIterator;
+typedef zypp::syscontent::Reader::Entry ZyppReaderEntry;
+typedef std::pair importMapPair;
#include
#include
#include
+#define DEFAULT_EXPORT_FILE_NAME "user-packages.xml"
+
using namespace std;
using std::string;
using std::wstring;
+using std::map;
+using std::pair;
/*
Textdomain "packages"
@@ -163,6 +173,8 @@
eventHandlerMap[ PkgNames::ShowDeps()->toString() ] = &PackageSelector::DependencyHandler;
eventHandlerMap[ PkgNames::AutoDeps()->toString() ] = &PackageSelector::DependencyHandler;
eventHandlerMap[ PkgNames::VerifySystem()->toString() ] = &PackageSelector::DependencyHandler;
+ eventHandlerMap[ PkgNames::ExportToFile()->toString() ] = &PackageSelector::FileHandler;
+ eventHandlerMap[ PkgNames::ImportFromFile()->toString() ] = &PackageSelector::FileHandler;
eventHandlerMap[ PkgNames::SaveSel()->toString() ] = &PackageSelector::SelectionHandler;
eventHandlerMap[ PkgNames::LoadSel()->toString() ] = &PackageSelector::SelectionHandler;
eventHandlerMap[ PkgNames::Testcase()->toString() ] = &PackageSelector::TestcaseHandler;
@@ -1291,6 +1303,78 @@
return displayPatch;
}
+void PackageSelector::importSelectable( ZyppSel selectable, bool isWanted, const char* kind )
+{
+ ZyppStatus oldStatus = selectable->status();
+ ZyppStatus newStatus = oldStatus;
+
+ //Package/Pattern is on the list
+ if (isWanted)
+ {
+ switch (oldStatus)
+ {
+ //Keep status for installed ones
+ case S_Install:
+ case S_AutoInstall:
+ case S_Update:
+ case S_AutoUpdate:
+ case S_KeepInstalled:
+ case S_Protected:
+ newStatus = oldStatus;
+ break;
+
+ //Keep also those marked for deletion
+ case S_Del:
+ case S_AutoDel:
+ newStatus = S_KeepInstalled;
+ NCDBG << "Keeping " << kind << " " << selectable->name().c_str() << endl;
+ break;
+
+ //Add not yet installed pkgs (if they have candidate available)
+ case S_NoInst:
+ case S_Taboo:
+ if ( selectable->hasCandidateObj() )
+ {
+ newStatus = S_Install;
+ NCDBG << "Adding " << kind << " " << selectable->name().c_str() << endl;
+ }
+ else
+ {
+ NCDBG << "Cannot add " << kind << " " << selectable->name().c_str() <<
+ " " << " - no candidate." << endl;
+ }
+ break;
+ }
+ }
+ //Package/Pattern is not on the list
+ else
+ {
+ switch (oldStatus)
+ {
+ //Mark installed ones for deletion
+ case S_Install:
+ case S_AutoInstall:
+ case S_Update:
+ case S_AutoUpdate:
+ case S_KeepInstalled:
+ case S_Protected:
+ newStatus = S_Del;
+ NCDBG << "Deleting " << kind << " " << selectable->name().c_str() << endl;
+ break;
+
+ //Keep status for not installed, taboo and to-be-deleted
+ case S_Del:
+ case S_AutoDel:
+ case S_NoInst:
+ case S_Taboo:
+ newStatus = oldStatus;
+ break;
+ }
+ }
+
+ if (oldStatus != newStatus)
+ selectable->set_status( newStatus );
+}
///////////////////////////////////////////////////////////////////
//
@@ -1845,6 +1929,12 @@
return found;
}
+///////////////////////////////////////////////////////////////////
+//
+// testcase handler
+//
+// generate solver testcase
+//
bool PackageSelector::TestcaseHandler ( const NCursesEvent& event )
{
string testCaseDir = "/var/log/YaST2/solverTestcase";
@@ -1864,7 +1954,150 @@
return success;
}
+///////////////////////////////////////////////////////////////////
+//
+// File handler
+//
+// export/import all packages and patterns list to/from file
+//
+bool PackageSelector::FileHandler( const NCursesEvent& event )
+{
+ if ( event.selection.isNull() )
+ {
+ return false;
+ }
+
+ //Export package list into file
+ if ( event.selection->compare( PkgNames::ExportToFile() ) == YO_EQUAL )
+ {
+ //Ask for file to save into
+ YCPValue filename = YNCursesUI::ui()->askForSaveFileName( YCPString(DEFAULT_EXPORT_FILE_NAME),
+ YCPString("*.xml"),
+ YCPString(_("Export List of All Packages and Patterns to File" )));
+
+ if ( filename->isString() && !filename->asString()->value().empty() )
+ {
+ zypp::syscontent::Writer writer;
+ const zypp::ResPool & pool = zypp::getZYpp()->pool();
+
+ //some strange C++ magic (c) by ma
+ for_each( pool.begin(), pool.end(),
+ boost::bind( &zypp::syscontent::Writer::addIf,
+ boost::ref(writer),
+ _1));
+
+ try
+ {
+ //open file for writing and try to dump syscontent into it
+ std::ofstream exportFile( filename ->asString()->value_cstr() );
+ exportFile.exceptions(std::ios_base::badbit | std::ios_base::failbit );
+ exportFile << writer;
+
+ NCMIL << "Exported list of packages and patterns to " << filename->toString() << endl;
+ }
+
+ catch (std::exception & exception)
+ {
+ NCWAR << "Error exporting list of packages and patterns to " << filename->toString() << endl;
+
+ //delete partially written file (don't care if it doesn't exist)
+ (void) unlink( filename->asString()->value_cstr() );
+
+ //present error popup to the user
+ NCPopupInfo errorMsg ( wpos( 2, 2 ),
+ YCPString( PkgNames::ErrorLabel()),
+ YCPString( _("Error exporting list of packages and patterns to ") + filename->toString() ),
+ PkgNames::OKLabel(),
+ "");
+ NCursesEvent input = errorMsg.showInfoPopup();
+
+ }
+
+ return true;
+ }
+ }
+ //Import package list from file
+ else if ( event.selection->compare( PkgNames::ImportFromFile() ) == YO_EQUAL )
+ {
+ //ask for file to open
+ YCPValue filename = YNCursesUI::ui()->askForExistingFile( YCPString(DEFAULT_EXPORT_FILE_NAME),
+ YCPString("*.xml"),
+ YCPString(_("Import List of All Packages and Patterns from File")));
+
+ if ( filename->isString() && !filename->asString()->value().empty() )
+ {
+ NCPkgTable * packageList = getPackageList();
+ NCMIL << "Importing list of packages and patterns from " << filename->toString() << endl;
+
+ try
+ {
+ std::ifstream importFile ( filename->asString()->value_cstr() );
+ zypp::syscontent::Reader reader (importFile);
+
+ //maps to store package/pattern data into
+ map importPkgs;
+ map importPatterns;
+
+ //Import syscontent reader to a map $[ "package_name" : pointer_to_data]
+ for (zypp::syscontent::Reader::const_iterator it = reader.begin();
+ it != reader.end();
+ it ++ )
+ {
+ string kind = it->kind();
+
+ // importMapPair => std::pair
+ if ( kind == "package" )
+ importPkgs.insert( importMapPair( it->name(), *it ) );
+ else if ( kind == "pattern" )
+ importPatterns.insert( importMapPair( it->name(), *it ) );
+ }
+
+ NCMIL << "Found " << importPkgs.size() << " packages and " << importPatterns.size() << " patterns." << endl;
+
+ //Change status of appropriate packages and patterns
+ for (ZyppPoolIterator it = zyppPkgBegin();
+ it != zyppPkgEnd();
+ it++ )
+ {
+ ZyppSel selectable = *it;
+ //isWanted => package name found in importPkgs map
+ importSelectable ( *it, importPkgs.find( selectable->name() ) != importPkgs.end(), "package" );
+ }
+
+ for (ZyppPoolIterator it = zyppPatternsBegin();
+ it != zyppPatternsEnd();
+ it++ )
+ {
+ ZyppSel selectable = *it;
+ importSelectable ( *it, importPatterns.find( selectable->name() ) != importPatterns.end(), "pattern" );
+ }
+
+ //Switch to installation summary filter
+ fillSummaryList(NCPkgTable::L_Changes);
+
+ //... and finally display the result
+ packageList->showInformation();
+ packageList->setKeyboardFocus();
+
+ return true;
+ }
+ catch ( const zypp::Exception & exception )
+ {
+ NCWAR << "Error importing list of packages and patterns from" << filename->toString() << endl;
+
+ NCPopupInfo errorMsg ( wpos( 2, 2 ),
+ YCPString( PkgNames::ErrorLabel()),
+ YCPString( _("Error importing list of packages and patterns from ") + filename->toString() ),
+ PkgNames::OKLabel(),
+ "");
+ NCursesEvent input = errorMsg.showInfoPopup();
+
+ }
+ }
+ }
+ return true;
+}
///////////////////////////////////////////////////////////////////
//
// HelpHandler
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/yast2-ncurses-2.15.3/src/PackageSelector.h new/yast2-ncurses-2.15.4/src/PackageSelector.h
--- old/yast2-ncurses-2.15.3/src/PackageSelector.h 2007-01-04 12:50:12.000000000 +0100
+++ new/yast2-ncurses-2.15.4/src/PackageSelector.h 2007-01-10 17:27:19.000000000 +0100
@@ -244,6 +244,12 @@
bool TestcaseHandler ( const NCursesEvent& event );
/**
+ * Export/Import list of all packages and patterns to/from file
+ *
+ */
+ bool FileHandler ( const NCursesEvent& event );
+
+ /**
* Handler function for "OK button pressed"
* @param event The Ncurses event
* @return bool
@@ -372,7 +378,18 @@
* @return bool
**/
bool checkPatch( ZyppPatch patch, ZyppSel selectable, string filter );
-
+
+ /**
+ * Set status of a selectable according to its presence
+ * in the list imported from xml file (zypp::syscontent::Reader)
+ *
+ * @param selectable a selectable
+ * @param isWanted should be installed or not
+ * @param kind "package" or "pattern"
+ * @return void
+ **/
+ void importSelectable ( ZyppSel selectable, bool isWanted, const char* kind );
+
/**
* Returns whether automatic dependency is on or off
* @return bool
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/yast2-ncurses-2.15.3/src/pkg_layout.ycp new/yast2-ncurses-2.15.4/src/pkg_layout.ycp
--- old/yast2-ncurses-2.15.3/src/pkg_layout.ycp 2007-01-04 13:30:32.000000000 +0100
+++ new/yast2-ncurses-2.15.4/src/pkg_layout.ycp 2007-01-10 17:50:55.000000000 +0100
@@ -7,7 +7,7 @@
*
* ncurses layout for package selection
*
- * $Id: pkg_layout.ycp 35058 2007-01-04 12:30:28Z kmachalkova $
+ * $Id: pkg_layout.ycp 35211 2007-01-10 16:50:49Z kmachalkova $
*/
{
textdomain "packages";
@@ -88,6 +88,13 @@
`item( `id("autodeps"), _( "[X] &Automatic Dependency Check" ) ),
`item( `id("verifysystem"), _( " &Verify System" ) ) ]
),
+ // menu item - list of all packages in the system
+ `menu( _("All &Packages List"),
+ // action on list of all packages-export to xml file
+ [`item( `id("export"), _("&Export to File") ),
+ // action on list of all packages-import from xml file
+ `item( `id("import"), _("&Import from File") ) ]
+ ),
`item( `id("testcase"), _( "Generate Dependency Resolver &Test Case" ) )
/*#ifdef FIXME
,
@@ -103,7 +110,6 @@
)
),
`HSpacing(0.3)
-
),
`VSpacing(0.3),
`VWeight( 50, `HBox(`HSpacing(0.3),
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/yast2-ncurses-2.15.3/src/PkgNames.cc new/yast2-ncurses-2.15.4/src/PkgNames.cc
--- old/yast2-ncurses-2.15.3/src/PkgNames.cc 2007-01-04 12:52:32.000000000 +0100
+++ new/yast2-ncurses-2.15.4/src/PkgNames.cc 2007-01-10 17:35:51.000000000 +0100
@@ -214,6 +214,20 @@
return value;
}
+// the menu entry Etc./Package list/Export to file
+const YCPValue& PkgNames::ExportToFile ()
+{
+ static const YCPValue value = createIdValue ( "export" );
+ return value;
+}
+
+// the menu entry Etc./Package list/Import from file
+const YCPValue& PkgNames::ImportFromFile ()
+{
+ static const YCPValue value = createIdValue ("import");
+ return value;
+}
+
// the menu entry Etc./Save selection
const YCPValue& PkgNames::SaveSel ()
{
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/yast2-ncurses-2.15.3/src/PkgNames.h new/yast2-ncurses-2.15.4/src/PkgNames.h
--- old/yast2-ncurses-2.15.3/src/PkgNames.h 2007-01-04 12:52:38.000000000 +0100
+++ new/yast2-ncurses-2.15.4/src/PkgNames.h 2007-01-10 17:35:52.000000000 +0100
@@ -230,6 +230,16 @@
*/
static const YCPValue& AutoDeps ();
+ /**
+ * Widget id of the Etc./Package List/Export menu item
+ */
+ static const YCPValue& ExportToFile ();
+
+ /**
+ * Widget id of the Etc./Package List/Import menu item
+ */
+ static const YCPValue& ImportFromFile ();
+
/**
* Widget id of the Etc./Selections menu item
*/
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/yast2-ncurses-2.15.3/VERSION new/yast2-ncurses-2.15.4/VERSION
--- old/yast2-ncurses-2.15.3/VERSION 2007-01-04 12:54:08.000000000 +0100
+++ new/yast2-ncurses-2.15.4/VERSION 2007-01-10 17:46:16.000000000 +0100
@@ -1 +1 @@
-2.15.3
+2.15.4
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org