Author: lslezak
Date: Thu Dec 6 15:42:40 2007
New Revision: 42764
URL: http://svn.opensuse.org/viewcvs/yast?rev=42764&view=rev
Log:
- TargetInit - added global progress
- Resolvable.cc and Target.cc have been split
Added:
trunk/pkg-bindings/src/Resolvable_Install.cc
trunk/pkg-bindings/src/Resolvable_Patches.cc
trunk/pkg-bindings/src/Resolvable_Properties.cc
trunk/pkg-bindings/src/Target_DU.cc
- copied, changed from r42708, trunk/pkg-bindings/src/Target.cc
trunk/pkg-bindings/src/Target_Load.cc
- copied, changed from r42708, trunk/pkg-bindings/src/Target.cc
Removed:
trunk/pkg-bindings/src/Resolvable.cc
Modified:
trunk/pkg-bindings/src/Makefile.am
trunk/pkg-bindings/src/Source_Load.cc
trunk/pkg-bindings/src/Target.cc
Modified: trunk/pkg-bindings/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Makefile.am?rev=42764&r1=42763&r2=42764&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Makefile.am (original)
+++ trunk/pkg-bindings/src/Makefile.am Thu Dec 6 15:42:40 2007
@@ -28,9 +28,11 @@
PkgModuleFunctions_Register.cc \
Package.cc \
Patch.cc \
- Resolvable.cc \
+ Resolvable_Install.cc \
+ Resolvable_Patches.cc \
+ Resolvable_Properties.cc \
Selection.cc \
- Target.cc \
+ Target.cc Target_DU.cc Target_Load.cc \
Locale.cc \
Source_Callbacks.cc \
Source_Create.cc \
Added: trunk/pkg-bindings/src/Resolvable_Install.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Resolvable_Install.cc?rev=42764&view=auto
==============================================================================
--- trunk/pkg-bindings/src/Resolvable_Install.cc (added)
+++ trunk/pkg-bindings/src/Resolvable_Install.cc Thu Dec 6 15:42:40 2007
@@ -0,0 +1,285 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/*
+ File: $Id$
+ Author: Ladislav Slezák
+ Summary: Install or remove resolvables
+*/
+
+#include "PkgModuleFunctions.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+/**
+ @builtin ResolvableInstallArchVersion
+ @short Install all resolvables with selected name, architecture and kind. Use it only in a special case, ResolvableInstall() should be prefrerred.
+ @param name_r name of the resolvable, if empty ("") install all resolvables of the kind
+ @param kind_r kind of resolvable, can be `product, `patch, `package, `selection or `pattern
+ @param arch architecture of the resolvable
+ @param vers Required version of the resolvable, empty string means any version
+ @return boolean false if failed
+*/
+YCPValue
+PkgModuleFunctions::ResolvableInstallArchVersion( const YCPString& name_r, const YCPSymbol& kind_r, const YCPString& arch, const YCPString& vers )
+{
+ zypp::Resolvable::Kind kind;
+
+ std::string req_kind = kind_r->symbol ();
+
+ std::string arch_str = arch->value();
+ if (arch_str.empty())
+ return YCPBoolean (false);
+
+ // ensure installation of the required architecture
+ zypp::Arch architecture(arch_str);
+
+ if( req_kind == "product" ) {
+ kind = zypp::ResTraitszypp::Product::kind;
+ }
+ else if ( req_kind == "patch" ) {
+ kind = zypp::ResTraitszypp::Patch::kind;
+ }
+ else if ( req_kind == "package" ) {
+ kind = zypp::ResTraitszypp::Package::kind;
+ }
+ else if ( req_kind == "selection" ) {
+ kind = zypp::ResTraitszypp::Selection::kind;
+ }
+ else if ( req_kind == "pattern" ) {
+ kind = zypp::ResTraitszypp::Pattern::kind;
+ }
+ else
+ {
+ y2error("Pkg::ResolvableInstall: unknown symbol: %s", req_kind.c_str());
+ return YCPBoolean(false);
+ }
+
+ std::string version_str = vers->value();
+
+ return YCPBoolean(
+ (name_r->value().empty())
+ ? DoProvideAllKind(kind)
+ : DoProvideNameKind (name_r->value(), kind, architecture, version_str)
+ );
+}
+
+// ------------------------
+/**
+ @builtin ResolvableInstall
+ @short Install all resolvables with selected name and kind
+ @param name_r name of the resolvable, if empty ("") install all resolvables of the kind
+ @param kind_r kind of resolvable, can be `product, `patch, `package, `selection or `pattern
+ @return boolean false if failed
+*/
+YCPValue
+PkgModuleFunctions::ResolvableInstall( const YCPString& name_r, const YCPSymbol& kind_r )
+{
+ return ResolvableInstallArchVersion(name_r, kind_r, YCPString(zypp_ptr()->architecture().asString()), YCPString(""));
+}
+
+// ------------------------
+/**
+ @builtin ResolvableRemove
+ @short Removes all resolvables with selected name and kind
+ @param name_r name of the resolvable, if empty ("") remove all resolvables of the kind
+ @param kind_r kind of resolvable, can be `product, `patch, `package, `selection or `pattern
+ @return boolean false if failed
+*/
+YCPValue
+PkgModuleFunctions::ResolvableRemove ( const YCPString& name_r, const YCPSymbol& kind_r )
+{
+ zypp::Resolvable::Kind kind;
+
+ std::string req_kind = kind_r->symbol ();
+
+ if( req_kind == "product" ) {
+ kind = zypp::ResTraitszypp::Product::kind;
+ }
+ else if ( req_kind == "patch" ) {
+ kind = zypp::ResTraitszypp::Patch::kind;
+ }
+ else if ( req_kind == "package" ) {
+ kind = zypp::ResTraitszypp::Package::kind;
+ }
+ else if ( req_kind == "selection" ) {
+ kind = zypp::ResTraitszypp::Selection::kind;
+ }
+ else if ( req_kind == "pattern" ) {
+ kind = zypp::ResTraitszypp::Pattern::kind;
+ }
+ else
+ {
+ y2error("Pkg::ResolvableRemove: unknown symbol: %s", req_kind.c_str());
+ return YCPBoolean(false);
+ }
+
+ return YCPBoolean(
+ (name_r->value().empty())
+ ? DoRemoveAllKind(kind)
+ : DoRemoveNameKind (name_r->value(), kind)
+ );
+}
+
+// ------------------------
+/**
+ @builtin ResolvableNeutral
+ @short Remove all transactions from all resolvables with selected name and kind
+ @param name_r name of the resolvable, if empty ("") use all resolvables of the kind
+ @param kind_r kind of resolvable, can be `product, `patch, `package, `selection or `pattern
+ @param force_r remove the transactions even on USER level - default is APPL_HIGH (use true value only if really needed!)
+ @return boolean false if failed
+*/
+YCPValue
+PkgModuleFunctions::ResolvableNeutral ( const YCPString& name_r, const YCPSymbol& kind_r, const YCPBoolean& force_r )
+{
+ zypp::Resolvable::Kind kind;
+
+ std::string req_kind = kind_r->symbol();
+ std::string name = name_r->value();
+ bool force = force_r->value();
+
+ if( req_kind == "product" ) {
+ kind = zypp::ResTraitszypp::Product::kind;
+ }
+ else if ( req_kind == "patch" ) {
+ kind = zypp::ResTraitszypp::Patch::kind;
+ }
+ else if ( req_kind == "package" ) {
+ kind = zypp::ResTraitszypp::Package::kind;
+ }
+ else if ( req_kind == "selection" ) {
+ kind = zypp::ResTraitszypp::Selection::kind;
+ }
+ else if ( req_kind == "pattern" ) {
+ kind = zypp::ResTraitszypp::Pattern::kind;
+ }
+ else
+ {
+ y2error("Pkg::ResolvableNeutral: unknown symbol: %s", req_kind.c_str());
+ return YCPBoolean(false);
+ }
+
+ bool ret = true;
+
+ try
+ {
+ for (zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(kind);
+ it != zypp_ptr()->pool().byKindEnd(kind);
+ ++it)
+ {
+ if (name.empty() || (*it)->name() == name)
+ {
+ if (!it->status().resetTransact(whoWantsIt))
+ {
+ ret = false;
+ }
+
+ // force neutralization on the user level
+ if (force && !it->status().resetTransact(zypp::ResStatus::USER))
+ {
+ ret = false;
+ }
+ }
+ }
+ }
+ catch (...)
+ {
+ return YCPBoolean(false);
+ }
+
+ return YCPBoolean(ret);
+}
+
+// ------------------------
+/**
+ @builtin ResolvableSetSoftLock
+ @short Soft lock - it prevents the solver from re-selecting item
+ if it's recommended (if it's required it will be selected).
+ @param name_r name of the resolvable, if empty ("") use all resolvables of the kind
+ @param kind_r kind of resolvable, can be `product, `patch, `package, `selection or `pattern
+ @return boolean false if failed
+*/
+YCPValue
+PkgModuleFunctions::ResolvableSetSoftLock ( const YCPString& name_r, const YCPSymbol& kind_r )
+{
+ zypp::Resolvable::Kind kind;
+
+ std::string req_kind = kind_r->symbol();
+ std::string name = name_r->value();
+
+ if( req_kind == "product" ) {
+ kind = zypp::ResTraitszypp::Product::kind;
+ }
+ else if ( req_kind == "patch" ) {
+ kind = zypp::ResTraitszypp::Patch::kind;
+ }
+ else if ( req_kind == "package" ) {
+ kind = zypp::ResTraitszypp::Package::kind;
+ }
+ else if ( req_kind == "selection" ) {
+ kind = zypp::ResTraitszypp::Selection::kind;
+ }
+ else if ( req_kind == "pattern" ) {
+ kind = zypp::ResTraitszypp::Pattern::kind;
+ }
+ else
+ {
+ y2error("Pkg::ResolvableSetSoftLock: unknown symbol: %s", req_kind.c_str());
+ return YCPBoolean(false);
+ }
+
+ bool ret = true;
+
+ try
+ {
+ for (zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(kind);
+ it != zypp_ptr()->pool().byKindEnd(kind);
+ ++it)
+ {
+ if (name.empty() || (*it)->name() == name)
+ {
+ if (!it->status().setSoftLock(whoWantsIt))
+ {
+ ret = false;
+ }
+ }
+ }
+ }
+ catch (...)
+ {
+ return YCPBoolean(false);
+ }
+
+ return YCPBoolean(ret);
+}
+
Added: trunk/pkg-bindings/src/Resolvable_Patches.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Resolvable_Patches.cc?rev=42764&view=auto
==============================================================================
--- trunk/pkg-bindings/src/Resolvable_Patches.cc (added)
+++ trunk/pkg-bindings/src/Resolvable_Patches.cc Thu Dec 6 15:42:40 2007
@@ -0,0 +1,160 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/*
+ File: $Id$
+ Author: Ladislav Slezák
+ Summary: Patch related functions
+*/
+
+#include "PkgModuleFunctions.h"
+
+#include <sstream>
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+/**
+ @builtin ResolvableCountPatches
+ @short Count patches which will be selected by ResolvablePreselectPatches() function
+ @description
+ Only non-optional patches are selected (even when `all parameter is passed!)
+ @param kind_r kind of preselected patches, can be `all, `interactive, `reboot_needed or `affects_pkg_manager
+ @return integer number of preselected patches
+*/
+YCPValue
+PkgModuleFunctions::ResolvableCountPatches (const YCPSymbol& kind_r)
+{
+ // only count the patches
+ return ResolvableSetPatches(kind_r, false);
+}
+
+/**
+ @builtin ResolvablePreselectPatches
+ @short Preselect patches for auto online update during the installation
+ @description
+ Only non-optional patches are selected (even when `all parameter is passed!)
+ @param kind_r kind of preselected patches, can be `all, `interactive, `reboot_needed or `affects_pkg_manager
+ @return integer number of preselected patches
+*/
+YCPValue
+PkgModuleFunctions::ResolvablePreselectPatches (const YCPSymbol& kind_r)
+{
+ // preselect the patches
+ return ResolvableSetPatches(kind_r, true);
+}
+
+// helper function
+YCPValue
+PkgModuleFunctions::ResolvableSetPatches (const YCPSymbol& kind_r, bool preselect)
+{
+ long long selected_patches = 0LL;
+ std::string kind = kind_r->symbol();
+
+ if (kind != "all" && kind != "interactive" && kind != "reboot_needed"
+ && kind != "affects_pkg_manager")
+ {
+ return YCPError("Pkg::ResolvablePreselectPatches: Wrong parameter '" + kind + "', use: `all, `interactive, `reboot_needed or `affects_pkg_manager", YCPInteger(0LL));
+ }
+
+ try
+ {
+ const zypp::ResPool & pool = zypp_ptr()->pool();
+
+ // pseudo code from
+ // http://svn.suse.de/trac/zypp/wiki/ZMD/YaST/update/yast
+
+ zypp::ResPool::const_iterator
+ b = pool.begin (),
+ e = pool.end (),
+ i;
+ for (i = b; i != e; ++i)
+ {
+ zypp::Patch::constPtr pch = zypp::asKindzypp::Patch(i->resolvable());
+
+ // is it a patch?
+ if (pch)
+ {
+ if (i->status().isNeeded()) // uninstalled
+ {
+ // dont auto-install optional patches
+ if (pch->category () != "optional")
+ {
+ if (kind == "all"
+ || (kind == "interactive" && pch->interactive())
+ || (kind == "affects_pkg_manager" && pch->affects_pkg_manager())
+ || (kind == "reboot_needed" && pch->reboot_needed())
+ )
+ {
+ if (!preselect)
+ {
+ selected_patches++;
+ }
+ else if (DoProvideNameKind(pch->name(), pch->kind(), pch->arch(),"",
+ true // only Needed patches
+ ))
+ // schedule for installation
+ // but take the best edition. Bug #206927
+ {
+ stringstream str;
+ str << *i << endl;
+ y2milestone( "Setting '%s' to transact", str.str().c_str() );
+ // selected successfully - increase the counter
+ selected_patches++;
+ }
+ }
+ else
+ {
+ y2milestone("Ignoring patch id: %s", pch->id().c_str());
+ }
+ }
+ else
+ {
+ y2milestone("Ignoring optional patch (id): %s", pch->id().c_str());
+ }
+ }
+ else
+ {
+ y2milestone("Patch %s is not applicable", pch->id().c_str());
+ }
+ }
+ }
+ }
+ catch (...)
+ {
+ y2error("An error occurred during patch selection.");
+ }
+
+ return YCPInteger(selected_patches);
+}
+
+
+
Added: trunk/pkg-bindings/src/Resolvable_Properties.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Resolvable_Properties.cc?rev=42764&view=auto
==============================================================================
--- trunk/pkg-bindings/src/Resolvable_Properties.cc (added)
+++ trunk/pkg-bindings/src/Resolvable_Properties.cc Thu Dec 6 15:42:40 2007
@@ -0,0 +1,414 @@
+/* ------------------------------------------------------------------------------
+ * Copyright (c) 2007 Novell, Inc. All Rights Reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of version 2 of the GNU General Public License as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may find
+ * current contact information at www.novell.com.
+ * ------------------------------------------------------------------------------
+ */
+
+/*
+ File: $Id$
+ Author: Ladislav Slezák
+ Summary: Resolvable properties
+*/
+
+#include "PkgModuleFunctions.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/**
+ @builtin ResolvableProperties
+
+ @short Return properties of resolvable
+ @description
+ return list of resolvables of selected kind with required name
+
+ @param name name of the resolvable, if empty returns all resolvables of the kind
+ @param kind_r kind of resolvable, can be `product, `patch, `package, `selection, `pattern or `language
+ @param version version of the resolvable, if empty all versions are returned
+
+ @return list