Author: locilka
Date: Wed Jul 2 11:48:31 2008
New Revision: 48766
URL: http://svn.opensuse.org/viewcvs/yast?rev=48766&view=rev
Log:
Making really possible to use OneClickInstall
Documentation of functions
More public functions
Modified:
trunk/packager/src/modules/WebpinPackageSearch.ycp
Modified: trunk/packager/src/modules/WebpinPackageSearch.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/modules/WebpinPackageSearch.ycp?rev=48766&r1=48765&r2=48766&view=diff
==============================================================================
--- trunk/packager/src/modules/WebpinPackageSearch.ycp (original)
+++ trunk/packager/src/modules/WebpinPackageSearch.ycp Wed Jul 2 11:48:31 2008
@@ -27,10 +27,47 @@
string temporary_file = Directory::tmpdir + "/package_search_webpin.xml";
+/**
+ * Base search URL, default is "http://api.opensuse-community.org/searchservice/"
+ */
string base_url = "http://api.opensuse-community.org/searchservice/";
+/**
+ * Sets base search URL
+ * WARNING: Use this only if you know what you are doing!
+ *
+ * @param string new base_url
+ */
+global void SetBaseSearchURL (string new_base_url) {
+ if (new_base_url == "" || new_base_url == nil) {
+ y2error ("Wrong base URL: '%1'", new_base_url);
+ return;
+ }
+
+ base_url = new_base_url;
+ y2milestone ("New base URL has been set: %1", base_url);
+}
+
+/**
+ * Returns base search URL
+ *
+ * @string current base_url
+ */
+global string GetBaseSearchURL () {
+ return base_url;
+}
+
string already_guessed = nil;
+/**
+ * Guesses the current distribution installed
+ *
+ * @return string distribution (Webpin format)
+ *
+ * @examle
+ * // Installed openSUSE 11.0
+ * GuessCurrentDistribution() -> "openSUSE_110"
+ */
string GuessCurrentDistribution () {
if (already_guessed != nil)
return already_guessed;
@@ -46,15 +83,36 @@
return already_guessed;
}
+/**
+ * Changes the Webpin distro format to OneClickInstall format.
+ *
+ * @param string distro
+ * @return string modified distro
+ *
+ * @example
+ * ModifyDistro ("openSUSE_110") -> "openSUSE 11.0"
+ */
string ModifyDistro (string distro) {
- // FIXMEEEEEEEEEEEEEEE!!!!!!
- if (distro == "openSUSE_110") {
- distro = "openSUSE 11.0";
+ if (regexpmatch (distro, "^.*_[0123456789]+[0123456789]$")) {
+ distro = regexpsub (distro, "^(.*)_([0123456789]+)([0123456789])$", "\\1 \\2.\\3");
+ } else if (regexpmatch (distro, "^.*_[0123456789]+")) {
+ distro = regexpsub (distro, "^(.*)_([0123456789]+)$", "\\1 \\2");
+ } else {
+ y2warning ("'%1' doesn't match any known regexp", distro);
}
return distro;
}
+/**
+ * Writes XML configuration file for OnleClickInstall client.
+ *
+ * @param list <map> packages_to_install (in the same format as got from SearchForPackages function)
+ * @param string save_to_file
+ * @return boolean if successful
+ *
+ * @see SearchForPackages() for the format of <map> package_to_install
+ */
global boolean PrepareOneClickInstallDescription (list <map> packages_to_install, string save_to_file) {
if (FileUtils::Exists (save_to_file)) {
y2warning ("File %1 already exists, removing", save_to_file);
@@ -72,7 +130,7 @@
map packages = $[];
foreach (map one_package, packages_to_install, {
- distro = one_package["distro"]:"";
+ distro = one_package["distro"]:GuessCurrentDistribution();
repoURL = one_package["repoURL"]:"";
repositories[distro] = add (repositories[distro]:[], repoURL);
@@ -81,6 +139,7 @@
"item" : [$[
"name" : [$[ "content" : one_package["name"]:"" ]],
"summary" : [$[ "content" : one_package["summary"]:"" ]],
+ "description" : [$[ "content" : one_package["description"]:one_package["summary"]:_("No further information available.") ]],
]]
]);
});
@@ -88,10 +147,11 @@
foreach (string distro, list <string> distro_repos, (map