#include "Tools.h"
#include <zypp/PoolQuery.h>
-#include <zypp/target/rpm/librpmDb.h>
///////////////////////////////////////////////////////////////////
//static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
static const Pathname sysRoot( "/tmp/Local/ma/DNL-test" );
-//static const Pathname sysRoot( "/" );
///////////////////////////////////////////////////////////////////
bool rres = false;
{
//zypp::base::LogControl::TmpLineWriter shutUp;
- rres = getZYpp()->resolver()->resolvePool();
+ //rres = test.resolver().resolvePool();
}
if ( ! rres )
{
ERR << "resolve " << rres << endl;
- getZYpp()->resolver()->problems();
return false;
}
MIL << "resolve " << rres << endl;
return true;
}
-bool upgrade()
-{
- bool rres = false;
- {
- //zypp::base::LogControl::TmpLineWriter shutUp;
- Measure x( "Upgrade" );
- rres = getZYpp()->resolver()->doUpgrade();
- }
- if ( ! rres )
- {
- Measure x( "Upgrade Error" );
- ERR << "upgrade " << rres << endl;
- getZYpp()->resolver()->problems();
- return false;
- }
- MIL << "upgrade " << rres << endl;
- return true;
-}
-
-namespace zypp
-{
- namespace target
- {
- void writeUpgradeTestcase();
- }
-}
-
int main( int argc, char * argv[] )
try {
--argc;
INT << "===[START]==========================================" << endl;
ZConfig::instance();
TestSetup::LoadSystemAt( sysRoot );
- getZYpp()->initializeTarget( sysRoot );
///////////////////////////////////////////////////////////////////
ResPool pool( ResPool::instance() );
sat::Pool satpool( sat::Pool::instance() );
USR << "pool: " << pool << endl;
///////////////////////////////////////////////////////////////////
- if ( 1 )
- {
- getZYpp()->resolver()->addRequire( Capability("emacs") );
- solve();
- vdumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
- }
-
- {
- ZYppCommitPolicy policy;
- policy.downloadMode( DownloadOnly );
- //policy.dryRun( true );
-
- USR << policy << endl;
- ZYppCommitResult result( getZYpp()->commit( policy ) );
- USR << result << endl;
- }
+ getZYpp()->resolver()->addRequire( Capability("xteddy") );
+ solve();
+ vdumpPoolStats( USR << "Transacting:"<< endl,
+ make_filter_begin<resfilter::ByTransact>(pool),
+ make_filter_end<resfilter::ByTransact>(pool) ) << endl;
///////////////////////////////////////////////////////////////////
#include "zypp/base/String.h"
#include "zypp/ZConfig.h"
+
#include "zypp/ZYppCommitPolicy.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- std::ostream & operator<<( std::ostream & str, DownloadMode obj )
- {
- switch ( obj )
- {
-#define OUTS(VAL) case VAL: return str << #VAL; break
- OUTS( DownloadOnly );
- OUTS( DownloadInAdvance );
- OUTS( DownloadImHeaps );
- OUTS( DownloadAsNeeded );
-#undef OUTS
- }
- return str << "DownloadMode(" << int(obj) << ")";
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ZYppCommitPolicy::Impl
- //
- ///////////////////////////////////////////////////////////////////
-
- class ZYppCommitPolicy::Impl
- {
- public:
- Impl()
- : _restrictToMedia ( 0 )
- , _dryRun ( false )
- , _downloadMode ( DownloadAsNeeded )
- , _rpmInstFlags ( ZConfig::instance().rpmInstallFlags() )
- , _syncPoolAfterCommit ( true )
- {}
-
- public:
- unsigned _restrictToMedia;
- bool _dryRun;
- DownloadMode _downloadMode;
- target::rpm::RpmInstFlags _rpmInstFlags;
- bool _syncPoolAfterCommit;
-
- private:
- friend Impl * rwcowClone<Impl>( const Impl * rhs );
- /** clone for RWCOW_pointer */
- Impl * clone() const { return new Impl( *this ); }
- };
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ZYppCommitPolicy
- //
- ///////////////////////////////////////////////////////////////////
-
ZYppCommitPolicy::ZYppCommitPolicy()
- : _pimpl( new Impl )
+ : _restrictToMedia ( 0 )
+ , _dryRun ( false )
+ , _rpmInstFlags ( ZConfig::instance().rpmInstallFlags() )
+ , _syncPoolAfterCommit( true )
{}
-
- ZYppCommitPolicy & ZYppCommitPolicy::restrictToMedia( unsigned mediaNr_r )
- { _pimpl->_restrictToMedia = ( mediaNr_r == 1 ) ? 1 : 0; return *this; }
-
- unsigned ZYppCommitPolicy::restrictToMedia() const
- { return _pimpl->_restrictToMedia; }
-
-
- ZYppCommitPolicy & ZYppCommitPolicy::dryRun( bool yesNo_r )
- { _pimpl->_dryRun = yesNo_r; return *this; }
-
- bool ZYppCommitPolicy::dryRun() const
- { return _pimpl->_dryRun; }
-
-
- ZYppCommitPolicy & ZYppCommitPolicy::downloadMode( DownloadMode val_r )
- { _pimpl->_downloadMode = val_r; return *this; }
-
- DownloadMode ZYppCommitPolicy::downloadMode() const
- { return _pimpl->_downloadMode; }
-
-
- ZYppCommitPolicy & ZYppCommitPolicy::rpmInstFlags( target::rpm::RpmInstFlags newFlags_r )
- { _pimpl->_rpmInstFlags = newFlags_r; return *this; }
-
- ZYppCommitPolicy & ZYppCommitPolicy::rpmNoSignature( bool yesNo_r )
- { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_NOSIGNATURE, yesNo_r ); return *this; }
-
- ZYppCommitPolicy & ZYppCommitPolicy::rpmExcludeDocs( bool yesNo_r )
- { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS, yesNo_r ); return *this; }
-
- target::rpm::RpmInstFlags ZYppCommitPolicy::rpmInstFlags() const
- { return _pimpl->_rpmInstFlags; }
-
- bool ZYppCommitPolicy::rpmNoSignature() const
- { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_NOSIGNATURE ); }
-
- bool ZYppCommitPolicy::rpmExcludeDocs() const
- { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_EXCLUDEDOCS ); }
-
-
- ZYppCommitPolicy & ZYppCommitPolicy::syncPoolAfterCommit( bool yesNo_r )
- { _pimpl->_syncPoolAfterCommit = yesNo_r; return *this; }
-
- bool ZYppCommitPolicy::syncPoolAfterCommit() const
- { return _pimpl->_syncPoolAfterCommit; }
-
-
std::ostream & operator<<( std::ostream & str, const ZYppCommitPolicy & obj )
{
str << "CommitPolicy(";
str << " restrictToMedia:" << obj.restrictToMedia();
if ( obj.dryRun() )
str << " dryRun";
- str << " " << obj.downloadMode();
if ( obj.syncPoolAfterCommit() )
str << " syncPoolAfterCommit";
if ( obj.rpmInstFlags() )
#include <iosfwd>
-#include "zypp/base/PtrTypes.h"
-
#include "zypp/target/rpm/RpmFlags.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- /** Supported commit download policies. */
- enum DownloadMode
- {
- DownloadOnly, //!< Just download all packages to the local cache.
- //!< Do not install. Implies a dry-run.
- DownloadInAdvance, //!< First download all packages to the local cache.
- //!< Then start to install.
- DownloadImHeaps, //!< Similar to DownloadInAdvance, but try to split
- //!< the transaction into heaps, where at the end of
- //!< each heap a consistent system state is reached.
- DownloadAsNeeded //!< Alternating download and install. Packages are
- //!< cached just to avid CD/DVD hopping. This is the
- //!< traditional behaviour.
- };
-
- /** \relates DownloadMode Stream output. */
- std::ostream & operator<<( std::ostream & str, DownloadMode obj );
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ZYppCommitPolicy
/** */
class ZYppCommitPolicy
{
- public:
-
- ZYppCommitPolicy();
-
- public:
- /** Restrict commit to media 1.
- * Fake outstanding YCP fix: Honour restriction to media 1
- * at installation, but install all remaining packages if
- * post-boot (called with <tt>mediaNr_r > 1</tt>).
- */
- ZYppCommitPolicy & restrictToMedia( unsigned mediaNr_r );
-
- /** Process all media (default) */
- ZYppCommitPolicy & allMedia()
- { return restrictToMedia( 0 ); }
-
- unsigned restrictToMedia() const;
-
-
- /** Set dry run (default: false).
- * Dry-run should not change anything on the system, unless
- * the \ref downloadMode is set to \ref DownloadOnly. In that
- * case packages are downloaded to the local cache.
- */
- ZYppCommitPolicy & dryRun( bool yesNo_r );
+ public:
+ ZYppCommitPolicy();
- bool dryRun() const;
+ public:
+ unsigned restrictToMedia() const
+ { return _restrictToMedia; }
+ bool dryRun() const
+ { return _dryRun; }
- /** Commit download policy to use. (default: \ref DownloadAsNeeded)
- * \note \ref DownloadOnly also implies a \ref dryRun.
- */
- ZYppCommitPolicy & downloadMode( DownloadMode val_r );
+ target::rpm::RpmInstFlags rpmInstFlags() const
+ { return _rpmInstFlags; }
- DownloadMode downloadMode() const;
+ bool rpmNoSignature() const
+ { return _rpmInstFlags.testFlag( target::rpm::RPMINST_NOSIGNATURE ); }
+ bool rpmExcludeDocs() const
+ { return _rpmInstFlags.testFlag( target::rpm::RPMINST_EXCLUDEDOCS ); }
- /** The default \ref target::rpm::RpmInstFlags. (default: none)*/
- ZYppCommitPolicy & rpmInstFlags( target::rpm::RpmInstFlags newFlags_r );
- /** Use rpm option --nosignature (default: false) */
- ZYppCommitPolicy & rpmNoSignature( bool yesNo_r );
+ bool syncPoolAfterCommit() const
+ { return _syncPoolAfterCommit; }
- /** Use rpm option --excludedocs (default: false) */
- ZYppCommitPolicy & rpmExcludeDocs( bool yesNo_r );
+ public:
+ /** Restrict commit to media 1.
+ * Fake outstanding YCP fix: Honour restriction to media 1
+ * at installation, but install all remaining packages if
+ * post-boot (called with <tt>mediaNr_r > 1</tt>).
+ */
+ ZYppCommitPolicy & restrictToMedia( unsigned mediaNr_r )
+ { _restrictToMedia = ( mediaNr_r == 1 ) ? 1 : 0; return *this; }
- target::rpm::RpmInstFlags rpmInstFlags() const;
+ /** Process all media (default) */
+ ZYppCommitPolicy & allMedia()
+ { return restrictToMedia( 0 ); }
- bool rpmNoSignature() const;
+ /** Set dry run (default: false) */
+ ZYppCommitPolicy & dryRun( bool yesNo_r )
+ { _dryRun = yesNo_r; return *this; }
- bool rpmExcludeDocs() const;
+ /** The default \ref target::rpm::RpmInstFlags. (default: none)*/
+ ZYppCommitPolicy & rpmInstFlags( target::rpm::RpmInstFlags newFlags_r )
+ { _rpmInstFlags = newFlags_r; return *this; }
+ /** Use rpm option --nosignature (default: false) */
+ ZYppCommitPolicy & rpmNoSignature( bool yesNo_r )
+ { _rpmInstFlags.setFlag( target::rpm::RPMINST_NOSIGNATURE, yesNo_r ); return *this; }
- /** Kepp pool in sync with the Target databases after commit (default: true) */
- ZYppCommitPolicy & syncPoolAfterCommit( bool yesNo_r );
+ /** Use rpm option --excludedocs (default: false) */
+ ZYppCommitPolicy & rpmExcludeDocs( bool yesNo_r )
+ { _rpmInstFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS, yesNo_r ); return *this; }
- bool syncPoolAfterCommit() const;
+ /** Kepp pool in sync with the Target databases after commit (default: true) */
+ ZYppCommitPolicy & syncPoolAfterCommit( bool yesNo_r )
+ { _syncPoolAfterCommit = yesNo_r; return *this; }
- public:
- /** Implementation */
- class Impl;
- private:
- /** Pointer to data. */
- RWCOW_pointer<Impl> _pimpl;
+ private:
+ unsigned _restrictToMedia;
+ bool _dryRun;
+ target::rpm::RpmInstFlags _rpmInstFlags;
+ bool _syncPoolAfterCommit;
};
///////////////////////////////////////////////////////////////////
#include "zypp/parser/ProductFileReader.h"
#include "zypp/pool/GetResolvablesToInsDel.h"
+#include "zypp/solver/detail/Helper.h"
#include "zypp/solver/detail/Testcase.h"
#include "zypp/repo/DeltaCandidates.h"
RepoProvidePackage( repo::RepoMediaAccess &access, ResPool pool_r )
: _pool(pool_r), _access(access)
- {}
+ {
+
+ }
ManagedFile operator()( const PoolItem & pi )
{
ZYppCommitResult TargetImpl::commit( ResPool pool_r, const ZYppCommitPolicy & policy_rX )
{
// ----------------------------------------------------------------- //
- ZYppCommitPolicy policy_r( policy_rX );
-
// Fake outstanding YCP fix: Honour restriction to media 1
// at installation, but install all remaining packages if post-boot.
+ ZYppCommitPolicy policy_r( policy_rX );
if ( policy_r.restrictToMedia() > 1 )
policy_r.allMedia();
-
- // DownloadOnly implies dry-run.
- if ( policy_r.downloadMode() == DownloadOnly )
- policy_r.dryRun( true );
// ----------------------------------------------------------------- //
MIL << "TargetImpl::commit(<pool>, " << policy_r << ")" << endl;
///////////////////////////////////////////////////////////////////
if ( getZYpp()->resolver()->upgradeMode() )
{
- if ( ! policy_r.dryRun() )
- {
- writeUpgradeTestcase();
- }
- else
- {
- DBG << "dryRun: Not writing upgrade testcase." << endl;
- }
+ writeUpgradeTestcase();
}
///////////////////////////////////////////////////////////////////
// Store non-package data:
///////////////////////////////////////////////////////////////////
- if ( ! policy_r.dryRun() )
+ filesystem::assert_dir( home() );
+ // requested locales
+ _requestedLocalesFile.setLocales( pool_r.getRequestedLocales() );
+ // weak locks
{
- filesystem::assert_dir( home() );
- // requested locales
- _requestedLocalesFile.setLocales( pool_r.getRequestedLocales() );
- // weak locks
- {
- SoftLocksFile::Data newdata;
- pool_r.getActiveSoftLocks( newdata );
- _softLocksFile.setData( newdata );
- }
- // hard locks
- if ( ZConfig::instance().apply_locks_file() )
- {
- HardLocksFile::Data newdata;
- pool_r.getHardLockQueries( newdata );
- _hardLocksFile.setData( newdata );
- }
+ SoftLocksFile::Data newdata;
+ pool_r.getActiveSoftLocks( newdata );
+ _softLocksFile.setData( newdata );
}
- else
+ // hard locks
+ if ( ZConfig::instance().apply_locks_file() )
{
- DBG << "dryRun: Not stroring non-package data." << endl;
+ HardLocksFile::Data newdata;
+ pool_r.getHardLockQueries( newdata );
+ _hardLocksFile.setData( newdata );
}
///////////////////////////////////////////////////////////////////
- // Compute transaction:
+ // Process packages:
///////////////////////////////////////////////////////////////////
+ DBG << "commit log file is set to: " << HistoryLog::fname() << endl;
+
ZYppCommitResult result;
+
TargetImpl::PoolItemList to_uninstall;
TargetImpl::PoolItemList to_install;
TargetImpl::PoolItemList to_srcinstall;
-
{
+
pool::GetResolvablesToInsDel
collect( pool_r, policy_r.restrictToMedia() ? pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR
: pool::GetResolvablesToInsDel::ORDER_BY_SOURCE );
MIL << "GetResolvablesToInsDel: " << endl << collect << endl;
- to_uninstall.swap ( collect._toDelete );
- to_install.swap ( collect._toInstall );
+ to_uninstall.swap( collect._toDelete );
+ to_install.swap( collect._toInstall );
to_srcinstall.swap( collect._toSrcinstall );
}
if ( policy_r.restrictToMedia() )
{
MIL << "Restrict to media number " << policy_r.restrictToMedia() << endl;
+ }
+ ///////////////////////////////////////////////////////////////////
+ // First collect and display all messages
+ // associated with patches to be installed.
+ ///////////////////////////////////////////////////////////////////
+ for_( it, to_install.begin(), to_install.end() )
+ {
+ if ( ! isKind<Patch>(it->resolvable()) )
+ continue;
+ if ( ! it->status().isToBeInstalled() )
+ continue;
+
+ Patch::constPtr patch( asKind<Patch>(it->resolvable()) );
+ if ( ! patch->message().empty() )
+ {
+ MIL << "Show message for " << patch << endl;
+ callback::SendReport<target::PatchMessageReport> report;
+ if ( ! report->show( patch ) )
+ {
+ WAR << "commit aborted by the user" << endl;
+ ZYPP_THROW( TargetAbortedException( N_("Installation has been aborted as directed.") ) );
+ }
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ // Remove/install packages.
+ ///////////////////////////////////////////////////////////////////
+ commit ( to_uninstall, policy_r, pool_r );
+
+ if (policy_r.restrictToMedia() == 0)
+ { // commit all
+ result._remaining = commit( to_install, policy_r, pool_r );
+ result._srcremaining = commit( to_srcinstall, policy_r, pool_r );
+ }
+ else
+ {
TargetImpl::PoolItemList current_install;
TargetImpl::PoolItemList current_srcinstall;
// Collect until the 1st package from an unwanted media occurs.
// Further collection could violate install order.
bool hitUnwantedMedia = false;
- for ( TargetImpl::PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it )
+ for (TargetImpl::PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it)
{
ResObject::constPtr res( it->resolvable() );
}
}
+ TargetImpl::PoolItemList bad = commit( current_install, policy_r, pool_r );
+ result._remaining.insert(result._remaining.end(), bad.begin(), bad.end());
+
for (TargetImpl::PoolItemList::iterator it = to_srcinstall.begin(); it != to_srcinstall.end(); ++it)
{
Resolvable::constPtr res( it->resolvable() );
Package::constPtr pkg( asKind<Package>(res) );
- if ( pkg && policy_r.restrictToMedia() != pkg->mediaNr() ) // check medianr for packages only
+ if (pkg && policy_r.restrictToMedia() != pkg->mediaNr()) // check medianr for packages only
{
+ XXX << "Package " << *pkg << ", wrong media " << pkg->mediaNr() << endl;
result._srcremaining.push_back( *it );
}
else
current_srcinstall.push_back( *it );
}
}
-
- to_install.swap ( current_install );
- to_srcinstall.swap( current_srcinstall );
- }
-
- ///////////////////////////////////////////////////////////////////
- // First collect and display all messages
- // associated with patches to be installed.
- ///////////////////////////////////////////////////////////////////
- if ( ! policy_r.dryRun() )
- {
- for_( it, to_install.begin(), to_install.end() )
- {
- if ( ! isKind<Patch>(it->resolvable()) )
- continue;
- if ( ! it->status().isToBeInstalled() )
- continue;
-
- Patch::constPtr patch( asKind<Patch>(it->resolvable()) );
- if ( ! patch->message().empty() )
- {
- MIL << "Show message for " << patch << endl;
- callback::SendReport<target::PatchMessageReport> report;
- if ( ! report->show( patch ) )
- {
- WAR << "commit aborted by the user" << endl;
- ZYPP_THROW( TargetAbortedException( N_("Installation has been aborted as directed.") ) );
- }
- }
- }
- }
- else
- {
- DBG << "dryRun: Not checking patch messages." << endl;
- }
-
- ///////////////////////////////////////////////////////////////////
- // Remove/install packages.
- ///////////////////////////////////////////////////////////////////
-
- DBG << "commit log file is set to: " << HistoryLog::fname() << endl;
- {
- // somewhat uggly constraint: The iterator passed to the CommitPackageCache
- // must match begin and end of the install PoolItemList passed to commit.
- // For the download policies it's the easiest, if we have just a single
- // toInstall list. So we unify to_install and to_srcinstall. In case
- // of errors we have to split it up again. This will be cleaned up when
- // we introduce the new install order.
- TargetImpl::PoolItemList items( to_install );
- items.insert( items.end(), to_srcinstall.begin(), to_srcinstall.end() );
-
- // prepare the package cache according to the download options:
- repo::RepoMediaAccess access;
- RepoProvidePackage repoProvidePackage( access, pool_r );
- CommitPackageCache packageCache( items.begin(), items.end(),
- root() / "tmp", repoProvidePackage );
-
- commit ( to_uninstall, policy_r, packageCache );
- {
- TargetImpl::PoolItemList bad = commit( items, policy_r, packageCache );
- if ( ! bad.empty() )
- {
- for_( it, bad.begin(), bad.end() )
- {
- if ( isKind<SrcPackage>(it->resolvable()) )
- result._srcremaining.push_back( *it );
- else
- result._remaining.push_back( *it );
- }
- }
- }
+ bad = commit( current_srcinstall, policy_r, pool_r );
+ result._srcremaining.insert(result._srcremaining.end(), bad.begin(), bad.end());
}
///////////////////////////////////////////////////////////////////
// Try to rebuild solv file while rpm database is still in cache.
///////////////////////////////////////////////////////////////////
- if ( ! policy_r.dryRun() )
- {
- buildCache();
- }
+ buildCache();
result._result = (to_install.size() - result._remaining.size());
MIL << "TargetImpl::commit(<pool>, " << policy_r << ") returns: " << result << endl;
TargetImpl::PoolItemList
TargetImpl::commit( const TargetImpl::PoolItemList & items_r,
const ZYppCommitPolicy & policy_r,
- CommitPackageCache & packageCache_r )
+ const ResPool & pool_r )
{
+ TargetImpl::PoolItemList remaining;
+ repo::RepoMediaAccess access;
MIL << "TargetImpl::commit(<list>" << policy_r << ")" << items_r.size() << endl;
bool abort = false;
std::vector<sat::Solvable> successfullyInstalledPackages;
- TargetImpl::PoolItemList remaining;
+
+ // 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++ )
{
ManagedFile localfile;
try
{
- localfile = packageCache_r.get( it );
+ localfile = packageCache.get( it );
}
catch ( const AbortRequestException &e )
{
{ /////////////////////////////////////////////////////////////////
DEFINE_PTR_TYPE(TargetImpl);
- class CommitPackageCache;
///////////////////////////////////////////////////////////////////
//
}
/** Commit ordered changes
- * @param packageCache_r Access to the package provider
+ * @param pool_r only needed for #160792
* @return uncommitted ones (due to error)
*/
- PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r,
- CommitPackageCache & packageCache_r );
+ PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
/** Install a source package on the Target. */
void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );