[yast-commit] r40636 - in /trunk/pkg-bindings: VERSION package/yast2-pkg-bindings.changes src/Package.cc src/PkgModuleFunctions.h yast2-pkg-bindings.spec.in
Author: lslezak Date: Thu Aug 30 20:11:24 2007 New Revision: 40636 URL: http://svn.opensuse.org/viewcvs/yast?rev=40636&view=rev Log: - added new builtins PkgAvailable() and PkgInstalled() which work with package names (in contrast to IsAvailable() or IsProvided() which work with 'provides' property) (#299683,#302246) - 2.15.47 Modified: trunk/pkg-bindings/VERSION trunk/pkg-bindings/package/yast2-pkg-bindings.changes trunk/pkg-bindings/src/Package.cc trunk/pkg-bindings/src/PkgModuleFunctions.h trunk/pkg-bindings/yast2-pkg-bindings.spec.in Modified: trunk/pkg-bindings/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/VERSION?rev=40636&r1=40635&r2=40636&view=diff ============================================================================== --- trunk/pkg-bindings/VERSION (original) +++ trunk/pkg-bindings/VERSION Thu Aug 30 20:11:24 2007 @@ -1 +1 @@ -2.15.46 +2.15.47 Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=40636&r1=40635&r2=40636&view=diff ============================================================================== --- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original) +++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Thu Aug 30 20:11:24 2007 @@ -6,6 +6,10 @@ - preliminary fix for source redirection (compile fix only) (#294481) - report errors when adding a new repository (#306272) +- added new builtins PkgAvailable() and PkgInstalled() which work + with package names (in contrast to IsAvailable() or IsProvided() + which work with 'provides' property) (#299683,#302246) +- 2.15.47 ------------------------------------------------------------------- Wed Aug 29 09:36:00 CEST 2007 - lslezak@suse.cz Modified: trunk/pkg-bindings/src/Package.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Package.cc?rev=40636&r1=40635&r2=40636&view=diff ============================================================================== --- trunk/pkg-bindings/src/Package.cc (original) +++ trunk/pkg-bindings/src/Package.cc Thu Aug 30 20:11:24 2007 @@ -526,6 +526,81 @@ return YCPBoolean( match.item ); } +YCPValue +PkgModuleFunctions::searchPackage(const YCPString &package, bool installed) +{ + bool found = false; + std::string pkg = package->value(); + + if (pkg.empty()) + { + y2warning("Pkg::%s: Package name is empty", installed ? "PkgInstalled" : "PkgAvailable"); + return YCPBoolean(false); + } + + try + { + for (zypp::ResPool::byName_iterator it = zypp_ptr()->pool().byNameBegin(pkg); + it != zypp_ptr()->pool().byNameEnd(pkg); + ++it) + { + zypp::Package::constPtr pkg = zypp::asKind<zypp::Package>( it->resolvable() ); + + if (pkg != NULL) + { + long long sid = logFindAlias(pkg->repository().info().alias()); + if ((installed && sid >= 0LL) || (!installed && sid < 0LL)) + { + found = true; + break; + } + } + } + } + catch (...) + { + } + + y2milestone("Package '%s' %s: %s", pkg.c_str(), installed ? "installed" : "available", found ? "true" : "false"); + + return YCPBoolean(found); +} + +/** + * @builtin PkgInstalled + * + * @short returns 'true' if the package is installed in the system + * @description + * tag can be a package name, a string from requires/provides + * or a file name (since a package implictly provides all its files) + * + * @param string package name of the package + * @return boolean + * @usage Pkg::PkgInstalled("glibc") -> true +*/ +YCPValue +PkgModuleFunctions::PkgInstalled(const YCPString& package) +{ + return searchPackage(package, true); +} + +// ------------------------ +/** + * @builtin PkgAvailable + * @short Check if package is available + * @description + * returns 'true' if the package is available on any of the currently + * active installation sources. (i.e. it is installable) + * + * @param string package name of the package + * @return boolean + * @usage Pkg::PkgInstalled("yast2") -> true +*/ +YCPValue +PkgModuleFunctions::PkgAvailable(const YCPString& package) +{ + return searchPackage(package, false); +} struct ProvideProcess { Modified: trunk/pkg-bindings/src/PkgModuleFunctions.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgModuleFunctions.h?rev=40636&r1=40635&r2=40636&view=diff ============================================================================== --- trunk/pkg-bindings/src/PkgModuleFunctions.h (original) +++ trunk/pkg-bindings/src/PkgModuleFunctions.h Thu Aug 30 20:11:24 2007 @@ -181,6 +181,8 @@ // convert Exception to string represenatation std::string ExceptionAsString(const zypp::Exception &e); + YCPValue searchPackage(const YCPString &package, bool installed); + private: /** @@ -566,9 +568,13 @@ /* TYPEINFO: boolean(string)*/ YCPValue IsProvided (const YCPString& tag); /* TYPEINFO: boolean(string)*/ + YCPValue PkgInstalled(const YCPString& package); + /* TYPEINFO: boolean(string)*/ YCPValue IsSelected (const YCPString& tag); /* TYPEINFO: boolean(string)*/ YCPValue IsAvailable (const YCPString& tag); + /* TYPEINFO: boolean(string)*/ + YCPValue PkgAvailable(const YCPString& package); /* TYPEINFO: map<string,any>(list<string>)*/ YCPValue DoProvide (const YCPList& args); /* TYPEINFO: map<string,any>(list<string>)*/ Modified: trunk/pkg-bindings/yast2-pkg-bindings.spec.in URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/yast2-pkg-bindings.spec.in?rev=40636&r1=40635&r2=40636&view=diff ============================================================================== --- trunk/pkg-bindings/yast2-pkg-bindings.spec.in (original) +++ trunk/pkg-bindings/yast2-pkg-bindings.spec.in Thu Aug 30 20:11:24 2007 @@ -2,11 +2,11 @@ @HEADER@ BuildRequires: blocxx-devel docbook-xsl-stylesheets doxygen gcc-c++ libgcrypt-devel libxcrypt-devel libxslt perl-XML-Writer rpm-devel sgml-skel yast2-core-devel yast2-devtools boost boost-devel dbus-1-devel hal-devel -BuildRequires: libzypp-devel >= 3.13.11 -BuildRequires: libzypp >= 3.13.11 +BuildRequires: libzypp-devel >= 3.21.0 +BuildRequires: libzypp >= 3.21.0 -# new API (RepoManager instead of SourceManager) -Requires: libzypp >= 3.13.11 +# changed requestMedia callback +Requires: libzypp >= 3.21.0 Summary: - -- 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