[yast-commit] r60297 - in /branches/SuSE-Code-11-SP1-Branch/pkg-bindings: VERSION package/yast2-pkg-bindings.changes src/Resolvable_Properties.cc
Author: lslezak Date: Fri Jan 8 18:07:40 2010 New Revision: 60297 URL: http://svn.opensuse.org/viewcvs/yast?rev=60297&view=rev Log: - Pkg::ResolvableProperties() - return product file and it's upgrades section for `product resolvables (bnc#559554) - 2.17.43 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/Resolvable_Properties.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=60297&r1=60296&r2=60297&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/VERSION (original) +++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/VERSION Fri Jan 8 18:07:40 2010 @@ -1 +1 @@ -2.17.42 +2.17.43 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=60297&r1=60296&r2=60297&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 Fri Jan 8 18:07:40 2010 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Jan 8 13:00:43 UTC 2010 - lslezak@suse.cz + +- Pkg::ResolvableProperties() - return product file and it's + upgrades section for `product resolvables (bnc#559554) +- 2.17.43 + +------------------------------------------------------------------- Wed Jan 6 17:50:26 UTC 2010 - lslezak@suse.cz - Pkg::ResolvableProperties() - always return "transact_by" flag, Modified: branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Properties.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Properties.cc?rev=60297&r1=60296&r2=60297&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Properties.cc (original) +++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Resolvable_Properties.cc Fri Jan 8 18:07:40 2010 @@ -45,6 +45,8 @@ #include <zypp/Dep.h> #include <zypp/sat/LocaleSupport.h> +#include <zypp/parser/ProductFileReader.h> +#include <zypp/base/Regex.h> /** @builtin ResolvableProperties @@ -89,6 +91,13 @@ + "description" + "display_name" + "short_name" + + "product_file" -> string : product file (full file name with target root prefix) + + "upgrades" -> list<map> : parsed data from the product file (upgrades section) + + "name" -> string + + "summary" -> string + + "repository" -> string : URL path + + "notify" -> boolean + + "status" -> string `patch keys: + "interactive" + "reboot_needed" @@ -370,6 +379,75 @@ info->add(YCPString("replaces"), rep_prods); } + + std::string product_file; + + // add reference file in /etc/products.d + if (status.isInstalled()) + { + product_file = (_target_root + "/etc/products.d/" + product->referenceFilename()).asString(); + y2milestone("Parsing product file %s", product_file.c_str()); + const zypp::parser::ProductFileData productFileData = zypp::parser::ProductFileReader::scanFile(product_file); + + YCPList upgrade_list; + + for_( upit, productFileData.upgrades().begin(), productFileData.upgrades().end() ) + { + const zypp::parser::ProductFileData::Upgrade & upgrade( *upit ); + + YCPMap upgrades; + upgrades->add(YCPString("name"), YCPString(upgrade.name())); + upgrades->add(YCPString("summary"), YCPString(upgrade.summary())); + upgrades->add(YCPString("repository"), YCPString(upgrade.repository())); + upgrades->add(YCPString("notify"), YCPBoolean(upgrade.notify())); + upgrades->add(YCPString("status"), YCPString(upgrade.status())); + + upgrade_list->add(upgrades); + } + + info->add(YCPString("upgrades"), upgrade_list); + } + else + { + // get the package + zypp::sat::Solvable refsolvable = product->referencePackage(); + + if (refsolvable != zypp::sat::Solvable::noSolvable) + { + // create a package pointer from the SAT solvable + zypp::Package::Ptr refpkg(zypp::make<zypp::Package>(refsolvable)); + + if (refpkg) + { + // get the package files + zypp::Package::FileList files( refpkg->filelist() ); + y2milestone("The reference package has %d files", files.size()); + + zypp::str::smatch what; + const zypp::str::regex product_file_regex("^/etc/products\\.d/(.*\\.prod)$"); + + // find the product file + for_(iter, files.begin(), files.end()) + { + if (zypp::str::regex_match(*iter, what, product_file_regex)) + { + product_file = what[1]; + break; + } + } + } + } + } + + if (product_file.empty()) + { + y2warning("The product file has not been found"); + } + else + { + y2milestone("Found product file %s", product_file.c_str()); + info->add(YCPString("product_file"), YCPString(product_file)); + } } // pattern specific info else if ( req_kind == "pattern" ) { -- 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