Mailinglist Archive: yast-commit (815 mails)
| < Previous | Next > |
[yast-commit] r40588 - /trunk/metapackage/src/OneClickInstallWorker.ycp
- From: benjimanw@xxxxxxxxxxxxxxxx
- Date: Wed, 29 Aug 2007 14:14:34 -0000
- Message-id: <20070829141434.A2966BA5A7@xxxxxxxxxxxxxxxx>
Author: benjimanw
Date: Wed Aug 29 16:14:34 2007
New Revision: 40588
URL: http://svn.opensuse.org/viewcvs/yast?rev=40588&view=rev
Log:
Switch to using the new 10.3 repository adding API - allows for a fix of
bug #300974. Now de-dupes repositories on alias & name against name in
YMP before adding. Also adds repositories with correct name. N.B. This
commit breaks compatability with 10.2.
Modified:
trunk/metapackage/src/OneClickInstallWorker.ycp
Modified: trunk/metapackage/src/OneClickInstallWorker.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/metapackage/src/OneClickInstallWorker.ycp?rev=40588&r1=40587&r2=40588&view=diff
==============================================================================
--- trunk/metapackage/src/OneClickInstallWorker.ycp (original)
+++ trunk/metapackage/src/OneClickInstallWorker.ycp Wed Aug 29 16:14:34 2007
@@ -8,6 +8,13 @@
import "PackageCallbacks";
import "SourceManager";
import "Progress";
+
+ boolean FuzzyMatch(string one, string two)
+ {
+ string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ return (tolower(filterchars(one,chars)) == tolower(filterchars(two,chars)));
+ }
+
/**
** Check whether this repository is already subscribed
**/
@@ -15,21 +22,32 @@
{
list<integer> sources = Pkg::SourceStartCache(true);
- list<string> existingSources = [];
list<string> deduped = [];
- foreach (integer value, sources,
- {
- string url = Pkg::SourceMediaData(value)["url"]:"Error";
-
- existingSources = add(existingSources,url);
- });
- foreach(string new, url_list,
+ foreach (string new, url_list,
{
- if (!contains(existingSources,new))
+ boolean dupeFound = false;
+ foreach (integer srcid, sources,
{
+ map<string,any> repoData = Pkg::SourceGeneralData(srcid);
+ if (repoData["url"]:"" == new)
+ {
+ dupeFound = true;
+ break;
+ }
+ if (FuzzyMatch(repoData["name"]:"",OneClickInstall::GetRepositoryName(new)))
+ {
+ dupeFound = true;
+ break;
+ }
+ if (FuzzyMatch(repoData["alias"]:"",OneClickInstall::GetRepositoryName(new)))
+ {
+ dupeFound = true;
+ break;
+ }
+ });
+ if (!dupeFound)
deduped = add(deduped,new);
- }
});
return deduped;
@@ -48,8 +66,17 @@
boolean again = true;
while(again)
{
- integer srcid = Pkg::SourceCreate(new_url, "/");
- if (srcid == -1)
+ map<string,any> repoData =
+ $[
+ "enabled":true,
+ "autorefresh":true,
+ "name":OneClickInstall::GetRepositoryName(new_url),
+ "alias":OneClickInstall::GetRepositoryName(new_url),
+ "base_urls":[new_url]
+ ];
+ integer srcid = Pkg::RepositoryAdd(repoData);
+ boolean success = Pkg::SourceRefreshNow(srcid);
+ if (!success)
{
if (Popup::YesNo (_("An error occurred while creating the installation source.") + "\n" + _("Details:") + "\n" + Pkg::LastError() + "\n" + _("Try again?")))
{
@@ -65,11 +92,11 @@
else
{
sourceids = add(sourceids,srcid);
- // enable and save the source
- Pkg::SourceSetEnabled(srcid, true);
+ // save the repository
Pkg::SourceSaveAll();
again = false;
}
+
}
});
return true;
@@ -81,6 +108,7 @@
**/
boolean installPackages(list<string> packages)
{
+ Pkg::SourceLoad();
foreach (string name, packages,
{
if (!Pkg::PkgInstall(name))
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
Date: Wed Aug 29 16:14:34 2007
New Revision: 40588
URL: http://svn.opensuse.org/viewcvs/yast?rev=40588&view=rev
Log:
Switch to using the new 10.3 repository adding API - allows for a fix of
bug #300974. Now de-dupes repositories on alias & name against name in
YMP before adding. Also adds repositories with correct name. N.B. This
commit breaks compatability with 10.2.
Modified:
trunk/metapackage/src/OneClickInstallWorker.ycp
Modified: trunk/metapackage/src/OneClickInstallWorker.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/metapackage/src/OneClickInstallWorker.ycp?rev=40588&r1=40587&r2=40588&view=diff
==============================================================================
--- trunk/metapackage/src/OneClickInstallWorker.ycp (original)
+++ trunk/metapackage/src/OneClickInstallWorker.ycp Wed Aug 29 16:14:34 2007
@@ -8,6 +8,13 @@
import "PackageCallbacks";
import "SourceManager";
import "Progress";
+
+ boolean FuzzyMatch(string one, string two)
+ {
+ string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ return (tolower(filterchars(one,chars)) == tolower(filterchars(two,chars)));
+ }
+
/**
** Check whether this repository is already subscribed
**/
@@ -15,21 +22,32 @@
{
list<integer> sources = Pkg::SourceStartCache(true);
- list<string> existingSources = [];
list<string> deduped = [];
- foreach (integer value, sources,
- {
- string url = Pkg::SourceMediaData(value)["url"]:"Error";
-
- existingSources = add(existingSources,url);
- });
- foreach(string new, url_list,
+ foreach (string new, url_list,
{
- if (!contains(existingSources,new))
+ boolean dupeFound = false;
+ foreach (integer srcid, sources,
{
+ map<string,any> repoData = Pkg::SourceGeneralData(srcid);
+ if (repoData["url"]:"" == new)
+ {
+ dupeFound = true;
+ break;
+ }
+ if (FuzzyMatch(repoData["name"]:"",OneClickInstall::GetRepositoryName(new)))
+ {
+ dupeFound = true;
+ break;
+ }
+ if (FuzzyMatch(repoData["alias"]:"",OneClickInstall::GetRepositoryName(new)))
+ {
+ dupeFound = true;
+ break;
+ }
+ });
+ if (!dupeFound)
deduped = add(deduped,new);
- }
});
return deduped;
@@ -48,8 +66,17 @@
boolean again = true;
while(again)
{
- integer srcid = Pkg::SourceCreate(new_url, "/");
- if (srcid == -1)
+ map<string,any> repoData =
+ $[
+ "enabled":true,
+ "autorefresh":true,
+ "name":OneClickInstall::GetRepositoryName(new_url),
+ "alias":OneClickInstall::GetRepositoryName(new_url),
+ "base_urls":[new_url]
+ ];
+ integer srcid = Pkg::RepositoryAdd(repoData);
+ boolean success = Pkg::SourceRefreshNow(srcid);
+ if (!success)
{
if (Popup::YesNo (_("An error occurred while creating the installation source.") + "\n" + _("Details:") + "\n" + Pkg::LastError() + "\n" + _("Try again?")))
{
@@ -65,11 +92,11 @@
else
{
sourceids = add(sourceids,srcid);
- // enable and save the source
- Pkg::SourceSetEnabled(srcid, true);
+ // save the repository
Pkg::SourceSaveAll();
again = false;
}
+
}
});
return true;
@@ -81,6 +108,7 @@
**/
boolean installPackages(list<string> packages)
{
+ Pkg::SourceLoad();
foreach (string name, packages,
{
if (!Pkg::PkgInstall(name))
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
| < Previous | Next > |