[yast-commit] r39829 - in /trunk/installation: package/yast2-installation.changes src/clients/inst_extrasources.ycp
Author: lslezak Date: Tue Jul 31 11:37:40 2007 New Revision: 39829 URL: http://svn.opensuse.org/viewcvs/yast?rev=39829&view=rev Log: - inst_extrasources - register the extra repositories in content file automatically without asking user (#290040), do not download metadata from the extra sources (offline registration) (#290040, #288640) Modified: trunk/installation/package/yast2-installation.changes trunk/installation/src/clients/inst_extrasources.ycp Modified: trunk/installation/package/yast2-installation.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/installation/package/yast2-installation.changes?rev=39829&r1=39828&r2=39829&view=diff ============================================================================== --- trunk/installation/package/yast2-installation.changes (original) +++ trunk/installation/package/yast2-installation.changes Tue Jul 31 11:37:40 2007 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Tue Jul 31 11:29:53 CEST 2007 - lslezak@suse.cz + +- inst_extrasources - register the extra repositories in content + file automatically without asking user (#290040), do not download + metadata from the extra sources (offline registration) (#290040, + #288640) + +------------------------------------------------------------------- Mon Jul 30 12:38:31 CEST 2007 - locilka@suse.cz - Added inst_upgrade_urls client which offers URLs used on the Modified: trunk/installation/src/clients/inst_extrasources.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/installation/src/clients/inst_extrasources.ycp?rev=39829&r1=39828&r2=39829&view=diff ============================================================================== --- trunk/installation/src/clients/inst_extrasources.ycp (original) +++ trunk/installation/src/clients/inst_extrasources.ycp Tue Jul 31 11:37:40 2007 @@ -1,7 +1,7 @@ /** * File: clients/inst_extrasources.ycp * Package: yast2-installation - * Summary: Add extra installation sources from content file + * Summary: Automatically register software repositories from content file * Authors: Ladislav Slezák <lslezak@suse.cz> * * Assumptions: @@ -9,6 +9,8 @@ * (bugzilla #263289) * - the sources will be saved afterwards * (which means that running this client alone will not work) + * - the added sources are disabled by default and they are added + * in offline mode (no metadata is dowloaded) * * $Id$ */ @@ -18,177 +20,22 @@ textdomain "installation"; import "GetInstArgs"; -import "Popup"; import "SourceManager"; -import "Label"; import "Mode"; -import "String"; -import "Internet"; import "PackageLock"; -import "Installation"; - -// editUrl() -include "packager/inst_source_dialogs.ycp"; // the tag providing location of the additional sources in content file string content_file_tag = "EXTRAURLS"; string optional_tag = "OPTIONALURLS"; /** - * Show a confirmation dialog with list of the extra sources. - * @param urls list of URLs - * @return boolean true if the user wants to register the sources - */ -list<string> ConfirmExtraSources(map<string,boolean> urls) -{ - list<term> items = []; - - // display the enabled sources at the beginning of the list - foreach(string url, boolean deflt, urls, - { - if (deflt) - { - items = add(items, `item(`id(url), url, deflt)); - } - } - ); - - foreach(string url, boolean deflt, urls, - { - if (!deflt) - { - items = add(items, `item(`id(url), url, deflt)); - } - } - ); - - integer width = 76; - integer height = 8; - - term popup = `HBox( - `HSpacing(1), - `VBox( - `VSpacing(0.2), - // heading in a popup window - `Heading(_("Additional Repositories")), - `VSpacing(0.2), - `VBox( - `HSpacing(width), - `HBox( - `VSpacing(height), - // label - `MultiSelectionBox(`id(`multi), _("Repository to Register"), items) - ) - ), - `VSpacing(0.2), - // label - use more lines for the translated message (no more than about 60 characters per line) - `Label(_("Later you can install additional software from these external repositories.\nRegister the repository now?")), - `VSpacing(0.5), - `HBox( - `HStretch(), - `PushButton(`id(`yes), `opt(`default, `key_F10), Label::YesButton()), - `HSpacing(2), - `PushButton(`id(`no), `opt(`key_F9), Label::NoButton()), - `HStretch() - ), - `VSpacing(0.5) - ), - `HSpacing(1) - ); - - UI::OpenDialog(`opt(`decorated), popup); - - symbol ui = (symbol)UI::UserInput(); - y2milestone("Extra sources confirmed: %1", ui); - - list<string> selected_items = (list<string>) UI::QueryWidget(`id(`multi), `SelectedItems); - y2milestone("Selected items: %1", selected_items); - - UI::CloseDialog(); - - return (ui == `yes) ? selected_items : []; -} - -/** - * Temporarily start the network - * @return map The network status before starting - */ -define map<string,boolean> NetworkStart() -{ - // network connection status - boolean already_up = false; - - // flag: demand has been changed - boolean i_set_demand = false; - - if (!Mode::test()) - already_up = Internet::Status(); - - if (!already_up) - { - // label - text in a popup window, progress indicator - UI::OpenDialog(`opt(`decorated), `Label(_("Testing the Internet Connection..."))); - - // this code is from inst_you.ycp - if (!Internet::demand) - { - Internet::SetDemand (true); - i_set_demand = true; - } - - Internet::Start (""); - - integer i = 150; - while (i > 0) - { - if (!Internet::Status ()) - break; - - if (Internet::Connected ()) - break; - - // ping anything (www.suse.com) to trigger dod connections - // - // This ping should only set the network up, - // The IP now is different to the current www.suse.com's IP - // but it doesn't matter, what we need is just a network traffic. - SCR::Execute (.target.bash_background, - "/bin/ping -c 1 -w 1 213.95.15.200"); - - sleep (1000); - } - - UI::CloseDialog(); - } - - return $["already_up" : already_up, "i_set_demand" : i_set_demand]; -} - -/** - * Restore the network status - * @param original_status original status before starting the network - */ -define void NetworkStop(map<string,boolean> original_status) -{ - if (!original_status["already_up"]:false) - { - Internet::Stop(""); - - if (original_status["i_set_demand"]:false) - { - Internet::SetDemand(false); - } - } -} - -/** * Dowload and parse content files from current installation sources - * @param registered - * @return map Extra URLs for each source: $[ string source_url : list<string> extra_urls ] + * @param registered URLs of already registered repositories (they will be ignored to not register the same repository one more) + * @return list<string> Extra URLs to register */ -define map<string,boolean> GetExtraURLs(list<string> registered) +define list<string> GetExtraURLs(list<string> registered) { - map<string,boolean> extra_urls = $[]; + list<string> extra_urls = []; list<map> products = Pkg::ResolvableProperties("", `product, ""); y2milestone("Products: %1", products); @@ -206,7 +53,7 @@ // is the URL already registered? if (!contains(registered, url)) { - extra_urls = add(extra_urls, url, true); + extra_urls = add(extra_urls, url); } else { @@ -223,7 +70,7 @@ // is the URL already registered? if (!contains(registered, url)) { - extra_urls = add(extra_urls, url, false); + extra_urls = add(extra_urls, url); } else { @@ -241,45 +88,41 @@ } /** - * Register the installation sources + * Register the installation sources in offline mode (no network connection required). + * The repository metadata will be downloaded by sw_single (or another yast module) when the repostory is enabled * @param url_list list of the sources to register * @return list<integer> list of created source IDs */ -define list<integer> RegisterSources(list<string> url_list) +define list<integer> RegisterRepos(list<string> url_list) { list<integer> ret = []; + y2milestone("Repositories to register: %1", url_list); foreach(string new_url, url_list, { - boolean again = true; - while (again) + // map with repository parameters: $[ "enabled" : boolean, + // "autorefresh" : boolean, "name" : string, "alias" : string, + // "base_urls" : list<string>, "prod_dir" : string, "type" : string ] + map<string,any> repo_prop = $[]; + + // extra repos are disabled by default + repo_prop["enabled"] = false; + repo_prop["autorefresh"] = true; + repo_prop["name"] = new_url; + repo_prop["alias"] = new_url; + repo_prop["base_urls"] = [ new_url ]; + + integer new_repo_id = Pkg::RepositoryAdd(repo_prop); + + if (new_repo_id >= 0) { - integer srcid = Pkg::SourceCreate(new_url, "/"); - y2milestone ("Created source %1: %2", srcid, new_url); + y2milestone("Registered extra repository: %1: %2", new_repo_id, repo_prop); - if (srcid == -1) - { - // popup message - if (Popup::YesNo (_("An error occurred while creating the installation source.") + "\n" - // popup message - + _("Details:") + "\n" + Pkg::LastError() + "\n" + _("Try again?"))) - { - new_url = editUrl (new_url); - } - else - { - again = false; - } - } - else - { - // disable the source - Pkg::SourceSetEnabled(srcid, false); - - // remember the ID - ret = add (ret, srcid); - again = false; - } + ret = add(ret, new_repo_id); + } + else + { + y2error("Cannot register: %1", repo_prop); } } ); @@ -341,16 +184,6 @@ return `auto; } -// remember the original network status -map<string,boolean> net_config = NetworkStart(); - -if (!Internet::Connected()) -{ - y2warning("Cannot connect to the internet, skipping extra source configuration"); - NetworkStop(net_config); - return `auto; -} - // bugzilla #263289 if (! InitializePackager()) { y2error ("Cannot connect to the Packager"); @@ -360,33 +193,23 @@ list <string> already_registered = RegisteredUrls(); // $[ string url : boolean default ] -map<string,boolean> register_url = GetExtraURLs(already_registered); - +list<string> register_url = GetExtraURLs(already_registered); // any confirmed source to register? if (size(register_url) > 0) { - list<string> confirmed_sources = ConfirmExtraSources(register_url); - { - // register (create) the sources - list<integer> added_ids = RegisterSources(confirmed_sources); + // register (create) the sources + list<integer> added_ids = RegisterRepos(register_url); - // synchronize the sources if any source has been added - if (size(added_ids) > 0) - { - // reload (disable) the resolvables - Pkg::SourceLoad(); - - y2milestone ("syncing to zmd"); - boolean synced = SourceManager::SyncAddedAndDeleted (added_ids, []); - y2milestone ("sync status: %1", synced); - } + // synchronize the sources if any source has been added + if (size(added_ids) > 0) + { + y2milestone ("syncing to zmd"); + boolean synced = SourceManager::SyncAddedAndDeleted (added_ids, []); + y2milestone ("sync status: %1", synced); } } -// restore the network status -NetworkStop(net_config); - return `auto; /* EOF */ -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn.opensuse.org