Author: jsuchome
Date: Mon Nov 5 22:37:39 2007
New Revision: 41809
URL: http://svn.opensuse.org/viewcvs/yast?rev=41809&view=rev
Log:
- do not allow source types not supported by kiwi (#339110)
- 2.13.21
Added:
branches/SuSE-SLE-10-SP1-Branch/product-creator/src/SourceDialogsLite.ycp (with props)
Modified:
branches/SuSE-SLE-10-SP1-Branch/product-creator/VERSION
branches/SuSE-SLE-10-SP1-Branch/product-creator/package/yast2-product-creator.changes
branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Kiwi.ycp
branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Makefile.am
branches/SuSE-SLE-10-SP1-Branch/product-creator/src/kiwi_dialogs.ycp
Modified: branches/SuSE-SLE-10-SP1-Branch/product-creator/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/product-creator/VERSION?rev=41809&r1=41808&r2=41809&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/product-creator/VERSION (original)
+++ branches/SuSE-SLE-10-SP1-Branch/product-creator/VERSION Mon Nov 5 22:37:39 2007
@@ -1 +1 @@
-2.13.20
+2.13.21
Modified: branches/SuSE-SLE-10-SP1-Branch/product-creator/package/yast2-product-creator.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/product-creator/package/yast2-product-creator.changes?rev=41809&r1=41808&r2=41809&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/product-creator/package/yast2-product-creator.changes (original)
+++ branches/SuSE-SLE-10-SP1-Branch/product-creator/package/yast2-product-creator.changes Mon Nov 5 22:37:39 2007
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Mon Nov 5 21:56:21 CET 2007 - jsuchome@suse.cz
+
+- do not allow source types not supported by kiwi (#339110)
+- 2.13.21
+
+-------------------------------------------------------------------
Fri Nov 2 11:02:42 CET 2007 - jsuchome@suse.cz
- correctly escape strings which should be written to config.xml
Modified: branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Kiwi.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Kiwi.ycp?rev=41809&r1=41808&r2=41809&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Kiwi.ycp (original)
+++ branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Kiwi.ycp Mon Nov 5 22:37:39 2007
@@ -21,6 +21,7 @@
import "Report";
import "Security";
import "String";
+ import "URL";
string encryption_method = nil;
@@ -58,6 +59,11 @@
// map with image templates (to base new projects on)
global map Templates = $[];
+ // repository schemes unsupported by kiwi
+ // (= not to be offered as new sources, to be deleted
+ // from current system sources)
+ global list<string> unsupported_schemes = [ "iso", "cd", "dvd", "nfs", "smb" ];
+
/**
* crypt given user password with current encryption algorithm
*/
@@ -759,10 +765,14 @@
integer srcid = source["SrcId"]:-1;
map data = Pkg::SourceGeneralData (srcid);
string url = data["url"]:"";
- current_repositories[url] = $[
- "url" : url,
- "plaindir" : data["type"]:"" == "Plaindir"
- ];
+ map parsed = URL::Parse(url);
+ if (! contains (unsupported_schemes, parsed["scheme"]:""))
+ {
+ current_repositories[url] = $[
+ "url" : url,
+ "plaindir" : data["type"]:"" == "Plaindir"
+ ];
+ }
});
return current_repositories;
}
Modified: branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Makefile.am?rev=41809&r1=41808&r2=41809&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Makefile.am (original)
+++ branches/SuSE-SLE-10-SP1-Branch/product-creator/src/Makefile.am Mon Nov 5 22:37:39 2007
@@ -26,7 +26,8 @@
module_DATA = \
ProductCreator.ycp \
- Kiwi.ycp
+ Kiwi.ycp \
+ SourceDialogsLite.ycp
EXTRA_DIST = $(client_DATA) $(ynclude_DATA) $(module_DATA) $(desktop_DATA)
Added: branches/SuSE-SLE-10-SP1-Branch/product-creator/src/SourceDialogsLite.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP1-Branch/product-creator/src/SourceDialogsLite.ycp?rev=41809&view=auto
==============================================================================
--- branches/SuSE-SLE-10-SP1-Branch/product-creator/src/SourceDialogsLite.ycp (added)
+++ branches/SuSE-SLE-10-SP1-Branch/product-creator/src/SourceDialogsLite.ycp Mon Nov 5 22:37:39 2007
@@ -0,0 +1,1031 @@
+/**
+ * File: SourceDialogsLite.ycp
+ *
+ * Authors: Jiri Srain
+ * Klaus Kaempf
+ * Gabriele Strattner
+ * Stefan Schubert
+ * Cornelius Schumacher
+ *
+ * Purpose:
+ * Reduced version of SourceDialogs.ycp: removed the support for
+ * source types unsupported by kiwi (#339110)
+ *
+ * $Id$
+ */
+
+{
+textdomain "packager";
+
+module "SourceDialogsLite";
+
+import "Label";
+import "URL";
+import "Popup";
+import "CWM";
+import "SourceManager";
+
+// common functions / data
+
+/**
+ * URL to work with
+ */
+string _url = "";
+
+/**
+ * Allow HTTPS for next source dialog?
+ */
+boolean _allow_https = true;
+
+/**
+ * Help text suffix for some types of the medias
+ */
+string multi_cd_help = _("<p>If the catalog is on multiple medias,
+set the location of the first media of the set.</p>");
+
+/**
+ * Set the URL to work with
+ * @param url string URL to run the dialogs with
+ */
+global void SetURL (string url) {
+ _url = url;
+}
+
+/**
+ * Return URL after the run of the dialog
+ * @return string the URL
+ */
+global string GetURL () {
+ return _url;
+}
+
+/**
+ * Postprocess URL of an ISO image
+ * @param url string URL in the original form
+ * @return string postprocessed URL
+ */
+string PosprocessISOURL (string url) {
+ y2milestone ("Updating ISO URL %1", url);
+ integer last = findlastof (url, "/") + 1;
+ string onlydir = substring (url, 0, last);
+ url = "iso:/?iso=" + substring (url, last) + "&url=" + onlydir;
+ y2milestone ("Updated URL: %1", url);
+ return url;
+}
+
+/**
+ * Check if URL is an ISO URL
+ * @param url string URL to check
+ * @return boolean true if URL is an ISO URL, false otherwise
+ */
+boolean IsISOURL (string url) {
+ boolean ret = substring (url, 0, 5) == "iso:/" &&
+ issubstring (url, "&url=");
+ y2milestone ("URL %1 is ISO: %2", url, ret);
+ return ret;
+}
+
+/**
+ * Preprocess the ISO URL to be used in the dialogs
+ * @param url string URL to preprocess
+ * @return string preprocessed URL
+ */
+string PreprocessISOURL (string url) {
+ y2milestone ("Preprocessing ISO URL %1", url);
+ integer url_pt = search (url, "&url=");
+ string serverpart = substring (url, url_pt + 5);
+ string isopart = substring (url, 0, url_pt);
+ url = serverpart + substring (isopart, search (isopart, "iso=") + 4);
+ y2milestone ("Updated URL: %1", url);
+ return url;
+}
+
+/**
+ * check if given path points to ISO file
+ * @param url string URL to check
+ * @return boolean true if URL is ISO image
+ */
+boolean PathIsISO (string url) {
+ if (size (url) < 4) return false;
+ return substring (url, size (url) - 4, 4) == ".iso";
+}
+
+/**
+ * Add a slash to the part of url, if it is not already present
+ * @param urlpart string a part of the URL
+ * @return string urlpart with leading slash
+ */
+string Slashed (string urlpart) {
+ if ( substring( urlpart, 0, 1 ) == "/" )
+ return urlpart;
+ return "/" + urlpart;
+}
+
+/**
+ * Remove leading and trailing (and inner) spaces from the host name
+ * @param host string original host name
+ * @return string host without leading and trailing spaces
+ */
+string NormalizeHost (string host) {
+ host = deletechars (host, " \t");
+ return host;
+}
+
+/**
+ * Return an HBox with ok and cancel buttons for use by other dialogs.
+ * @return An HBox term for use in a CreateDialog call.
+ */
+term PopupButtons() {
+ return `HBox(
+ `PushButton( `id( `ok ), `opt( `default ), Label::OKButton() ),
+ `HStretch(),
+ `PushButton( `id( `cancel ), Label::CancelButton() )
+ );
+}
+
+/**
+ * Get scheme of a URL, also for ISO URL get scheme of the access protocol
+ * @param url string URL to get scheme for
+ * @return string URL scheme
+ */
+string URLScheme (string url) {
+ string scheme = "";
+ if (IsISOURL (url))
+ {
+ string tmp_url = PreprocessISOURL (url);
+ map parsed = URL::Parse (tmp_url);
+ scheme = parsed["scheme"]:"";
+ }
+ else
+ {
+ map parsed = URL::Parse (url);
+ scheme = parsed["scheme"]:"";
+ }
+
+ if (scheme == "" || scheme == nil)
+ scheme = "url";
+ y2milestone ("URL scheme for URL %1: %2", url, scheme);
+ return scheme;
+}
+
+// raw URL editation widget
+
+/**
+ * Init function of a widget
+ * @param key string widget key
+ */
+void PlainURLInit (string key) {
+ UI::ChangeWidget (`id (`url), `Value, _url);
+ UI::SetFocus (`url);
+}
+
+/**
+ * Store function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ */
+void PlainURLStore (string key, map event) {
+ _url = (string)UI::QueryWidget (`id (`url), `Value);
+}
+
+boolean PlainURLValidate (string key, map event) {
+ string url = (string)UI::QueryWidget (`id (`url), `Value);
+ if (url == "")
+ {
+ UI::SetFocus (`id (`url));
+ // popup message
+ Popup::Message (_("URL cannot be empty."));
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Get widget description map
+ * @return widget description map
+ */
+map PlainURLWidget () {
+ return $[
+ "widget" : `custom,
+ "custom_widget" : `VBox (
+ // text entry
+ `TextEntry( `id( `url ), _("&URL") )
+ ),
+ "init" : PlainURLInit,
+ "store" : PlainURLStore,
+ "validate_type" : `function,
+ "validate_function" : PlainURLValidate,
+ // help text
+ "help" : _("<p><big><b>Catalog URL</b></big><br>
+Use <b>URL</b> to specify the URL of the catalog.<p>") + multi_cd_help,
+ ];
+}
+
+// NFS editation widget
+
+/**
+ * Init function of a widget
+ * @param key string widget key
+ */
+void NFSInit (string key) {
+ boolean iso = IsISOURL (_url);
+ if (iso)
+ _url = PreprocessISOURL (_url);
+ map parsed = URL::Parse (_url);
+ UI::ChangeWidget (`id (`server), `Value, parsed["host"]:"");
+ UI::ChangeWidget (`id (`dir), `Value, parsed["path"]:"");
+ UI::SetFocus (`server);
+}
+
+/**
+ * Store function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ */
+void NFSStore (string key, map event) {
+ map parsed = $[
+ "scheme" : "nfs",
+ "host" : NormalizeHost (
+ (string)UI::QueryWidget (`id (`server), `Value)),
+ "path" : (string)UI::QueryWidget (`id (`dir), `Value),
+ ];
+ _url = URL::Build (parsed);
+}
+
+/**
+ * Get widget description map
+ * @return widget description map
+ */
+map NFSWidget () {
+ return $[
+ "widget" : `custom,
+ "custom_widget" : `VBox (
+ // text entry
+ `TextEntry (`id (`server), _("&Server Name")),
+ // text entry
+ `TextEntry (`id (`dir), _("&Path to Directory"))
+ ),
+ "init" : NFSInit,
+ "store" : NFSStore,
+ // help text
+ "help" : _("<p><big><b>NFS Server</b></big><br>
+Use <b>Server Name</b> and <b>Path to Directory</b>
+to specify the NFS server host name and path on the server.<p>")
++ multi_cd_help,
+ ];
+}
+
+// CD/DVD source widget
+
+/**
+ * Init function of a widget
+ * @param key string widget key
+ */
+void CDInit (string key) {
+ map parsed = URL::Parse (_url);
+ string scheme = parsed["scheme"]:"";
+ if (scheme == "dvd")
+ UI::ChangeWidget (`id (`cd), `Value, true);
+ else
+ UI::ChangeWidget (`id (`dvd), `Value, true);
+ UI::SetFocus (`cd);
+}
+
+/**
+ * Store function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ */
+void CDStore (string key, map event) {
+ symbol device = (symbol)UI::QueryWidget (`id (`device), `CurrentButton);
+ if (device == `cd)
+ _url = "cd:///";
+ else
+ _url = "dvd:///";
+}
+
+/**
+ * Get widget description map
+ * @return widget description map
+ */
+map CDWidget () {
+ return $[
+ "widget" : `custom,
+ "custom_widget" : `RadioButtonGroup (`id (`device), `VBox (
+ // radio button
+ `Left (`RadioButton (`id (`cd), _("&CD-ROM"))),
+ // radio button
+ `Left (`RadioButton (`id (`dvd ), _("&DVD-ROM")))
+ )),
+ "init" : CDInit,
+ "store" : CDStore,
+ "help" : _("<p><big><b>CD or DVD Media</b></big><br>
+Set <b>CD-ROM</b> or <b>DVD-ROM</b> to specify the type of media.</p>"),
+ ];
+}
+
+// File / Directory source widget
+
+/**
+ * Init function of a widget
+ * @param key string widget key
+ */
+void DirInit (string key) {
+ boolean iso = IsISOURL (_url);
+ if (iso)
+ _url = PreprocessISOURL (_url);
+ map parsed = URL::Parse (_url);
+ UI::ChangeWidget (`id (`dir), `Value, parsed["path"]:"");
+ UI::SetFocus (`dir);
+
+}
+
+/**
+ * Store function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ */
+void DirStore (string key, map event) {
+ map parsed = $[
+ "scheme" : "dir",
+ "path" : (string)UI::QueryWidget (`id (`dir), `Value),
+ ];
+ _url = URL::Build (parsed);
+
+ if (UI::WidgetExists(`id(`ch_iso)))
+ {
+ boolean iso = (boolean)UI::QueryWidget (`id (`ch_iso), `Value);
+ if (iso)
+ _url = PosprocessISOURL (_url);
+ }
+}
+
+/**
+ * Handle function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ * @return always nil
+ */
+symbol DirHandle (string key, map event) {
+
+ string dir = (string)UI::QueryWidget (`id (`dir), `Value);
+ string result =
+ // dialog caption
+ UI::AskForExistingDirectory (dir, _("Local Directory"));
+ if ( result != nil )
+ UI::ChangeWidget (`id (`dir), `Value, result);
+ return nil;
+}
+
+/**
+ * Get widget description map
+ * @return widget description map
+ */
+map DirWidget () {
+ return $[
+ "widget" : `custom,
+ "custom_widget" : `VBox(
+ `HBox(
+ // text entry
+ `TextEntry (`id (`dir), _("&Path to Directory")),
+ `VBox (
+ `Label (""),
+ // push button
+ `PushButton (`id (`browse), _("&Browse..."))
+ )
+ )
+ ),
+ "init" : DirInit,
+ "store" : DirStore,
+ "handle" : DirHandle,
+ "handle_events" : [ `browse ],
+ "help" : _("<p><big><b>Local Directory</b></big><br>
+Ise <b>Path to Directory</b> to specify the path to the
+directory of the installation media.</p>")
++ multi_cd_help,
+ ];
+
+}
+
+/**
+ * Store function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ */
+void PlainDirStore (string key, map event) {
+ map parsed = $[
+ "scheme" : "pkg",
+ "path" : (string)UI::QueryWidget (`id (`dir), `Value),
+ ];
+ _url = URL::Build (parsed);
+}
+/**
+ * Get widget description map
+ * @return widget description map
+ */
+map PlainDirWidget () {
+ return $[
+ "widget" : `custom,
+ "custom_widget" : `VBox(
+ `HBox(
+ // text entry
+ `TextEntry (`id (`dir), _("&Path to Directory")),
+ `VBox (
+ `Label (""),
+ // push button
+ `PushButton (`id (`browse), _("&Browse..."))
+ )
+ )
+ ),
+ "init" : DirInit,
+ "store" : PlainDirStore,
+ "handle" : DirHandle,
+ "handle_events" : [ `browse ],
+ "help" : _("<p><big><b>Local Directory</b></big><br>
+Use <b>Path to Directory</b> to specify the path to the
+directory holding RPM packages.</p>")
+ ];
+
+}
+
+// HTTP(s)/FTP/SMB/CIFS source widget
+
+/**
+ * Handle function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ * @return always nil
+ */
+symbol ServerHandle (string key, map event) {
+ y2debug("ServerHandle: %1, %2", key, event);
+ any id = event["ID"]:nil;
+ if (is (id, symbol)
+ && contains ([`http, `https, `ftp, `samba, `rb_type], (symbol)id))
+ {
+ symbol type = (symbol)UI::QueryWidget (`id (`rb_type), `CurrentButton);
+ string server = UI::WidgetExists (`id (`server))
+ ? (string)UI::QueryWidget (`id (`server), `Value)
+ : "";
+ string dir = UI::WidgetExists (`id (`dir))
+ ? (string)UI::QueryWidget (`id (`dir), `Value)
+ : "";
+ boolean anonymous = UI::WidgetExists (`id (`anonymous))
+ ? (boolean)UI::QueryWidget (`id (`anonymous), `Value)
+ : false;
+ string username = UI::WidgetExists (`id (`username))
+ ? (string)UI::QueryWidget (`id (`username), `Value)
+ : "";
+ string password = UI::WidgetExists (`id (`password))
+ ? (string)UI::QueryWidget (`id (`password), `Value)
+ : "";
+ term widget = `VBox (
+ // text entry
+ `TextEntry (`id (`server), _("Server &Name"), server),
+ type == `samba
+ // text entry
+ ? `TextEntry (`id (`share), _("&Share"))
+ : `Empty (),
+ type == `samba
+ ? `VBox (
+ `TextEntry (`id (`dir),
+ // text entry
+ _("&Path to Directory"), dir)
+ )
+ // text entry
+ : `TextEntry( `id( `dir ), _("&Directory on Server"), dir),
+ `HBox (
+ `HSpacing (0.5),
+ // frame
+ `Frame (_("Au&thentication"), `VBox (
+ `Left (`CheckBox (`id (`anonymous), `opt (`notify),
+ // check box
+ _("&Anonymous"), anonymous)),
+ // text entry
+ `TextEntry (`id (`username), _("&User Name"), username),
+ // password entry
+ `Password (`id (`password), _("&Password"), password)
+ )),
+ `HSpacing (0.5)
+ )
+ );
+ UI::ReplaceWidget (`id (`server_rp), widget);
+
+ // update widget status
+ UI::ChangeWidget (`id (`username), `Enabled, !anonymous);
+ UI::ChangeWidget (`id (`password), `Enabled, !anonymous);
+ return nil;
+ }
+ if (event["ID"]:nil == `anonymous)
+ {
+ boolean anonymous = (boolean)UI::QueryWidget (`id (`anonymous),
+ `Value);
+ UI::ChangeWidget (`id (`username), `Enabled, !anonymous);
+ UI::ChangeWidget (`id (`password), `Enabled, !anonymous);
+ return nil;
+ }
+}
+
+/**
+ * Init function of a widget
+ * @param key string widget key
+ */
+void ServerInit (string key) {
+ term protocol_box = `HBox (
+ `HStretch (),
+ // radio button
+ `RadioButton (`id (`ftp),`opt (`notify), _("&FTP")),
+ `HStretch(),
+ // radio button
+ `RadioButton (`id (`http),`opt (`notify), _("H&TTP")),
+ `HStretch()
+ );
+ if (_allow_https)
+ {
+ protocol_box = add (protocol_box,
+ // radio button
+ `RadioButton (`id (`https), `opt (`notify), _("HTT&PS"))
+ );
+ protocol_box = add (protocol_box, `HStretch ());
+ }
+ protocol_box = add (protocol_box, `HStretch ());
+ protocol_box = `RadioButtonGroup (`id (`rb_type), `opt (`notify),
+ protocol_box);
+ UI::ReplaceWidget (`id (`rb_type_rp), protocol_box);
+
+ boolean iso = IsISOURL (_url);
+ if (iso)
+ _url = PreprocessISOURL (_url);
+ map parsed = URL::Parse (_url);
+ symbol type = `ftp;
+ if ( parsed["scheme"]:"" == "http" )
+ type = `http;
+ else if ( parsed["scheme"]:"" == "https" )
+ type = `https;
+ UI::ChangeWidget (`id (`rb_type), `CurrentButton, type);
+ ServerHandle (key, $[ "ID" : `rb_type ]);
+
+ UI::ChangeWidget (`id (`server), `Value, parsed["host"]:"");
+ string dir = parsed["path"]:"";
+ UI::ChangeWidget (`id (`dir), `Value, dir);
+ UI::ChangeWidget (`id (`username), `Value, parsed["user"]:"");
+ UI::ChangeWidget (`id (`password), `Value, parsed["pass"]:"");
+ boolean anonymous = ! (parsed["user"]:"" != "" || parsed["pass"]:"" != "");
+ y2milestone ("Anonymous: %1", anonymous);
+ UI::ChangeWidget (`id (`anonymous), `Value, anonymous);
+ if (anonymous)
+ {
+ UI::ChangeWidget (`id (`username), `Enabled, false);
+ UI::ChangeWidget (`id (`password), `Enabled, false);
+ }
+}
+
+/**
+ * Store function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ */
+void ServerStore (string key, map event) {
+ y2debug("Server store: %1, %2", key, event);
+
+ symbol type = (symbol) UI::QueryWidget( `id( `rb_type), `CurrentButton );
+ map parsed = $[];
+ if ( type == `ftp )
+ parsed["scheme"] = "ftp";
+ else if ( type == `http )
+ parsed["scheme"] = "http";
+ else if ( type == `https )
+ parsed["scheme"] = "https";
+
+ boolean anonymous = (boolean)UI::QueryWidget (`id (`anonymous), `Value);
+ if ( !anonymous ) {
+ string user = (string)UI::QueryWidget (`id (`username), `Value);
+ string pass = (string)UI::QueryWidget (`id (`password ), `Value);
+ if (size (user) != 0)
+ parsed["user"] = user;
+ if (size (pass) != 0)
+ parsed["pass"] = pass;
+ }
+
+ string host = NormalizeHost((string)UI::QueryWidget (`id (`server), `Value));
+ string directory = (string)UI::QueryWidget (`id (`dir), `Value);
+
+ // is / in the host name?
+ integer pos = findfirstof(host, "/");
+ if (pos != nil)
+ {
+ // update the hostname and the directory,
+ // URL::Build return empty URL when the hostname is not valid
+ y2milestone("The hostname contains a path: %1", host);
+ string dir = substring(host, pos);
+
+ if (substring(dir, size(dir) - 1, 1) != "/" && substring(directory, 0, 1) != "/")
+ {
+ dir = dir + "/";
+ }
+
+ directory = dir + directory;
+ host = substring(host, 0, pos);
+
+ y2milestone("Updated hostname: %1, directory: %2", host, directory);
+ }
+
+ parsed["host"] = host;
+
+ if (type != `ftp)
+ // FTP needs to distinguish absolute and relative path
+ {
+ directory = Slashed (directory);
+ }
+ parsed["path"] = directory;
+ y2milestone("Entered URL: %1", parsed);
+ _url = URL::Build (parsed);
+ y2milestone("URL::Build: %1", _url);
+ if (UI::WidgetExists (`id (`ch_iso)))
+ {
+ boolean iso = (boolean)UI::QueryWidget (`id (`ch_iso), `Value);
+ if (iso)
+ _url = PosprocessISOURL (_url);
+ }
+}
+
+
+/**
+ * Get widget description map
+ * @return widget description map
+ */
+map ServerWidget () {
+ return $[
+ "widget" : `custom,
+ "custom_widget" : `VBox (
+ `HBox (
+ `HSpacing (0.5),
+ // frame
+ `Frame (_("P&rotocol"), `ReplacePoint (`id (`rb_type_rp),
+ `Empty ())
+ ),
+ `HSpacing( 0.5 )
+ ),
+ `ReplacePoint (`id (`server_rp), `Empty ())
+ ),
+ "init" : ServerInit,
+ "store" : ServerStore,
+ "handle" : ServerHandle,
+ "help" : _("<p><big><b>Server and Directory</b></big><br>
+Use <b>Server Name</b> and <b>Path to Directory</b>
+to specify the server host name and path on the server.
+To enable authentication, uncheck <b>Anonymous</b> and specify the
+<b>User Name</b> and the <b>Password</b>.
+</p>")
++ multi_cd_help,
+ ];
+}
+
+/**
+ * Checks whether some network is available in the current moment,
+ * see the bug #170147 for more information.
+ */
+boolean IsAnyNetworkAvailable () {
+ boolean ret = false;
+
+ string command = "TERM=dumb /sbin/ip -o address show | grep inet | grep -v scope.host";
+ y2milestone("Running %1", command);
+ map cmd_run = (map) SCR::Execute(.target.bash_output, command);
+ y2milestone("Command returned: %1", cmd_run);
+
+ // command failed
+ if (cmd_run["exit"]:-1 != 0) {
+ // some errors were there, we don't know the status, rather return that it's available
+ // `grep` also returns non zero exit code when there is nothing to do...
+ if (cmd_run["stdout"]:"" != "") {
+ y2error("Checking the network failed");
+ ret = true;
+ }
+ // some devices are listed
+ } else if (cmd_run["stdout"]:"" != nil && cmd_run["stdout"]:"" != "") {
+ ret = true;
+ }
+
+ return ret;
+}
+
+
+term SelectRadioWidget () {
+ term contents = `HBox (`HStretch (), `VBox (
+ `RadioButtonGroup (`id (`type), `VBox (
+ `VStretch (),
+ // radio button
+ `Left (`RadioButton(`id(`slp), _("&Scan Using SLP..."))),
+ // radio button
+ `Left (`RadioButton(`id(`ftp), _("&FTP..."))),
+ // radio button
+ `Left (`RadioButton(`id(`http), _("&HTTP..."))),
+ // radio button
+ `Left (`RadioButton(`id(`https), _("HTT&PS..."))),
+ // radio button
+ /*
+ `Left (`RadioButton(`id(`samba), _("&SMB/CIFS"))),
+ // radio button
+ `Left (`RadioButton(`id(`nfs), _("&NFS..."))),
+ // radio button
+ `Left (`RadioButton(`id(`cd), _("&CD..."))),
+ // radio button
+ `Left (`RadioButton(`id(`dvd), _("&DVD..."))),
+ */
+ // radio button
+ `Left (`RadioButton(`id(`local_dir), _("&Local Directory..."))),
+ // radio button
+ `Left (`RadioButton(`id(`pkg), _("&Package Directory..."))),
+ // radio button
+// `Left (`RadioButton (`id (`specify_url),_("Specify &URL..."))),
+ `VStretch ()
+ ))), `HStretch ()
+ );
+ if (! IsAnyNetworkAvailable()) {
+ y2milestone ("Network is not available, skipping all Network-related options...");
+
+ contents = `HBox (`HStretch (), `VBox (
+ `RadioButtonGroup (`id (`type), `VBox (
+ `VStretch (),
+ /*
+ // radio button
+ `Left (`RadioButton(`id(`cd), _("&CD..."))),
+ // radio button
+ `Left (`RadioButton(`id(`dvd), _("&DVD..."))),
+ */
+ // radio button
+ `Left (`RadioButton(`id(`local_dir), _("&Local Directory..."))),
+ // radio button
+ `Left (`RadioButton(`id(`pkg), _("&Package Directory..."))),
+ // radio button
+// `Left (`RadioButton (`id (`specify_url),_("Specify &URL..."))),
+ `VStretch ()
+ ))), `HStretch ()
+ );
+ } else {
+ y2milestone("Network is available, allowing Network-related options...");
+ }
+ return contents;
+}
+
+string SelectWidgetHelp () {
+ // help text
+ string help_text = _("<p><big><b>Catalog Media</b></big><br>
+The software catalog can be located on CD, on a network server,
+or on the hard disk.</p>");
+
+ // help, continued
+ help_text = help_text + _("<p>
+The product CDs can be copied to the hard disk.
+Insert the path where the first
+CD is located, for example, /data1/<b>CD1</b>.
+Only the base path is required if all CDs are copied
+into one directory.</p>
+");
+
+ // help, continued
+ help_text = help_text + _("<p>
+Network installation requires a working network connection.
+Specify the directory where the packages from
+the first CD are located, such as /data1/CD1.</p>
+");
+ return help_text;
+}
+
+boolean SelectValidate (string key, map event) {
+ symbol selected = (symbol)UI::QueryWidget (`id (`type), `CurrentButton);
+ if (selected == nil)
+ {
+ // error popup
+ Popup::Message (_("Select the media type."));
+ return false;
+ }
+ if (selected == `cd || selected == `dvd)
+ {
+ Pkg::SourceReleaseAll();
+ string msg = selected == `cd
+ ? _("Insert the add-on product CD")
+ : _("Insert the add-on product DVD");
+ if (! SourceManager::AskForCD (msg))
+ return false;
+ }
+ return true;
+}
+
+symbol SelectHandle (string key, map event) {
+ if (! (event["ID"]:nil == `next || event["ID"]:nil == `ok))
+ return nil;
+ symbol selected = (symbol)UI::QueryWidget (`id (`type), `CurrentButton);
+ if (selected == nil)
+ return nil;
+ if (selected == `slp || selected == `cd || selected == `dvd)
+ return `finish;
+}
+
+void SelectStore (string key, map event) {
+ _url = "";
+ symbol selected = (symbol)UI::QueryWidget (`id (`type), `CurrentButton);
+ if (contains ([`ftp, `http, `https, `samba, `nfs, `cd, `dvd,
+ `local_dir, `specify__url, `slp, `pkg], selected))
+ {
+ if ( selected == `ftp ) _url = "ftp://";
+ else if ( selected == `http ) _url = "http://";
+ else if ( selected == `https ) _url = "https://";
+ else if ( selected == `samba ) _url = "smb://";
+ else if ( selected == `nfs ) _url = "nfs://";
+ else if ( selected == `cd ) _url = "cd:///";
+ else if ( selected == `dvd ) _url = "dvd:///";
+ else if ( selected == `local_dir ) _url = "dir://";
+ else if ( selected == `pkg ) _url = "pkg://"; // hack for local PlainDir source
+ else if ( selected == `slp ) _url = "slp://";
+ }
+}
+
+map SelectWidget () {
+ return $[
+ "widget" : `func,
+ "widget_func" : SelectRadioWidget,
+ "help" : SelectWidgetHelp (),
+ "validate_type" : `function,
+ "validate_function" : SelectValidate,
+ "store" : SelectStore,
+ "handle" : SelectHandle,
+ ];
+}
+
+// general data
+
+/**
+ * Individual widgets
+ */
+map > _widgets = $[];
+
+/**
+ * Get individual widgets
+ * @return individual widgets
+ */
+map > Widgets () {
+ if (size (_widgets) == 0)
+ _widgets = $[
+ "url" : PlainURLWidget (),
+ "nfs" : NFSWidget (),
+ "cd" : CDWidget (),
+ "dvd" : CDWidget (),
+ "dir" : DirWidget (),
+ "file" : DirWidget (),
+ "pkg" : PlainDirWidget(),
+ "http" : ServerWidget (),
+ "https" : ServerWidget (),
+ "ftp" : ServerWidget (),
+ "smb" : ServerWidget (),
+ "cifs" : ServerWidget (),
+ "select" : SelectWidget (),
+ ];
+ return _widgets;
+}
+
+/**
+ * Captions for individual protocols
+ */
+map _caption = $[
+ // label / dialog caption
+ "url" : _("Catalog URL"),
+ // label / dialog caption
+ "nfs" : _("NFS Server"),
+ // label / dialog caption
+ "cd" : _("CD or DVD Media"),
+ // label / dialog caption
+ "dvd" : _("CD or DVD Media"),
+ // label / dialog caption
+ "dir" : _("Local Directory"),
+ // label / dialog caption
+ "file" : _("Local Directory"),
+ // label / dialog caption
+ "pkg" : _("Package Directory"),
+ // label / dialog caption
+ "http" : _("Server and Directory"),
+ // label / dialog caption
+ "https" : _("Server and Directory"),
+ // label / dialog caption
+ "ftp" : _("Server and Directory"),
+ // label / dialog caption
+ "smb" : _("Server and Directory"),
+ // label / dialog caption
+ "cifs" : _("Server and Directory"),
+];
+
+// general functions
+
+/**
+ * Get contents of a popup for specified protocol
+ * @param proto string protocol to display popup for
+ * @return term popup contents
+ */
+term PopupContents (string proto) {
+ return `VBox (
+ `HSpacing (50),
+ // label
+ `Label (_caption[proto]:""),
+ proto,
+ PopupButtons ()
+ );
+};
+
+/**
+ * URL editation popup with the HTTPS option
+ * @param url string url URL to edit
+ * @return string modified URL or empty string if canceled
+ */
+global string EditPopup (string url) {
+ SetURL (url);
+ string proto = URLScheme (url);
+ y2milestone ("Displaying popup for protocol %1", proto);
+
+ list