From 892ff08f22541d9d8a9e333b834f8eedae9afb11 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Fri, 24 Oct 2008 14:10:31 +0000 Subject: [PATCH] - Provide the /etc/products.d enties filename as Product::referenceFilename. Use it to remove orphan products. (bnc #432932) - Fix media exception handling in commit (bnc #395704) --- VERSION.cmake | 4 +-- libzypp.spec.cmake | 2 +- package/libzypp.changes | 9 +++++++ zypp/Product.cc | 3 +++ zypp/Product.h | 5 ++++ zypp/sat/SolvAttr.cc | 1 + zypp/sat/SolvAttr.h | 1 + zypp/target/TargetImpl.cc | 65 ++++++++++++++++++++++++++++++++++------------- 8 files changed, 70 insertions(+), 20 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index 97ef450..79f4324 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -60,9 +60,9 @@ # SET(LIBZYPP_MAJOR "5") SET(LIBZYPP_COMPATMINOR "17") -SET(LIBZYPP_MINOR "17") +SET(LIBZYPP_MINOR "18") SET(LIBZYPP_PATCH "0") # -# LAST RELEASED: 5.17.0 (17) +# LAST RELEASED: 5.18.0 (17) # (The number in parenthesis is LIBZYPP_COMPATMINOR) #======= diff --git a/libzypp.spec.cmake b/libzypp.spec.cmake index 60882a2..0600c7c 100644 --- a/libzypp.spec.cmake +++ b/libzypp.spec.cmake @@ -25,7 +25,7 @@ Provides: yast2-packagemanager Obsoletes: yast2-packagemanager Recommends: logrotate BuildRequires: cmake -BuildRequires: libsatsolver-devel >= 0.12.0 openssl-devel +BuildRequires: libsatsolver-devel >= 0.12.1 openssl-devel BuildRequires: boost-devel curl-devel dejagnu doxygen gcc-c++ gettext-devel graphviz hal-devel libxml2-devel %if 0%{?suse_version} diff --git a/package/libzypp.changes b/package/libzypp.changes index 34f8dca..305d5e5 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Fri Oct 24 16:07:45 CEST 2008 - ma@suse.de + +- Provide the /etc/products.d enties filename as Product::referenceFilename. + Use it to remove orphan products. (bnc #432932) +- Fix media exception handling in commit (bnc #395704) +- revision 11485 +- version 5.18.0 (17) + +------------------------------------------------------------------- Fri Oct 24 10:29:19 CEST 2008 - schubi@suse.de - Taking "unlock" instead of setTransact(false) in the solutions (bnc #436923) diff --git a/zypp/Product.cc b/zypp/Product.cc index 3d09b4d..32f93a7 100644 --- a/zypp/Product.cc +++ b/zypp/Product.cc @@ -91,6 +91,9 @@ namespace zypp return sat::Solvable::noSolvable; } + std::string Product::referenceFilename() const + { return lookupStrAttribute( sat::SolvAttr::productReferenceFile ); } + Product::ReplacedProducts Product::replacedProducts() const { std::vector ret; diff --git a/zypp/Product.h b/zypp/Product.h index 093ed0a..1e1a9d7 100644 --- a/zypp/Product.h +++ b/zypp/Product.h @@ -43,6 +43,11 @@ namespace zypp */ sat::Solvable referencePackage() const; + /** For installed products the name of the coddesponding + * \c /etc/products.d entry. + .*/ + std::string referenceFilename() const; + public: /***/ typedef std::vector ReplacedProducts; diff --git a/zypp/sat/SolvAttr.cc b/zypp/sat/SolvAttr.cc index 41fb62f..d531acd 100644 --- a/zypp/sat/SolvAttr.cc +++ b/zypp/sat/SolvAttr.cc @@ -98,6 +98,7 @@ namespace sat const SolvAttr SolvAttr::extends ( SOLVABLE_EXTENDS ); // product + const SolvAttr SolvAttr::productReferenceFile ( PRODUCT_REFERENCEFILE ); const SolvAttr SolvAttr::productProductLine ( PRODUCT_PRODUCTLINE ); const SolvAttr SolvAttr::productShortlabel ( PRODUCT_SHORTLABEL ); const SolvAttr SolvAttr::productDistproduct ( PRODUCT_DISTPRODUCT ); diff --git a/zypp/sat/SolvAttr.h b/zypp/sat/SolvAttr.h index b16c5c3..31a14ed 100644 --- a/zypp/sat/SolvAttr.h +++ b/zypp/sat/SolvAttr.h @@ -127,6 +127,7 @@ namespace sat /** \name product */ //@{ + static const SolvAttr productReferenceFile; static const SolvAttr productProductLine; static const SolvAttr productShortlabel; static const SolvAttr productDistproduct; diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index e661606..7aff868 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -683,16 +683,16 @@ namespace zypp bool abort = false; std::vector successfullyInstalledPackages; - RepoProvidePackage repoProvidePackage( access, pool_r); // prepare the package cache. + RepoProvidePackage repoProvidePackage( access, pool_r ); CommitPackageCache packageCache( items_r.begin(), items_r.end(), root() / "tmp", repoProvidePackage ); - for (TargetImpl::PoolItemList::const_iterator it = items_r.begin(); it != items_r.end(); it++) + for ( TargetImpl::PoolItemList::const_iterator it = items_r.begin(); it != items_r.end(); it++ ) { - if (isKind(it->resolvable())) + if ( (*it)->isKind() ) { - Package::constPtr p = asKind(it->resolvable()); + Package::constPtr p = (*it)->asKind(); if (it->status().isToBeInstalled()) { ManagedFile localfile; @@ -706,15 +706,14 @@ namespace zypp WAR << "Skipping package " << p << " in commit" << endl; continue; } -#if 0 - // bnc #395704: missing catch causes abort. see if packageCache fails to handle - // errors correctly. catch ( const Exception &e ) { + // bnc #395704: missing catch causes abort. + // TODO see if packageCache fails to handle errors correctly. ZYPP_CAUGHT( e ); - SEC << e << endl; + INT << "Unexpected Error: Skipping package " << p << " in commit" << endl; + continue; } -#endif #warning Exception handling // create a installation progress report proxy @@ -813,15 +812,47 @@ namespace zypp progress.disconnect(); } } - else if (!policy_r.dryRun()) // other resolvables (non-Package) + else if ( ! policy_r.dryRun() ) // other resolvables (non-Package) { - if (it->buddy() == sat::Solvable()) - { - // Reset transaction only if this solvable has no buddy (Bug #417799) - // e.g. do not reset Products cause the concerning release package - // could not already be installed. - it->status().resetTransact( ResStatus::USER ); - } + // Status is changed as the buddy package buddy + // gets installed/deleted. Handle non-buddies only. + if ( ! it->buddy() ) + { + if ( (*it)->isKind() ) + { + Product::constPtr p = (*it)->asKind(); + if ( it->status().isToBeInstalled() ) + { + ERR << "Can't install orphan product without release-package! " << (*it) << endl; + } + else + { + // Deleting the corresponding product entry is all we con do. + // So the product will no longer be visible as installed. + std::string referenceFilename( p->referenceFilename() ); + if ( referenceFilename.empty() ) + { + ERR << "Can't remove orphan product without 'referenceFilename'! " << (*it) << endl; + } + else + { + PathInfo referenceFile( Pathname::assertprefix( _root, Pathname( "/etc/products.d" ) ) / referenceFilename ); + if ( ! referenceFile.isFile() || filesystem::unlink( referenceFile.path() ) != 0 ) + { + ERR << "Delete orphan product failed: " << referenceFile << endl; + } + } + } + } + else if ( (*it)->isKind() && it->status().isToBeInstalled() ) + { + // SrcPackage is install-only + SrcPackage::constPtr p = (*it)->asKind(); + installSrcPackage( p ); + } + + it->status().resetTransact( ResStatus::USER ); + } } // other resolvables } // for -- 2.7.4