Mailinglist Archive: yast-commit (126 mails)

< Previous Next >
[yast-commit] r67598 - in /branches/SuSE-Code-11-SP1-Branch/pkg-bindings: VERSION package/yast2-pkg-bindings.changes src/PkgFunctions.h src/Resolvable_Install.cc
Author: lslezak
Date: Thu Mar 8 13:36:38 2012
New Revision: 67598

URL: http://svn.opensuse.org/viewcvs/yast?rev=67598&view=rev
Log:
- added Pkg::ResolvableUpdate() to avoid downgrading resolvables
(bnc#751147)
- 2.17.45.6

Modified:
branches/SuSE-Code-11-SP1-Branch/pkg-bindings/VERSION

branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes
branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h
branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Install.cc

Modified: branches/SuSE-Code-11-SP1-Branch/pkg-bindings/VERSION
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bindings/VERSION?rev=67598&r1=67597&r2=67598&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/VERSION (original)
+++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/VERSION Thu Mar 8 13:36:38
2012
@@ -1 +1 @@
-2.17.45.5
+2.17.45.6

Modified:
branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes?rev=67598&r1=67597&r2=67598&view=diff
==============================================================================
---
branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes
(original)
+++
branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes
Thu Mar 8 13:36:38 2012
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Thu Mar 8 08:16:23 UTC 2012 - lslezak@xxxxxxx
+
+- added Pkg::ResolvableUpdate() to avoid downgrading resolvables
+ (bnc#751147)
+- 2.17.45.6
+
+-------------------------------------------------------------------
Thu Jan 26 11:50:25 UTC 2012 - lslezak@xxxxxxx

- fixed saving additional repositories added by registration

Modified: branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h?rev=67598&r1=67597&r2=67598&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h (original)
+++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h Thu Mar 8
13:36:38 2012
@@ -235,6 +235,17 @@

// a helper function to add or remove an upgrade repository
YCPValue AddRemoveUpgradeRepo(const YCPInteger &repo, bool add);
+
+ // action for a resolvable
+ enum ResolvableAction
+ {
+ Install,
+ Remove,
+ Update
+ };
+
+ // helper for installing/removing/upgrading a resolvable
+ bool ResolvableUpdateInstallOrDelete(const YCPString& name_r, const
YCPSymbol& kind_r, ResolvableAction action);

public:
// general
@@ -791,6 +802,8 @@
/* TYPEINFO: boolean(string,symbol,integer)*/
YCPValue ResolvableInstallRepo( const YCPString& name_r, const
YCPSymbol& kind_r, const YCPInteger& repo_r );
/* TYPEINFO: boolean(string,symbol)*/
+ YCPValue ResolvableUpdate( const YCPString& name_r, const YCPSymbol&
kind_r );
+ /* TYPEINFO: boolean(string,symbol)*/
YCPValue ResolvableRemove( const YCPString& name_r, const YCPSymbol&
kind_r );
/* TYPEINFO: boolean(string,symbol,boolean)*/
YCPValue ResolvableNeutral( const YCPString& name_r, const YCPSymbol&
kind_r, const YCPBoolean& force_r );

Modified:
branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Install.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Install.cc?rev=67598&r1=67597&r2=67598&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Install.cc
(original)
+++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Install.cc Thu
Mar 8 13:36:38 2012
@@ -236,7 +236,7 @@
return YCPBoolean(ret);
}

-bool ResolvableInstallOrDelete(const YCPString& name_r, const YCPSymbol&
kind_r, bool install)
+bool PkgFunctions::ResolvableUpdateInstallOrDelete(const YCPString& name_r,
const YCPSymbol& kind_r, ResolvableAction action)
{
zypp::Resolvable::Kind kind;

@@ -275,9 +275,68 @@

if (s)
{
- y2milestone("%s: %s:%s ", install ? "Installing" : "Removing",
req_kind.c_str(), name.c_str());
- return install ? s->setToInstall(zypp::ResStatus::APPL_HIGH):
- s->setToDelete(zypp::ResStatus::APPL_HIGH);
+ if (action == Install)
+ {
+ y2milestone("Installing %s %s ", req_kind.c_str(), name.c_str());
+ return s->setToInstall(zypp::ResStatus::APPL_HIGH);
+ }
+ else if (action == Remove)
+ {
+ y2milestone("Removing %s %s ", req_kind.c_str(), name.c_str());
+ return s->setToDelete(zypp::ResStatus::APPL_HIGH);
+ }
+ else if (action == Update)
+ {
+ y2milestone("Updating %s %s ", req_kind.c_str(), name.c_str());
+
+ // update candidate
+ zypp::PoolItem update = s->updateCandidateObj();
+
+ // installed version
+ zypp::PoolItem installed;
+ if (zypp::traits::isPseudoInstalled(s->kind()))
+ {
+ for_(it, s->availableBegin(), s->availableEnd())
+ // this is OK also for patches - isSatisfied() excludes
!isRelevant()
+ if (it->status().isSatisfied()
+ && (!installed || installed->edition() <
(*it)->edition()))
+ installed = *it;
+ }
+ else
+ {
+ installed = s->installedObj();
+ }
+
+ if (!installed)
+ {
+ y2milestone("%s is not installed, nothing to update",
name.c_str());
+ return false;
+ }
+
+ if (!update)
+ {
+ y2milestone("Update for %s is not available, no change",
name.c_str());
+ return false;
+ }
+
+ if (update->edition() > installed->edition())
+ {
+ y2milestone("Updating %s from %s.%s to %s.%s", name.c_str(),
installed->edition().asString().c_str(),
+ installed->arch().asString().c_str(),
update->edition().asString().c_str(), update->arch().asString().c_str());
+ return update.status().setToBeInstalled(whoWantsIt);
+ }
+ else
+ {
+ y2milestone("%s %s: installed version (%s) is higher than
available update (%s), no change",
+ req_kind.c_str(), name.c_str(),
installed->edition().asString().c_str(), update->edition().asString().c_str());
+ return false;
+ }
+ }
+ else
+ {
+ y2internal("Unknown resolvable action");
+ return false;
+ }
}
else
{
@@ -298,12 +357,27 @@
YCPValue
PkgFunctions::ResolvableInstall( const YCPString& name_r, const YCPSymbol&
kind_r )
{
- // true = install
- return YCPBoolean(ResolvableInstallOrDelete(name_r, kind_r, true));
+ return YCPBoolean(ResolvableUpdateInstallOrDelete(name_r, kind_r,
Install));
}

// ------------------------
/**
+ @builtin ResolvableUpgrade
+ @short Install all resolvables with selected name and kind
+ @param name_r name of the resolvable
+ @param kind_r kind of resolvable, can be `product, `patch, `package,
`srcpackage or `pattern
+ @return boolean true if upgrade candidate was selected, false if the
highest version is already installed or if there is no upgrade candidate
+ *
+*/
+YCPValue
+PkgFunctions::ResolvableUpdate( const YCPString& name_r, const YCPSymbol&
kind_r )
+{
+ return YCPBoolean(ResolvableUpdateInstallOrDelete(name_r, kind_r, Update));
+}
+
+
+// ------------------------
+/**
@builtin ResolvableRemove
@short Removes all resolvables with selected name and kind
@param name_r name of the resolvable
@@ -314,7 +388,7 @@
PkgFunctions::ResolvableRemove ( const YCPString& name_r, const YCPSymbol&
kind_r )
{
// false = remove
- return YCPBoolean(ResolvableInstallOrDelete(name_r, kind_r, false));
+ return YCPBoolean(ResolvableUpdateInstallOrDelete(name_r, kind_r, Remove));
}

// ------------------------

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages