YaST Commits
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2011
- 16 participants
- 288 discussions
[yast-commit] r63951 - /tags/branch-Code-11-SP2-2_17_2/snapper/
by jsuchome@svn2.opensuse.org 11 May '11
by jsuchome@svn2.opensuse.org 11 May '11
11 May '11
Author: jsuchome
Date: Wed May 11 11:36:29 2011
New Revision: 63951
URL: http://svn.opensuse.org/viewcvs/yast?rev=63951&view=rev
Log:
Created tag branch-Code-11-SP2-2_17_2 for snapper
Added:
tags/branch-Code-11-SP2-2_17_2/snapper/
- copied from r63950, branches/SuSE-Code-11-SP2-Branch/snapper/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
11 May '11
Author: jsuchome
Date: Wed May 11 11:36:25 2011
New Revision: 63950
URL: http://svn.opensuse.org/viewcvs/yast?rev=63950&view=rev
Log:
Created tag branch-Code-11-SP2-2_17_2
Added:
tags/branch-Code-11-SP2-2_17_2/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r63949 - in /branches/SuSE-Code-11-SP2-Branch/snapper: VERSION package/yast2-snapper.changes yast2-snapper.spec.in
by jsuchome@svn2.opensuse.org 11 May '11
by jsuchome@svn2.opensuse.org 11 May '11
11 May '11
Author: jsuchome
Date: Wed May 11 11:36:01 2011
New Revision: 63949
URL: http://svn.opensuse.org/viewcvs/yast?rev=63949&view=rev
Log:
- only require libsnapper-devel
- 2.17.2
Modified:
branches/SuSE-Code-11-SP2-Branch/snapper/VERSION
branches/SuSE-Code-11-SP2-Branch/snapper/package/yast2-snapper.changes
branches/SuSE-Code-11-SP2-Branch/snapper/yast2-snapper.spec.in
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/VERSION (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/VERSION Wed May 11 11:36:01 2011
@@ -1 +1 @@
-2.17.1
+2.17.2
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/package/yast2-snapper.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/package/yast2-snapper.changes (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/package/yast2-snapper.changes Wed May 11 11:36:01 2011
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Wed May 11 11:35:31 CEST 2011 - jsuchome(a)suse.cz
+
+- only require libsnapper-devel
+- 2.17.2
+
+-------------------------------------------------------------------
Wed May 11 11:28:15 CEST 2011 - jsuchome(a)suse.cz
- added initialization code to agent, check for exceptions
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/yast2-snapper.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/yast2-snapper.spec.in (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/yast2-snapper.spec.in Wed May 11 11:36:01 2011
@@ -1,9 +1,9 @@
@HEADER-COMMENT@
@HEADER@
-Requires: yast2 libsnapper
+Requires: yast2
License: GPL v2 or later
-BuildRequires: update-desktop-files yast2 yast2-devtools yast2-testsuite libsnapper libsnapper-devel doxygen yast2-core-devel gcc-c++ perl-XML-Writer
+BuildRequires: update-desktop-files yast2 yast2-devtools yast2-testsuite libsnapper-devel doxygen yast2-core-devel gcc-c++ perl-XML-Writer
Summary: YaST - file system snapshots review
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r63948 - in /trunk/fcoe-client/src: FcoeClient.ycp complex.ycp
by gs@svn2.opensuse.org 11 May '11
by gs@svn2.opensuse.org 11 May '11
11 May '11
Author: gs
Date: Wed May 11 11:35:14 2011
New Revision: 63948
URL: http://svn.opensuse.org/viewcvs/yast?rev=63948&view=rev
Log:
store values from edit dialo
Modified:
trunk/fcoe-client/src/FcoeClient.ycp
trunk/fcoe-client/src/complex.ycp
Modified: trunk/fcoe-client/src/FcoeClient.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/FcoeClient.ycp?r…
==============================================================================
--- trunk/fcoe-client/src/FcoeClient.ycp (original)
+++ trunk/fcoe-client/src/FcoeClient.ycp Wed May 11 11:35:14 2011
@@ -484,6 +484,11 @@
return network_interfaces;
}
+global list <string> GetCurrentNetworkCard()
+{
+ return (list <string>)network_interfaces[ current_card ]:[];
+}
+
global void SetNetworkCardsValue( integer row, list card )
{
network_interfaces[row] = card;
@@ -512,6 +517,14 @@
}
//
+// Set value in fcoe_general_config
+//
+global void SetFcoeConfigValue( string param, string value )
+{
+ fcoe_general_config[ param ] = value;
+}
+
+//
// Returns the map containing general FCoE configuration
//
global map <string, string> GetFcoeConfig()
Modified: trunk/fcoe-client/src/complex.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/complex.ycp?rev=…
==============================================================================
--- trunk/fcoe-client/src/complex.ycp (original)
+++ trunk/fcoe-client/src/complex.ycp Wed May 11 11:35:14 2011
@@ -86,7 +86,8 @@
* Init
**/
void InitServicesDialog (string id) {
-
+ y2milestone( "Init services dialog" );
+
map status_map = FcoeClient::GetServiceStatus();
if ( status_map["fcoe"]:false == true )
@@ -99,7 +100,6 @@
UI::ChangeWidget( `id( "fcoe_startup_auto" ), `Value, false );
UI::ChangeWidget( `id( "fcoe_startup_manual" ), `Value, true );
}
- y2milestone( "Init services dialog" );
}
//
@@ -325,37 +325,49 @@
FcoeClient::SetServiceStatus( "fcoe", true );
y2milestone( "Setting auto start of FCoE to true");
}
- // Check whether FCoE already running and start if required
+ // Check whether FCoE is already running and start if required
integer status = Service::Status("fcoe");
if ( status != 0 )
{
- Service::Start("fcoe");
- y2milestone( "Starting FCoE (/etc/init.d/fcoe start)");
+ boolean success = Service::Start("fcoe");
+ if ( success )
+ {
+ y2milestone( "FCoE started (/etc/init.d/fcoe start)");
+ }
+ else
+ {
+ y2error( "Cannot start FCoE service - '/etc/init.d/fcoe start' failed" );
+ Popup::Error( "Cannot start FCoE service.
+'/etc/init.d/fcoe start' failed" );
+ }
}
else
{
- y2milestone( "FCoE running");
+ y2milestone( "FCoE service is running");
}
-
-
}
-void StoreInterfacesDialog (string id, map event) {
- y2milestone( "Store interfaces dialog" );
+void StoreInterfacesDialog (string id, map event)
+{
+ y2milestone( "Store interfaces dialog" );
}
-void StoreConfigurationDialog (string id, map event) {
- y2milestone( "Store configuration dialog" );
+void StoreConfigurationDialog (string id, map event)
+{
+ y2milestone( "Store configuration dialog" );
}
-void StoreEditDialog (string id, map event) {
- y2milestone( "Store edit dialog" );
-
- string fcoe_enabled = (string)UI::QueryWidget( `id(`fcoe), `Value );
- string dcb_required = (string)UI::QueryWidget( `id(`dcb), `Value );
-
-
+void StoreEditDialog (string id, map event)
+{
+ y2milestone( "Store edit dialog" );
+ list <string> card = FcoeClient::GetCurrentNetworkCard();
+ string fcoe_enabled = (string)UI::QueryWidget( `id(`fcoe), `Value );
+ card[4] = fcoe_enabled;
+ string dcb_required = (string)UI::QueryWidget( `id(`dcb), `Value );
+ card[5] = dcb_required;
+
+ FcoeClient::SetNetworkCardsValue( FcoeClient::current_card, card );
}
/* EOF */
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r63947 - /tags/branch-Code-11-SP2-2_17_1/snapper/
by jsuchome@svn2.opensuse.org 11 May '11
by jsuchome@svn2.opensuse.org 11 May '11
11 May '11
Author: jsuchome
Date: Wed May 11 11:31:19 2011
New Revision: 63947
URL: http://svn.opensuse.org/viewcvs/yast?rev=63947&view=rev
Log:
Created tag branch-Code-11-SP2-2_17_1 for snapper
Added:
tags/branch-Code-11-SP2-2_17_1/snapper/
- copied from r63946, branches/SuSE-Code-11-SP2-Branch/snapper/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
11 May '11
Author: jsuchome
Date: Wed May 11 11:31:15 2011
New Revision: 63946
URL: http://svn.opensuse.org/viewcvs/yast?rev=63946&view=rev
Log:
Created tag branch-Code-11-SP2-2_17_1
Added:
tags/branch-Code-11-SP2-2_17_1/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r63945 - in /branches/SuSE-Code-11-SP2-Branch/snapper: ./ agent-snapper/doc/ agent-snapper/src/ package/ src/
by jsuchome@svn2.opensuse.org 11 May '11
by jsuchome@svn2.opensuse.org 11 May '11
11 May '11
Author: jsuchome
Date: Wed May 11 11:31:04 2011
New Revision: 63945
URL: http://svn.opensuse.org/viewcvs/yast?rev=63945&view=rev
Log:
- added initialization code to agent, check for exceptions
- updated agent documentation
- 2.17.1
Modified:
branches/SuSE-Code-11-SP2-Branch/snapper/VERSION
branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/doc/snapper.html
branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/src/SnapperAgent.cc
branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/src/SnapperAgent.h
branches/SuSE-Code-11-SP2-Branch/snapper/package/yast2-snapper.changes
branches/SuSE-Code-11-SP2-Branch/snapper/src/Snapper.ycp
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/VERSION (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/VERSION Wed May 11 11:31:04 2011
@@ -1 +1 @@
-2.17.0
+2.17.1
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/doc/snapper.html
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/doc/snapper.html (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/doc/snapper.html Wed May 11 11:31:04 2011
@@ -32,6 +32,8 @@
<ul><tt>.snapper</tt></ul>
+The initialization call of Execute (.snapper) must be done before any other calls.
+
<P>
<h2>Complete Read paths table</h2>
@@ -43,7 +45,18 @@
<th align="left">Result</th>
</tr>
- <tr><td><tt>.snapper.snapshots</td><td></td><td align="left">YCPList</td>
+ <tr><td><tt>.snapper.error</td><td>(none)</td><td align="left">YCPMap</td>
+ <td>Return information about last error.<br>
+ <b>Example of result</b>:
+ <pre>
+ $[
+ "type" : "config_not_found"
+ ]
+ </pre>
+ </td>
+ </tr>
+
+ <tr><td><tt>.snapper.snapshots</td><td>(none)</td><td align="left">YCPList</td>
<td>Return list of current snapshot maps.<br>
<b>Example of result</b>:
<pre>
@@ -75,7 +88,7 @@
</td>
</tr>
- <tr><td><tt>.snapper.diff</td><td>YCPMap</td><td align="left">YCPList</td>
+ <tr><td><tt>.snapper.diff_list</td><td>YCPMap</td><td align="left">YCPList</td>
<td>Returns the list of files modified between given snapshots.
Each file is described by YCPMap which contains file path and type of the change.
Argument map contains 2 integers, identifying the snapshots.<br>
@@ -100,6 +113,93 @@
]
</pre>
</td></tr>
+
+ <tr><td><tt>.snapper.diff_index</td><td>YCPMap</td><td align="left">YCPMap</td>
+ <td>Returns the differences between snapnots num1 and num2 as one-level map
+ (mapping each file to its changes).<br>
+ <b>Example of argument map</b>:
+ <pre>
+ $[
+ "from" : 1,
+ "to" : 2
+ $]
+ </pre>
+ <b>Example of result</b>:
+ <pre>
+ $[
+ "/etc/group" : "c...",
+ "/etc/group.YaST2save" : "c..."
+ ]
+ </pre>
+ </td></tr>
+
+ <tr><td><tt>.snapper.diff_tree</td><td>YCPMap</td><td align="left">YCPMap</td>
+ <td>Returns the differences between snapnots num1 and num2 as a tree.
+ Map is recursively describing the filesystem structure; it is used to build Tree widget contents
+ in yast2-snapper UI.
+ <br>
+ <b>Example of argument map</b>:
+ <pre>
+ $[
+ "from" : 1,
+ "to" : 2
+ $]
+ </pre>
+ <b>Example of result</b>:
+ <pre>
+ $[
+ "etc" : $[
+ "group" : $[],
+ "group.YaST2save" : $[],
+ "passwd" : $[],
+ "passwd.YaST2save" : $[]
+ ],
+ "var" : $[
+ "log" : $[
+ "YaST2" : $[
+ "y2changes" : $[],
+ "y2log" : $[]
+ ],
+ "messages" : $[],
+ "snapper.log" : $[]
+ ]
+ ]
+ ]
+ </pre>
+ </td></tr>
+</table>
+
+<P>
+<h2>Complete Execute paths table</h2>
+
+<table border=3>
+ <tr>
+ <th width="20%" align="left">Path</th>
+ <th width="10%" align="left">Argument</th>
+ <th width="10%" align="left">Type of Result</th>
+ <th align="left">Result</th>
+ </tr>
+
+ <tr><td><tt>.snapper</td><td>(none)</td><td align="left">YCPBoolean</td>
+ <td>Initializes snapper object. In case of init failure, sets the internal error ID.
+ Use Read (.snapper.error) to get the error info.
+ </td>
+ </tr>
+
+ <tr><td><tt>.snapper.rollback</td><td>YCPMap</td><td align="left">YCPBoolean</td>
+ <td>Rollback the list of given files from snapshot num1 to num2. If num2 is not present,
+ current system is used as a default.
+ <b>Example of argument map</b>:
+ <pre>
+ $[
+ "files" : [
+ "/etc/passwd",
+ "/etc/group"
+ ]
+ "from" : 1,
+ $]
+ </pre>
+ </td></tr>
</table>
<P>
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/src/SnapperAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/src/SnapperAgent.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/src/SnapperAgent.cc Wed May 11 11:31:04 2011
@@ -86,7 +86,9 @@
*/
SnapperAgent::SnapperAgent() : SCRAgent()
{
- sh = createSnapper();
+ sh = NULL;
+ snapper_initialized = false;
+ snapper_error = "";
}
/**
@@ -94,7 +96,10 @@
*/
SnapperAgent::~SnapperAgent()
{
- deleteSnapper(sh);
+ if (sh)
+ {
+ deleteSnapper(sh);
+ }
}
@@ -133,14 +138,21 @@
YCPMap argmap;
if (!arg.isNull() && arg->isMap())
argmap = arg->asMap();
+
+ if (!snapper_initialized && PC(0) != "error") {
+ y2error ("snapper not initialized: use Execute (.snapper) first!");
+ snapper_error = "not_initialized";
+ return YCPVoid();
+ }
if (path->length() == 1) {
/**
- * error: Read(.snapper.error) -> returns last error message
+ * error: Read (.snapper.error) -> returns last error message
*/
if (PC(0) == "error") {
YCPMap retmap;
+ retmap->add (YCPString ("type"), YCPString (snapper_error));
return retmap;
}
/**
@@ -286,6 +298,38 @@
if (!arg.isNull() && arg->isMap())
argmap = arg->asMap();
+ /**
+ * Execute (.snapper) call: Initialize snapper object
+ */
+ if (path->length() == 0) {
+
+ try {
+ sh = createSnapper();
+ }
+ catch (const ConfigNotFoundException& e)
+ {
+ y2error ("Config not found.");
+ snapper_error = "config_not_found";
+ sh = NULL;
+ return YCPBoolean (false);
+ }
+ catch (const InvalidConfigException& e)
+ {
+ y2error ("Config is invalid.");
+ snapper_error = "config_invalid";
+ sh = NULL;
+ return YCPBoolean (false);
+ }
+ snapper_initialized = true;
+ return ret;
+ }
+
+ if (!snapper_initialized) {
+ y2error ("snapper not initialized: use Execute (.snapper) first!");
+ snapper_error = "not_initialized";
+ return YCPVoid();
+ }
+
if (path->length() == 1) {
/**
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/src/SnapperAgent.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/src/SnapperAgent.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/agent-snapper/src/SnapperAgent.h Wed May 11 11:31:04 2011
@@ -29,6 +29,10 @@
* Agent private variables and methods
*/
+ snapper::Snapper* sh;
+ bool snapper_initialized;
+ string snapper_error;
+
/**
* 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
@@ -92,11 +96,6 @@
* Used for mounting the agent.
*/
virtual YCPValue otherCommand(const YCPTerm& term);
-
-private:
-
- snapper::Snapper* sh;
-
};
#endif /* _SnapperAgent_h */
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/package/yast2-snapper.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/package/yast2-snapper.changes (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/package/yast2-snapper.changes Wed May 11 11:31:04 2011
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed May 11 11:28:15 CEST 2011 - jsuchome(a)suse.cz
+
+- added initialization code to agent, check for exceptions
+- updated agent documentation
+- 2.17.1
+
+-------------------------------------------------------------------
Tue Apr 19 11:24:05 CEST 2011 - jsuchome(a)suse.cz
- initial version for SP2, based on Factory version 2.21.4
Modified: branches/SuSE-Code-11-SP2-Branch/snapper/src/Snapper.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/snapp…
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/snapper/src/Snapper.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/snapper/src/Snapper.ycp Wed May 11 11:31:04 2011
@@ -37,6 +37,7 @@
import "FileUtils";
import "Label";
import "Progress";
+import "Report";
// global list of all snapshot
@@ -163,6 +164,41 @@
return true;
}
+global map LastSnapperErrorMap () {
+
+ return (map) SCR::Read (.snapper.error);
+}
+
+/**
+ * Initialize snapper agent
+ * Return true on success
+ */
+global boolean InitializeSnapper () {
+
+ boolean init = (boolean) SCR::Execute (.snapper);
+ if (!init)
+ {
+ map err_map = LastSnapperErrorMap ();
+ string type = err_map["type"]:"";
+ string details = _("Reason not known.");
+ if (type == "config_not_found")
+ {
+ details = _("Configuration not found.");
+ }
+ else if (type == "config_invalid")
+ {
+ details = _("Configuration is not valid.");
+ }
+
+ y2warning ("init failed with '%1'", err_map);
+ // error popup
+ Report::Error (sformat (_("Failed to initialize snapper library:
+%1"), details));
+ }
+ return init;
+
+}
+
/**
* Read all snapper settings
* @return true on success
@@ -188,7 +224,11 @@
);
Progress::NextStage();
- // read database
+
+ if (!InitializeSnapper ())
+ {
+ return false;
+ }
ReadSnapshots ();
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
11 May '11
Author: jsuchome
Date: Wed May 11 11:26:50 2011
New Revision: 63944
URL: http://svn.opensuse.org/viewcvs/yast?rev=63944&view=rev
Log:
Created tag stable-2_21_5 for snapper
Added:
tags/stable-2_21_5/snapper/
- copied from r63943, trunk/snapper/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r63943 - in /trunk/snapper: VERSION agent-snapper/doc/snapper.html package/yast2-snapper.changes
by jsuchome@svn2.opensuse.org 11 May '11
by jsuchome@svn2.opensuse.org 11 May '11
11 May '11
Author: jsuchome
Date: Wed May 11 11:26:28 2011
New Revision: 63943
URL: http://svn.opensuse.org/viewcvs/yast?rev=63943&view=rev
Log:
- added initialization code to agent, check for exceptions
- updated agent documentation
- 2.21.5
Modified:
trunk/snapper/VERSION
trunk/snapper/agent-snapper/doc/snapper.html
trunk/snapper/package/yast2-snapper.changes
Modified: trunk/snapper/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/VERSION?rev=63943&r1=639…
==============================================================================
--- trunk/snapper/VERSION (original)
+++ trunk/snapper/VERSION Wed May 11 11:26:28 2011
@@ -1 +1 @@
-2.21.4
+2.21.5
Modified: trunk/snapper/agent-snapper/doc/snapper.html
URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/doc/snappe…
==============================================================================
--- trunk/snapper/agent-snapper/doc/snapper.html (original)
+++ trunk/snapper/agent-snapper/doc/snapper.html Wed May 11 11:26:28 2011
@@ -32,6 +32,8 @@
<ul><tt>.snapper</tt></ul>
+The initialization call of Execute (.snapper) must be done before any other calls.
+
<P>
<h2>Complete Read paths table</h2>
@@ -43,7 +45,18 @@
<th align="left">Result</th>
</tr>
- <tr><td><tt>.snapper.snapshots</td><td></td><td align="left">YCPList</td>
+ <tr><td><tt>.snapper.error</td><td>(none)</td><td align="left">YCPMap</td>
+ <td>Return information about last error.<br>
+ <b>Example of result</b>:
+ <pre>
+ $[
+ "type" : "config_not_found"
+ ]
+ </pre>
+ </td>
+ </tr>
+
+ <tr><td><tt>.snapper.snapshots</td><td>(none)</td><td align="left">YCPList</td>
<td>Return list of current snapshot maps.<br>
<b>Example of result</b>:
<pre>
@@ -75,7 +88,7 @@
</td>
</tr>
- <tr><td><tt>.snapper.diff</td><td>YCPMap</td><td align="left">YCPList</td>
+ <tr><td><tt>.snapper.diff_list</td><td>YCPMap</td><td align="left">YCPList</td>
<td>Returns the list of files modified between given snapshots.
Each file is described by YCPMap which contains file path and type of the change.
Argument map contains 2 integers, identifying the snapshots.<br>
@@ -100,6 +113,93 @@
]
</pre>
</td></tr>
+
+ <tr><td><tt>.snapper.diff_index</td><td>YCPMap</td><td align="left">YCPMap</td>
+ <td>Returns the differences between snapnots num1 and num2 as one-level map
+ (mapping each file to its changes).<br>
+ <b>Example of argument map</b>:
+ <pre>
+ $[
+ "from" : 1,
+ "to" : 2
+ $]
+ </pre>
+ <b>Example of result</b>:
+ <pre>
+ $[
+ "/etc/group" : "c...",
+ "/etc/group.YaST2save" : "c..."
+ ]
+ </pre>
+ </td></tr>
+
+ <tr><td><tt>.snapper.diff_tree</td><td>YCPMap</td><td align="left">YCPMap</td>
+ <td>Returns the differences between snapnots num1 and num2 as a tree.
+ Map is recursively describing the filesystem structure; it is used to build Tree widget contents
+ in yast2-snapper UI.
+ <br>
+ <b>Example of argument map</b>:
+ <pre>
+ $[
+ "from" : 1,
+ "to" : 2
+ $]
+ </pre>
+ <b>Example of result</b>:
+ <pre>
+ $[
+ "etc" : $[
+ "group" : $[],
+ "group.YaST2save" : $[],
+ "passwd" : $[],
+ "passwd.YaST2save" : $[]
+ ],
+ "var" : $[
+ "log" : $[
+ "YaST2" : $[
+ "y2changes" : $[],
+ "y2log" : $[]
+ ],
+ "messages" : $[],
+ "snapper.log" : $[]
+ ]
+ ]
+ ]
+ </pre>
+ </td></tr>
+</table>
+
+<P>
+<h2>Complete Execute paths table</h2>
+
+<table border=3>
+ <tr>
+ <th width="20%" align="left">Path</th>
+ <th width="10%" align="left">Argument</th>
+ <th width="10%" align="left">Type of Result</th>
+ <th align="left">Result</th>
+ </tr>
+
+ <tr><td><tt>.snapper</td><td>(none)</td><td align="left">YCPBoolean</td>
+ <td>Initializes snapper object. In case of init failure, sets the internal error ID.
+ Use Read (.snapper.error) to get the error info.
+ </td>
+ </tr>
+
+ <tr><td><tt>.snapper.rollback</td><td>YCPMap</td><td align="left">YCPBoolean</td>
+ <td>Rollback the list of given files from snapshot num1 to num2. If num2 is not present,
+ current system is used as a default.
+ <b>Example of argument map</b>:
+ <pre>
+ $[
+ "files" : [
+ "/etc/passwd",
+ "/etc/group"
+ ]
+ "from" : 1,
+ $]
+ </pre>
+ </td></tr>
</table>
<P>
Modified: trunk/snapper/package/yast2-snapper.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/package/yast2-snapper.ch…
==============================================================================
--- trunk/snapper/package/yast2-snapper.changes (original)
+++ trunk/snapper/package/yast2-snapper.changes Wed May 11 11:26:28 2011
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed May 11 10:41:42 CEST 2011 - jsuchome(a)suse.cz
+
+- added initialization code to agent, check for exceptions
+- updated agent documentation
+- 2.21.5
+
+-------------------------------------------------------------------
Mon Apr 18 09:16:36 CEST 2011 - jsuchome(a)suse.cz
- removed YCP code for Tree recursive selection, widget can do it
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r63942 - /branches/tmp/dmacvicar/zc10/pkg-bindings/src/
by dmacvicar@svn2.opensuse.org 11 May '11
by dmacvicar@svn2.opensuse.org 11 May '11
11 May '11
Author: dmacvicar
Date: Wed May 11 11:22:32 2011
New Revision: 63942
URL: http://svn.opensuse.org/viewcvs/yast?rev=63942&view=rev
Log:
It builds
Added:
branches/tmp/dmacvicar/zc10/pkg-bindings/src/GPGMap.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/GPGMap.h
branches/tmp/dmacvicar/zc10/pkg-bindings/src/HelpTexts.h
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Network.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Network.h
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Callbacks.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Create.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Download.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Get.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Installation.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Load.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Misc.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Resolvables.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Save.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Set.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/i18n.h
Removed:
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source.cc
Modified:
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Callbacks.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Callbacks.h
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Makefile.am
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Package.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgModuleFunctions.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgModuleFunctions.h
branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgProgress.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgProgress.h
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Target.cc
branches/tmp/dmacvicar/zc10/pkg-bindings/src/Utils.cc
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Callbacks.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Callbacks.cc (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Callbacks.cc Wed May 11 11:22:32 2011
@@ -26,16 +26,20 @@
#include <y2util/stringutil.h>
#include "PkgModuleFunctions.h"
+#include "log.h"
#include "Callbacks.h"
#include "Callbacks.YCP.h" // PkgModuleFunctions::CallbackHandler::YCPCallbacks
+#include "GPGMap.h"
-#include <zypp/ZYppCallbacks.h>
-#include <zypp/Package.h>
-#include <zypp/Product.h>
-#include <zypp/KeyRing.h>
-#include <zypp/PublicKey.h>
-#include <zypp/Digest.h>
-#include <zypp/SourceManager.h>
+#include "zypp/ZYppCallbacks.h"
+#include "zypp/Package.h"
+#include "zypp/Patch.h"
+#include "zypp/KeyRing.h"
+#include "zypp/PublicKey.h"
+#include "zypp/Digest.h"
+#include "zypp/base/String.h"
+
+#include <ctime>
// FIXME: do this nicer, source create use this to avoid user feedback
// on probing of source type
@@ -43,7 +47,16 @@
ZyppRecipients::MediaChangeSensitivity _silent_probing = ZyppRecipients::MEDIA_CHANGE_FULL;
// remember redirected URLs
-std::map<zypp::Source_Ref::NumericId, std::map<unsigned, std::string> > redirect_map;
+// FIXME huh?
+
+typedef std::map<unsigned, zypp::Url> MediaMap;
+typedef std::map<zypp::Url, MediaMap> RedirectMap;
+
+RedirectMap redirect_map;
+
+// default timeout for callbacks, evaluate the callbacks after 3 seconds
+// even if the progress percent has not been changed
+static const time_t callback_timeout = 3;
///////////////////////////////////////////////////////////////////
namespace ZyppRecipients {
@@ -108,11 +121,7 @@
CB callback( ycpcb( YCPCallbacks::CB_ProgressConvertDb ) );
if (callback._set) {
callback.addInt( value );
- // TODO adapt callback typeinfo to zypp
- callback.addInt( 100 );
- callback.addInt( 0 /*failed*/ );
- callback.addInt( 0 /* ignored */ );
- callback.addInt( 1 /*alreadyInV4*/ );
+ callback.addStr(pth.asString());
callback.evaluate();
}
@@ -126,7 +135,7 @@
if (callback._set) {
callback.addInt( error );
callback.addStr( reason );
- callback.evaluateStr(); // return value ignored by RpmDb
+ callback.evaluate();
}
}
};
@@ -175,20 +184,23 @@
if (callback._set) {
callback.addInt( error );
callback.addStr( reason );
- callback.evaluateStr(); // return value ignored by RpmDb
+ callback.evaluate();
}
}
};
+
///////////////////////////////////////////////////////////////////
// InstallPkgCallback
///////////////////////////////////////////////////////////////////
struct InstallPkgReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::target::rpm::InstallResolvableReport>
{
zypp::Resolvable::constPtr _last;
+ PkgModuleFunctions &_pkg_ref;
int last_reported;
+ time_t last_reported_time;
- InstallPkgReceive(RecipientCtl & construct_r) : Recipient(construct_r)
+ InstallPkgReceive(RecipientCtl & construct_r, PkgModuleFunctions &pk) : Recipient(construct_r), _last(NULL), _pkg_ref(pk)
{
}
@@ -204,6 +216,7 @@
{
// initialize the counter
last_reported = 0;
+ last_reported_time = time(NULL);
#warning install non-package
zypp::Package::constPtr res =
@@ -213,13 +226,30 @@
if( _last == resolvable )
return;
+ // convert the repo ID
+ PkgModuleFunctions::RepoId source_id = _pkg_ref.logFindAlias(res->repoInfo().alias());
+ int media_nr = res->mediaNr();
+
+ if( source_id != _pkg_ref.LastReportedRepo() || media_nr != _pkg_ref.LastReportedMedium())
+ {
+ CB callback( ycpcb( YCPCallbacks::CB_SourceChange ) );
+ if (callback._set) {
+ callback.addInt( source_id );
+ callback.addInt( media_nr );
+ callback.evaluate();
+ }
+
+ _pkg_ref.SetReportedSource(source_id, media_nr);
+ }
+
CB callback( ycpcb( YCPCallbacks::CB_StartPackage ) );
if (callback._set) {
- callback.addStr(res->location());
+ callback.addStr(res->name());
+ callback.addStr(res->location().filename());
callback.addStr(res->summary());
- callback.addInt(res->size());
+ callback.addInt(res->installSize());
callback.addBool(false); // is_delete = false (package installation)
- callback.evaluateBool();
+ callback.evaluate();
}
_last = resolvable;
@@ -229,8 +259,9 @@
{
CB callback( ycpcb( YCPCallbacks::CB_ProgressPackage) );
// call the callback function only if the difference since the last call is at least 5%
- // or if 100% is reached
- if (callback._set && (value - last_reported >= 5 || last_reported - value >= 5 || value == 100))
+ // or if 100% is reached or at least 3 seconds have elapsed
+ time_t current_time = time(NULL);
+ if (callback._set && (value - last_reported >= 5 || last_reported - value >= 5 || value == 100 || current_time - last_reported_time >= callback_timeout))
{
callback.addInt( value );
bool res = callback.evaluateBool();
@@ -239,6 +270,7 @@
y2milestone( "Package installation callback returned abort" );
last_reported = value;
+ last_reported_time = current_time;
return res;
}
@@ -321,9 +353,10 @@
if (callback._set) {
callback.addStr(resolvable->name());
callback.addStr(std::string());
+ callback.addStr(std::string());
callback.addInt(-1);
callback.addBool(true); // is_delete = true
- callback.evaluateBool();
+ callback.evaluate();
}
}
@@ -347,6 +380,33 @@
return zypp::target::rpm::RemoveResolvableReport::progress(value, resolvable);
}
+ virtual Action problem(
+ zypp::Resolvable::constPtr resolvable
+ , zypp::target::rpm::RemoveResolvableReport::Error error
+ , const std::string &description
+ )
+ {
+ CB callback( ycpcb( YCPCallbacks::CB_DonePackage) );
+ if (callback._set) {
+ callback.addInt( error );
+ callback.addStr( description );
+
+ std::string ret = callback.evaluateStr();
+
+ // "R" = retry
+ if (ret == "R") return zypp::target::rpm::RemoveResolvableReport::RETRY;
+
+ // "C" = cancel
+ if (ret == "C") return zypp::target::rpm::RemoveResolvableReport::ABORT;
+
+ // otherwise ignore
+ return zypp::target::rpm::RemoveResolvableReport::IGNORE;
+ }
+
+ return zypp::target::rpm::RemoveResolvableReport::problem
+ (resolvable, error, description);
+ }
+
virtual void finish(zypp::Resolvable::constPtr resolvable, zypp::target::rpm::RemoveResolvableReport::Error error, const std::string &reason)
{
CB callback( ycpcb( YCPCallbacks::CB_DonePackage) );
@@ -358,19 +418,46 @@
}
};
+
+ struct ProgressReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::ProgressReport>
+ {
+ ProgressReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
+
+ virtual void start(const zypp::ProgressData &task)
+ {
+ }
+
+ virtual bool progress(const zypp::ProgressData &task)
+ {
+ return zypp::ProgressReport::progress(task);
+ }
+
+ virtual void finish( const zypp::ProgressData &task )
+ {
+ }
+ };
+
+
+
///////////////////////////////////////////////////////////////////
// DownloadResolvableCallback
///////////////////////////////////////////////////////////////////
- struct DownloadResolvableReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::source::DownloadResolvableReport>
+ struct DownloadResolvableReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::repo::DownloadResolvableReport>
{
- static int last_source_id;
- static int last_source_media;
+ PkgModuleFunctions &_pkg_ref;
- DownloadResolvableReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
+ DownloadResolvableReceive( RecipientCtl & construct_r, PkgModuleFunctions &pk ) : Recipient( construct_r ), _pkg_ref(pk) {}
int last_reported;
+ time_t last_reported_time;
+
int last_reported_delta_download;
+ time_t last_reported_delta_download_time;
+
int last_reported_delta_apply;
+ time_t last_reported_delta_apply_time;
+
int last_reported_patch_download;
+ time_t last_reported_patch_download_time;
virtual void reportbegin()
{
@@ -384,18 +471,20 @@
{
unsigned size = 0;
last_reported = 0;
+ last_reported_time = time(NULL);
if ( zypp::isKind<zypp::Package> (resolvable_ptr) )
{
zypp::Package::constPtr pkg =
zypp::asKind<zypp::Package>(resolvable_ptr);
- size = pkg->archivesize();
+ size = pkg->downloadSize();
- int source_id = pkg->source().numericId();
- int media_nr = pkg->sourceMediaNr();
+ // convert the repo ID
+ PkgModuleFunctions::RepoId source_id = _pkg_ref.logFindAlias(pkg->repoInfo().alias());
+ int media_nr = pkg->mediaNr();
- if( source_id != last_source_id || media_nr != last_source_media )
+ if( source_id != _pkg_ref.LastReportedRepo() || media_nr != _pkg_ref.LastReportedMedium())
{
CB callback( ycpcb( YCPCallbacks::CB_SourceChange ) );
if (callback._set) {
@@ -403,23 +492,24 @@
callback.addInt( media_nr );
callback.evaluate();
}
- last_source_id = source_id;
- last_source_media = media_nr;
+ _pkg_ref.SetReportedSource(source_id, media_nr);
}
}
CB callback( ycpcb( YCPCallbacks::CB_StartProvide ) );
if (callback._set) {
- bool remote = url.getScheme() != "cd" && url.getScheme() != "dvd"
- && url.getScheme() != "nfs";
+ std::string scheme = zypp::str::toLower(url.getScheme());
+
+ bool remote = scheme != "cd" && scheme != "dvd" && scheme != "nfs" && scheme != "dir" && scheme != "file";
+
callback.addStr(resolvable_ptr->name());
callback.addInt( size );
callback.addBool(remote);
- callback.evaluateBool();
+ callback.evaluate();
}
}
- virtual void finish(zypp::Resolvable::constPtr resolvable, zypp::source::DownloadResolvableReport::Error error, const std::string &reason)
+ virtual void finish(zypp::Resolvable::constPtr resolvable, zypp::repo::DownloadResolvableReport::Error error, const std::string &reason)
{
CB callback( ycpcb( YCPCallbacks::CB_DoneProvide) );
if (callback._set) {
@@ -433,17 +523,19 @@
virtual bool progress(int value, zypp::Resolvable::constPtr resolvable_ptr)
{
CB callback( ycpcb( YCPCallbacks::CB_ProgressProvide) );
- if (callback._set && (value - last_reported >= 5 || last_reported - value >= 5 || value == 100))
+ time_t current_time = time(NULL);
+ if (callback._set && (value - last_reported >= 5 || last_reported - value >= 5 || value == 100 || current_time - last_reported_time >= callback_timeout))
{
last_reported = value;
+ last_reported_time = current_time;
callback.addInt( value );
return callback.evaluateBool(); // return value ignored by RpmDb
}
- return zypp::source::DownloadResolvableReport::progress(value, resolvable_ptr);
+ return zypp::repo::DownloadResolvableReport::progress(value, resolvable_ptr);
}
- virtual Action problem(zypp::Resolvable::constPtr resolvable_ptr, zypp::source::DownloadResolvableReport::Error error, const std::string &description)
+ virtual Action problem(zypp::Resolvable::constPtr resolvable_ptr, zypp::repo::DownloadResolvableReport::Error error, const std::string &description)
{
CB callback( ycpcb( YCPCallbacks::CB_DoneProvide) );
if (callback._set) {
@@ -453,19 +545,19 @@
std::string ret = callback.evaluateStr();
// "R" = retry
- if (ret == "R") return zypp::source::DownloadResolvableReport::RETRY;
+ if (ret == "R") return zypp::repo::DownloadResolvableReport::RETRY;
// "C" = cancel
- if (ret == "C") return zypp::source::DownloadResolvableReport::ABORT;
+ if (ret == "C") return zypp::repo::DownloadResolvableReport::ABORT;
// "I" = ignore
- if (ret == "I") return zypp::source::DownloadResolvableReport::IGNORE;
+ if (ret == "I") return zypp::repo::DownloadResolvableReport::IGNORE;
// otherwise return the default value from the parent class
}
// return the default value from the parent class
- return zypp::source::DownloadResolvableReport::problem(resolvable_ptr, error, description);
+ return zypp::repo::DownloadResolvableReport::problem(resolvable_ptr, error, description);
}
// Download delta rpm:
@@ -477,6 +569,7 @@
{
// reset the counter
last_reported_delta_download = 0;
+ last_reported_delta_download_time = time(NULL);
CB callback( ycpcb( YCPCallbacks::CB_StartDeltaDownload) );
if (callback._set) {
@@ -490,15 +583,17 @@
virtual bool progressDeltaDownload( int value )
{
CB callback( ycpcb( YCPCallbacks::CB_ProgressDeltaDownload) );
- if (callback._set && (value - last_reported_delta_download >= 5 || last_reported_delta_download - value >= 5 || value == 100))
+ time_t current_time = time(NULL);
+ if (callback._set && (value - last_reported_delta_download >= 5 || last_reported_delta_download - value >= 5 || value == 100 || current_time - last_reported_delta_download_time >= callback_timeout))
{
last_reported_delta_download = value;
+ last_reported_delta_download_time = current_time;
callback.addInt( value );
return callback.evaluateBool();
}
- return zypp::source::DownloadResolvableReport::progressDeltaDownload(value);
+ return zypp::repo::DownloadResolvableReport::progressDeltaDownload(value);
}
virtual void problemDeltaDownload( const std::string &description )
@@ -520,7 +615,7 @@
callback.evaluate();
}
}
-
+
// Apply delta rpm:
// - local path of downloaded delta
@@ -530,6 +625,7 @@
{
// reset the counter
last_reported_delta_apply = 0;
+ last_reported_delta_apply_time = time(NULL);
CB callback( ycpcb( YCPCallbacks::CB_StartDeltaApply) );
if (callback._set) {
@@ -542,9 +638,11 @@
virtual void progressDeltaApply( int value )
{
CB callback( ycpcb( YCPCallbacks::CB_ProgressDeltaApply ) );
- if (callback._set && (value - last_reported_delta_apply >= 5 || last_reported_delta_apply - value >= 5 || value == 100))
+ time_t current_time = time(NULL);
+ if (callback._set && (value - last_reported_delta_apply >= 5 || last_reported_delta_apply - value >= 5 || value == 100 || current_time - last_reported_delta_apply_time >= callback_timeout))
{
last_reported_delta_apply = value;
+ last_reported_delta_apply_time = current_time;
callback.addInt( value );
callback.evaluate();
@@ -571,7 +669,7 @@
callback.evaluate();
}
}
-
+
// Download patch rpm:
// - path below url reported on start()
@@ -581,6 +679,7 @@
{
// reset the counter
last_reported_patch_download = 0;
+ last_reported_patch_download_time = time(NULL);
CB callback( ycpcb( YCPCallbacks::CB_StartPatchDownload ) );
if (callback._set) {
@@ -594,15 +693,17 @@
virtual bool progressPatchDownload( int value )
{
CB callback( ycpcb( YCPCallbacks::CB_ProgressPatchDownload) );
- if (callback._set && (value - last_reported_patch_download >= 5 || last_reported_patch_download - value >= 5 || value == 100))
+ time_t current_time = time(NULL);
+ if (callback._set && (value - last_reported_patch_download >= 5 || last_reported_patch_download - value >= 5 || value == 100 || current_time - last_reported_patch_download_time >= callback_timeout))
{
last_reported_patch_download = value;
+ last_reported_patch_download_time = current_time;
callback.addInt( value );
return callback.evaluateBool();
}
- return zypp::source::DownloadResolvableReport::progressPatchDownload(value);
+ return zypp::repo::DownloadResolvableReport::progressPatchDownload(value);
}
virtual void problemPatchDownload( const std::string &description )
@@ -628,22 +729,20 @@
};
- int DownloadResolvableReceive::last_source_id = -1;
- int DownloadResolvableReceive::last_source_media = -1;
-
-
///////////////////////////////////////////////////////////////////
// DownloadProgressReceive
///////////////////////////////////////////////////////////////////
struct DownloadProgressReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::media::DownloadProgressReport>
{
int last_reported;
+ time_t last_reported_time;
DownloadProgressReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
virtual void start( const zypp::Url &file, zypp::Pathname localfile )
{
last_reported = 0;
+ last_reported_time = time(NULL);
CB callback( ycpcb( YCPCallbacks::CB_StartDownload ) );
if ( callback._set )
@@ -654,21 +753,24 @@
}
}
- virtual bool progress(int value, const zypp::Url &file)
+ virtual bool progress(int value, const zypp::Url &file, double bps_avg, double bps_current)
{
CB callback( ycpcb( YCPCallbacks::CB_ProgressDownload ) );
// call the callback function only if the difference since the last call is at least 5%
- // or if 100% is reached
- if (callback._set && (value - last_reported >= 5 || last_reported - value >= 5 || value == 100))
+ // or if 100% is reached or if at least 3 seconds have elapsed
+ time_t current_time = time(NULL);
+ if (callback._set && (value - last_reported >= 5 || last_reported - value >= 5 || value == 100 || current_time - last_reported_time >= callback_timeout))
{
last_reported = value;
+ last_reported_time = current_time;
// report changed values
callback.addInt( value );
- callback.addInt( 100 );
+ callback.addInt( (long long) bps_avg );
+ callback.addInt( (long long) bps_current );
return callback.evaluateBool( true ); // default == continue
}
- return zypp::media::DownloadProgressReport::progress(value, file);
+ return zypp::media::DownloadProgressReport::progress(value, file, bps_avg, bps_current);
}
virtual Action problem( const zypp::Url &file, zypp::media::DownloadProgressReport::Error error, const std::string &description)
@@ -697,12 +799,21 @@
return zypp::media::DownloadProgressReport::problem(file, error, description);
}
- virtual void finish( const zypp::Url &file, zypp::media::DownloadProgressReport::Error error, const std::string &reason)
+ virtual void finish( const zypp::Url &file, zypp::media::DownloadProgressReport::Error error, const std::string &reason)
{
CB callback( ycpcb( YCPCallbacks::CB_DoneDownload ) );
+ zypp::media::DownloadProgressReport::Error err = error;
+
+ // ignore errors for optional files
+ if ( _silent_probing == MEDIA_CHANGE_DISABLE ||
+ _silent_probing == MEDIA_CHANGE_OPTIONALFILE)
+ {
+ err = zypp::media::DownloadProgressReport::NO_ERROR;
+ }
+
if ( callback._set ) {
- callback.addInt( error );
+ callback.addInt( err );
callback.addStr( reason );
callback.evaluate();
}
@@ -713,31 +824,31 @@
///////////////////////////////////////////////////////////////////
// ScriptExecCallbacks
///////////////////////////////////////////////////////////////////
- struct ScriptExecReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::target::ScriptResolvableReport>
+ struct ScriptExecReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::target::PatchScriptReport>
{
ScriptExecReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
- virtual void start( const zypp::Resolvable::constPtr &script_r, const zypp::Pathname &path_r, zypp::target::ScriptResolvableReport::Task task)
+ virtual void start( const zypp::Package::constPtr &pkg, const zypp::Pathname &path_r)
{
CB callback( ycpcb( YCPCallbacks::CB_ScriptStart) );
if ( callback._set )
{
- callback.addStr(script_r->name());
- callback.addStr(script_r->edition().asString());
- callback.addStr(script_r->arch().asString());
+ callback.addStr(pkg->name());
+ callback.addStr(pkg->edition().asString());
+ callback.addStr(pkg->arch().asString());
callback.addStr(path_r);
- callback.addBool(task == zypp::target::ScriptResolvableReport::DO);
+
callback.evaluate();
}
}
-
- virtual bool progress( zypp::target::ScriptResolvableReport::Notify ping, const std::string &out = std::string() )
+
+ virtual bool progress( zypp::target::PatchScriptReport::Notify ping, const std::string &out = std::string() )
{
CB callback( ycpcb( YCPCallbacks::CB_ScriptProgress) );
if ( callback._set )
{
- callback.addBool(ping == zypp::target::ScriptResolvableReport::PING);
+ callback.addBool(ping == zypp::target::PatchScriptReport::PING);
callback.addStr(out);
// false = abort the script
@@ -746,19 +857,35 @@
else
{
// return the default implementation
- return zypp::target::ScriptResolvableReport::progress(ping, out);
+ return zypp::target::PatchScriptReport::progress(ping, out);
}
}
- virtual void problem( const std::string &description )
+ virtual zypp::target::PatchScriptReport::Action problem( const std::string &description )
{
CB callback( ycpcb( YCPCallbacks::CB_ScriptProblem) );
if ( callback._set )
{
callback.addStr(description);
- callback.evaluate();
+
+ std::string ret = callback.evaluateStr();
+
+ // "A" = abort
+ if (ret == "A") return zypp::target::PatchScriptReport::ABORT;
+
+ // "I" = ignore
+ if (ret == "I") return zypp::target::PatchScriptReport::IGNORE;
+
+ // "R" = retry
+ if (ret == "R") return zypp::target::PatchScriptReport::RETRY;
+
+ y2error("Unknown return value: %s", ret.c_str());
}
+
+ // return the defaulf when the callback is not registered
+ // or the returned value is unknown
+ return zypp::target::PatchScriptReport::problem(description);
}
virtual void finish()
@@ -772,28 +899,93 @@
}
};
- struct MessageReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::target::MessageResolvableReport>
+ struct MessageReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::target::PatchMessageReport>
{
MessageReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
- virtual void show(zypp::Message::constPtr message)
+ virtual bool show(zypp::Patch::constPtr &p)
{
CB callback( ycpcb( YCPCallbacks::CB_Message) );
if ( callback._set )
{
- zypp::Patch::constPtr p = message->patch();
-
callback.addStr(p->name());
callback.addStr(p->edition().asString());
callback.addStr(p->arch().asString());
- callback.addStr(message->text().asString());
+ callback.addStr(p->message(zypp::ZConfig::instance().textLocale()));
- callback.evaluate();
+ return callback.evaluateBool();
}
+
+ // return the default
+ return zypp::target::PatchMessageReport::show(p);
}
};
+/*
+ struct AuthReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::media::AuthenticationReport>
+ {
+ AuthReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
+
+ virtual bool prompt(const zypp::Url& url, const std::string& msg, zypp::media::AuthData& auth_data)
+ {
+ CB callback( ycpcb( YCPCallbacks::CB_Authentication ) );
+
+ if (callback._set)
+ {
+ callback.addStr(url.asString());
+ callback.addStr(msg);
+ callback.addStr(auth_data.username());
+ callback.addStr(auth_data.password());
+
+ YCPMap cbk(callback.evaluateMap());
+
+ YCPValue ycp_val = cbk->value(YCPString("username"));
+ if (!ycp_val.isNull() && ycp_val->isString())
+ {
+ // set the entered username
+ auth_data.setUsername(ycp_val->asString()->value());
+ }
+ else
+ {
+ y2error("Invalid/missing value 'username'");
+ }
+
+ ycp_val = cbk->value(YCPString("password"));
+ if (!ycp_val.isNull() && ycp_val->isString())
+ {
+ // set the entered password
+ auth_data.setPassword(ycp_val->asString()->value());
+ }
+ else
+ {
+ y2error("Invalid/missing value 'password'");
+ }
+
+ // authentication confirmed?
+ bool ret = false;
+
+ ycp_val = cbk->value(YCPString("continue"));
+ if (!ycp_val.isNull() && ycp_val->isBoolean())
+ {
+ // continue?
+ ret = ycp_val->asBoolean()->value();
+ y2milestone("Use the authentication data: %s", ret ? "true" : "false");
+ }
+ else
+ {
+ y2error("Invalid/missing value 'continue'");
+ }
+
+ return ret;
+ }
+
+ // return the default value from the parent class
+ return zypp::media::AuthenticationReport::prompt(url, msg, auth_data);
+ }
+ };
+*/
+
///////////////////////////////////////////////////////////////////
// MediaChangeCallback
///////////////////////////////////////////////////////////////////
@@ -801,7 +993,32 @@
{
MediaChangeReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
- virtual Action requestMedia(zypp::Source_Ref source, unsigned mediumNr, zypp::media::MediaChangeReport::Error error, const std::string &description)
+ std::string MediaChangeErrorAsString(zypp::media::MediaChangeReport::Error error)
+ {
+ // convert enum to a string
+ std::string error_str;
+
+ switch(error)
+ {
+ // no error
+ case zypp::media::MediaChangeReport::NO_ERROR : error_str = "NO_ERROR"; break;
+ case zypp::media::MediaChangeReport::NOT_FOUND : error_str = "NOT_FOUND"; break;
+ case zypp::media::MediaChangeReport::IO : error_str = "IO"; break;
+ case zypp::media::MediaChangeReport::INVALID : error_str = "INVALID"; break;
+ case zypp::media::MediaChangeReport::WRONG : error_str = "WRONG"; break;
+ case zypp::media::MediaChangeReport::IO_SOFT : error_str = "IO_SOFT"; break;
+ }
+
+ return error_str;
+ }
+
+ virtual Action requestMedia(zypp::Url &url,
+ unsigned int mediumNr,
+ const std::string & label,
+ zypp::media::MediaChangeReport::Error error,
+ const std::string &description,
+ const std::vector<std::string> & devices,
+ unsigned int &dev_current)
{
if ( _silent_probing == MEDIA_CHANGE_DISABLE )
return zypp::media::MediaChangeReport::ABORT;
@@ -817,14 +1034,14 @@
callback.addStr( description );
// search URL in the redirection map
- std::map<zypp::Source_Ref::NumericId, std::map<unsigned, std::string> >::const_iterator source_it = redirect_map.find(source.numericId());
+ RedirectMap::const_iterator source_it = redirect_map.find(url);
bool found = false;
- std::string report_url;
+ zypp::Url report_url;
if (source_it != redirect_map.end())
{
// search medium in the redirection map
- std::map<unsigned, std::string>::const_iterator media_it = (*source_it).second.find(mediumNr);
+ MediaMap::const_iterator media_it = (*source_it).second.find(mediumNr);
if (media_it != (*source_it).second.end())
{
@@ -832,23 +1049,23 @@
found = true;
// report the redirected URL
report_url = (*media_it).second;
- y2milestone("Using redirected URL %s, original URL: %s", report_url.c_str(), source.url().asString().c_str());
+
+ y2milestone("Using redirected URL %s, original URL: %s", report_url.asString().c_str(), url.asString().c_str());
}
}
if (!found)
{
// the source has not been redirected
- // use URL of the source
- report_url = source.url().asString();
+ // use URL of the source
+ report_url = url;
}
-
// current URL
- callback.addStr( report_url );
+ callback.addStr( report_url.asString() );
- // current product name (use the alias, see #214886)
- callback.addStr( source.alias() );
+ // repo alias (see bnc#330094)
+ callback.addStr( label );
// current medium, -1 means enable [Ignore]
callback.addInt( 0 );
@@ -879,19 +1096,28 @@
// "E" = eject media
if (ret == "E") return zypp::media::MediaChangeReport::EJECT;
+ // "E" + numbure = eject the required device
+ if (ret.size() > 1 && ret[0] == 'E')
+ {
+ // change the device
+ dev_current = zypp::str::strtonum<unsigned int>(ret.c_str() + 1);
+ y2milestone("Ejecting device %d", dev_current);
+ return zypp::media::MediaChangeReport::EJECT;
+ }
+
// "S" = skip (ignore) this media
if (ret == "S") return zypp::media::MediaChangeReport::IGNORE;
// otherwise change media URL
// try/catch to catch invalid URLs
try {
- zypp::Url ret_url (ret);
- source.redirect( mediumNr, ret_url );
+ // set the new URL
+ url = zypp::Url(ret);
- // remember the redirection
- std::map<unsigned, std::string> source_redir = redirect_map[source.numericId()];
- source_redir[mediumNr] = ret;
- redirect_map[source.numericId()] = source_redir;
+ // remember the redirection
+ MediaMap source_redir = redirect_map[url];
+ source_redir[mediumNr] = url;
+ redirect_map[url] = source_redir;
y2milestone("Source redirected to %s", ret.c_str());
@@ -905,18 +1131,18 @@
}
// return default value from the parent class
- return zypp::media::MediaChangeReport::requestMedia(source, mediumNr, error, description);
+ return zypp::media::MediaChangeReport::requestMedia(url, mediumNr, label, error, description, devices, dev_current);
}
};
- struct SourceCreateReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::source::SourceCreateReport>
+ struct SourceCreateReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::repo::RepoCreateReport>
{
SourceCreateReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
virtual void reportbegin()
{
CB callback( ycpcb( YCPCallbacks::CB_SourceCreateInit ) );
- y2debug("Source Create begin");
+ y2debug("Repo Create begin");
if (callback._set)
{
@@ -927,7 +1153,7 @@
virtual void reportend()
{
CB callback( ycpcb( YCPCallbacks::CB_SourceCreateDestroy ) );
- y2debug("Source Create destroy");
+ y2debug("Repo Create destroy");
if (callback._set)
{
@@ -958,10 +1184,10 @@
return callback.evaluateBool();
}
- return zypp::source::SourceCreateReport::progress(value);
+ return zypp::repo::RepoCreateReport::progress(value);
}
- std::string CreateSrcErrorAsString(zypp::source::SourceCreateReport::Error error)
+ std::string CreateSrcErrorAsString(zypp::repo::RepoCreateReport::Error error)
{
// convert enum to string
std::string error_str;
@@ -969,23 +1195,23 @@
switch(error)
{
// no error
- case zypp::source::SourceCreateReport::NO_ERROR : error_str = "NO_ERROR"; break;
+ case zypp::repo::RepoCreateReport::NO_ERROR : error_str = "NO_ERROR"; break;
// the requested Url was not found
- case zypp::source::SourceCreateReport::NOT_FOUND : error_str = "NOT_FOUND"; break;
+ case zypp::repo::RepoCreateReport::NOT_FOUND : error_str = "NOT_FOUND"; break;
// IO error
- case zypp::source::SourceCreateReport::IO : error_str = "IO"; break;
+ case zypp::repo::RepoCreateReport::IO : error_str = "IO"; break;
// the source is invalid
- case zypp::source::SourceCreateReport::INVALID : error_str = "INVALID"; break;
+ case zypp::repo::RepoCreateReport::INVALID : error_str = "INVALID"; break;
// rejected
- case zypp::source::SourceCreateReport::REJECTED : error_str = "REJECTED"; break;
+ case zypp::repo::RepoCreateReport::REJECTED : error_str = "REJECTED"; break;
// unknown error
- case zypp::source::SourceCreateReport::UNKNOWN : error_str = "UNKNOWN"; break;
+ case zypp::repo::RepoCreateReport::UNKNOWN : error_str = "UNKNOWN"; break;
}
return error_str;
}
- virtual Action problem( const zypp::Url &url, zypp::source::SourceCreateReport::Error error, const std::string &description )
+ virtual Action problem( const zypp::Url &url, zypp::repo::RepoCreateReport::Error error, const std::string &description )
{
CB callback( ycpcb( YCPCallbacks::CB_SourceCreateError ) );
@@ -998,8 +1224,8 @@
std::string result = callback.evaluateSymbol();
// check the returned symbol
- if ( result == "ABORT" ) return zypp::source::SourceCreateReport::ABORT;
- if ( result == "RETRY" ) return zypp::source::SourceCreateReport::RETRY;
+ if ( result == "ABORT" ) return zypp::repo::RepoCreateReport::ABORT;
+ if ( result == "RETRY" ) return zypp::repo::RepoCreateReport::RETRY;
// still here?
y2error("Unexpected symbol '%s' returned from callback.", result.c_str());
@@ -1007,10 +1233,10 @@
}
// return the default implementation
- return zypp::source::SourceCreateReport::problem(url, error, description);
+ return zypp::repo::RepoCreateReport::problem(url, error, description);
}
- virtual void finish( const zypp::Url &url, zypp::source::SourceCreateReport::Error error, const std::string &reason )
+ virtual void finish( const zypp::Url &url, zypp::repo::RepoCreateReport::Error error, const std::string &reason )
{
CB callback( ycpcb( YCPCallbacks::CB_SourceCreateEnd ) );
@@ -1025,18 +1251,17 @@
}
};
-
///////////////////////////////////////////////////////////////////
- // ProbeSourceReport
+ // ProbeSourceReceive
///////////////////////////////////////////////////////////////////
- struct ProbeSourceReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::source::ProbeSourceReport>
+ struct ProbeSourceReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::repo::ProbeRepoReport>
{
ProbeSourceReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
virtual void start(const zypp::Url &url)
{
_silent_probing = MEDIA_CHANGE_DISABLE;
-
+
CB callback( ycpcb( YCPCallbacks::CB_SourceProbeStart ) );
if (callback._set)
@@ -1073,7 +1298,7 @@
}
}
- std::string ProbeSrcErrorAsString(zypp::source::ProbeSourceReport::Error error)
+ std::string ProbeSrcErrorAsString(zypp::repo::ProbeRepoReport::Error error)
{
// convert enum to string
std::string error_str;
@@ -1081,21 +1306,21 @@
switch(error)
{
// no error
- case zypp::source::ProbeSourceReport::NO_ERROR : error_str = "NO_ERROR"; break;
+ case zypp::repo::ProbeRepoReport::NO_ERROR : error_str = "NO_ERROR"; break;
// the requested Url was not found
- case zypp::source::ProbeSourceReport::NOT_FOUND : error_str = "NOT_FOUND"; break;
+ case zypp::repo::ProbeRepoReport::NOT_FOUND : error_str = "NOT_FOUND"; break;
// IO error
- case zypp::source::ProbeSourceReport::IO : error_str = "IO"; break;
+ case zypp::repo::ProbeRepoReport::IO : error_str = "IO"; break;
// the source is invalid
- case zypp::source::ProbeSourceReport::INVALID : error_str = "INVALID"; break;
+ case zypp::repo::ProbeRepoReport::INVALID : error_str = "INVALID"; break;
// unknow error
- case zypp::source::ProbeSourceReport::UNKNOWN : error_str = "UNKNOWN"; break;
+ case zypp::repo::ProbeRepoReport::UNKNOWN : error_str = "UNKNOWN"; break;
}
return error_str;
}
- virtual void finish(const zypp::Url &url, zypp::source::ProbeSourceReport::Error error, const std::string &reason )
+ virtual void finish(const zypp::Url &url, zypp::repo::ProbeRepoReport::Error error, const std::string &reason )
{
_silent_probing = MEDIA_CHANGE_FULL;
@@ -1123,10 +1348,11 @@
return callback.evaluateBool();
}
- return zypp::source::ProbeSourceReport::progress(url, value);
+ return zypp::repo::ProbeRepoReport::progress(url, value);
+ return true;
}
- virtual zypp::source::ProbeSourceReport::Action problem( const zypp::Url &url, zypp::source::ProbeSourceReport::Error error, const std::string &description )
+ virtual zypp::repo::ProbeRepoReport::Action problem( const zypp::Url &url, zypp::repo::ProbeRepoReport::Error error, const std::string &description )
{
CB callback( ycpcb( YCPCallbacks::CB_SourceProbeError ) );
@@ -1139,8 +1365,8 @@
std::string result = callback.evaluateSymbol();
// check the returned symbol
- if ( result == "ABORT" ) return zypp::source::ProbeSourceReport::ABORT;
- if ( result == "RETRY" ) return zypp::source::ProbeSourceReport::RETRY;
+ if ( result == "ABORT" ) return zypp::repo::ProbeRepoReport::ABORT;
+ if ( result == "RETRY" ) return zypp::repo::ProbeRepoReport::RETRY;
// still here?
y2error("Unexpected symbol '%s' returned from callback.", result.c_str());
@@ -1148,12 +1374,14 @@
}
// return the default value
- return zypp::source::ProbeSourceReport::problem(url, error, description);
+ return zypp::repo::ProbeRepoReport::problem(url, error, description);
}
};
- struct SourceReport : public Recipient, public zypp::callback::ReceiveReport<zypp::source::SourceReport>
+
+ struct RepoReport : public Recipient, public zypp::callback::ReceiveReport<zypp::repo::RepoReport>
{
+ const PkgModuleFunctions &_pkg_ref;
virtual void reportbegin()
{
CB callback( ycpcb( YCPCallbacks::CB_SourceReportInit ) );
@@ -1176,37 +1404,44 @@
}
}
- SourceReport( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
+ RepoReport( RecipientCtl & construct_r, const PkgModuleFunctions &pk ) : Recipient( construct_r ), _pkg_ref(pk) {}
- virtual void start( zypp::Source_Ref source, const std::string &task )
+ virtual void start(const zypp::ProgressData &task, const zypp::RepoInfo repo)
{
CB callback( ycpcb( YCPCallbacks::CB_SourceReportStart ) );
if (callback._set)
{
- callback.addInt(source.numericId());
- callback.addStr(source.url());
- callback.addStr(task);
+ callback.addInt(_pkg_ref.logFindAlias(repo.alias()));
+
+ std::string url;
+ if (repo.baseUrlsBegin() != repo.baseUrlsEnd())
+ {
+ url = repo.baseUrlsBegin()->asString();
+ }
+
+ callback.addStr(url);
+ callback.addStr(task.name());
callback.evaluate();
}
}
- virtual bool progress( int value )
+ virtual bool progress(const zypp::ProgressData &task)
{
CB callback( ycpcb( YCPCallbacks::CB_SourceReportProgress ) );
if (callback._set)
{
- callback.addInt(value);
+ callback.addInt(task.reportValue());
return callback.evaluateBool();
}
- return zypp::source::SourceReport::progress(value);
+ return zypp::repo::RepoReport::progress(task);
}
- std::string SrcReportErrorAsString(zypp::source::SourceReport::Error error)
+ std::string SrcReportErrorAsString(zypp::repo::RepoReport::Error error)
{
// convert enum to string
std::string error_str;
@@ -1214,42 +1449,51 @@
switch(error)
{
// no error
- case zypp::source::SourceReport::NO_ERROR : error_str = "NO_ERROR"; break;
+ case zypp::repo::RepoReport::NO_ERROR : error_str = "NO_ERROR"; break;
// the requested Url was not found
- case zypp::source::SourceReport::NOT_FOUND : error_str = "NOT_FOUND"; break;
+ case zypp::repo::RepoReport::NOT_FOUND : error_str = "NOT_FOUND"; break;
// IO error
- case zypp::source::SourceReport::IO : error_str = "IO"; break;
+ case zypp::repo::RepoReport::IO : error_str = "IO"; break;
// the source is invalid
- case zypp::source::SourceReport::INVALID : error_str = "INVALID"; break;
+ case zypp::repo::RepoReport::INVALID : error_str = "INVALID"; break;
}
return error_str;
}
- virtual zypp::source::SourceReport::Action problem( zypp::Source_Ref source, zypp::source::SourceReport::Error error, const std::string &description )
+ virtual zypp::repo::RepoReport::Action problem(zypp::Repository source,
+ zypp::repo::RepoReport::Error error, const std::string &description)
{
CB callback( ycpcb( YCPCallbacks::CB_SourceReportError ) );
-
- // the file is optional, ignore the error
+
+ // the file is optional, ignore the error
if (_silent_probing == ZyppRecipients::MEDIA_CHANGE_OPTIONALFILE)
{
y2milestone("The file is optional, ignoring the error");
- return zypp::source::SourceReport::IGNORE;
+ return zypp::repo::RepoReport::IGNORE;
}
if ( callback._set )
{
- callback.addInt(source.numericId());
- callback.addStr(source.url());
+ // search Yast source ID
+ callback.addInt(_pkg_ref.logFindAlias(source.info().alias()));
+
+ std::string url;
+ if (source.info().baseUrlsBegin() != source.info().baseUrlsEnd())
+ {
+ url = source.info().baseUrlsBegin()->asString();
+ }
+
+ callback.addStr(url);
callback.addStr(SrcReportErrorAsString(error));
callback.addStr(description);
std::string result = callback.evaluateSymbol();
// check the returned symbol
- if ( result == "ABORT" ) return zypp::source::SourceReport::ABORT;
- if ( result == "RETRY" ) return zypp::source::SourceReport::RETRY;
- if ( result == "IGNORE" ) return zypp::source::SourceReport::IGNORE;
+ if ( result == "ABORT" ) return zypp::repo::RepoReport::ABORT;
+ if ( result == "RETRY" ) return zypp::repo::RepoReport::RETRY;
+ if ( result == "IGNORE" ) return zypp::repo::RepoReport::IGNORE;
// still here?
y2error("Unexpected symbol '%s' returned from callback.", result.c_str());
@@ -1257,17 +1501,26 @@
}
// return the default value
- return zypp::source::SourceReport::problem(source, error, description);
+ return zypp::repo::RepoReport::problem(source, error, description);
}
- virtual void finish( zypp::Source_Ref source, const std::string &task, zypp::source::SourceReport::Error error, const std::string &reason )
+ virtual void finish(zypp::Repository source, const std::string &task,
+ zypp::repo::RepoReport::Error error, const std::string &reason)
{
CB callback( ycpcb( YCPCallbacks::CB_SourceReportEnd ) );
if (callback._set)
{
- callback.addInt(source.numericId());
- callback.addStr(source.url());
+ // search Yast source ID
+ callback.addInt(_pkg_ref.logFindAlias(source.info().alias()));
+
+ std::string url;
+ if (source.info().baseUrlsBegin() != source.info().baseUrlsEnd())
+ {
+ url = source.info().baseUrlsBegin()->asString();
+ }
+ callback.addStr(url);
+
callback.addStr(task);
callback.addStr(SrcReportErrorAsString(error));
callback.addStr(reason);
@@ -1277,31 +1530,6 @@
}
};
-
- struct ResolvableReport : public Recipient, public zypp::callback::ReceiveReport<zypp::target::MessageResolvableReport>
- {
- ResolvableReport( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
-
- virtual void show(zypp::Message::constPtr message)
- {
- CB callback( ycpcb( YCPCallbacks::CB_ResolvableReport) );
-
- if (callback._set)
- {
- zypp::Patch::constPtr patch = message->patch();
-
- // patch name
- callback.addStr(patch ? patch->name() : message->name());
- // patch summary
- callback.addStr(patch ? patch->summary() : message->summary());
- // message itself
- callback.addStr(message->text().asString());
-
- callback.evaluate();
- }
- }
- };
-
///////////////////////////////////////////////////////////////////
// DigestReport handler
///////////////////////////////////////////////////////////////////
@@ -1353,7 +1581,7 @@
return zypp::DigestReport::askUserToAcceptWrongDigest(file, requested, found);
}
-
+
};
@@ -1362,59 +1590,41 @@
///////////////////////////////////////////////////////////////////
struct KeyRingReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::KeyRingReport>
{
- KeyRingReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
+ const PkgModuleFunctions &_pkg_ref;
+ KeyRingReceive( RecipientCtl & construct_r, const PkgModuleFunctions &pk) : Recipient( construct_r ), _pkg_ref(pk) {}
- virtual bool askUserToImportKey( const zypp::PublicKey &key)
+ virtual zypp::KeyRingReport::KeyTrust askUserToAcceptKey( const zypp::PublicKey &key, const zypp::KeyContext &context)
{
CB callback( ycpcb( YCPCallbacks::CB_ImportGpgKey) );
if (callback._set)
{
- callback.addStr(key.id());
- callback.addStr(key.name());
- callback.addStr(key.fingerprint());
-
- bool res = callback.evaluateBool();
- y2milestone("Callback ImportGpgKey value: %s", res ? "true" : "false");
-
- return res;
- }
-
- y2milestone("Callback ImportGpgKey not registered, using default value: %s", zypp::KeyRingReport::askUserToImportKey(key) ? "true" : "false");
-
- return zypp::KeyRingReport::askUserToImportKey(key);
- }
-
- virtual bool askUserToTrustKey(const zypp::PublicKey& key)
- {
- CB callback( ycpcb( YCPCallbacks::CB_AcceptNonTrustedGpgKey) );
-
- if (callback._set)
- {
- callback.addStr(key.path().asString());
- callback.addStr(key.id());
+ GPGMap gpgmap(key);
- callback.addStr(key.name());
- callback.addStr(key.fingerprint());
+ callback.addMap(gpgmap.getMap());
+ long long srcid = _pkg_ref.logFindAlias(context.repoInfo().alias());
+ callback.addInt(srcid);
bool res = callback.evaluateBool();
- y2milestone("Callback AcceptNonTrustedGpgKey value: %s", res ? "true" : "false");
+ y2milestone("Callback ImportGpgKey value: %s", res ? "true" : "false");
- return res;
+ return res ? KEY_TRUST_AND_IMPORT : KEY_DONT_TRUST;
}
- y2milestone("Callback AcceptNonTrustedGpgKey not registered, using default value: %s", zypp::KeyRingReport::askUserToTrustKey(key) ? "true" : "false");
+ y2milestone("Callback ImportGpgKey not registered, using default value: %s", zypp::KeyRingReport::askUserToAcceptKey(key, context) ? "true" : "false");
- return zypp::KeyRingReport::askUserToTrustKey(key);
+ return zypp::KeyRingReport::askUserToAcceptKey(key, context);
}
- virtual bool askUserToAcceptUnsignedFile(const std::string &file)
+ virtual bool askUserToAcceptUnsignedFile(const std::string &file, const zypp::KeyContext &context)
{
CB callback( ycpcb( YCPCallbacks::CB_AcceptUnsignedFile) );
if (callback._set)
{
callback.addStr(file);
+ long long srcid = _pkg_ref.logFindAlias(context.repoInfo().alias());
+ callback.addInt(srcid);
return callback.evaluateBool();
}
@@ -1422,7 +1632,7 @@
return zypp::KeyRingReport::askUserToAcceptUnsignedFile(file);
}
- virtual bool askUserToAcceptUnknownKey(const std::string &file, const std::string &id)
+ virtual bool askUserToAcceptUnknownKey(const std::string &file, const std::string &id, const zypp::KeyContext &context)
{
CB callback( ycpcb( YCPCallbacks::CB_AcceptUnknownGpgKey) );
@@ -1430,6 +1640,8 @@
{
callback.addStr(file);
callback.addStr(id);
+ long long srcid = _pkg_ref.logFindAlias(context.repoInfo().alias());
+ callback.addInt(srcid);
bool res = callback.evaluateBool();
y2milestone("Callback AcceptUnknownGpgKey value: %s", res ? "true" : "false");
@@ -1442,16 +1654,18 @@
return zypp::KeyRingReport::askUserToAcceptUnknownKey(file,id);
}
- virtual bool askUserToAcceptVerificationFailed(const std::string &file, const zypp::PublicKey &key)
+ virtual bool askUserToAcceptVerificationFailed(const std::string &file, const zypp::PublicKey &key, const zypp::KeyContext &context)
{
CB callback( ycpcb( YCPCallbacks::CB_AcceptVerificationFailed) );
if (callback._set)
{
+ GPGMap gpgmap(key);
+
callback.addStr(file);
- callback.addStr(key.id());
- callback.addStr(key.name());
- callback.addStr(key.fingerprint());
+ callback.addMap(gpgmap.getMap());
+ long long srcid = _pkg_ref.logFindAlias(context.repoInfo().alias());
+ callback.addInt(srcid);
return callback.evaluateBool();
}
@@ -1467,27 +1681,29 @@
{
KeyRingSignal ( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
- virtual void trustedKeyAdded( const zypp::KeyRing &/*keyring*/, const zypp::PublicKey &key )
+ virtual void trustedKeyAdded( const zypp::PublicKey &key )
{
CB callback( ycpcb( YCPCallbacks::CB_TrustedKeyAdded) );
if (callback._set)
{
- callback.addStr(key.id());
- callback.addStr(key.name());
- callback.addStr(key.fingerprint());
+ GPGMap gpgmap(key);
+
+ callback.addMap(gpgmap.getMap());
+ callback.evaluate();
}
}
- virtual void trustedKeyRemoved( const zypp::KeyRing &/*keyring*/, const zypp::PublicKey &key )
+ virtual void trustedKeyRemoved( const zypp::PublicKey &key )
{
CB callback( ycpcb( YCPCallbacks::CB_TrustedKeyRemoved) );
if (callback._set)
{
- callback.addStr(key.id());
- callback.addStr(key.name());
- callback.addStr(key.fingerprint());
+ GPGMap gpgmap(key);
+
+ callback.addMap(gpgmap.getMap());
+ callback.evaluate();
}
}
};
@@ -1527,11 +1743,10 @@
// source manager callback
ZyppRecipients::SourceCreateReceive _sourceCreateReceive;
- ZyppRecipients::SourceReport _sourceReport;
+ ZyppRecipients::RepoReport _sourceReport;
ZyppRecipients::ProbeSourceReceive _probeSourceReceive;
- // resolvable report
- ZyppRecipients::ResolvableReport _resolvableReport;
+ ZyppRecipients::ProgressReceive _progressReceive;
// digest callback
ZyppRecipients::DigestReceive _digestReceive;
@@ -1542,26 +1757,30 @@
// key ring signal callback
ZyppRecipients::KeyRingSignal _keyRingSignal;
+ // authentication callback
+ //ZyppRecipients::AuthReceive _authReceive;
+
public:
- ZyppReceive( const YCPCallbacks & ycpcb_r )
+ ZyppReceive( const YCPCallbacks & ycpcb_r, PkgModuleFunctions &pkg)
: RecipientCtl( ycpcb_r )
, _convertDbReceive( *this )
, _rebuildDbReceive( *this )
- , _installPkgReceive( *this )
+ , _installPkgReceive( *this, pkg )
, _removePkgReceive( *this )
- , _providePkgReceive( *this )
+ , _providePkgReceive( *this, pkg )
, _mediaChangeReceive( *this )
, _downloadProgressReceive( *this )
, _scriptExecReceive( *this )
, _messageReceive( *this )
, _sourceCreateReceive( *this )
- , _sourceReport( *this )
+ , _sourceReport( *this, pkg)
, _probeSourceReceive( *this )
- , _resolvableReport( *this )
+ , _progressReceive( *this )
, _digestReceive( *this )
- , _keyRingReceive( *this )
+ , _keyRingReceive( *this, pkg )
, _keyRingSignal( *this )
+ //, _authReceive( *this )
{
// connect the receivers
_convertDbReceive.connect();
@@ -1571,15 +1790,16 @@
_providePkgReceive.connect();
_mediaChangeReceive.connect();
_downloadProgressReceive.connect();
- _scriptExecReceive.connect();
- _messageReceive.connect();
+ //_scriptExecReceive.connect();
+ //_messageReceive.connect();
_sourceCreateReceive.connect();
_sourceReport.connect();
_probeSourceReceive.connect();
- _resolvableReport.connect();
+ _progressReceive.connect();
_digestReceive.connect();
_keyRingReceive.connect();
_keyRingSignal.connect();
+// _authReceive.connect();
}
virtual ~ZyppReceive()
@@ -1597,10 +1817,11 @@
_sourceCreateReceive.disconnect();
_sourceReport.disconnect();
_probeSourceReceive.disconnect();
- _resolvableReport.disconnect();
+ _progressReceive.disconnect();
_digestReceive.disconnect();
_keyRingReceive.disconnect();
_keyRingSignal.disconnect();
+// _authReceive.disconnect();
}
public:
@@ -1618,9 +1839,9 @@
// METHOD NAME : PkgModuleFunctions::CallbackHandler::CallbackHandler
// METHOD TYPE : Constructor
//
-PkgModuleFunctions::CallbackHandler::CallbackHandler( )
+PkgModuleFunctions::CallbackHandler::CallbackHandler(PkgModuleFunctions &pk)
: _ycpCallbacks( *new YCPCallbacks() )
- , _zyppReceive( *new ZyppReceive( _ycpCallbacks ) )
+ , _zyppReceive( *new ZyppReceive(_ycpCallbacks, pk) )
{
}
@@ -1637,592 +1858,3 @@
delete &_ycpCallbacks;
}
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : PkgModuleFunctions
-//
-// Set YCPCallbacks. _ycpCallbacks
-//
-///////////////////////////////////////////////////////////////////
-
-#define SET_YCP_CB(E,A) _callbackHandler._ycpCallbacks.setYCPCallback( CallbackHandler::YCPCallbacks::E, A );
-
-YCPValue PkgModuleFunctions::CallbackStartProvide( const YCPString& args ) {
- return SET_YCP_CB( CB_StartProvide, args );
-}
-YCPValue PkgModuleFunctions::CallbackProgressProvide( const YCPString& args ) {
- return SET_YCP_CB( CB_ProgressProvide, args );
-}
-YCPValue PkgModuleFunctions::CallbackDoneProvide( const YCPString& args ) {
- return SET_YCP_CB( CB_DoneProvide, args );
-}
-
-YCPValue PkgModuleFunctions::CallbackStartPackage( const YCPString& args ) {
- return SET_YCP_CB( CB_StartPackage, args );
-}
-YCPValue PkgModuleFunctions::CallbackProgressPackage( const YCPString& args ) {
- return SET_YCP_CB( CB_ProgressPackage, args );
-}
-YCPValue PkgModuleFunctions::CallbackDonePackage( const YCPString& args ) {
- return SET_YCP_CB( CB_DonePackage, args );
-}
-
-YCPValue PkgModuleFunctions::CallbackResolvableReport( const YCPString& args ) {
- return SET_YCP_CB( CB_ResolvableReport, args );
-}
-
-/**
- * @builtin CallbackImportGpgKey
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>boolean(string keyid, string keyname, string keydetails)</code>. The callback function should ask user whether the key is trusted, returned true value means the key is trusted.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackImportGpgKey( const YCPString& args ) {
- return SET_YCP_CB( CB_ImportGpgKey, args );
-}
-
-/**
- * @builtin CallbackAcceptUnknownGpgKey
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>boolean(string filename, string keyid)</code>. The callback function should ask user whether the unknown key can be accepted, returned true value means to accept the key.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackAcceptUnknownGpgKey( const YCPString& args ) {
- return SET_YCP_CB( CB_AcceptUnknownGpgKey, args );
-}
-
-/**
- * @builtin CallbackAcceptNonTrustedGpgKey
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>boolean(string filename, string keyid, string keyname, string fingerprint)</code>. The callback function should ask user whether the unknown key can be accepted, returned true value means to accept the file.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackAcceptNonTrustedGpgKey( const YCPString& args ) {
- return SET_YCP_CB( CB_AcceptNonTrustedGpgKey, args );
-}
-
-/**
- * @builtin CallbackAcceptUnsignedFile
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>boolean(string filename)</code>. The callback function should ask user whether the unsigned file can be accepted, returned true value means to accept the file.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackAcceptUnsignedFile( const YCPString& args ) {
- return SET_YCP_CB( CB_AcceptUnsignedFile, args );
-}
-
-/**
- * @builtin CallbackAcceptFileWithoutChecksum
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>boolean(string filename)</code>. The callback function should ask user whether the unsigned file can be accepted, returned true value means to accept the file.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackAcceptFileWithoutChecksum( const YCPString& args ) {
- return SET_YCP_CB( CB_AcceptFileWithoutChecksum, args );
-}
-
-/**
- * @builtin CallbackAcceptVerificationFailed
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>boolean(string filename, string keyid, string keyname)</code>. The callback function should ask user whether the unsigned file can be accepted, returned true value means to accept the file.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackAcceptVerificationFailed( const YCPString& args ) {
- return SET_YCP_CB( CB_AcceptVerificationFailed, args );
-}
-
-/**
- * @builtin CallbackAcceptWrongDigest
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>boolean(string filename, string requested_digest, string found_digest)</code>. The callback function should ask user whether the wrong digest can be accepted, returned true value means to accept the file.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackAcceptWrongDigest( const YCPString& func)
-{
- return SET_YCP_CB( CB_AcceptWrongDigest, func );
-}
-
-/**
- * @builtin CallbackAcceptUnknownDigest
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>boolean(string filename, string name)</code>. The callback function should ask user whether the uknown digest can be accepted, returned true value means to accept the digest.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackAcceptUnknownDigest( const YCPString& func)
-{
- return SET_YCP_CB( CB_AcceptUnknownDigest, func );
-}
-
-/**
- * @builtin CallbackTrustedKeyAdded
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>void(string keyid, string keyname)</code>. The callback function should inform user that a trusted key has been added.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackTrustedKeyAdded( const YCPString& args ) {
- return SET_YCP_CB( CB_TrustedKeyAdded, args );
-}
-
-/**
- * @builtin CallbackTrustedKeyRemoved
- * @short Register callback function
- * @param string args Name of the callback handler function. Required callback prototype is <code>void(string keyid, string keyname)</code>. The callback function should inform user that a trusted key has been removed.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackTrustedKeyRemoved( const YCPString& args ) {
- return SET_YCP_CB( CB_TrustedKeyRemoved, args );
-}
-
-YCPValue PkgModuleFunctions::CallbackMediaChange( const YCPString& args ) {
- // FIXME: Allow omission of 'src' argument in 'src, name'. Since we can
- // handle one callback function at most, passing a src argument
- // implies a per-source callback which isn't implemented anyway.
- return SET_YCP_CB( CB_MediaChange, args );
-}
-
-YCPValue PkgModuleFunctions::CallbackSourceChange( const YCPString& args ) {
- return SET_YCP_CB( CB_SourceChange, args );
-}
-
-
-YCPValue PkgModuleFunctions::CallbackYouProgress( const YCPString& args ) {
- y2warning("Pkg::CallbackYouProgress is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-
-YCPValue PkgModuleFunctions::CallbackYouPatchProgress( const YCPString& args ) {
- y2warning("Pkg::CallbackYouPatchProgress is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-
-YCPValue PkgModuleFunctions::CallbackYouError( const YCPString& args ) {
- y2warning("Pkg::CallbackYouError is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-
-YCPValue PkgModuleFunctions::CallbackYouMessage( const YCPString& args ) {
- y2warning("Pkg::CallbackYouMessage is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-
-YCPValue PkgModuleFunctions::CallbackYouLog( const YCPString& args ) {
- y2warning("Pkg::CallbackYouLog is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-
-YCPValue PkgModuleFunctions::CallbackYouExecuteYcpScript( const YCPString& args ) {
- y2warning("Pkg::CallbackYouExecuteYcpScript is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-YCPValue PkgModuleFunctions::CallbackYouScriptProgress( const YCPString& args ) {
- y2warning("Pkg::CallbackYouScriptProgress is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-
-YCPValue PkgModuleFunctions::CallbackStartRebuildDb( const YCPString& args ) {
- return SET_YCP_CB( CB_StartRebuildDb, args );
-}
-YCPValue PkgModuleFunctions::CallbackProgressRebuildDb( const YCPString& args ) {
- return SET_YCP_CB( CB_ProgressRebuildDb, args );
-}
-YCPValue PkgModuleFunctions::CallbackNotifyRebuildDb( const YCPString& args ) {
- return SET_YCP_CB( CB_NotifyRebuildDb, args );
-}
-YCPValue PkgModuleFunctions::CallbackStopRebuildDb( const YCPString& args ) {
- return SET_YCP_CB( CB_StopRebuildDb, args );
-}
-
-YCPValue PkgModuleFunctions::CallbackStartConvertDb( const YCPString& args ) {
- return SET_YCP_CB( CB_StartConvertDb, args );
-}
-YCPValue PkgModuleFunctions::CallbackProgressConvertDb( const YCPString& args ) {
- return SET_YCP_CB( CB_ProgressConvertDb, args );
-}
-YCPValue PkgModuleFunctions::CallbackNotifyConvertDb( const YCPString& args ) {
- return SET_YCP_CB( CB_NotifyConvertDb, args );
-}
-YCPValue PkgModuleFunctions::CallbackStopConvertDb( const YCPString& args ) {
- return SET_YCP_CB( CB_StopConvertDb, args );
-}
-
-
-/**
- * @builtin CallbackStartDeltaDownload
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string filename, integer download_size)</code>. If the download size is unknown download_size is 0. The callback function is evaluated when a delta RPM download has been started.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackStartDeltaDownload( const YCPString& func ) {
- return SET_YCP_CB( CB_StartDeltaDownload, func );
-}
-
-/**
- * @builtin CallbackProgressDeltaDownload
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>boolean (integer value)</code>. The callback function is evaluated when more than 5% of the size has been downloaded since the last evaluation. If the handler returns false the download is aborted.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackProgressDeltaDownload( const YCPString& func ) {
- return SET_YCP_CB( CB_ProgressDeltaDownload, func );
-}
-
-/**
- * @builtin CallbackProblemDeltaDownload
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string description)</code>. The callback function should inform user that a problem has occurred during delta file download. This is not fatal, it still may be possible to download the full RPM instead.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackProblemDeltaDownload( const YCPString& func ) {
- return SET_YCP_CB( CB_ProblemDeltaDownload, func );
-}
-
-/**
- * @builtin CallbackStartDeltaApply
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string filename)</code>. The callback function should inform user that a delta application has been started.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackStartDeltaApply( const YCPString& func ) {
- return SET_YCP_CB( CB_StartDeltaApply, func );
-}
-
-/**
- * @builtin CallbackProgressDeltaApply
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(integer value)</code>. The callback function is evaluated when more than 5% of the delta size has been applied since the last evaluation.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackProgressDeltaApply( const YCPString& func ) {
- return SET_YCP_CB( CB_ProgressDeltaApply, func );
-}
-
-/**
- * @builtin CallbackProblemDeltaApply
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string description)</code>. The callback function should inform user that a problem has occurred during delta file application. This is not fatal, it still may be possible to use the full RPM instead.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackProblemDeltaApply( const YCPString& func ) {
- return SET_YCP_CB( CB_ProblemDeltaApply, func );
-}
-
-/**
- * @builtin CallbackStartPatchDownload
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string filename, integer download_size)</code>. If the download size is unknown download_size is 0. The callback function is evaluated when a patch download has been started.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackStartPatchDownload( const YCPString& func ) {
- return SET_YCP_CB( CB_StartPatchDownload, func );
-}
-
-/**
- * @builtin CallbackProgressPatchDownload
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>boolean(integer value)</code>. The callback function is evaluated when more than 5% of the patch size has been downloaded since the last evaluation. If the handler returns false the download is aborted.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackProgressPatchDownload( const YCPString& func ) {
- return SET_YCP_CB( CB_ProgressPatchDownload, func );
-}
-
-/**
- * @builtin CallbackProblemPatchDownload
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string description)</code>. The callback function should inform user that a problem has occurred during download of the patch.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackProblemPatchDownload( const YCPString& func ) {
- return SET_YCP_CB( CB_ProblemPatchDownload, func );
-}
-
-
-/**
- * @builtin CallbackFinishDeltaDownload
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void()</code>. The callback function is evaluated when the delta download has been finished.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackFinishDeltaDownload( const YCPString& func)
-{
- return SET_YCP_CB( CB_FinishDeltaDownload, func );
-}
-
-/**
- * @builtin CallbackFinishDeltaApply
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void()</code>. The callback function is evaluated when the delta download has been applied.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackFinishDeltaApply( const YCPString& func)
-{
- return SET_YCP_CB( CB_FinishDeltaApply, func );
-}
-
-/**
- * @builtin CallbackFinishPatchDownload
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void()</code>. The callback function is evaluated when the patch download has been finished.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackFinishPatchDownload( const YCPString& func)
-{
- return SET_YCP_CB( CB_FinishPatchDownload, func );
-}
-
-
-/**
- * @builtin CallbackSourceCreateStart
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string url)</code>. The callback is evaluated when a source creation has been started.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceCreateStart( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceCreateStart, func );
-}
-
-
-/**
- * @builtin CallbackSourceProgressData
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>boolean(integer value)</code>. The callback function is evaluated when more than 5% of the data has been processed since the last evaluation. If the handler returns false the download is aborted.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceCreateProgress( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceCreateProgress, func );
-}
-
-/**
- * @builtin CallbackSourceCreateError
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>string(string url, string err_code, string description)</code>. err_code is "NO_ERROR", "NOT_FOUND" (the URL was not found), "IO" (I/O error) or "INVALID" (the source is not valid). The callback function must return "ABORT" or "RETRY". The callback function is evaluated when an error occurrs during creation of the source.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceCreateError( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceCreateError, func );
-}
-
-/**
- * @builtin CallbackSourceCreateEnd
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string url, string err_code, string description)</code>. err_code is "NO_ERROR", "NOT_FOUND" (the URL was not found), "IO" (I/O error) or "INVALID" (the source is not valid). The callback function is evaluated when creation of the source has been finished.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceCreateEnd( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceCreateEnd, func );
-}
-
-
-
-
-/**
- * @builtin CallbackSourceProbeStart
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string url)</code>. The callback function is evaluated when source probing has been started.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceProbeStart( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceProbeStart, func );
-}
-
-/**
- * @builtin CallbackSourceProbeFailed
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string url, string type)</code>. The callback function is evaluated when the probed source has different type.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceProbeFailed( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceProbeFailed, func );
-}
-
-/**
- * @builtin CallbackSourceProbeSucceeded
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string url, string type)</code>. The callback function is evaluated when the probed source has type <code>type</code>.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceProbeSucceeded( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceProbeSucceeded, func );
-}
-
-/**
- * @builtin CallbackSourceProbeEnd
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string url, string error, string reason)</code>. The callback function is evaluated when source probing has been finished.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceProbeEnd( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceProbeEnd, func );
-}
-
-/**
- * @builtin CallbackSourceProbeProgress
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>boolean(integer value)</code>. If the handler returns false the refresh is aborted.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceProbeProgress( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceProbeProgress, func );
-}
-
-/**
- * @builtin CallbackSourceProbeError
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>string(string url, string error, string reason)</code>. The callback function is evaluated when an error occurrs. The callback function must return string "ABORT" or "RETRY".
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceProbeError( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceProbeError, func );
-}
-
-
-YCPValue PkgModuleFunctions::CallbackSourceReportInit( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceReportInit, func );
-}
-
-YCPValue PkgModuleFunctions::CallbackSourceReportDestroy( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceReportDestroy, func );
-}
-
-YCPValue PkgModuleFunctions::CallbackSourceCreateInit( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceCreateInit, func );
-}
-
-YCPValue PkgModuleFunctions::CallbackSourceCreateDestroy( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceCreateDestroy, func );
-}
-
-/**
- * @builtin CallbackSourceProbeStart
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(integer source_id, string url, string task)</code>.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceReportStart( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceReportStart, func );
-}
-
-/**
- * @builtin CallbackSourceReportProgress
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>boolean(integer value)</code>. If the handler returns false the task is aborted.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceReportProgress( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceReportProgress, func );
-}
-
-/**
- * @builtin CallbackSourceReportError
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>string(integer numeric_id, string url, string error, string reason)</code>. Parameter error is "NO_ERROR", "NOT_FOUND", "IO" or "INVALID". The callback function is evaluated when an error occurrs. The callback function must return string "ABORT", "IGNORE" or "RETRY".
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceReportError( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceReportError, func );
-}
-
-/**
- * @builtin CallbackSourceReportEnd
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(integer numeric_id, string url, string error, string reason)</code>. Parameter error is "NO_ERROR", "NOT_FOUND", "IO" or "INVALID". The callback function is evaluated when an error occurrs. The callback function must return string "ABORT", "IGNORE" or "RETRY".
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackSourceReportEnd( const YCPString& func)
-{
- return SET_YCP_CB( CB_SourceReportEnd, func );
-}
-
-
-YCPValue PkgModuleFunctions::CallbackStartDownload( const YCPString& args ) {
- return SET_YCP_CB( CB_StartDownload, args );
-}
-YCPValue PkgModuleFunctions::CallbackProgressDownload( const YCPString& args ) {
- return SET_YCP_CB( CB_ProgressDownload, args );
-}
-YCPValue PkgModuleFunctions::CallbackDoneDownload( const YCPString& args ) {
- return SET_YCP_CB( CB_DoneDownload, args );
-}
-
-
-/**
- * @builtin CallbackScriptStart
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string patch_name, string patch_version, string patch_arch, string script_path, boolean installation)</code>. Parameter 'installation' is true when the script is called during installation of a patch, false means patch removal. The callback function is evaluated when a script (which is part of a patch) has been started.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackScriptStart( const YCPString& args ) {
- return SET_YCP_CB( CB_ScriptStart, args );
-}
-/**
- * @builtin CallbackScriptProgress
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(boolean ping, string output)</code>. If parameter 'ping' is true than there is no output available, but the script is still running (This functionality enables aborting the script). If it is false, 'output' contains (part of) the script output. The callback function is evaluated when a script is running.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackScriptProgress( const YCPString& args ) {
- return SET_YCP_CB( CB_ScriptProgress, args );
-}
-/**
- * @builtin CallbackScriptProblem
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string description)</code>. The callback function is evaluated when an error occurrs.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackScriptProblem( const YCPString& args ) {
- return SET_YCP_CB( CB_ScriptProblem, args );
-}
-/**
- * @builtin CallbackScriptFinish
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void()</code>. The callback function is evaluated when the script has been finished.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackScriptFinish( const YCPString& args ) {
- return SET_YCP_CB( CB_ScriptFinish, args );
-}
-/**
- * @builtin CallbackMessage
- * @short Register callback function
- * @param string func Name of the callback handler function. Required callback prototype is <code>void(string patch_name, string patch_version, string patch_arch, string message)</code>. The callback function is evaluated when a message which is part of a patch should be displayed.
- * @return void
- */
-YCPValue PkgModuleFunctions::CallbackMessage( const YCPString& args ) {
- return SET_YCP_CB( CB_Message, args );
-}
-
-YCPValue PkgModuleFunctions::CallbackStartSourceRefresh( const YCPString& args ) {
- y2warning("Pkg::CallbackStartSourceRefresh is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-YCPValue PkgModuleFunctions::CallbackProgressSourceRefresh( const YCPString& args ) {
- y2warning("Pkg::CallbackProgressSourceRefresh is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-YCPValue PkgModuleFunctions::CallbackErrorSourceRefresh( const YCPString& args ) {
- y2warning("Pkg::CallbackErrorSourceRefresh is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-YCPValue PkgModuleFunctions::CallbackDoneSourceRefresh( const YCPString& args ) {
- y2warning("Pkg::CallbackDoneSourceRefresh is obsoleted, do not use it (empty implementation)!");
- return YCPVoid();
-}
-
-#undef SET_YCP_CB
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Callbacks.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Callbacks.h (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Callbacks.h Wed May 11 11:22:32 2011
@@ -87,7 +87,7 @@
* Constructor. Setup handler and redirect Y2PMCallbacks
* to the ZyppReceiver.
**/
- CallbackHandler();
+ CallbackHandler(PkgModuleFunctions &);
/**
* Destructor. Reset Y2PMCallbacks to it's defaults.
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/GPGMap.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/GPGMap.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/GPGMap.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,63 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2008 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: $Id$
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Class for converting zypp::PublicKey to YCPMap
+*/
+
+#include "GPGMap.h"
+#include "i18n.h"
+
+#include <ycp/YCPString.h>
+#include <ycp/YCPInteger.h>
+#include <ycp/YCPBoolean.h>
+
+#include <zypp/Date.h>
+#include <zypp/PublicKey.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+GPGMap::GPGMap(const zypp::PublicKey &key)
+{
+ gpg_map->add(YCPString("id"), YCPString(key.id()));
+ gpg_map->add(YCPString("name"), YCPString(key.name()));
+ gpg_map->add(YCPString("fingerprint"), YCPString(key.fingerprint()));
+ gpg_map->add(YCPString("path"), YCPString(key.path().asString()));
+
+ zypp::Date date(key.created());
+ // %x = date only, see man strftime
+ gpg_map->add(YCPString("created"), YCPString(date.form("%x")));
+ gpg_map->add(YCPString("created_raw"), YCPInteger(zypp::Date::ValueType(date)));
+
+ date = key.expires();
+ std::string expires((date == 0) ? _("Never") : date.form("%x"));
+ gpg_map->add(YCPString("expires"), YCPString(expires));
+ gpg_map->add(YCPString("expires_raw"), YCPInteger(zypp::Date::ValueType(date)));
+}
+
+void GPGMap::setTrusted(bool trusted)
+{
+ // is the key trusted?
+ gpg_map->add(YCPString("trusted"), YCPBoolean(trusted));
+}
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/GPGMap.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/GPGMap.h (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/GPGMap.h Wed May 11 11:22:32 2011
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2008 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: $Id$
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Class for converting zypp::PublicKey to YCPMap
+*/
+
+namespace zypp
+{
+ class PublicKey;
+}
+
+#include <ycp/YCPMap.h>
+
+class GPGMap
+{
+ public:
+
+ GPGMap(const zypp::PublicKey &key);
+
+ void setTrusted(bool trusted);
+
+ YCPMap getMap() const
+ {
+ return gpg_map;
+ }
+
+ private:
+
+ YCPMap gpg_map;
+};
+
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/HelpTexts.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/HelpTexts.h (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/HelpTexts.h Wed May 11 11:22:32 2011
@@ -0,0 +1,58 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id$
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Help texts for callbacks
+*/
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+#include <i18n.h>
+
+namespace HelpTexts
+{
+ // help text
+ static const char *load_resolvables = _("<P><BIG><B>Loading Available Packages</B></BIG></P>"
+"<P>Loading available objects from the configured repositories is in progress. This "
+"may take a while...</P>");
+
+
+ // help text
+ static const char *load_target = _("<P><BIG><B>Loading Installed Packages</B></BIG></P>"
+"<P>The package manager is reading installed packages...</P>");
+
+
+ // help text
+ static const char *create_help = _("<P><BIG><B>Registering a New Repository</B></BIG></P>"
+"<P>A new repository is being registered. The package manager is reading "
+"the list of available packages in the repository...</P>");
+
+
+ static const char *save_help = _("<P><BIG><B>Saving Repositories</B></BIG></P>"
+"<P>The package manager is updating configured repositories...</P>");
+
+ static const char *refresh_help = _("<P><BIG><B>Refreshing the Repository</B></BIG></P>"
+"<P>The package manager is updating the repository content...</P>");
+}
+
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Makefile.am (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Makefile.am Wed May 11 11:22:32 2011
@@ -17,6 +17,7 @@
plugin_LTLIBRARIES = libpy2Pkg.la
libpy2Pkg_la_SOURCES = \
+ GPGMap.h GPGMap.cc \
PkgError.cc PkgError.h \
Y2PkgComponent.cc Y2PkgComponent.h \
Y2CCPkg.cc Y2CCPkg.h \
@@ -27,6 +28,7 @@
Utils.h Utils.cc \
ServiceManager.cc ServiceManager.h \
PkgService.cc PkgService.h \
+ Network.cc Network.h \
PkgModuleFunctions.h \
PkgModuleFunctions.cc \
Package.cc \
@@ -34,7 +36,16 @@
Resolvable.cc \
Selection.cc \
Target.cc \
- Source.cc \
+ Source_Callbacks.cc \
+ Source_Create.cc \
+ Source_Download.cc \
+ Source_Get.cc \
+ Source_Installation.cc \
+ Source_Load.cc \
+ Source_Misc.cc \
+ Source_Resolvables.cc \
+ Source_Save.cc \
+ Source_Set.cc \
Keyring.cc \
Callbacks.h \
Callbacks.YCP.h \
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Network.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Network.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Network.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,62 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2008 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: $Id: Source_Load.cc 49526 2008-07-30 13:28:18Z mvidner $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Network related functions
+ Namespace: Pkg
+*/
+
+#include "log.h"
+
+// system()
+#include <cstdlib>
+
+#include "Network.h"
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+/*
+ A helper function
+ Detect whether there is a network connection.
+ See isNetworkRunning() function in NetworkService.ycp
+*/
+bool NetworkDetected()
+{
+ y2milestone("Checking the network status...");
+ // check IPv4 network
+ int result = ::system("ip addr|grep -v '127.0.0\\|inet6'|grep -q inet &> /dev/null");
+ y2milestone("Network is running: %s", (result == 0) ? "yes" : "no");
+
+ return !result;
+}
+
+/*
+ A helper function
+ Is the URL remote?
+*/
+bool remoteRepo(const zypp::Url &url)
+{
+ // is it a remote repository?
+ return url.schemeIsRemote();
+}
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Network.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Network.h (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Network.h Wed May 11 11:22:32 2011
@@ -0,0 +1,11 @@
+
+#ifndef PKGBINDINGS_NETWORK_H
+#define PKGBINDINGS_NETWORK_H
+
+#include <zypp/Url.h>
+
+bool NetworkDetected();
+
+bool remoteRepo(const zypp::Url &url);
+
+#endif
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Package.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Package.cc (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Package.cc Wed May 11 11:22:32 2011
@@ -763,19 +763,6 @@
return YCPVoid();
}
-PkgModuleFunctions::RepoId PkgModuleFunctions::logFindAlias(const std::string &alias) const
-{
- RepoId index = 0LL;
-
- for(RepoCont::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index)
- {
- if (!(*it)->isDeleted() && (*it)->repoInfo().alias() == alias)
- return index;
- }
-
- return -1LL;
-}
-
YCPValue
PkgModuleFunctions::PkgProp(const zypp::PoolItem &item)
{
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgModuleFunctions.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgModuleFunctions.cc (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgModuleFunctions.cc Wed May 11 11:22:32 2011
@@ -174,11 +174,12 @@
PkgModuleFunctions::PkgModuleFunctions ()
: Y2Namespace()
, _target_root( "/" )
+ , _target_loaded(false)
, zypp_pointer(NULL)
+ , autorefresh_skipped(false)
, last_reported_repo(-1)
, last_reported_mediumnr(-1)
- ,_callbackHandler( *new CallbackHandler( ) )
- , _target_loaded(false)
+ ,_callbackHandler( *new CallbackHandler(*this ) )
{
registerFunctions ();
@@ -312,19 +313,6 @@
}
/**
- * @builtin InstSysMode
- * @short obsoleted - do not use
- * @return void
- */
-YCPValue
-PkgModuleFunctions::InstSysMode ()
-{
- y2warning("Pkg::InstSysMode() is obsoleted, it's not needed anymore");
- return YCPVoid();
-}
-
-
-/**
* @short Set Package Manager Locale
* @description
* Set the given locale as the output locale -- all messages from the package manager (errors, warnings,...)
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgModuleFunctions.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgModuleFunctions.h (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgModuleFunctions.h Wed May 11 11:22:32 2011
@@ -40,6 +40,7 @@
#include <zypp/ZYpp.h>
#include <zypp/Pathname.h>
+#include <zypp/TmpPath.h>
#include <zypp/Url.h>
#include <zypp/Arch.h>
#include <zypp/RepoManager.h>
@@ -49,6 +50,8 @@
#include "Utils.h"
#include "ServiceManager.h"
+class PkgProgress;
+
// textdomain
extern "C" {
#include <libintl.h>
@@ -77,19 +80,8 @@
protected:
- // container for the internal structure
- typedef std::vector<YRepo_Ptr> RepoCont;
-
- zypp::RepoManager CreateRepoManager();
- ServiceManager service_manager;
-
- public:
- typedef RepoCont::size_type RepoId;
- protected:
-
zypp::Pathname _target_root;
-
- std::set<std::string> _broken_sources;
+ bool _target_loaded;
zypp::ZYpp::Ptr zypp_pointer;
@@ -99,35 +91,69 @@
// add the main locale to the additional ones
zypp::Locale preferred_locale;
+ zypp::Pathname _download_area;
+
/**
* ZYPP
*/
zypp::ZYpp::Ptr zypp_ptr();
- private: // source related
- YCPValue CommitHelper(const zypp::ZYppCommitPolicy &policy);
+ // container for the internal structure
+ typedef std::vector<YRepo_Ptr> RepoCont;
- zypp::Product::constPtr base_product;
- RepoId last_reported_repo;
- int last_reported_mediumnr;
+ YCPValue CommitHelper(const zypp::ZYppCommitPolicy &policy);
- bool CreateBaseProductSymlink();
+ public:
+
+ // ID type
+ typedef RepoCont::size_type RepoId;
+
+ private: // source related
- // all known installation sources
+ // all known installation sources
RepoCont repos;
- // helper
- YCPValue PkgMediaSizesOrCount (bool sizes, bool download_size=false);
+ // table for converting libzypp source type to Yast type (for backward compatibility)
+ std::map<std::string, std::string> type_conversion_table;
+
+ // flag for skipping autorefresh
+ volatile bool autorefresh_skipped;
+
+ RepoId last_reported_repo;
+ int last_reported_mediumnr;
+
+ YCPValue SourceRefreshHelper(const YCPInteger &id, bool forced = false);
+
+ // helper - is the network running?
+ bool NetworkDetected();
+
+ // is the URL remote?
+ bool remoteRepo(const zypp::Url &url);
+
+ // conversion methods for type string between Yast and libzypp (for backward compatibility)
+ std::string zypp2yastType(const std::string &type);
+ std::string yast2zyppType(const std::string &type);
+
+ // helper - create a directory if it doesn't exist
+ bool CreateDir(const std::string &path);
+ // helper - copy a file or directory
+ bool CopyToDir(const std::string &source, const std::string &target, bool backup = false, bool recursive = true);
+
+ void RemoveResolvablesFrom(YRepo_Ptr repo);
+ bool LoadResolvablesFrom(YRepo_Ptr repo, const zypp::ProgressData::ReceiverFnc & progressrcv = zypp::ProgressData::ReceiverFnc(), bool network_check = false);
+ std::string UniqueAlias(const std::string &alias);
- bool DoProvideNameKind( const std::string & name, zypp::Resolvable::Kind kind, zypp::Arch architecture,
- const std::string& version, const bool onlyNeeded = false);
- bool DoRemoveNameKind( const std::string & name, zypp::Resolvable::Kind kind);
- bool DoProvideAllKind(zypp::Resolvable::Kind kind);
- bool DoRemoveAllKind(zypp::Resolvable::Kind kind);
- bool DoAllKind(zypp::Resolvable::Kind kind, bool provide);
YCPValue GetPkgLocation(const YCPString& p, bool full_path);
- YCPValue PkgProp( const zypp::PoolItem &item );
+ YCPValue PkgProp(const zypp::PoolItem &item);
+ YCPValue PkgMediaSizesOrCount (bool sizes, bool download_size = false);
+ YCPValue TargetInitInternal(const YCPString& root, bool rebuild_rpmdb);
+
+ bool aliasExists(const std::string &alias, const std::list<zypp::RepoInfo> &reps) const;
+
+ zypp::Product::constPtr FindBaseProduct(const std::string &alias) const;
+
+ zypp::RepoManager CreateRepoManager();
void SetCurrentDU();
@@ -141,11 +167,43 @@
void CallSourceReportInit();
void CallSourceReportDestroy();
+ void CallInitDownload(const std::string &task);
+ void CallDestDownload();
+ void RefreshWithCallbacks(const zypp::RepoInfo &repo,
+ const zypp::ProgressData::ReceiverFnc & progressrcv = zypp::ProgressData::ReceiverFnc(),
+ zypp::RepoManager::RawMetadataRefreshPolicy refresh = zypp::RepoManager::RefreshIfNeeded);
+ zypp::repo::RepoType ProbeWithCallbacks(const zypp::Url &url);
+ void ScanProductsWithCallBacks(const zypp::Url &url);
+ void CallRefreshStarted();
+ void CallRefreshDone();
+ YCPValue SourceProvideDirectoryInternal(const YCPInteger& id, const YCPInteger& mid,
+ const YCPString& d, const YCPBoolean &optional,
+ const YCPBoolean &recursive, bool check_signatures);
+
+ YCPValue SourceLoadImpl(PkgProgress &progress);
+ YCPValue SourceStartManagerImpl(const YCPBoolean& enable, PkgProgress &progress);
+
// After all, APPL_HIGH might be more appropriate, because we suggest
// the user what he should do and if it does not work, it's his job to
// fix it (using USER). --ma
static const zypp::ResStatus::TransactByValue whoWantsIt; // #156875
+ // convert MountPointSet to YCP Map
+ YCPMap MPS2YCPMap(const zypp::DiskUsageCounter::MountPointSet &mps);
+
+ YCPMap PoolQuery2YCPMap(const zypp::PoolQuery &pool_query);
+
+ zypp::Url shortenUrl(const zypp::Url &url);
+
+ // convert Exception to string represenatation
+ std::string ExceptionAsString(const zypp::Exception &e);
+
+ YCPValue searchPackage(const YCPString &package, bool installed);
+
+ bool CreateBaseProductSymlink();
+
+ YCPMap Resolvable2YCPMap(const zypp::PoolItem &item, const std::string &req_kind, bool dependencies);
+
private:
/**
@@ -154,28 +212,29 @@
**/
CallbackHandler & _callbackHandler;
- bool _target_loaded;
-
PkgError _last_error;
- /**
- * Logging helper:
- * search for a repository and in case of exception, log error
- * and setLastError AND RETHROW
- */
- YRepo_Ptr logFindRepository(RepoId id);
+ ServiceManager service_manager;
- RepoId logFindAlias(const std::string &alias) const;
+ zypp::Product::constPtr base_product;
+
+ std::vector<zypp::filesystem::TmpDir> tmp_dirs;
- YCPMap Resolvable2YCPMap(const zypp::PoolItem &item, const std::string &req_kind, bool dependencies);
+ RepoId createManagedSource(const zypp::Url & url_r,
+ const zypp::Pathname & path_r, const std::string& type,
+ const std::string &alias_r, PkgProgress &progress, const zypp::ProgressData::ReceiverFnc & progressrcv = zypp::ProgressData::ReceiverFnc());
+
+ /**
+ * provides SourceProvideFile and SourceProvideFileCommon
+ */
+ YCPValue SourceProvideFileCommon(const YCPInteger &id, const YCPInteger &mid,
+ const YCPString& f, const bool optional, const bool check_signatures,
+ const bool digested);
+
+ // Compat helpers
+ YCPValue SourceCreateExCode11(const YCPString& media, const YCPString& pd, bool base, const YCPString& source_type, bool scan_only);
+ YCPValue SourceProvideDirectory(const YCPInteger& id, const YCPInteger& mid, const YCPString& d, const YCPBoolean &optional, const YCPBoolean &recursive);
- YCPValue SourceProvideDirectoryInternal(const YCPInteger& id, const YCPInteger& mid, const YCPString& d, const YCPBoolean &optional, const YCPBoolean &recursive, bool check_signatures);
- YCPValue SourceProvideFileCommon(const YCPInteger &id,
- const YCPInteger &mid,
- const YCPString& f,
- const bool optional,
- const bool check_signatures,
- const bool digested);
public:
// general
@@ -648,6 +707,19 @@
YCPValue ResolvablePropertiesEx(const YCPString& name, const YCPSymbol& kind_r, const YCPString& version, bool dependencies);
YCPValue ResolvableSetPatches(const YCPSymbol& kind_r, bool preselect);
+ /**
+ * Logging helper:
+ * search for a repository and in case of exception, log error
+ * and setLastError AND RETHROW
+ */
+ YRepo_Ptr logFindRepository(RepoId id);
+ RepoId logFindAlias(const std::string &alias) const;
+
+ RepoId LastReportedRepo() const;
+ int LastReportedMedium() const;
+ void SetReportedSource(RepoId repo, int medium);
+
+
/**
* Constructor.
*/
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgProgress.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgProgress.cc (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgProgress.cc Wed May 11 11:22:32 2011
@@ -23,3 +23,5 @@
{
}
+
+
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgProgress.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgProgress.h (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/PkgProgress.h Wed May 11 11:22:32 2011
@@ -31,7 +31,17 @@
void Done();
+ const zypp::ProgressData::ReceiverFnc & Receiver()
+ {
+ return progress_handler;
+ }
+
+
~PkgProgress();
+
+ private:
+ zypp::ProgressData::ReceiverFnc progress_handler;
+
};
#endif
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Callbacks.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Callbacks.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Callbacks.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,190 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Callbacks.cc 49913 2008-08-11 08:56:03Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Callbacks functions related to repository registration
+ Namespace: Pkg
+*/
+
+#include <Callbacks.h>
+#include <Callbacks.YCP.h>
+
+#include <PkgModuleFunctions.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+void PkgModuleFunctions::CallSourceReportStart(const std::string &text)
+{
+ // get the YCP callback handler
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_SourceReportStart);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // add parameters
+ ycp_handler->appendParameter( YCPInteger(0LL) );
+ ycp_handler->appendParameter( YCPString("") );
+ ycp_handler->appendParameter( YCPString(text) );
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+}
+
+void PkgModuleFunctions::CallSourceReportEnd(const std::string &text)
+{
+ // get the YCP callback handler for end event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_SourceReportEnd);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // add parameters
+ ycp_handler->appendParameter( YCPInteger(0LL) );
+ ycp_handler->appendParameter( YCPString("") );
+ ycp_handler->appendParameter( YCPString(text) );
+ ycp_handler->appendParameter( YCPString("NO_ERROR") );
+ ycp_handler->appendParameter( YCPString("") );
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+}
+
+void PkgModuleFunctions::CallSourceReportInit()
+{
+ // get the YCP callback handler for init event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_SourceReportInit);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+}
+
+void PkgModuleFunctions::CallSourceReportDestroy()
+{
+ // get the YCP callback handler for destroy event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_SourceReportDestroy);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+}
+
+void PkgModuleFunctions::CallInitDownload(const std::string &task)
+{
+/*
+ // get the YCP callback handler for destroy event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_InitDownload);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ ycp_handler->appendParameter(YCPString(task));
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+/*
+}
+
+void PkgModuleFunctions::CallDestDownload()
+{
+/*
+ // get the YCP callback handler for destroy event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_DestDownload);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+*/
+}
+
+// this method should be used instead of RepoManager::refreshMetadata()
+void PkgModuleFunctions::RefreshWithCallbacks(const zypp::RepoInfo &repo, const zypp::ProgressData::ReceiverFnc &progressrcv, zypp::RepoManager::RawMetadataRefreshPolicy refresh)
+{
+ CallInitDownload(std::string(_("Refreshing repository ") + repo.alias()));
+
+ try
+ {
+ zypp::RepoManager repomanager = CreateRepoManager();
+ repomanager.refreshMetadata(repo, refresh, progressrcv);
+ }
+ catch(...)
+ {
+ // call the final event even in case of exception
+ CallDestDownload();
+ // rethrow the execption
+ throw;
+ }
+
+ CallDestDownload();
+}
+
+// this method should be used instead of RepoManager::probe()
+zypp::repo::RepoType PkgModuleFunctions::ProbeWithCallbacks(const zypp::Url &url)
+{
+ CallInitDownload(std::string(_("Probing repository ") + url.asString()));
+
+ zypp::repo::RepoType repotype;
+
+ extern ZyppRecipients::MediaChangeSensitivity _silent_probing;
+ // remember the current value
+ ZyppRecipients::MediaChangeSensitivity _silent_probing_old = _silent_probing;
+
+ // disable media change callback for optional file
+ _silent_probing = ZyppRecipients::MEDIA_CHANGE_DISABLE;
+
+ try
+ {
+ // probe type of the repository
+ zypp::RepoManager repomanager = CreateRepoManager();
+ repotype = repomanager.probe(url);
+ }
+ catch(...)
+ {
+ // call the final event even in case of exception
+ CallDestDownload();
+
+ // restore the probing flag
+ _silent_probing = _silent_probing_old;
+
+ // rethrow the execption
+ throw;
+ }
+
+ CallDestDownload();
+
+ // restore the probing flag
+ _silent_probing = _silent_probing_old;
+
+ return repotype;
+}
+
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Create.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Create.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Create.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,656 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Create.cc 63716 2011-04-05 11:33:32Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Functions related to repository registration
+ Namespace: Pkg
+*/
+
+#include <Callbacks.h>
+#include <Callbacks.YCP.h>
+
+#include <PkgModuleFunctions.h>
+#include <PkgProgress.h>
+#include "log.h"
+
+#include <HelpTexts.h>
+
+#include <zypp/MediaProducts.h>
+#include <zypp/media/Mount.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+// scanned available products
+// hack: zypp/MediaProducts.h cannot be included in PkgModuleFunctions.h
+zypp::MediaProductSet available_products;
+
+// this method should be used instead of zypp::productsInMedia()
+// it initializes the download callbacks
+void PkgModuleFunctions::ScanProductsWithCallBacks(const zypp::Url &url)
+{
+ CallInitDownload(std::string(_("Scanning products in ") + url.asString()));
+
+ extern ZyppRecipients::MediaChangeSensitivity _silent_probing;
+ // remember the current value
+ ZyppRecipients::MediaChangeSensitivity _silent_probing_old = _silent_probing;
+
+ // disable media change callback for optional file
+ _silent_probing = ZyppRecipients::MEDIA_CHANGE_DISABLE;
+
+ y2milestone("Scanning products in %s ...", url.asString().c_str());
+
+ try
+ {
+ available_products.clear();
+ zypp::productsInMedia(url, available_products);
+ }
+ catch(...)
+ {
+ // call the final event even in case of exception
+ CallDestDownload();
+
+ // restore the probing flag
+ _silent_probing = _silent_probing_old;
+
+ // rethrow the execption
+ throw;
+ }
+
+ CallDestDownload();
+
+ // restore the probing flag
+ _silent_probing = _silent_probing_old;
+}
+
+static std::string timestamp ()
+{
+ time_t t = time(NULL);
+ struct tm * tmp = localtime(&t);
+
+ if (tmp == NULL) {
+ return "";
+ }
+
+ char outstr[50];
+ if (strftime(outstr, sizeof(outstr), "%Y%m%d-%H%M%S", tmp) == 0) {
+ return "";
+ }
+ return outstr;
+}
+
+/**
+ * Take the ?alias=foo part of old_url, if any, and return it,
+ * putting the rest to new_url.
+ * \throws Exception on malformed URLs I guess
+ */
+static std::string removeAlias (const zypp::Url & old_url,
+ zypp::Url & new_url)
+{
+ std::string alias;
+ new_url = old_url;
+ zypp::url::ParamMap query = new_url.getQueryStringMap ();
+ zypp::url::ParamMap::iterator alias_it = query.find ("alias");
+ if (alias_it != query.end ())
+ {
+ alias = alias_it->second;
+ query.erase (alias_it);
+ new_url.setQueryStringMap (query);
+ }
+ return alias;
+}
+
+
+/**
+ * helper - add "mountoptions=ro" for mountable URL schemes if "mountoptions" option is not empty and
+ * "rw" or "ro" option is missing
+ */
+zypp::Url addRO(const zypp::Url &url)
+{
+ zypp::Url ret(url);
+ std::string scheme = zypp::str::toLower(url.getScheme());
+
+ if (scheme == "nfs"
+ || scheme == "hd"
+ || scheme == "smb"
+ || scheme == "iso"
+ || scheme == "cd"
+ || scheme == "dvd"
+ )
+ {
+ const std::string mountoptions = "mountoptions";
+ zypp::media::Mount::Options options(url.getQueryParam(mountoptions));
+
+ y2debug("Current mountoptions: %s", options.asString().c_str());
+
+ // if mountoptions are empty lizypp uses "ro" by default
+ // don't override "rw" option from application
+ // don't add "ro" if it's already present
+ if (!options.empty() && !options.has("rw") && !options.has("ro"))
+ {
+ options["ro"];
+
+ ret.setQueryParam(mountoptions, options.asString());
+ y2milestone("Adding read only mount option: '%s' -> '%s'", url.asString().c_str(), ret.asString().c_str());
+ }
+ }
+
+ return ret;
+}
+
+/** Create a Source and immediately put it into the SourceManager.
+ * \return the SourceId
+ * \throws Exception if Source creation fails
+*/
+PkgModuleFunctions::RepoId
+PkgModuleFunctions::createManagedSource( const zypp::Url & url_r,
+ const zypp::Pathname & path_r,
+ const std::string& type,
+ const std::string &alias_r,
+ PkgProgress &progress,
+ const zypp::ProgressData::ReceiverFnc & progressrcv)
+{
+ // parse URL
+ y2milestone ("Original URL: %s, product directory: %s", url_r.asString().c_str(), path_r.asString().c_str());
+
+ // #158850#c17, if the URL contains an alias, we use that
+ zypp::Url url;
+
+ std::string alias = removeAlias(url_r, url);
+ y2milestone("Alias from URL: '%s'", alias.c_str());
+
+ // repository type
+ zypp::repo::RepoType repotype;
+ zypp::RepoManager repomanager = CreateRepoManager();
+
+ const bool do_probing = type.empty();
+
+ if (!do_probing)
+ {
+ try
+ {
+ // do conversion from the Yast type ("YaST", "YUM", "Plaindir")
+ // to libzypp type ("yast", "yum", "plaindir")
+ repotype = repotype.parse(yast2zyppType(type));
+ }
+ catch (zypp::repo::RepoUnknownTypeException &e)
+ {
+ y2warning("Unknown source type '%s'", type.c_str());
+ }
+ }
+
+ // the type is not specified or is wrong, autoprobe the type
+ if (repotype == zypp::repo::RepoType::NONE)
+ {
+ zypp::Url probe_url(url_r);
+
+ if (!path_r.asString().empty())
+ {
+ zypp::Pathname pth(probe_url.getPathName());
+ pth /= path_r;
+
+ probe_url.setPathName(pth.asString());
+ }
+
+ y2milestone("Probing source type: '%s'", probe_url.asString().c_str());
+
+ // autoprobe type of the repository
+ repotype = ProbeWithCallbacks(probe_url);
+
+ if (do_probing)
+ {
+ progress.NextStage();
+ }
+ }
+
+ y2milestone("Using source type: %s", repotype.asString().c_str());
+
+
+ // create source definition object
+ zypp::RepoInfo repo;
+
+ std::string name;
+
+ // set alias and name
+ if (alias.empty())
+ {
+ // alias not set via URL, use the passed alias or the URL path
+ if (alias_r.empty())
+ {
+ alias = zypp::RepoManager::makeStupidAlias(url);
+
+ y2milestone("Using alias: %s", alias.c_str());
+ }
+ else
+ {
+ alias = alias_r;
+ }
+
+ name = alias;
+ }
+ else
+ {
+ name = alias;
+ }
+
+
+ y2milestone("Name of the repository: '%s'", name.c_str());
+
+ // alias must be unique, add a suffix if it's already used
+ alias = UniqueAlias(alias);
+
+ // add read only mount option to the URL if needed
+ url = addRO(url);
+
+ bool autorefresh = true;
+
+ std::string scheme = zypp::str::toLower(url.getScheme());
+ if (scheme == "cd" || scheme == "dvd")
+ {
+ y2milestone("Disabling autorefresh for CD/DVD repository");
+ autorefresh = false;
+ }
+
+ repo.setAlias(alias);
+ repo.setName(name);
+ repo.setType(repotype);
+ repo.addBaseUrl(url);
+ // do not keep dowloaded packages by default
+ repo.setKeepPackages(false);
+ repo.setPath(path_r);
+ repo.setEnabled(true);
+ repo.setAutorefresh(autorefresh);
+
+{
+ zypp::ProgressData prg(90);
+ prg.sendTo(progressrcv);
+ prg.toMin();
+
+ zypp::CombinedProgressData subprogrcv_ref(prg, 20);
+ zypp::CombinedProgressData subprogrcv_build(prg, 70);
+
+ // set metadata path (#293428)
+ zypp::Pathname metadatapath = repomanager.metadataPath(repo);
+ repo.setMetadataPath(metadatapath);
+ // set packages path
+ repo.setPackagesPath(repomanager.packagesPath(repo));
+
+ y2milestone("Adding source '%s' (%s, dir: %s)", repo.alias().c_str(), url.asString().c_str(), path_r.asString().c_str());
+ // note: exceptions should be caught by the calling code
+ RefreshWithCallbacks(repo, subprogrcv_ref);
+ progress.NextStage();
+
+ // remove the cache
+ if (repomanager.isCached(repo))
+ {
+ y2milestone("Removing cache for repository '%s'...", repo.alias().c_str());
+ repomanager.cleanCache(repo);
+ }
+
+ y2milestone("Caching repository '%s'...", repo.alias().c_str());
+ repomanager.buildCache(repo, zypp::RepoManager::BuildIfNeeded, subprogrcv_build);
+
+ progress.NextStage();
+
+ prg.toMax();
+}
+ repos.push_back(new YRepo(repo));
+
+ y2milestone("Added source '%s': '%s', enabled: %s, autorefresh: %s",
+ repo.alias().c_str(),
+ repo.baseUrlsBegin()->asString().c_str(),
+ repo.enabled() ? "true" : "false",
+ repo.autorefresh() ? "true" : "false"
+ );
+
+ // the source is at the end of the list
+ return repos.size() - 1;
+}
+
+/****************************************************************************************
+ * @builtin SourceCreate
+ *
+ * @short Create a Source
+ * @description
+ * Load and enable all InstSrces found at media_url, i.e. all sources mentioned in /media.1/products.
+ * If no /media.1/products is available, InstSrc is expected to be located directly below
+ * media_url (product_dir: /).
+ *
+ * If a product_dir is provided, only the InstSrc located at media_url/product_dir is loaded
+ * and enabled.
+ *
+ * @param string url The media to scan.
+ * @optarg string product_dir Restrict scan to a certain InstSrc located in media_url/product_dir.
+ *
+ * @return integer The source_id of the first InstSrc found on the media.
+ **/
+YCPValue
+PkgModuleFunctions::SourceCreate (const YCPString& media, const YCPString& pd)
+{
+ // not base product, autoprobe source type
+ return SourceCreateEx (media, pd, false, YCPString(""));
+}
+
+YCPValue
+PkgModuleFunctions::SourceCreateBase (const YCPString& media, const YCPString& pd)
+{
+ // base product, autoprobe source type
+ return SourceCreateEx (media, pd, true, YCPString(""));
+}
+
+/**
+ * @builtin SourceCreateType
+ * @short Create source of required type
+ * @description
+ * Create a source without autoprobing the source type. This builtin should be used only for "Plaindir" sources, because Plaindir sources are not automatically probed in SourceCreate() builtin.
+ * @param media URL of the source
+ * @param pd product directory (if empty the products will be searched)
+ * @param type type of the source ("YaST", "YUM" or "Plaindir")
+*/
+
+YCPValue
+PkgModuleFunctions::SourceCreateType (const YCPString& media, const YCPString& pd, const YCPString& type)
+{
+ // not base product, autoprobe source type
+ return SourceCreateEx (media, pd, false, type);
+}
+
+// Code10 API compatible
+YCPValue
+PkgModuleFunctions::SourceCreateEx (const YCPString& media, const YCPString& pd, bool base, const YCPString& source_type)
+{
+ return SourceCreateExCode11(media, pd, base, source_type, false);
+}
+
+YCPValue
+PkgModuleFunctions::SourceCreateExCode11(const YCPString& media, const YCPString& pd, bool base, const YCPString& source_type, bool scan_only)
+{
+ y2debug("Creating source...");
+
+ zypp::Pathname pn(pd->value ());
+
+ zypp::Url url;
+
+ try {
+ url = zypp::Url(media->value ());
+ }
+ catch(const zypp::Exception & expt )
+ {
+ y2error ("Invalid URL: %s", expt.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(expt));
+ return YCPInteger (-1LL);
+ }
+
+ const std::string type = source_type->value();
+ const bool scan = pd->value().empty();
+
+ // steps: (scan), download, build cache, load resolvables
+ PkgProgress pkgprogress(_callbackHandler);
+ std::list<std::string> stages;
+
+ // display the scan stage only when needed
+ if (scan)
+ {
+ stages.push_back(_("Search Available Products"));
+ }
+
+ if (source_type->value().empty())
+ {
+ stages.push_back(_("Probe Source Type"));
+ }
+
+ stages.push_back(_("Download Descriptions"));
+ stages.push_back(_("Rebuild Cache"));
+
+ if (!scan_only)
+ {
+ stages.push_back(_("Load Data"));
+ }
+
+ pkgprogress.Start(_("Adding the Repository..."), stages, _(HelpTexts::create_help));
+
+ zypp::ProgressData prg(100);
+ prg.sendTo(pkgprogress.Receiver());
+ prg.toMin();
+
+ // remember the new ids for loading the resolvables
+ std::list<RepoId> new_repos;
+
+ if (scan) {
+ // scan all sources
+ zypp::MediaProductSet products;
+
+ try {
+ ScanProductsWithCallBacks(url);
+ products = available_products;
+ }
+ catch ( const zypp::Exception& excpt)
+ {
+ _last_error.setLastError(ExceptionAsString(excpt));
+ y2error( "Cannot read the product list from the media" );
+ return YCPInteger(-1LL);
+ }
+
+ if( products.empty() )
+ {
+ // no products found, use the base URL instead
+ zypp::MediaProductEntry entry ;
+ products.insert( entry );
+ }
+
+ // scanning has been finished
+ prg.set(5);
+ pkgprogress.NextStage();
+
+ // register the repositories
+ for( zypp::MediaProductSet::const_iterator it = products.begin();
+ it != products.end() ; ++it )
+ {
+ y2milestone("Using product %s in directory %s", it->_name.c_str(), it->_dir.c_str());
+ zypp::CombinedProgressData subprogrcv(prg, 85/products.size());
+
+ try
+ {
+ // don't use spaces in alias
+ std::string alias(it->_name);
+ zypp::str::replaceAll(alias, " ", "-");
+
+ RepoId id = createManagedSource(url, it->_dir, type, alias, pkgprogress, subprogrcv);
+
+ new_repos.push_back(id);
+ }
+ catch ( const zypp::Exception& excpt)
+ {
+ y2error("SourceCreate for '%s' product '%s' has failed"
+ , url.asString().c_str(), pn.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ return YCPInteger(-1LL);
+ }
+ }
+
+ if (!scan_only)
+ {
+ // load resolvables
+ for(std::list<RepoId>::const_iterator it = new_repos.begin();
+ it != new_repos.end() ; ++it )
+ {
+ zypp::CombinedProgressData subprogrcv2(prg, 10/products.size());
+
+ try
+ {
+ YRepo_Ptr repo = logFindRepository(*it);
+
+ // no detailed progress needed, refresh has been done in createManagedSource()
+ LoadResolvablesFrom(repo, subprogrcv2);
+
+ // search for a base product if it hasn't been set
+ if (base && !base_product)
+ {
+ y2milestone("Searching a base product...");
+ base_product = FindBaseProduct(repo->repoInfo().alias());
+ }
+ }
+ catch ( const zypp::Exception& excpt)
+ {
+ y2error("SourceCreate for '%s' product '%s' has failed"
+ , url.asString().c_str(), pn.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ return YCPInteger(-1LL);
+ }
+ }
+ }
+ } else {
+ y2debug("Creating source...");
+
+ zypp::CombinedProgressData subprogrcv_create(prg, 80);
+ zypp::CombinedProgressData subprogrcv_load(prg, 20);
+
+ try
+ {
+ RepoId new_id = createManagedSource(url, pn, type, "", pkgprogress, subprogrcv_create);
+ new_repos.push_back(new_id);
+
+ if (!scan_only)
+ {
+ pkgprogress.NextStage();
+
+ YRepo_Ptr repo = logFindRepository(new_id);
+
+ // load the resolvables
+ LoadResolvablesFrom(repo, subprogrcv_load);
+
+ if (base && !base_product)
+ {
+ y2milestone("Searching the base product...");
+ base_product = FindBaseProduct(repo->repoInfo().alias());
+ }
+ }
+ }
+ catch ( const zypp::Exception& excpt)
+ {
+ y2error("SourceCreate for '%s' product '%s' has failed"
+ , url.asString().c_str(), pn.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ return YCPInteger(-1LL);
+ }
+ }
+
+ prg.toMax();
+
+ if (!scan_only)
+ {
+ PkgFreshen();
+ return YCPInteger(*new_repos.begin());
+ }
+ else
+ {
+ YCPList ids;
+
+ // load resolvables
+ for(std::list<RepoId>::const_iterator it = new_repos.begin();
+ it != new_repos.end() ; ++it )
+ {
+ ids->add(YCPInteger(*it));
+ }
+
+ return ids;
+ }
+}
+
+/****************************************************************************************
+ * @builtin SourceScan
+ * @short Scan a Source Media
+ * @description
+ * Load all InstSrces found at media_url, i.e. all sources mentioned in /media.1/products.
+ * If no /media.1/products is available, InstSrc is expected to be located directly
+ * below media_url (product_dir: /).
+ *
+ * If a product_dir is provided, only the InstSrc located at media_url/product_dir is loaded.
+ *
+ * In contrary to @ref SourceCreate, InstSrces are loaded into the InstSrcManager,
+ * but not enabled (packages and selections are not provided to the PackageManager),
+ * and the SrcIds of <b>all</b> InstSrces found are returned.
+ *
+ * @param string url The media to scan.
+ * @optarg string product_dir Restrict scan to a certain InstSrc located in media_url/product_dir.
+ *
+ * @return list<integer> list of SrcIds (integer).
+ **/
+YCPValue
+PkgModuleFunctions::SourceScan (const YCPString& media, const YCPString& pd)
+{
+ // not base product, autoprobe source type, scanning only
+ return SourceCreateExCode11(media, pd, false, YCPString(""), true);
+}
+
+zypp::Product::constPtr PkgModuleFunctions::FindBaseProduct(const std::string &alias) const
+{
+ zypp::Product::constPtr product = NULL;
+
+ // access to the Pool of Selectables
+ zypp::ResPoolProxy selectablePool(zypp::ResPool::instance().proxy());
+
+ // iterate over zypp::Products
+ for_(it, selectablePool.byKindBegin<zypp::Product>(), selectablePool.byKindEnd<zypp::Product>())
+ {
+ // search an available product from the required repository
+ for_(avail_it, (*it)->availableBegin(), (*it)->availableEnd())
+ {
+ // get the resolvable
+ zypp::ResObject::constPtr res = *avail_it;
+
+ // check the repository
+ if (res && res->repoInfo().alias() == alias)
+ {
+ product = boost::dynamic_pointer_cast<const zypp::Product>(res);
+
+ if (product)
+ {
+ break;
+ }
+ }
+ }
+
+ if (product)
+ {
+ break;
+ }
+ }
+
+ // no product in the pool
+ if (!product)
+ {
+ y2error("No base product has been found");
+ }
+ else
+ {
+ y2milestone("Found base product: %s %s (%s-%s)",
+ product->summary().c_str(),
+ product->edition().asString().c_str(),
+ product->name().c_str(),
+ product->edition().asString().c_str()
+ );
+ }
+
+ return product;
+}
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Download.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Download.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Download.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,377 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Download.cc 54392 2009-01-06 11:43:32Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Functions for downloading files from a repository
+ Namespace: Pkg
+*/
+
+#include <Callbacks.h>
+#include <Callbacks.YCP.h>
+
+#include <PkgModuleFunctions.h>
+#include <PkgProgress.h>
+#include "log.h"
+
+#include <HelpTexts.h>
+
+#include <zypp/Fetcher.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+YCPValue PkgModuleFunctions::SourceProvideFileCommon(const YCPInteger &id,
+ const YCPInteger &mid,
+ const YCPString& f,
+ const bool optional,
+ const bool check_signatures,
+ const bool digested)
+{
+ if (id.isNull() || mid.isNull() || f.isNull())
+ {
+ y2error("ProvideFile: nil argument!");
+ return YCPVoid();
+ }
+
+ CallInitDownload(std::string(_("Downloading ") + f->value()));
+
+ bool found = true;
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ found = false;
+
+ extern ZyppRecipients::MediaChangeSensitivity _silent_probing;
+ // remember the current value
+ ZyppRecipients::MediaChangeSensitivity _silent_probing_old = _silent_probing;
+
+ // disable media change callback for optional file
+ if (optional)
+ _silent_probing = ZyppRecipients::MEDIA_CHANGE_OPTIONALFILE;
+
+ y2milestone("Downloading %s%sfile %s from repository %lld, medium %lld",
+ (optional ? "optional " : ""),
+ (check_signatures ? (digested ? "digested " : "signed ") : ""),
+ f->value().c_str(),
+ id->value(),
+ mid->value()
+ );
+
+ zypp::filesystem::Pathname path; // FIXME use ManagedMedia
+ if (found)
+ {
+ try
+ {
+ if (check_signatures)
+ {
+ // use a Fetcher for downloading signed files (see bnc#409927)
+ zypp::Fetcher fch;
+ fch.reset();
+ fch.setOptions(zypp::Fetcher::AutoAddIndexes);
+
+ // path - add "/" to the beginning if it's missing there
+ std::string media_path(f->value());
+ if (media_path.size() >= 1 && media_path[0] != '/')
+ {
+ media_path = "/" + media_path;
+ }
+
+ zypp::OnMediaLocation mloc(media_path, mid->value());
+ // the file is never optional for zypp (it cannot tell whether an optional file failed)
+ mloc.setOptional(false);
+
+ // create the tmpdir in <_download_area>/var/tmp
+ zypp::filesystem::TmpDir tmpdir(_download_area / zypp::filesystem::TmpDir::defaultLocation());
+
+ // keep a reference to the tmpdir so the directory is not deleted at the and of the block
+ tmp_dirs.push_back(tmpdir);
+ path = tmpdir.path();
+
+ if (digested)
+ {
+ fch.enqueueDigested(mloc);
+ }
+ else
+ {
+ fch.addIndex(mloc);
+ }
+
+ fch.start(path, *repo->mediaAccess()); // uses MediaAccess to retrieve
+ fch.reset();
+ path /= f->value();
+ }
+ else
+ {
+ path = repo->mediaAccess()->provideFile(f->value(), mid->value());
+ y2milestone("local path: '%s'", path.asString().c_str());
+ }
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ found = false;
+
+ if (!optional)
+ {
+ _last_error.setLastError(ExceptionAsString(excpt));
+ y2milestone("File not found: %s", f->value_cstr());
+ }
+ }
+ }
+
+ // set the original probing value
+ _silent_probing = _silent_probing_old;
+
+ CallDestDownload();
+
+ if (found)
+ {
+ return YCPString(path.asString());
+ }
+ else
+ {
+ return YCPVoid();
+ }
+}
+
+
+/****************************************************************************************
+ * @builtin SourceProvideFile
+ *
+ * @short Make a file available at the local filesystem
+ * @description
+ * Let an InstSrc provide some file (make it available at the local filesystem).
+ * Warning: The downloaded files are removed in Pkg::SourceReleaseAll()!
+ *
+ * @param integer SrcId Specifies the InstSrc .
+ * @param integer medianr Number of the media the file is located on ('1' for the 1st media).
+ * @param string file Filename relative to the media root.
+ *
+ * @return string local path as string
+ **/
+YCPValue
+PkgModuleFunctions::SourceProvideFile (const YCPInteger& id, const YCPInteger& mid, const YCPString& f)
+{
+ return SourceProvideFileCommon(id, mid, f, false /*optional*/, false /* signed */, true /* digested, doesn't matter in this case*/);
+}
+
+/****************************************************************************************
+ * @builtin SourceProvideOptionalFile
+ *
+ * @short Make an optional file available at the local filesystem
+ * @description
+ * Let an InstSrc provide some file (make it available at the local filesystem).
+ * If the file doesn't exist don't ask user for another medium and return nil
+ * Warning: The downloaded files are removed in Pkg::SourceReleaseAll()!
+ *
+ * @param integer SrcId Specifies the InstSrc .
+ * @param integer medianr Number of the media the file is located on ('1' for the 1st media).
+ * @param string file Filename relative to the media root.
+ *
+ * @return string local path as string
+ **/
+YCPValue
+PkgModuleFunctions::SourceProvideOptionalFile (const YCPInteger& id, const YCPInteger& mid, const YCPString& f)
+{
+ return SourceProvideFileCommon(id, mid, f, true /*optional*/, false /* signed */, true /* digested, doesn't matter in this case*/);
+}
+
+/****************************************************************************************
+ * @builtin SourceProvideDir
+ * @short make a directory available at the local filesystem
+ * @description
+ * Let an InstSrc provide some directory (make it available at the local filesystem) and
+ * all the files within it (non recursive).
+ * Warning: The downloaded files are removed in Pkg::SourceReleaseAll()!
+ *
+ * @param integer SrcId Specifies the InstSrc .
+ * @param integer medianr Number of the media the file is located on ('1' for the 1st media).
+ * @param string dir Directoryname relative to the media root.
+ * @return string local path as string
+ */
+YCPValue
+PkgModuleFunctions::SourceProvideDir (const YCPInteger& id, const YCPInteger& mid, const YCPString& d)
+{
+ y2warning("Pkg::SourceProvideDir() is obsoleted use Pkg::SourceProvideDirectory() instead");
+ // non optional, non recursive
+ return SourceProvideDirectory(id, mid, d, false, false);
+}
+
+
+/****************************************************************************************
+ * @builtin SourceProvideDirectory
+ * @short make a directory available at the local filesystem
+ * @description
+ * Download a directory from repository (make it available at the local filesystem) and
+ * all the files within it.
+ * Warning: The downloaded files are removed in Pkg::SourceReleaseAll()!
+ *
+ * @param integer id repository to use (id)
+ * @param integer mid Number of the media where the directory is located on ('1' for the 1st media).
+ * @param string d Directory name relative to the media root.
+ * @param boolean optional set to true if the directory may not exist (do not report errors)
+ * @param boolean recursive set to true to provide all subdirectories recursively
+ * @return string local path as string or nil when an error occured
+ */
+YCPValue
+PkgModuleFunctions::SourceProvideDirectory(const YCPInteger& id, const YCPInteger& mid, const YCPString& d, const YCPBoolean &optional, const YCPBoolean &recursive)
+{
+ // dowanload the directory, do not check the signatures
+ return SourceProvideDirectoryInternal(id, mid, d, optional, recursive, false);
+}
+
+YCPValue
+PkgModuleFunctions::SourceProvideDirectoryInternal(const YCPInteger& id, const YCPInteger& mid, const YCPString& d, const YCPBoolean &optional, const YCPBoolean &recursive, bool check_signatures)
+{
+ CallInitDownload(std::string(_("Downloading ") + d->value()));
+
+ bool found = true;
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ found = false;
+
+ zypp::filesystem::Pathname path; // FIXME user ManagedMedia
+
+ extern ZyppRecipients::MediaChangeSensitivity _silent_probing;
+ // remember the current value
+ ZyppRecipients::MediaChangeSensitivity _silent_probing_old = _silent_probing;
+
+ // disable media change callback for optional file
+ if (optional->value())
+ _silent_probing = ZyppRecipients::MEDIA_CHANGE_OPTIONALFILE;
+
+ if (found)
+ {
+ try
+ {
+ if (check_signatures)
+ {
+ // use a Fetcher for downloading signed files (see bnc#409927)
+ zypp::Fetcher f;
+ f.reset();
+ zypp::OnMediaLocation mloc(d->value(), mid->value());
+ // create the tmpdir in <_root>/var/tmp
+ zypp::filesystem::TmpDir tmpdir(_download_area / zypp::filesystem::TmpDir::defaultLocation() );
+
+ // keep the reference to the tmpdir so the directory is not deleted at the and of the block
+ tmp_dirs.push_back(tmpdir);
+ path = tmpdir.path();
+ f.setOptions(zypp::Fetcher::AutoAddIndexes);
+ f.enqueueDigestedDir(mloc, recursive->value());
+ f.start(path, *repo->mediaAccess()); // uses MediaAccess to retrieve
+ f.reset();
+ }
+ else
+ {
+ path = repo->mediaAccess()->provideDir(d->value(), recursive->value(), mid->value());
+ }
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ _last_error.setLastError(ExceptionAsString(excpt));
+ y2milestone ("Directory not found: %s", d->value_cstr());
+ found = false;
+ }
+ }
+
+ // set the original probing value
+ _silent_probing = _silent_probing_old;
+
+ CallDestDownload();
+
+ if (found)
+ {
+ return YCPString(path.asString());
+ }
+ else
+ {
+ return YCPVoid();
+ }
+}
+
+
+
+YCPValue
+PkgModuleFunctions::SourceRefreshHelper (const YCPInteger& id, bool forced)
+{
+ y2milestone("Forced refresh : %s", forced ? "true" : "false");
+
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPBoolean(false);
+
+ PkgProgress pkgprogress(_callbackHandler);
+ std::list<std::string> stages;
+
+ // stages: "download", "build cache"
+ stages.push_back(_("Refresh Metadata"));
+ stages.push_back(_("Rebuild Cache"));
+
+ // two steps
+ zypp::ProgressData prog_total(2);
+ prog_total.sendTo(pkgprogress.Receiver());
+
+ // 3 steps per repository (download, cache rebuild, load resolvables)
+ pkgprogress.Start(_("Refreshing Repository..."), stages, _(HelpTexts::refresh_help));
+
+ try
+ {
+ zypp::RepoManager repomanager = CreateRepoManager();
+ y2milestone("Refreshing metadata '%s'", repo->repoInfo().alias().c_str());
+ RefreshWithCallbacks(repo->repoInfo(), zypp::ProgressData::ReceiverFnc(), forced ? zypp::RepoManager::RefreshForced : zypp::RepoManager::RefreshIfNeeded);
+
+ // next stage, increase progress
+ prog_total.incr();
+ pkgprogress.NextStage();
+
+ y2milestone("Caching source '%s'...", repo->repoInfo().alias().c_str());
+ repomanager.buildCache(repo->repoInfo(), forced ? zypp::RepoManager::BuildForced : zypp::RepoManager::BuildIfNeeded);
+ }
+ catch ( const zypp::Exception & expt )
+ {
+ y2error ("Error while refreshing the source: %s", expt.asString().c_str());
+ _last_error.setLastError(repo->repoInfo().alias() + ": " + ExceptionAsString(expt));
+ return YCPBoolean(false);
+ }
+
+ pkgprogress.Done();
+
+ return YCPBoolean( true );
+}
+
+/****************************************************************************************
+ * @builtin SourceRefreshNow
+ * @short Attempt to immediately refresh a Source
+ * @description
+ * The InsrSrc will be encouraged to check and refresh all metadata
+ * cached on disk.
+ *
+ * @param integer SrcId Specifies the InstSrc.
+ *
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceRefreshNow (const YCPInteger& id)
+{
+ // refresh if needed
+ return SourceRefreshHelper(id);
+}
+
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Get.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Get.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Get.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,481 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Get.cc 56467 2009-03-30 14:32:58Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Functions for reading repository properties
+ Namespace: Pkg
+*/
+
+#include <PkgModuleFunctions.h>
+#include "log.h"
+#include "ycpTools.h"
+
+#include <zypp/Product.h>
+#include <zypp/Repository.h>
+#include <zypp/Package.h>
+#include <zypp/media/CredentialManager.h>
+
+#include <ycp/YCPBoolean.h>
+#include <ycp/YCPMap.h>
+#include <ycp/YCPInteger.h>
+#include <ycp/YCPVoid.h>
+#include <ycp/YCPString.h>
+#include <ycp/YCPList.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+/****************************************************************************************
+ * @builtin SourceGetCurrent
+ *
+ * @short Return the list of all InstSrc Ids.
+ *
+ * @param boolean enabled_only If true, or omitted, return the Ids of all enabled InstSrces.
+ * If false, return the Ids of all known InstSrces.
+ *
+ * @return list<integer> list of SrcIds (integer)
+ **/
+YCPValue
+PkgModuleFunctions::SourceGetCurrent (const YCPBoolean& enabled)
+{
+ YCPList res;
+
+ RepoId index = 0LL;
+ for( RepoCont::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index )
+ {
+ // ignore disabled sources if requested
+ if (enabled->value())
+ {
+ // Note: enabled() is tribool!
+ if ((*it)->repoInfo().enabled())
+ {
+ }
+ else if (!(*it)->repoInfo().enabled())
+ {
+ continue;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ // ignore deleted sources
+ if ((*it)->isDeleted())
+ {
+ continue;
+ }
+
+ res->add( YCPInteger(index) );
+ }
+
+ return res;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Query individual sources
+/////////////////////////////////////////////////////////////////////////////////////////
+
+/****************************************************************************************
+ * @builtin SourceGeneralData
+ *
+ * @short Get general data about the source
+ * @description
+ * Return general data about the source as a map:
+ *
+ * <code>
+ * $[
+ * "enabled" : YCPBoolean,
+ * "autorefresh": YCPBoolean,
+ * "product_dir": YCPString,
+ * "type" : YCPString,
+ * "url" : YCPString (without password, but see SourceURL),
+ * "alias" : YCPString,
+ * "name" : YCPString,
+ * "service" : YCPString, (service to which the repo belongs, empty if there is no service assigned)
+ * "keeppackages" : YCPBoolean,
+ * "is_update_repo" : YCPBoolean, (true if this is an update repo - this requires loaded objects in pool otherwise the flag is not returned! The value is stored in repo metadata, not in .repo file!)
+ * ];
+ *
+ * </code>
+ * @param integer SrcId Specifies the InstSrc to query.
+ * @return map
+ **/
+YCPValue
+PkgModuleFunctions::SourceGeneralData (const YCPInteger& id)
+{
+ YCPMap data;
+
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPVoid ();
+
+ // convert type to the old strings ("YaST", "YUM" or "Plaindir")
+ std::string srctype = zypp2yastType(repo->repoInfo().type().asString());
+
+ data->add( YCPString("enabled"), YCPBoolean(repo->repoInfo().enabled()));
+ data->add( YCPString("autorefresh"), YCPBoolean(repo->repoInfo().autorefresh()));
+ data->add( YCPString("type"), YCPString(srctype));
+ data->add( YCPString("product_dir"), YCPString(repo->repoInfo().path().asString()));
+
+ // check if there is an URL
+ if (repo->repoInfo().baseUrlsBegin() != repo->repoInfo().baseUrlsEnd())
+ {
+ data->add( YCPString("url"), YCPString(repo->repoInfo().baseUrlsBegin()->asString()));
+ }
+
+ data->add( YCPString("alias"), YCPString(repo->repoInfo().alias()));
+ data->add( YCPString("name"), YCPString(repo->repoInfo().name()));
+
+ YCPList base_urls;
+ for( zypp::RepoInfo::urls_const_iterator it = repo->repoInfo().baseUrlsBegin(); it != repo->repoInfo().baseUrlsEnd(); ++it)
+ {
+ base_urls->add(YCPString(it->asString()));
+ }
+ data->add( YCPString("base_urls"), base_urls);
+
+ data->add( YCPString("mirror_list"), YCPString(repo->repoInfo().mirrorListUrl().asString()));
+
+ data->add( YCPString("priority"), YCPInteger(repo->repoInfo().priority()));
+
+ data->add( YCPString("service"), YCPString(repo->repoInfo().service()));
+
+ data->add( YCPString("keeppackages"), YCPBoolean(repo->repoInfo().keepPackages()));
+
+ // add Repository data
+ zypp::Repository repository(zypp::ResPool::instance().reposFind(repo->repoInfo().alias()));
+
+ if (repository != zypp::Repository::noRepository)
+ {
+ y2debug("adding zypp::Repository info");
+ data->add( YCPString("is_update_repo"), YCPBoolean(repository.isUpdateRepo()));
+ }
+
+ return data;
+}
+
+/******************************************************************************
+ * @builtin SourceURL
+ *
+ * @short Get full source URL, including password
+ * @param integer SrcId Specifies the InstSrc to query.
+ * @return string or nil on failure
+ **/
+YCPValue
+PkgModuleFunctions::SourceURL (const YCPInteger& id)
+{
+
+ const YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPVoid();
+
+ zypp::Url url;
+
+ if (repo->repoInfo().baseUrlsBegin() != repo->repoInfo().baseUrlsEnd())
+ {
+ // #186842
+ url = *(repo->repoInfo().baseUrlsBegin());
+
+ // add authentication data if exist
+ zypp::media::CredentialManager cm;
+
+ zypp::media::AuthData_Ptr auth = cm.getCred(url);
+
+ if (auth)
+ {
+ y2milestone("Authentication data found, adding to URL...");
+
+ if (auth->valid())
+ {
+ if (!auth->username().empty())
+ {
+ y2debug("Adding username...");
+ url.setUsername(auth->username());
+ }
+
+ if (!auth->password().empty())
+ {
+ y2debug("Adding password...");
+ url.setPassword(auth->password());
+ }
+ }
+ else
+ {
+ y2warning("Invalid authentication data, returning URL without username and password");
+ }
+
+ // does the url contain credentials query?
+ zypp::url::ParamMap params = url.getQueryStringMap();
+ zypp::url::ParamMap::iterator map_it = params.find("credentials");
+
+ if (map_it != params.end())
+ {
+ y2milestone("Removing credentials query from URL");
+ params.erase(map_it);
+ url.setQueryStringMap(params);
+ }
+ }
+
+ }
+
+ return YCPString(url.asCompleteString());
+}
+
+/****************************************************************************************
+ * @builtin SourceMediaData
+ * @short Return media data about the source
+ * @description
+ * Return media data about the source as a map:
+ *
+ * <code>
+ * $["media_count": YCPInteger,
+ * "media_id" : YCPString,
+ * "media_vendor" : YCPString,
+ * "url" : YCPString,
+ * ];
+ * </code>
+ *
+ * @param integer SrcId Specifies the InstSrc to query.
+ * @return map
+ **/
+YCPValue
+PkgModuleFunctions::SourceMediaData (const YCPInteger& id)
+{
+ YCPMap data;
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPVoid ();
+
+ std::string alias = repo->repoInfo().alias();
+ bool found_resolvable = false;
+ int max_medium = 1;
+
+ // search the maximum source number of a package in the repository
+ try
+ {
+ for (zypp::ResPoolProxy::const_iterator it = zypp_ptr()->poolProxy().byKindBegin(zypp::ResKind::package);
+ it != zypp_ptr()->poolProxy().byKindEnd(zypp::ResKind::package);
+ ++it)
+ {
+ // search in available products
+ for (zypp::ui::Selectable::available_iterator aval_it = (*it)->availableBegin();
+ aval_it != (*it)->availableEnd();
+ ++aval_it)
+ {
+ zypp::Package::constPtr pkg = boost::dynamic_pointer_cast<const zypp::Package>(aval_it->resolvable());
+
+ if (pkg && pkg->repoInfo().alias() == alias)
+ {
+ found_resolvable = true;
+
+ int medium = pkg->mediaNr();
+
+ if (medium > max_medium)
+ {
+ max_medium = medium;
+ }
+ }
+ }
+ }
+ }
+ catch (...)
+ {
+ }
+
+ if (found_resolvable)
+ {
+ data->add( YCPString("media_count"), YCPInteger(max_medium));
+ }
+ else
+ {
+ y2error("No resolvable from repository '%s' found, cannot get number of media (use Pkg::SourceLoad() to load the resolvables)", alias.c_str());
+ }
+
+ y2warning("Pkg::SourceMediaData() doesn't return \"media_id\" and \"media_vendor\" values anymore.");
+
+ // SourceMediaData returns URLs without password
+ if (repo->repoInfo().baseUrlsBegin() != repo->repoInfo().baseUrlsEnd())
+ {
+ data->add( YCPString("url"), YCPString(repo->repoInfo().baseUrlsBegin()->asString()));
+
+ // add all base URLs
+ YCPList base_urls;
+ for( zypp::RepoInfo::urls_const_iterator it = repo->repoInfo().baseUrlsBegin(); it != repo->repoInfo().baseUrlsEnd(); ++it)
+ {
+ base_urls->add(YCPString(it->asString()));
+ }
+ data->add( YCPString("base_urls"), base_urls);
+ }
+
+ return data;
+}
+
+/****************************************************************************************
+ * @builtin SourceProductData
+ * @short Return Product data about the source
+ * @param integer SrcId Specifies the InstSrc to query.
+ * @description
+ * Product data about the source as a map:
+ *
+ * <code>
+ * $[
+ * "label" : string,
+ * "vendor" : string,
+ * "productname" : string,
+ * "productversion" : string,
+ * "relnotesurl" : string,
+ * "relnotes_urls" : list<string>
+ * "register_urls" : list<string>
+ * "smolt_urls" : list<string>
+ * "update_urls" : list<string>
+ * "extra_urls" : list<string>
+ * "optional_urls" : list<string>
+ * ];
+ * </code>
+ *
+ * @return map
+ **/
+YCPValue
+PkgModuleFunctions::SourceProductData (const YCPInteger& src_id)
+{
+ YCPMap ret;
+
+ YRepo_Ptr repo = logFindRepository(src_id->value());
+ if (!repo)
+ return YCPVoid ();
+
+ std::string alias = repo->repoInfo().alias();
+
+ try
+ {
+ for (zypp::ResPoolProxy::const_iterator it = zypp_ptr()->poolProxy().byKindBegin(zypp::ResKind::product);
+ it != zypp_ptr()->poolProxy().byKindEnd(zypp::ResKind::product);
+ ++it)
+ {
+ zypp::Product::constPtr product = NULL;
+
+ // search in available products
+ for (zypp::ui::Selectable::available_iterator aval_it = (*it)->availableBegin();
+ aval_it != (*it)->availableEnd();
+ ++aval_it)
+ {
+ zypp::Product::constPtr prod = boost::dynamic_pointer_cast<const zypp::Product>(aval_it->resolvable());
+ if (prod && prod->repoInfo().alias() == alias)
+ {
+ product = prod;
+ break;
+ }
+ }
+
+ if (product)
+ {
+ ret->add( YCPString("label"), YCPString( product->summary() ) );
+ ret->add( YCPString("vendor"), YCPString( product->vendor() ) );
+ ret->add( YCPString("productname"), YCPString( product->name() ) );
+ ret->add( YCPString("productversion"), YCPString( product->edition().version() ) );
+ ret->add( YCPString("relnotesurl"), YCPString( product->releaseNotesUrls().first().asString()));
+
+ ret->add( YCPString("relnotes_urls"), asYCPList(product->releaseNotesUrls()));
+ ret->add( YCPString("register_urls"), asYCPList(product->registerUrls()));
+ ret->add( YCPString("smolt_urls"), asYCPList(product->smoltUrls()));
+ ret->add( YCPString("update_urls"), asYCPList(product->updateUrls()));
+ ret->add( YCPString("extra_urls"), asYCPList(product->extraUrls()));
+ ret->add( YCPString("optional_urls"), asYCPList(product->optionalUrls()));
+
+ break;
+ }
+ }
+
+ if(ret->size() == 0)
+ {
+ y2warning("Product for source '%lld' not found", src_id->value());
+ }
+ }
+ catch (...)
+ {
+ }
+
+ return ret;
+}
+
+/****************************************************************************************
+ * @builtin SourceProduct
+ * @short Obsoleted function, do not use, see SourceProductData builtin
+ * @deprecated
+ * @param integer
+ * @return map empty map
+ **/
+YCPValue
+PkgModuleFunctions::SourceProduct (const YCPInteger& id)
+{
+ y2error("Pkg::SourceProduct() is obsoleted, use Pkg::SourceProductData() instead!");
+ return SourceProductData(id);
+}
+
+/****************************************************************************************
+ * @builtin SourceEditGet
+ *
+ * @short Get state of Sources
+ * @description
+ * Return a list of states for all known InstSources sorted according to the
+ * source priority (highest first). A source state is a map:
+ * $[
+ * "SrcId" : YCPInteger,
+ * "enabled" : YCPBoolean,
+ * "autorefresh": YCPBoolean,
+ * "name" : YCPString,
+ * "service" : YCPString,
+ * "keeppackages" : YCPBoolean,
+ * ];
+ *
+ * @return list<map> list of source states (map)
+ **/
+YCPValue
+PkgModuleFunctions::SourceEditGet ()
+{
+ YCPList ret;
+
+ unsigned long index = 0;
+ for( RepoCont::const_iterator it = repos.begin(); it != repos.end(); ++it, ++index)
+ {
+ if (!(*it)->isDeleted())
+ {
+ YCPMap src_map;
+
+ src_map->add(YCPString("SrcId"), YCPInteger(index));
+ // Note: enabled() is tribool
+ src_map->add(YCPString("enabled"), YCPBoolean((*it)->repoInfo().enabled()));
+ // Note: autorefresh() is tribool
+ src_map->add(YCPString("autorefresh"), YCPBoolean((*it)->repoInfo().autorefresh()));
+ src_map->add(YCPString("name"), YCPString((*it)->repoInfo().name()));
+ src_map->add(YCPString("priority"), YCPInteger((*it)->repoInfo().priority()));
+ src_map->add(YCPString("service"), YCPString((*it)->repoInfo().service()));
+ src_map->add(YCPString("keeppackages"), YCPBoolean((*it)->repoInfo().keepPackages()));
+
+ ret->add(src_map);
+ }
+ }
+
+ return ret;
+}
+
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Installation.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Installation.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Installation.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,327 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Installation.cc 54407 2009-01-06 16:23:19Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Functions used during system installation
+ Namespace: Pkg
+*/
+
+#include <PkgModuleFunctions.h>
+#include "log.h"
+
+#include <zypp/ExternalProgram.h>
+
+#include <ycp/YCPBoolean.h>
+#include <ycp/YCPVoid.h>
+#include <ycp/YCPString.h>
+
+extern "C"
+{
+// stat()
+#include <unistd.h>
+// errno
+#include <errno.h>
+}
+
+// getenv()
+#include <cstdlib>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+/****************************************************************************************
+ * @builtin SourceSetRamCache
+ * @short Obsoleted function, do not use
+ * @param boolean
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceSetRamCache (const YCPBoolean& a)
+{
+ y2warning( "Pkg::SourceSetRamCache is obsolete and does nothing");
+ return YCPBoolean( true );
+}
+
+bool PkgModuleFunctions::CreateDir(const std::string &path)
+{
+ if (path.empty())
+ {
+ y2error("Empty directory path");
+ return false;
+ }
+
+ // check if the target exists
+ struct stat stat_buf;
+ if (::stat(path.c_str(), &stat_buf) == 0)
+ {
+ // it exists, is it a directory?
+ if (S_ISDIR(stat_buf.st_mode))
+ {
+ return true;
+ }
+ else
+ {
+ // error message (followed by directory name)
+ _last_error.setLastError(_("Target is not a directory: ") + path);
+ y2error("Target %s exists but it's not a directory", path.c_str());
+ return false;
+ }
+ }
+ else
+ {
+ // "No such file or directory" error, the target doesn't exist
+ if (errno == ENOENT)
+ {
+ y2milestone("Creating directory %s...", path.c_str());
+
+ const char* argv[] =
+ {
+ "mkdir",
+ // create parent dir
+ "-p",
+ // finish parameter list
+ "--",
+ // target
+ path.c_str(),
+ NULL
+ };
+
+ // discard stderr, no pty, stderr_fd = -1, use the default locale
+ zypp::ExternalProgram prog(argv, zypp::ExternalProgram::Discard_Stderr, false, -1, true);
+
+ if (prog.close())
+ {
+ // error message (followed by directory name)
+ _last_error.setLastError(_("Cannot create directory ") + path);
+ y2error("Cannot create target directory %s", path.c_str());
+ return false;
+ }
+ }
+ // other error
+ else
+ {
+ // error message (followed by directory name)
+ _last_error.setLastError(_("Cannot check status of directory ") + path);
+ y2error("Cannot stat %s: %s", path.c_str(), ::strerror(errno));
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool PkgModuleFunctions::CopyToDir(const std::string &source, const std::string &target, bool backup, bool recursive)
+{
+ if (source.empty())
+ {
+ y2error("CopyToDir: Empty source parameter");
+ return false;
+ }
+
+ if (target.empty())
+ {
+ y2error("CopyToDir: Empty target parameter");
+ return false;
+ }
+
+ // check if the source exists
+ struct stat stat_buf;
+ if (::stat(source.c_str(), &stat_buf) != 0 && errno == ENOENT)
+ {
+ y2milestone("Source %s does not exist, skipping", source.c_str());
+ return true;
+ }
+
+ // create the target directory
+ if (!CreateDir(target))
+ {
+ return false;
+ }
+
+ const char* argv[] =
+ {
+ "cp",
+ // preserve the time stamps and permissions
+ "-a",
+ // fill the parameters later
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+
+ int pos = 2;
+
+ if (recursive)
+ {
+ argv[pos++] = "-r";
+ }
+
+ if (backup)
+ {
+ argv[pos++] = "-b";
+ }
+
+ // finish parameter list
+ argv[pos++] = "--";
+
+ // source
+ argv[pos++] = source.c_str();
+
+ // target
+ argv[pos++] = target.c_str();
+
+ // discard stderr, no pty, stderr_fd = -1, use the default locale
+ zypp::ExternalProgram prog(argv, zypp::ExternalProgram::Discard_Stderr, false, -1, true);
+
+ if (prog.close())
+ {
+ // error message (followed by detailed description)
+ const std::string msg = _("Error: Cannot copy the cache to the target directory\n");
+
+ // error message
+ _last_error.setLastError(msg + _("Copying failed"));
+ y2error("Cannot copy %s to %s", source.c_str(), target.c_str());
+ return false;
+ }
+
+ return true;
+}
+
+/****************************************************************************************
+ * @builtin SourceCacheCopyTo
+ *
+ * @short Copy cache data of all installation sources to the target
+ * @description
+ * Copy cache data of all installation sources to the target located below 'dir'.
+ * To be called at end of initial installation.
+ *
+ * @param string dir Root directory of target.
+ * @return boolean true on success
+ **/
+YCPValue
+PkgModuleFunctions::SourceCacheCopyTo (const YCPString& dir)
+{
+ // error message (followed by detailed description)
+ const std::string msg = _("Error: Cannot copy the cache to the target directory\n");
+
+ std::string d(dir->value());
+ y2milestone("Copying source cache to '%s'...", d.c_str());
+
+ if (d.empty())
+ {
+ y2error("Empty parameter in Pkg::SourceCacheCopyTo()!");
+ return YCPBoolean(false);
+ }
+
+ if (!CreateDir(d))
+ {
+ return YCPBoolean(false);
+ }
+
+ std::string target(d + "/var/cache");
+
+ // copy /var/cache/zypp to the target system
+ if (!CopyToDir("/var/cache/zypp", target))
+ {
+ return YCPBoolean(false);
+ }
+
+ // copy optional files in /etc/zypp/credentials.d directory
+ std::string source_cred("/etc/zypp/credentials.d");
+ std::string target_cred(d + "/etc/zypp");
+
+ // true = backup target files
+ if (!CopyToDir(source_cred, target_cred, true))
+ {
+ return YCPBoolean(false);
+ }
+
+ // copy user's credentials
+ char *homedir = ::getenv("HOME");
+ if (homedir)
+ {
+ // see file zypp/media/CredentialManager.cc for the user's file definition
+ source_cred = std::string(homedir) + "/.zypp/credentials.cat";
+ target_cred = d + homedir + "/.zypp";
+
+ // copy optional files in $HOME/.zypp/credentials.cat file
+ // true = backup target files
+ if (!CopyToDir(source_cred, target_cred, true))
+ {
+ return YCPBoolean(false);
+ }
+ }
+
+ return YCPBoolean(true);
+}
+/****************************************************************************************
+ * @builtin SourceMoveDownloadArea
+ *
+ * @short Move download area of CURL-based sources to specified directory
+ * @param path specifies the path to move the download area to
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceMoveDownloadArea (const YCPString & path)
+{
+ if (path.isNull())
+ {
+ y2error("Error: Pkg::SourceMoveDownloadArea(): nil argument");
+ return YCPBoolean(false);
+ }
+
+ try
+ {
+ y2milestone("Moving download area of all sources to %s", path->value().c_str());
+ zypp::media::MediaManager manager;
+ manager.setAttachPrefix(path->value());
+ _download_area = path->value();
+ }
+ catch (zypp::Exception & excpt)
+ {
+ _last_error.setLastError(ExceptionAsString(excpt));
+ y2error("Pkg::SourceMoveDownloadArea has failed: %s", excpt.msg().c_str());
+ return YCPBoolean(false);
+ }
+
+ y2milestone( "Download areas moved");
+
+ return YCPBoolean(true);
+}
+
+/**
+ * @builtin InstSysMode
+ * @short obsoleted - do not use
+ * @return void
+ */
+YCPValue
+PkgModuleFunctions::InstSysMode ()
+{
+ y2warning("Pkg::InstSysMode() is obsoleted, it's not needed anymore");
+ return YCPVoid();
+}
+
+
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Load.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Load.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Load.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,593 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Load.cc 63716 2011-04-05 11:33:32Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Functions for initializing the package manager
+ Namespace: Pkg
+*/
+
+#include <Callbacks.h>
+#include <Callbacks.YCP.h>
+
+#include <PkgModuleFunctions.h>
+#include "log.h"
+
+#include <PkgProgress.h>
+#include <HelpTexts.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+/****************************************************************************************
+ * @builtin SourceRestore
+ *
+ * @short Restore the sources from the persistent store
+ * @description
+ * Make sure the Source Manager is up and knows all available installation sources.
+ * It's safe to call this multiple times, and once the installation sources are
+ * actually enabled, it's even cheap
+ *
+ * @return boolean True on success
+ **/
+YCPValue
+PkgModuleFunctions::SourceRestore()
+{
+ // return value
+ bool success = true;
+
+ if (repos.size() > 0)
+ {
+ y2warning("Number of registered repositories: %zd, skipping repository load!", repos.size());
+ return YCPBoolean(success);
+ }
+
+ try
+ {
+ zypp::RepoManager repomanager = CreateRepoManager();
+
+ if (!service_manager.empty())
+ {
+ y2warning("Number of known services: %zd, skipping service load!", service_manager.size());
+ }
+ else
+ {
+ try
+ {
+ service_manager.LoadServices(repomanager);
+
+ if (!service_manager.empty())
+ {
+ // refresh services at first
+ ServiceManager::Services services(service_manager.GetServices());
+ bool network_is_running = NetworkDetected();
+
+ for_(srv_it, services.begin(), services.end())
+ {
+ try
+ {
+ if (srv_it->enabled() && srv_it->autorefresh())
+ {
+ zypp::Url url(srv_it->url());
+
+ if (!network_is_running && remoteRepo(url))
+ {
+ y2warning("No network connection, skipping autorefresh of remote service %s (%s)",
+ srv_it->alias().c_str(), url.asString().c_str());
+ }
+ else
+ {
+ y2milestone("Autorefreshing service %s (%s)...", srv_it->alias().c_str(), url.asString().c_str());
+ service_manager.RefreshService(srv_it->alias(), repomanager);
+ }
+ }
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ // service refresh is not fatal, let's continue
+ y2error ("Error in service refresh: %s", excpt.asString().c_str());
+ // error message, service name and URL is appened at the end of the string
+ _last_error.setLastError(std::string(_("Error refreshing service")) + " " + srv_it->name() + " ("
+ + srv_it->url().asString() + "):\n\n" + ExceptionAsString(excpt));
+ success = false;
+ }
+ }
+ }
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ _last_error.setLastError(ExceptionAsString(excpt));
+ success = false;
+ }
+ }
+
+ std::list<zypp::RepoInfo> reps = repomanager.knownRepositories();
+
+ for (std::list<zypp::RepoInfo>::iterator it = reps.begin();
+ it != reps.end(); ++it)
+ {
+ repos.push_back(new YRepo(*it));
+ }
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ // FIXME: assuming the sources are already initialized
+ y2error ("Error in SourceRestore: %s", excpt.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ success = false;
+ }
+
+ return YCPBoolean(success);
+}
+
+/****************************************************************************************
+ * @builtin SourceGetBrokenSources
+ *
+ * @short Return list of broken sources (sources which failed to restore)
+ * @description
+ * Get list of all sources which could not have been restored.
+ * @return list<string> list of aliases (product names or URLs)
+ **/
+YCPValue PkgModuleFunctions::SourceGetBrokenSources()
+{
+ y2warning("Pkg::SourceGetBrokenSources() is obsoleted, it's not needed anymore.");
+ return YCPList();
+}
+
+/****************************************************************************************
+ * @builtin SourceLoad
+ *
+ * @short Load resolvables from the installation sources
+ * @description
+ * Refresh the pool - Add/remove resolvables from the enabled/disabled sources.
+ * @return boolean True on success
+ **/
+YCPValue
+PkgModuleFunctions::SourceLoad()
+{
+ std::list<std::string> stages;
+ stages.push_back(_("Refresh Sources"));
+ stages.push_back(_("Rebuild Cache"));
+ stages.push_back(_("Load Data"));
+
+ PkgProgress pkgprogress(_callbackHandler);
+
+ // 3 steps per repository (download, cache rebuild, load resolvables)
+ pkgprogress.Start(_("Loading the Package Manager..."), stages, _(HelpTexts::load_resolvables));
+
+ YCPValue ret = SourceLoadImpl(pkgprogress);
+
+ pkgprogress.Done();
+
+ return ret;
+}
+
+void PkgModuleFunctions::CallRefreshStarted()
+{
+ // get the YCP callback handler for destroy event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_StartSourceRefresh);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+}
+
+void PkgModuleFunctions::CallRefreshDone()
+{
+ // get the YCP callback handler for destroy event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_DoneSourceRefresh);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+}
+
+YCPValue
+PkgModuleFunctions::SourceLoadImpl(PkgProgress &progress)
+{
+ bool success = true;
+
+ int repos_to_load = 0;
+ int repos_to_refresh = 0;
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
+ {
+ repos_to_load++;
+
+ if ((*it)->repoInfo().autorefresh())
+ {
+ repos_to_refresh++;
+ }
+ }
+ }
+
+ y2debug("repos_to_load: %d, repos_to_refresh: %d", repos_to_load, repos_to_refresh);
+
+ // set max. value (3 steps per repository - refresh, rebuild, load)
+ zypp::ProgressData prog_total(repos_to_load * 3 * 100);
+ prog_total.sendTo(progress.Receiver());
+ y2debug("Progress status: %lld", prog_total.val());
+
+ zypp::RepoManager repomanager = CreateRepoManager();
+
+ autorefresh_skipped = false;
+
+ bool refresh_started_called = false;
+ bool network_is_running = NetworkDetected();
+
+ // remember failed repositories during autorefresh,
+ // don't load packages from them
+ RepoCont failed_refresh;
+
+ if (repos_to_refresh > 0)
+ {
+ // refresh metadata
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ // load resolvables only from enabled repos which are not deleted
+ if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
+ {
+ // sub tasks
+ zypp::CombinedProgressData refresh_subprogress(prog_total, 100);
+ zypp::ProgressData prog(100);
+ prog.sendTo(refresh_subprogress);
+ y2debug("Progress status: %lld", prog_total.val());
+
+ if ((*it)->isLoaded())
+ {
+ y2milestone("Resolvables from '%s' are already present, not loading", (*it)->repoInfo().alias().c_str());
+ }
+ else
+ {
+ zypp::RepoStatus raw_metadata_status = repomanager.metadataStatus((*it)->repoInfo());
+
+ // autorefresh the source
+ if ((*it)->repoInfo().autorefresh() || raw_metadata_status.empty())
+ {
+ // do not autorefresh remote repositories when the network is not running
+ if (!network_is_running)
+ {
+ zypp::Url url = *((*it)->repoInfo().baseUrlsBegin());
+
+ if (remoteRepo(url))
+ {
+ y2warning("No network connection, skipping autorefresh of remote repository %s (%s)",
+ (*it)->repoInfo().alias().c_str(), url.asString().c_str());
+ continue;
+ }
+ }
+
+ try
+ {
+ zypp::RepoManager::RefreshCheckStatus ref_stat = repomanager.checkIfToRefreshMetadata((*it)->repoInfo(), *((*it)->repoInfo().baseUrlsBegin()));
+
+ if (ref_stat != zypp::RepoManager::REFRESH_NEEDED)
+ {
+ y2internal("Skipping repository '%s' - refresh is not needed", (*it)->repoInfo().alias().c_str());
+ continue;
+ }
+
+ y2milestone("Autorefreshing source: %s", (*it)->repoInfo().alias().c_str());
+ // refresh the repository
+ if (!refresh_started_called)
+ {
+ // call the init callback
+ CallRefreshStarted();
+ refresh_started_called = true;
+ }
+ RefreshWithCallbacks((*it)->repoInfo(), prog.receiver());
+ }
+ // NOTE: subtask progresses are reported as done in the destructor
+ // no need to handle them in the exception code
+ catch (const zypp::Exception& excpt)
+ {
+ // remember the failed autorefresh
+ failed_refresh.push_back(*it);
+
+ if (autorefresh_skipped)
+ {
+ y2warning("autorefresh_skipped, ignoring the exception");
+ }
+ else
+ {
+ y2error ("Error in SourceLoad: %s", excpt.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ success = false;
+ }
+ }
+
+ if (autorefresh_skipped)
+ {
+ y2warning("Skipping autorefresh for the rest of repositories");
+ break;
+ }
+ else
+ {
+ y2debug("Continuing with autorefresh");
+ }
+ }
+ }
+ prog.toMax();
+ y2debug("Progress status: %lld", prog_total.val());
+ }
+ }
+ }
+
+ progress.NextStage();
+
+ // rebuild cache
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ // load resolvables only from enabled repos which are not deleted
+ if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
+ {
+ // sub tasks
+ zypp::CombinedProgressData rebuild_subprogress(prog_total, 100);
+ zypp::ProgressData prog(100);
+ prog.sendTo(rebuild_subprogress);
+
+ y2debug("Progress status: %lld", prog_total.val());
+ if ((*it)->isLoaded())
+ {
+ y2milestone("Resolvables from '%s' are already present, not rebuilding the cache", (*it)->repoInfo().alias().c_str());
+ }
+ else
+ {
+ // autorefresh the source
+ if ((*it)->repoInfo().autorefresh())
+ {
+ zypp::RepoStatus raw_metadata_status = repomanager.metadataStatus((*it)->repoInfo());
+
+ // autorefresh the source
+ if (raw_metadata_status.empty() )
+ {
+ y2error("Missinga metadata, not rebuilding the cache");
+ continue;
+ }
+
+ try
+ {
+ // rebuild cache (the default policy is "if needed")
+ y2milestone("Rebuilding cache for '%s'...", (*it)->repoInfo().alias().c_str());
+
+ //repomanager.buildCache((*it)->repoInfo(), zypp::RepoManager::BuildIfNeeded, prog.receiver());
+ repomanager.buildCache((*it)->repoInfo(), zypp::RepoManager::BuildIfNeeded, rebuild_subprogress);
+ }
+ // NOTE: subtask progresses are reported as done in the descructor
+ // no need to handle them in the exception code
+ catch (const zypp::Exception& excpt)
+ {
+ if (autorefresh_skipped)
+ {
+ y2warning("autorefresh_skipped, ignoring the exception");
+ }
+ else
+ {
+ y2error ("Error in SourceLoad: %s", excpt.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ success = false;
+ }
+ }
+
+ if (autorefresh_skipped)
+ {
+ y2warning("Skipping autorefresh for the rest of repositories");
+ break;
+ }
+ else
+ {
+ y2debug("Continuing with autorefresh");
+ }
+ }
+ }
+ prog.toMax();
+ y2debug("Progress status: %lld", prog_total.val());
+ }
+ }
+
+ if (refresh_started_called)
+ {
+ // call the finish callback
+ CallRefreshDone();
+ }
+
+ progress.NextStage();
+
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ // load resolvables only from enabled repos which are not deleted
+ if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
+ {
+ // check whether the refresh failed or not
+ RepoCont::iterator failed_it = find(failed_refresh.begin(), failed_refresh.end(), *it);
+ if (failed_it != failed_refresh.end())
+ {
+ y2warning("Ignoring packages from repository '%s' (%s) - refresh has failed", (*it)->repoInfo().name().c_str(), (*it)->repoInfo().alias().c_str());
+ continue;
+ }
+
+ y2debug("Loading: %s, Status: %lld", (*it)->repoInfo().alias().c_str(), prog_total.val());
+
+ // subtask
+ zypp::CombinedProgressData load_subprogress(prog_total, 100);
+
+ if ((*it)->isLoaded())
+ {
+ y2milestone("Resolvables from '%s' are already present, not loading", (*it)->repoInfo().alias().c_str());
+ }
+ else
+ {
+ // load objects, do network status check
+ success = LoadResolvablesFrom(*it, load_subprogress, true) && success;
+ }
+ }
+ y2debug("Progress status: %lld", prog_total.val());
+ }
+
+ // report 100%
+ prog_total.toMax();
+
+ autorefresh_skipped = false;
+ return YCPBoolean(success);
+}
+
+
+/****************************************************************************************
+ * @builtin SourceStartManager
+ *
+ * @short Start the source manager - restore the sources and load the resolvables
+ * @description
+ * Calls SourceRestore(), if argument enable is true SourceLoad() is called.
+ * @param boolean enable If true the resolvables are loaded from the enabled sources
+ *
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceStartManager (const YCPBoolean& enable)
+{
+ PkgProgress pkgprogress(_callbackHandler);
+
+ // display the progress only when sources will be loaded
+ if (enable->value() && repos.size() == 0)
+ {
+ std::list<std::string> stages;
+ stages.push_back(_("Load Sources"));
+ stages.push_back(_("Refresh Sources"));
+ stages.push_back(_("Rebuild Cache"));
+ stages.push_back(_("Load Data"));
+
+ // 3 steps per repository (download, cache rebuild, load resolvables)
+ pkgprogress.Start(_("Loading the Package Manager..."), stages, _(HelpTexts::load_resolvables));
+ }
+
+ YCPValue ret = SourceStartManagerImpl(enable, pkgprogress);
+
+ if (enable->value())
+ {
+ pkgprogress.Done();
+ }
+
+ return ret;
+}
+
+/****************************************************************************************
+ * Helper function
+ * @short Start the source manager - restore the sources and load the resolvables
+ * @description
+ * Calls SourceRestore(), if argument enable is true SourceLoad() is called.
+ * @param boolean enable If true the resolvables are loaded from the enabled sources
+ *
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceStartManagerImpl(const YCPBoolean& enable, PkgProgress &progress)
+{
+ YCPValue success = SourceRestore();
+
+ progress.NextStage();
+
+ if( enable->value() )
+ {
+ if (!success->asBoolean()->value())
+ {
+ y2warning("SourceStartManager: Some sources have not been restored, loading only the active sources...");
+ }
+
+ // enable all sources and load the resolvables
+ success = YCPBoolean(SourceLoadImpl(progress)->asBoolean()->value() && success->asBoolean()->value());
+ }
+
+ return success;
+}
+
+/****************************************************************************************
+ * @builtin SourceStartCache
+ *
+ * @short Make sure the InstSrcManager is up, and return the list of SrcIds.
+ * @description
+ * Make sure the InstSrcManager is up, and return the list of SrcIds.
+ * In fact nothing more than:
+ *
+ * <code>
+ * SourceStartManager( enabled_only );
+ * return SourceGetCurrent( enabled_only );
+ * </code>
+ *
+ * @param boolean enabled_only If true, make sure all InstSrces are enabled according to
+ * their default, and return the Ids of enabled InstSrces only. If false, return
+ * the Ids of all known InstSrces.
+ *
+ * @return list<integer> list of SrcIds
+ **/
+YCPValue
+PkgModuleFunctions::SourceStartCache (const YCPBoolean& enabled)
+{
+ try
+ {
+ SourceStartManager(enabled);
+
+ return SourceGetCurrent(enabled);
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ y2error ("Error in SourceStartCache: %s", excpt.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ }
+ // catch an exception from boost (e.g. a file cannot be read by non-root user)
+ catch (const std::exception& err)
+ {
+ y2error ("Error in SourceStartCache: %s", err.what());
+ _last_error.setLastError(err.what());
+ }
+ catch (...)
+ {
+ y2error("Unknown error in SourceStartCache");
+ }
+
+ return YCPList();
+}
+
+/****************************************************************************************
+ * @builtin SourceCleanupBroken - obsoleted, do not use!
+ *
+ * @short Clean up all sources that were not properly restored on the last
+ * call of SourceStartManager or SourceStartCache.
+ *
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceCleanupBroken ()
+{
+ y2warning("Pkg::SourceCleanupBroken() is obsoleted, it's not needed anymore.");
+ return YCPBoolean(true);
+}
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Misc.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Misc.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Misc.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,234 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Misc.cc 58008 2009-07-10 11:30:50Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Generic functions for accessing repositories from Yast
+ Namespace: Pkg
+*/
+
+#include <PkgModuleFunctions.h>
+#include "log.h"
+
+#include <sstream> // ostringstream
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+/**
+ * Logging helper:
+ * call zypp::SourceManager::sourceManager()->findSource
+ * and in case of exception, log error and setLastError AND RETHROW
+ */
+YRepo_Ptr PkgModuleFunctions::logFindRepository(RepoId id)
+{
+ try
+ {
+ if (id < 0 || id >= repos.size())
+ {
+ // not found
+ throw(std::exception());
+ }
+
+ if (!repos[id])
+ {
+ // not found
+ throw(std::exception());
+ }
+
+ if (repos[id]->isDeleted())
+ {
+ y2error("Source %zd has been deleted, the ID is not valid", id);
+ return YRepo_Ptr();
+ }
+
+ return repos[id];
+ }
+ catch (...)
+ {
+ y2error("Cannot find source with ID: %zd", id);
+ // TODO: improve the error message
+ _last_error.setLastError(_("Cannot find source"));
+ }
+
+ // not found, return empty pointer
+ return YRepo_Ptr();
+}
+
+PkgModuleFunctions::RepoId PkgModuleFunctions::logFindAlias(const std::string &alias) const
+{
+ RepoId index = 0LL;
+
+ for(RepoCont::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index)
+ {
+ if (!(*it)->isDeleted() && (*it)->repoInfo().alias() == alias)
+ return index;
+ }
+
+ return -1LL;
+}
+
+bool PkgModuleFunctions::aliasExists(const std::string &alias, const std::list<zypp::RepoInfo> &reps) const
+{
+ // search in loaded repositories
+ for(RepoCont::const_iterator it = repos.begin(); it != repos.end() ; ++it)
+ {
+ if ((*it)->repoInfo().alias() == alias)
+ return true;
+ }
+
+ // search in stored repositories
+ for (std::list<zypp::RepoInfo>::const_iterator it = reps.begin();
+ it != reps.end(); ++it)
+ {
+ if (it->alias() == alias)
+ return true;
+ }
+
+ return false;
+}
+
+// convert libzypp type to yast strings ("YaST", "YUM" or "Plaindir")
+std::string PkgModuleFunctions::zypp2yastType(const std::string &type)
+{
+ std::string ret(type);
+
+ if (type_conversion_table.empty())
+ {
+ // initialize the conversion map
+ type_conversion_table["rpm-md"] = "YUM";
+ type_conversion_table["yast2"] = "YaST";
+ type_conversion_table["plaindir"] = "Plaindir";
+ type_conversion_table["NONE"] = "NONE";
+ }
+
+ std::map<std::string,std::string>::const_iterator it = type_conversion_table.find(type);
+
+ // found in the conversion table
+ if (it != type_conversion_table.end())
+ {
+ ret = it->second;
+ }
+ else
+ {
+ y2error("Cannot convert type '%s'", type.c_str());
+ }
+
+ return ret;
+}
+
+std::string PkgModuleFunctions::yast2zyppType(const std::string &type)
+{
+ // do conversion from the Yast type ("YaST", "YUM", "Plaindir")
+ // to libzypp type ("yast", "yum", "plaindir")
+ // we can simply use toLower instead of a conversion table
+ // in this case
+ return zypp::str::toLower(type);
+}
+
+std::string PkgModuleFunctions::UniqueAlias(const std::string &alias)
+{
+ // make a copy
+ std::string ret = alias;
+
+ unsigned int id = 0;
+
+ // search in stored repositories
+ std::list<zypp::RepoInfo> reps = CreateRepoManager().knownRepositories();
+
+ while(aliasExists(ret, reps))
+ {
+ y2milestone("Alias %s already found: %zd", ret.c_str(), logFindAlias(ret));
+
+ // the alias already exists - add a counter
+ std::ostringstream ostr;
+ ostr << alias << "_" << id;
+
+ ret = ostr.str();
+
+ y2milestone("Using alias %s", ret.c_str());
+ ++id;
+ }
+
+ return ret;
+}
+
+// helper function
+zypp::Url PkgModuleFunctions::shortenUrl(const zypp::Url &url)
+{
+ std::string url_path = url.getPathName();
+ std::string begin_path;
+ std::string end_path;
+
+ // try to convert 'http://server/dir1/dir2/dir3/dir4' -> 'http://server/dir1/.../dir4'
+ std::string::size_type pos_first = url_path.find("/");
+ if (pos_first == 0)
+ {
+ pos_first = url_path.find("/", 1);
+ }
+
+ if (pos_first == std::string::npos)
+ {
+ const int num = 5;
+
+ // "/" not found use the beginning and the end part
+ // 'http://server/very_long_directory_name' -> 'http://server/very_..._name'
+ begin_path = std::string(url_path, 0, num);
+ end_path = std::string(url_path, url_path.size() - num - 1, num);
+ }
+ else
+ {
+ unsigned int pos_last = url_path.rfind("/");
+ if (pos_last == url_path.size() - 1)
+ {
+ pos_last = url_path.rfind("/", url_path.size() - 1);
+ }
+
+ if (pos_last == pos_first || pos_last < pos_first)
+ {
+ const int num = 5;
+
+ // "/" not found use the beginning and the end part
+ begin_path = std::string(url_path, 0, num);
+ end_path = std::string(url_path, url_path.size() - num - 1, num);
+ }
+ else
+ {
+ begin_path = std::string(url_path, 0, pos_first + 1);
+ end_path = std::string(url_path, pos_last);
+ }
+ }
+
+ std::string new_path = begin_path + "..." + end_path;
+ zypp::Url ret(url);
+
+ // use the shorter path
+ ret.setPathName(new_path);
+ // remove query parameters
+ ret.setQueryString("");
+ // remove fragmet
+ ret.setFragment("");
+
+ y2milestone("Using shortened URL: '%s' -> '%s'", url.asString().c_str(), ret.asString().c_str());
+ return ret;
+}
+
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Resolvables.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Resolvables.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Resolvables.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,157 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Resolvables.cc 63716 2011-04-05 11:33:32Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Functions for adding/removing resolvables in the pool
+ Namespace: Pkg
+*/
+
+#include <Callbacks.h>
+#include <Callbacks.YCP.h>
+
+#include <PkgModuleFunctions.h>
+#include "log.h"
+
+#include <zypp/sat/Pool.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+/*
+ * A helper function - remove all resolvables from the repository from the pool
+ */
+void PkgModuleFunctions::RemoveResolvablesFrom(YRepo_Ptr repo)
+{
+ const std::string &alias = repo->repoInfo().alias();
+ y2milestone("Removing resolvables from '%s'", alias.c_str());
+ // remove the resolvables if they have been loaded
+ zypp::sat::Pool::instance().reposErase(alias);
+
+ repo->resetLoaded();
+}
+
+/*
+ * A helper function - load resolvable from the repository into the pool
+ */
+bool PkgModuleFunctions::LoadResolvablesFrom(YRepo_Ptr repo, const zypp::ProgressData::ReceiverFnc &progressrcv, bool network_check)
+{
+ if (repo->isLoaded())
+ {
+ y2milestone("Repository is already loaded");
+ return true;
+ }
+
+ const zypp::RepoInfo &repoinfo = repo->repoInfo();
+ bool success = true;
+ unsigned int size_start = zypp_ptr()->pool().size();
+ y2milestone("Loading resolvables from '%s', pool size at start: %d", repoinfo.alias().c_str(), size_start);
+
+ // sub tasks
+ zypp::ProgressData prog(100);
+ prog.sendTo(progressrcv);
+ zypp::CombinedProgressData load_subprogress(prog, 100);
+
+ try
+ {
+ zypp::RepoManager repomanager = CreateRepoManager();
+ bool refresh = true;
+
+ // build cache if needed
+ if (!repomanager.isCached(repoinfo) && !autorefresh_skipped)
+ {
+ zypp::RepoStatus raw_metadata_status = repomanager.metadataStatus(repoinfo);
+ if (raw_metadata_status.empty())
+ {
+ if (network_check)
+ {
+ zypp::Url url = *(repoinfo.baseUrlsBegin());
+
+ if (remoteRepo(url) && !NetworkDetected())
+ {
+ y2warning("No network connection, skipping autorefresh of remote repository %s (%s)",
+ repoinfo.alias().c_str(), url.asString().c_str());
+
+ refresh = false;
+ }
+ }
+
+ if (refresh)
+ {
+ y2milestone("Missing metadata for source '%s', downloading...", repoinfo.alias().c_str());
+
+ CallRefreshStarted();
+
+ RefreshWithCallbacks(repoinfo);
+
+ CallRefreshDone();
+ }
+ }
+
+ if (refresh)
+ {
+ y2milestone("Caching source '%s'...", repoinfo.alias().c_str());
+ repomanager.buildCache(repoinfo, zypp::RepoManager::BuildIfNeeded, load_subprogress);
+ }
+ }
+
+ repomanager.loadFromCache(repoinfo);
+ repo->setLoaded();
+ //y2milestone("Loaded %zd resolvables", store.size());
+ }
+ catch(const zypp::repo::RepoNotCachedException &excpt )
+ {
+ if (!autorefresh_skipped)
+ {
+ std::string alias = repoinfo.alias();
+ zypp::Url url(repoinfo.url());
+ y2error ("Resolvables from '%s' havn't been loaded: %s", alias.c_str(), excpt.asString().c_str());
+ _last_error.setLastError("'" + alias + "': " + url.asString() + "\n" + ExceptionAsString(excpt));
+ success = false;
+ }
+ else
+ {
+ y2internal("Autorefresh disabled, the cache is missing -> cannot load resolvables");
+ }
+
+ // FIXME ??
+ /*
+ // disable the source
+ y2error("Disabling source %s", url.c_str());
+ repo->disable();
+ */
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ std::string alias = repoinfo.alias();
+ y2internal("Error: Loading resolvables failed: %s", ExceptionAsString(excpt).c_str());
+ _last_error.setLastError("'" + alias + "': " + ExceptionAsString(excpt));
+ success = false;
+ }
+
+ unsigned int size_end = zypp_ptr()->pool().size();
+ y2milestone("Pool size at end: %d (loaded %d resolvables)", size_end, size_end - size_start);
+
+ prog.toMax();
+
+ return success;
+}
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Save.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Save.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Save.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,295 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Save.cc 63716 2011-04-05 11:33:32Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Functions for saving repository configuration
+ Namespace: Pkg
+*/
+
+#include <Callbacks.h>
+#include <Callbacks.YCP.h>
+
+#include <PkgModuleFunctions.h>
+#include "log.h"
+#include <PkgProgress.h>
+
+#include <HelpTexts.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+/****************************************************************************************
+ * @builtin SourceReleaseAll
+ *
+ * @short Release all medias hold by all sources
+ * Warning: It also deletes the downloaded files!
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceReleaseAll ()
+{
+ y2milestone("Releasing all sources...");
+ bool ret = true;
+
+ y2milestone("Removing all tmp directories");
+ tmp_dirs.clear();
+
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ try
+ {
+ (*it)->mediaAccess()->release();
+ }
+ catch (const zypp::media::MediaException & ex)
+ {
+ y2warning("Failed to release media for repo: %s", ex.msg().c_str());
+ ret = false;
+ }
+ }
+
+ return YCPBoolean(ret);
+}
+
+/******************************************************************************
+ * @builtin SourceSaveAll
+ *
+ * @short Save all InstSrces.
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceSaveAll ()
+{
+ y2milestone("Saving the source setup...");
+ bool ret = true;
+
+ // nothing to save, return success
+ if (repos.empty() && service_manager.empty())
+ {
+ y2debug("No repository or service defined, saving skipped");
+ return YCPBoolean(ret);
+ }
+
+ zypp::RepoManager repomanager = CreateRepoManager();
+
+ // save the services
+ try
+ {
+ service_manager.SaveServices(repomanager);
+ y2milestone("All services have been saved");
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ _last_error.setLastError(ExceptionAsString(excpt));
+ ret = false;
+ }
+
+ // count removed repos
+ int removed_repos = 0;
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ // the repo has been removed
+ if ((*it)->isDeleted())
+ {
+ removed_repos++;
+ }
+ }
+
+ y2debug("Found %d removed repositories", removed_repos);
+
+ // number of steps:
+ // for removed repository: 3 (remove metadata, remove from cache, remove .repo file)
+ // for other repositories: 1 (just save/update .repo file)
+ // (so there are 2 extra steps for removed repos)
+ int save_steps = 2*removed_repos + repos.size();
+
+ PkgProgress pkgprogress(_callbackHandler);
+ std::list<std::string> stages;
+
+ if (removed_repos > 0)
+ {
+ stages.push_back(_("Remove Repositories"));
+ }
+
+
+ // stages: "download", "build cache"
+ stages.push_back(_("Save Repositories"));
+
+ // set number of step
+ zypp::ProgressData prog_total(save_steps);
+ // set the receiver
+ prog_total.sendTo(pkgprogress.Receiver());
+
+ // start the process
+ pkgprogress.Start(_("Saving Repositories..."), stages, _(HelpTexts::save_help));
+
+ // remove deleted repos (the old configurations) at first
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ // the repo has been removed
+ if ((*it)->isDeleted())
+ {
+ std::string repo_alias = (*it)->repoInfo().alias();
+
+ try
+ {
+ // remove the metadata
+ zypp::RepoStatus raw_metadata_status = repomanager.metadataStatus((*it)->repoInfo());
+ if (!raw_metadata_status.empty())
+ {
+ y2milestone("Removing metadata for source '%s'...", repo_alias.c_str());
+ repomanager.cleanMetadata((*it)->repoInfo());
+ }
+ prog_total.incr();
+
+ // remove the cache
+ if (repomanager.isCached((*it)->repoInfo()))
+ {
+ y2milestone("Removing cache for '%s'...", repo_alias.c_str());
+ repomanager.cleanCache((*it)->repoInfo());
+ }
+ prog_total.incr();
+
+ // does the repository exist?
+ repomanager.getRepositoryInfo(repo_alias);
+ y2milestone("Removing repository '%s'", repo_alias.c_str());
+ repomanager.removeRepository((*it)->repoInfo());
+ prog_total.incr();
+ }
+ catch (const zypp::repo::RepoNotFoundException &ex)
+ {
+ // repository not found -- not critical, continue
+ y2warning("No such repository: %s", repo_alias.c_str());
+ }
+ catch (const zypp::Exception & excpt)
+ {
+ y2error("Pkg::SourceSaveAll has failed: %s", excpt.msg().c_str() );
+ _last_error.setLastError(ExceptionAsString(excpt));
+ return YCPBoolean(false);
+ }
+ }
+ }
+
+ if (removed_repos > 0)
+ {
+ pkgprogress.NextStage();
+ }
+
+ // save all repos (the current configuration)
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ if (!(*it)->isDeleted())
+ {
+ std::string current_alias = (*it)->repoInfo().alias();
+
+ try
+ {
+ try
+ {
+ // if the repository already exists then just modify it
+ repomanager.getRepositoryInfo(current_alias);
+ y2milestone("Modifying repository '%s'", current_alias.c_str());
+ repomanager.modifyRepository(current_alias, (*it)->repoInfo());
+ }
+ catch (const zypp::repo::RepoNotFoundException &ex)
+ {
+ // the repository was not found, add it
+ y2milestone("Adding repository '%s'", current_alias.c_str());
+ repomanager.addRepository((*it)->repoInfo());
+ }
+ }
+ catch (zypp::Exception & excpt)
+ {
+ y2error("Pkg::SourceSaveAll has failed: %s", excpt.msg().c_str() );
+ _last_error.setLastError(ExceptionAsString(excpt));
+ return YCPBoolean(false);
+ }
+
+ prog_total.incr();
+ }
+ }
+
+ y2milestone("All sources have been saved");
+
+ return YCPBoolean(ret);
+}
+
+/****************************************************************************************
+ * @builtin SourceFinishAll
+ *
+ * @short Release all instalation sources
+ * @description
+ * Release all known installation repositories. Releasing is done automaticaly in Pkg::
+ * destructor, but can be done explicitly to force reloading of registered repositories.
+ * Use SourceSaveAll() to not loose the new registered sources before calling SourceFinishAll()!
+ * @return boolean true on success
+ **/
+YCPValue
+PkgModuleFunctions::SourceFinishAll ()
+{
+ try
+ {
+ y2milestone( "Unregistering all sources...") ;
+
+ // remove all resolvables
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ RemoveResolvablesFrom(*it);
+ }
+
+ // release all repositories
+ repos.clear();
+
+ // release all services
+ service_manager.Reset();
+ }
+ catch (zypp::Exception & excpt)
+ {
+ y2error("Pkg::SourceFinishAll has failed: %s", excpt.msg().c_str() );
+ _last_error.setLastError(ExceptionAsString(excpt));
+ return YCPBoolean(false);
+ }
+
+ y2milestone("All sources and services have been unregistered");
+
+ return YCPBoolean(true);
+}
+
+
+/****************************************************************************************
+ * @builtin SourceFinish
+ * @short Disable an Installation Source - obsoleted
+ * @param integer SrcId Specifies the InstSrc.
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceFinish (const YCPInteger& id)
+{
+ y2warning("Pkg::SourceFinish() is obsoleted, use Pkg::SourceSetEnabled(id, false) instead");
+ return SourceSetEnabled(id, false);
+}
+
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Set.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Set.cc (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Source_Set.cc Wed May 11 11:22:32 2011
@@ -0,0 +1,426 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id: Source_Set.cc 63716 2011-04-05 11:33:32Z lslezak $
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: Functions for changing properties of a repository
+ Namespace: Pkg
+*/
+
+#include <Callbacks.h>
+#include <Callbacks.YCP.h>
+
+#include <PkgModuleFunctions.h>
+#include "log.h"
+
+#include <PkgProgress.h>
+#include <HelpTexts.h>
+
+/*
+ Textdomain "pkg-bindings"
+*/
+
+/****************************************************************************************
+ * @builtin SourceSetEnabled
+ *
+ * @short Set the default activation state of an InsrSrc.
+ * @param integer SrcId Specifies the InstSrc.
+ * @param boolean enabled Default activation state of source.
+ *
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceSetEnabled (const YCPInteger& id, const YCPBoolean& e)
+{
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPBoolean(false);
+
+ // no change required
+ bool enable = e->value();
+ if ((enable && repo->repoInfo().enabled())
+ || (!enable && !repo->repoInfo().enabled()))
+ return YCPBoolean(true);
+
+ bool success = true;
+
+ try
+ {
+ repo->repoInfo().setEnabled(enable);
+
+ // add/remove resolvables
+ if (enable)
+ {
+ // load resolvables only when they haven't been loaded yet
+ if (!repo->isLoaded())
+ {
+ std::list<std::string> stages;
+ stages.push_back(_("Load Data"));
+
+ PkgProgress pkgprogress(_callbackHandler);
+ zypp::ProgressData prog_total(100);
+ prog_total.sendTo(pkgprogress.Receiver());
+ zypp::CombinedProgressData load_subprogress(prog_total, 100);
+
+ pkgprogress.Start(_("Loading the Package Manager..."), stages, _(HelpTexts::load_resolvables));
+
+ success = LoadResolvablesFrom(repo, load_subprogress);
+ }
+ }
+ else
+ {
+ // the source has been disabled, remove resolvables from the pool
+ RemoveResolvablesFrom(repo);
+ }
+
+ PkgFreshen();
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ std::string alias = repo->repoInfo().alias();
+ y2error ("Error for '%s': %s", alias.c_str(), excpt.asString().c_str());
+ _last_error.setLastError(alias + ": " + ExceptionAsString(excpt));
+ success = false;
+ }
+
+ return YCPBoolean(success);
+}
+
+/****************************************************************************************
+ * @builtin SourceSetAutorefresh
+ *
+ * @short Set whether this source should automaticaly refresh it's
+ * meta data when it gets enabled. (default true, if not CD/DVD)
+ * @param integer SrcId Specifies the InstSrc.
+ * @param boolean enabled Whether autorefresh should be turned on or off.
+ *
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceSetAutorefresh (const YCPInteger& id, const YCPBoolean& e)
+{
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPBoolean(false);
+
+ repo->repoInfo().setAutorefresh(e->value());
+
+ return YCPBoolean( true );
+}
+
+/****************************************************************************************
+ * @builtin SourceEditSet
+ *
+ * @short Configure properties of installation sources
+ * @description
+ * Set states of installation sources. Note: Enabling/disabling a source does not
+ * (un)load the packages from the source! Use SourceSetEnabled() if you need to refresh
+ * the packages in the pool.
+ *
+ * @param list source_states List of source states. Same format as returned by
+ * @see SourceEditGet.
+ *
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceEditSet (const YCPList& states)
+{
+ bool error = false;
+
+ for (int index = 0; index < states->size(); index++ )
+ {
+ if( ! states->value(index)->isMap() )
+ {
+ y2error( "Pkg::SourceEditSet, entry not a map at index %d", index);
+ error = true;
+ continue;
+ }
+
+ YCPMap descr = states->value(index)->asMap();
+
+ if (descr->value( YCPString("SrcId") ).isNull() || !descr->value(YCPString("SrcId"))->isInteger())
+ {
+ y2error( "Pkg::SourceEditSet, SrcId not defined for a source description at index %d", index);
+ error = true;
+ continue;
+ }
+
+ RepoId id = descr->value( YCPString("SrcId") )->asInteger()->value();
+
+ YRepo_Ptr repo = logFindRepository(id);
+ if (!repo)
+ {
+ y2error( "Pkg::SourceEditSet, source %d not found", index);
+ error = true;
+ continue;
+ }
+
+ // now, we have the source
+ if( ! descr->value( YCPString("enabled")).isNull() && descr->value(YCPString("enabled"))->isBoolean ())
+ {
+ bool enable = descr->value(YCPString("enabled"))->asBoolean ()->value();
+
+ if (repo->repoInfo().enabled() != enable)
+ {
+ y2warning("Pkg::SourceEditSet() does not refresh the pool (src: %zd, state: %s)", id, enable ? "disabled -> enabled" : "enabled -> disabled");
+ }
+
+ y2debug("set enabled: %d", enable);
+ repo->repoInfo().setEnabled(enable);
+ }
+
+ if( !descr->value(YCPString("autorefresh")).isNull() && descr->value(YCPString("autorefresh"))->isBoolean ())
+ {
+ bool autorefresh = descr->value(YCPString("autorefresh"))->asBoolean()->value();
+ y2debug("set autorefresh: %d", autorefresh);
+ repo->repoInfo().setAutorefresh( autorefresh );
+ }
+
+ if( !descr->value(YCPString("name")).isNull() && descr->value(YCPString("name"))->isString())
+ {
+ // rename the source
+ y2debug("set name: %s", descr->value(YCPString("name"))->asString()->value().c_str());
+ repo->repoInfo().setName(descr->value(YCPString("name"))->asString()->value());
+ }
+
+ if( !descr->value(YCPString("priority")).isNull() && descr->value(YCPString("priority"))->isInteger())
+ {
+ unsigned int priority = descr->value(YCPString("priority"))->asInteger()->value();
+
+ // set the priority
+ repo->repoInfo().setPriority(priority);
+ y2debug("set priority: %d", priority);
+ }
+
+ if(!descr->value(YCPString("keeppackages")).isNull() && descr->value(YCPString("keeppackages"))->isBoolean())
+ {
+ bool keeppackages = descr->value(YCPString("keeppackages"))->asBoolean()->value();
+ y2debug("set keeppackages: %d", keeppackages);
+ repo->repoInfo().setKeepPackages( keeppackages );
+ }
+ }
+
+ PkgFreshen();
+ return YCPBoolean( !error );
+}
+
+/****************************************************************************************
+ * @builtin SourceChangeUrl
+ * @short Change Source URL
+ * @description
+ * Change url of an InstSrc. Used primarely when re-starting during installation
+ * and a cd-device changed from hdX to srX since ide-scsi was activated.
+ * @param integer SrcId Specifies the InstSrc.
+ * @param string url The new url to use.
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceChangeUrl (const YCPInteger& id, const YCPString& u)
+{
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPBoolean(false);
+
+ try
+ {
+ if (repo->repoInfo().baseUrlsSize() > 1)
+ {
+ // store current urls
+ std::set<zypp::Url> baseUrls (repo->repoInfo().baseUrlsBegin(), repo->repoInfo().baseUrlsEnd());
+
+ // reset url list and store the new one there
+ repo->repoInfo().setBaseUrl(zypp::Url(u->value()));
+
+ // add the rest of base urls
+ for (std::set<zypp::Url>::const_iterator i = baseUrls.begin();
+ i != baseUrls.end(); ++i)
+ repo->repoInfo().addBaseUrl(*i);
+ }
+ else
+ repo->repoInfo().setBaseUrl(zypp::Url(u->value()));
+ }
+ catch (const zypp::Exception & excpt)
+ {
+ _last_error.setLastError(ExceptionAsString(excpt));
+ y2error ("Cannot set the new URL for source %s (%lld): %s",
+ repo->repoInfo().alias().c_str(), id->asInteger()->value(), excpt.msg().c_str());
+ return YCPBoolean(false);
+ }
+
+ return YCPBoolean(true);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+//
+// DEPRECATED
+//
+/////////////////////////////////////////////////////////////////////////////////////////
+
+/****************************************************************************************
+ * Pkg::SourceRaisePriority (integer SrcId) -> bool
+ *
+ * Raise priority of source.
+ *
+ * @param SrcId Specifies the InstSrc.
+ *
+ * @return bool
+ **/
+YCPValue
+PkgModuleFunctions::SourceRaisePriority (const YCPInteger& id)
+{
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPBoolean(false);
+
+ // check the current priority
+ unsigned int prio = repo->repoInfo().priority();
+
+ // maximum priority already reached - priority is 1 (max.) to 99 (min.)
+ if (prio <= 1)
+ {
+ return YCPBoolean(false);
+ }
+ else
+ {
+ // increase the priority
+ prio--;
+
+ // set the new priority
+ repo->repoInfo().setPriority(prio);
+ }
+
+ return YCPBoolean(true);
+}
+
+/****************************************************************************************
+ * Pkg::SourceLowerPriority (integer SrcId) -> void
+ *
+ * Lower priority of source.
+ *
+ * @param SrcId Specifies the InstSrc.
+ *
+ * @return bool
+ */
+YCPValue
+PkgModuleFunctions::SourceLowerPriority (const YCPInteger& id)
+{
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPBoolean(false);
+
+ // check the current priority
+ unsigned int prio = repo->repoInfo().priority();
+
+ // manimum priority already reached - priority is 1 (max.) to 99 (min.)
+ if (prio >= 99)
+ {
+ return YCPBoolean(false);
+ }
+ else
+ {
+ // decrease the priority
+ prio++;
+
+ // set the new priority
+ repo->repoInfo().setPriority(prio);
+ }
+
+ return YCPBoolean(true);
+}
+
+/****************************************************************************************
+ * Pkg::SourceSaveRanks () -> boolean
+ *
+ * @short Obsoleted function, do not use
+ * @return boolean true
+ **/
+YCPValue
+PkgModuleFunctions::SourceSaveRanks ()
+{
+ y2error( "SourceSaveRanks not implemented" );
+
+ return YCPBoolean( true );
+}
+
+/****************************************************************************************
+ * @builtin SourceInstallOrder
+ *
+ * @short not implemented, do not use (Explicitly set an install order.)
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceInstallOrder (const YCPMap& ord)
+{
+#warning SourceInstallOrder is not implemented
+ return YCPBoolean( true );
+}
+
+
+/****************************************************************************************
+ * @builtin SourceDelete
+ * @short Delete a Source
+ * @description
+ * Delete an InsrSrc. The InsrSrc together with all metadata cached on disk
+ * is removed. The SrcId passed becomes invalid (other SrcIds stay valid).
+ *
+ * @param integer SrcId Specifies the InstSrc.
+ *
+ * @return boolean
+ **/
+YCPValue
+PkgModuleFunctions::SourceDelete (const YCPInteger& id)
+{
+ YRepo_Ptr repo = logFindRepository(id->value());
+ if (!repo)
+ return YCPBoolean(false);
+
+ bool success = true;
+ const std::string repo_alias(repo->repoInfo().alias());
+
+ try
+ {
+
+ // the resolvables cannot be used anymore, remove them
+ RemoveResolvablesFrom(repo);
+
+ // update 'repos'
+ repo->setDeleted();
+
+ // removing the base product repository?
+ if (base_product && base_product->repoInfo().alias() == repo_alias)
+ {
+ y2warning("Resetting the base product, the base product repository has been removed");
+ base_product = NULL;
+ }
+
+ PkgFreshen();
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ y2error ("Error for '%s': %s", repo_alias.c_str(), excpt.asString().c_str());
+ _last_error.setLastError(repo_alias + ": " + ExceptionAsString(excpt));
+ success = false;
+ }
+
+ return YCPBoolean(success);
+}
+
+
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Target.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Target.cc (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Target.cc Wed May 11 11:22:32 2011
@@ -42,7 +42,8 @@
#include <zypp/Locks.h>
#include <zypp/DiskUsageCounter.h>
-#include <PkgProgress.h>
+#include "PkgProgress.h"
+#include "HelpTexts.h"
using namespace zypp;
@@ -73,7 +74,7 @@
stages.push_back(_("Read Installed Packages"));
PkgProgress pkgprogress(_callbackHandler);
- pkgprogress.Start(_("Loading the Package Manager..."), stages, _(""));
+ pkgprogress.Start(_("Loading the Package Manager..."), stages, _(HelpTexts::load_resolvables));
try
{
@@ -162,7 +163,7 @@
PkgProgress pkgprogress(_callbackHandler);
- pkgprogress.Start(_("Loading the Package Manager..."), stages, _(""));
+ pkgprogress.Start(_("Loading the Package Manager..."), stages, _(HelpTexts::load_resolvables));
try
{
Modified: branches/tmp/dmacvicar/zc10/pkg-bindings/src/Utils.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/Utils.cc (original)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/Utils.cc Wed May 11 11:22:32 2011
@@ -15,3 +15,4 @@
return ret;
}
+
Added: branches/tmp/dmacvicar/zc10/pkg-bindings/src/i18n.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/pkg-bindin…
==============================================================================
--- branches/tmp/dmacvicar/zc10/pkg-bindings/src/i18n.h (added)
+++ branches/tmp/dmacvicar/zc10/pkg-bindings/src/i18n.h Wed May 11 11:22:32 2011
@@ -0,0 +1,39 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 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: $Id$
+ Author: Ladislav Slezák <lslezak(a)novell.com>
+ Summary: definition of _() translation macro
+*/
+
+// textdomain
+extern "C" {
+#include <libintl.h>
+}
+
+// undefine _ macro from libzypp
+#ifdef _
+#undef _
+#endif
+
+// define new _ macro
+#define _(MSG) ::dgettext("pkg-bindings", MSG)
+
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0