Author: locilka
Date: Thu Oct 2 17:30:46 2008
New Revision: 51799
URL: http://svn.opensuse.org/viewcvs/yast?rev=51799&view=rev
Log:
- Added new PackagesProposal module which provides unified API for
YaST modules in installation that want to select resolvables for
installation (bnc #431580).
- 2.17.24
Added:
trunk/packager/src/modules/PackagesProposal.ycp
Modified:
trunk/packager/VERSION
trunk/packager/package/yast2-packager.changes
trunk/packager/src/modules/Packages.ycp
Modified: trunk/packager/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/VERSION?rev=51799&r1=51798&r2=51799&view=diff
==============================================================================
--- trunk/packager/VERSION (original)
+++ trunk/packager/VERSION Thu Oct 2 17:30:46 2008
@@ -1 +1 @@
-2.17.23
+2.17.24
Modified: trunk/packager/package/yast2-packager.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/package/yast2-packager.changes?rev=51799&r1=51798&r2=51799&view=diff
==============================================================================
--- trunk/packager/package/yast2-packager.changes (original)
+++ trunk/packager/package/yast2-packager.changes Thu Oct 2 17:30:46 2008
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Thu Oct 2 17:26:05 CEST 2008 - locilka@suse.cz
+
+- Added new PackagesProposal module which provides unified API for
+ YaST modules in installation that want to select resolvables for
+ installation (bnc #431580).
+- 2.17.24
+
+-------------------------------------------------------------------
Thu Oct 2 13:42:19 CEST 2008 - locilka@suse.cz
- Handling new tag in 'desktops' in control file:
Modified: trunk/packager/src/modules/Packages.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/modules/Packages.ycp?rev=51799&r1=51798&r2=51799&view=diff
==============================================================================
--- trunk/packager/src/modules/Packages.ycp (original)
+++ trunk/packager/src/modules/Packages.ycp Thu Oct 2 17:30:46 2008
@@ -40,6 +40,7 @@
import "PackageCallbacks";
import "Installation";
import "URL";
+import "PackagesProposal";
include "packager/load_release_notes.ycp";
@@ -589,11 +590,14 @@
/**
* Add a package to list to be selected before proposal
* Can be called only before the installation proposal, later doesn't
- * have any effect
+ * have any effect.
+ * OBSOLETE! Please, use PackagesProposal::AddResolvables() instead.
+ *
* @param package string package to be selected
*/
global void addAdditionalPackage(string package)
{
+ y2warning ("OBSOLETE! Please, use PackagesProposal::AddResolvables() instead");
additional_packages = add (additional_packages, package);
}
@@ -867,8 +871,14 @@
install_list = (list<string>) union (install_list, storage_packages);
}
+ if (size (additional_packages) > 0)
+ y2warning ("Additional packages are still in use, please, change it to use PackagesProposal API");
install_list = (list<string>) union (install_list, additional_packages);
+ // bnc #431580
+ // New API for packages selected by
+ install_list = (list<string>) union (install_list, PackagesProposal::GetAllResolvables (`package));
+
// Kernel is added in autoinstPackages () if autoinst is enabled
if (!Mode::update () || !Mode::autoinst ())
{
Added: trunk/packager/src/modules/PackagesProposal.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/modules/PackagesProposal.ycp?rev=51799&view=auto
==============================================================================
--- trunk/packager/src/modules/PackagesProposal.ycp (added)
+++ trunk/packager/src/modules/PackagesProposal.ycp Thu Oct 2 17:30:46 2008
@@ -0,0 +1,186 @@
+/**
+ * File: PackagesProposal.ycp
+ * Package: Packages installation
+ * Summary: API for selecting or de-selecting packages for installation
+ * Authors: Lukas Ocilka
+ *
+ * $Id$
+ */
+
+{
+ module "PackagesProposal";
+
+ textdomain "packager";
+
+ /**
+ * @struct $[
+ * "unique_ID" : $[
+ * `package : [ "list", "of", "packages", "to", "install" ],
+ * `pattern : [ "list", "of", "patterns", "to", "install" ],
+ * ]
+ * ]
+ */
+ map > resolvables_to_install = $[];
+
+ /**
+ * List of currently supported types of resolvables
+ */
+ list <symbol> supported_resolvables = [`package];
+
+ boolean IsSupportedResolvableType (symbol type) {
+ if (type == nil) {
+ y2error ("Wrong type: %1", type);
+ return false;
+ }
+
+ return contains (supported_resolvables, type);
+ }
+
+ /**
+ * Adds list of packages to pool that is then used by software proposal
+ * to propose a selection of resolvables to install.
+ *
+ * @param string unique_ID
+ * @param symbol resolvable type
+ * @param list <string> of resolvables to add for installation
+ * @return boolean whether successful
+ *
+ * @example
+ * AddResolvables ("y2_kdump", `package, ["yast2-kdump", "kdump"]) -> true
+ * // `not_supported is definitely not a supported resolvable
+ * AddResolvables ("test", `not_supported, ["bash"]) -> false
+ *
+ * @see supported_resolvables
+ * @see RemoveResolvables()
+ */
+ global boolean AddResolvables (string unique_ID, symbol type, list <string> resolvables) {
+ if (unique_ID == nil || unique_ID == "") {
+ y2error ("Unique ID cannot be: %1", unique_ID);
+ return false;
+ }
+
+ if (! IsSupportedResolvableType (type)) {
+ y2error ("Not a supported type: %1, supported are only: %2", type, supported_resolvables);
+ return false;
+ }
+
+ if (! haskey (resolvables_to_install, unique_ID)) {
+ y2debug ("Creating '%1' key in resolvables_to_install", unique_ID);
+ resolvables_to_install[unique_ID] = $[];
+ }
+
+ if (! haskey (resolvables_to_install[unique_ID]:$[], type)) {
+ y2debug ("Creating '%1' key in resolvables_to_install[%2]", type, unique_ID);
+ resolvables_to_install[unique_ID, type] = [];
+ }
+
+ y2milestone ("Adding resolvables %1 type %2 for %3", resolvables, type, unique_ID);
+ resolvables_to_install[unique_ID, type] =
+ (list <string>) union (resolvables_to_install[unique_ID, type]:[], resolvables);
+
+ return true;
+ }
+
+ /**
+ * Removes list of packages from pool that is then used by software proposal
+ * to propose a selection of resolvables to install.
+ *
+ * @param string unique_ID
+ * @param symbol resolvable type
+ * @param list <string> of resolvables to remove from list selected for installation
+ * @return boolean whether successful
+ *
+ * @example
+ * RemoveResolvables ("y2_kdump", `package, ["kdump"]) -> true
+ *
+ * @see supported_resolvables
+ * @see AddResolvables()
+ */
+ global boolean RemoveResolvables (string unique_ID, symbol type, list <string> resolvables) {
+ if (unique_ID == nil || unique_ID == "") {
+ y2error ("Unique ID cannot be: %1", unique_ID);
+ return false;
+ }
+
+ if (! IsSupportedResolvableType (type)) {
+ y2error ("Not a supported type: %1, supported are only: %2", type, supported_resolvables);
+ return false;
+ }
+
+ if (! haskey (resolvables_to_install, unique_ID)) {
+ y2debug ("Creating '%1' key in resolvables_to_install", unique_ID);
+ resolvables_to_install[unique_ID] = $[];
+ }
+
+ if (! haskey (resolvables_to_install[unique_ID]:$[], type)) {
+ y2debug ("Creating '%1' key in resolvables_to_install[%2]", type, unique_ID);
+ resolvables_to_install[unique_ID, type] = [];
+ }
+
+ y2milestone ("Removing resolvables %1 type %2 for %3", resolvables, type, unique_ID);
+ resolvables_to_install[unique_ID, type] = filter (string one_resolvable, resolvables_to_install[unique_ID, type]:[], {
+ return ! contains (resolvables, one_resolvable);
+ });
+ y2milestone ("Resolvables left: %1", resolvables_to_install[unique_ID, type]:[]);
+
+ return true;
+ }
+
+ /**
+ * Returns all resolvables selected for installation.
+ *
+ * @param string unique_ID
+ * @param symbol resolvable type
+ * @return list <string> of resolvables
+ *
+ * @example
+ * GetResolvables ("y2_kdump", `package) -> ["yast2-kdump", "kdump"]
+ */
+ global list <string> GetResolvables (string unique_ID, symbol type) {
+ if (unique_ID == nil || unique_ID == "") {
+ y2error ("Unique ID cannot be: %1", unique_ID);
+ return nil;
+ }
+
+ if (! IsSupportedResolvableType (type)) {
+ y2error ("Not a supported type: %1, supported are only: %2", type, supported_resolvables);
+ return nil;
+ }
+
+ return resolvables_to_install[unique_ID, type]:[];
+ }
+
+ global list <string> GetAllResolvables (symbol type) {
+ if (! IsSupportedResolvableType (type)) {
+ y2error ("Not a supported type: %1, supported are only: %2", type, supported_resolvables);
+ return nil;
+ }
+
+ list <string> ret = [];
+
+ foreach (string unique_ID, map resolvables, resolvables_to_install, {
+ if (haskey (resolvables, type)) {
+ ret = (list <string>) union (ret, resolvables[type]:[]);
+ }
+ });
+
+ return ret;
+ }
+
+ /**
+ * Return whether a unique ID is already in use.
+ *
+ * @param string unique_ID to check
+ * @return boolean whether the ID is not in use yet
+ */
+ global boolean IsUniqueID (string unique_ID) {
+ if (unique_ID == nil || unique_ID == "") {
+ y2error ("Unique ID cannot be: %1", unique_ID);
+ return nil;
+ }
+
+ return ! haskey (resolvables_to_install, unique_ID);
+ }
+
+/* EOF */
+}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org