UpgradeStatistics.h \
TranslatedText.h \
ZYpp.h \
+ ZYppCommit.h \
+ ZYppCommitPolicy.h \
ZYppCommitResult.h \
ZYppFactory.h \
ZYppCallbacks.h \
VendorAttr.cc \
UpgradeStatistics.cc \
ZYpp.cc \
+ ZYppCommitPolicy.cc \
+ ZYppCommitResult.cc \
TranslatedText.cc \
ZYppFactory.cc \
KeyRing.cc
#include <iosfwd>
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
#include "zypp/base/PtrTypes.h"
#include "zypp/base/Deprecated.h"
class RpmDb;
}
}
+ namespace zypp_detail
+ {
+ class ZYppImpl;
+ }
DEFINE_PTR_TYPE(Target);
/** All resolvables provided by the target. */
const ResStore & resolvables();
+
/** Null implementation */
static Target_Ptr nullimpl();
+
/** Refference to the RPM database */
target::rpm::RpmDb & rpmDb();
+
/** Commit changes in the pool
* \param medianr 0 = all/any media
* > 0 means only the given media number
*
* \todo Interface to commit should be ZYpp::commit( medianr ). This call
* should be removed from the targets public interface, as soon as ZYpp::Impl
- * is able to call Target::I,pl.
+ * is able to call Target::Impl.
*/
- int commit( ResPool pool_r, int medianr, PoolItemList & errors_r
- , PoolItemList & remaining_r, PoolItemList & srcremaining_r, bool dry_run = false ) ZYPP_DEPRECATED;
+ int commit( ResPool pool_r, int medianr,
+ PoolItemList & errors_r,
+ PoolItemList & remaining_r,
+ PoolItemList & srcremaining_r,
+ bool dry_run = false ) ZYPP_DEPRECATED;
- /** If the package is installed and provides the file
- Needed to evaluate split provides during Resolver::Upgrade() */
- bool providesFile (const std::string & name_str, const std::string & path_str) const;
+ /** If the package is installed and provides the file
+ Needed to evaluate split provides during Resolver::Upgrade() */
+ bool providesFile (const std::string & name_str, const std::string & path_str) const;
- ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
+ ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
- /** JUST FOR TESTSUITE */
- /** Sort according to prereqs and media numbers */
- void getResolvablesToInsDel ( const ResPool pool_r,
- PoolItemList & dellist_r,
- PoolItemList & instlist_r,
- PoolItemList & srclist_r ) const;
+ /** JUST FOR TESTSUITE */
+ /** Sort according to prereqs and media numbers
+ * \todo provide it as standalone algorithm
+ */
+ void getResolvablesToInsDel ( const ResPool pool_r,
+ PoolItemList & dellist_r,
+ PoolItemList & instlist_r,
+ PoolItemList & srclist_r ) const;
#ifndef STORAGE_DISABLED
/** enables the storage target */
std::ostream & dumpOn( std::ostream & str ) const;
private:
+ /** Direct access to Impl. */
+ friend class zypp_detail::ZYppImpl;
+
/** Pointer to implementation */
RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
static Target_Ptr _nullimpl;
-
- public:
};
///////////////////////////////////////////////////////////////////
void ZYpp::finishTarget()
{ _pimpl->finishTarget(); }
- ZYpp::CommitResult ZYpp::commit( int medianr_r, bool dry_run )
- { return _pimpl->commit( medianr_r, dry_run ); }
+ ZYppCommitResult ZYpp::commit( const ZYppCommitPolicy & policy_r )
+ { return _pimpl->commit( policy_r ); }
///////////////////////////////////////////////////////////////////
Arch ZYpp::architecture() const
{ return _pimpl->architecture(); }
+
void ZYpp::setArchitecture( const Arch & arch )
{ _pimpl->setArchitecture( arch ); }
Pathname ZYpp::homePath() const
{ return _pimpl->homePath(); }
+
void ZYpp::setHomePath( const Pathname & path )
{ _pimpl->setHomePath(path); }
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
#include "zypp/base/PtrTypes.h"
+
+#include "zypp/base/Deprecated.h"
+#include "zypp/ZYppCommit.h"
+
#include "zypp/Target.h"
#include "zypp/Resolver.h"
#include "zypp/KeyRing.h"
public:
- /** Result returned from ZYpp::commit. */
- struct CommitResult;
+ typedef ZYppCommitResult CommitResult;
/** Commit changes and transactions.
- * \param medianr 0 = all/any media
- * > 0 means only the given media number
+ * \param \ref CommitPolicy
* \return \ref CommitResult
* \throws Exception
*/
- CommitResult commit( int medianr_r, bool dry_run = false );
+ ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
+
+ ZYPP_DEPRECATED ZYppCommitResult commit( int medianr_r, bool dry_run = false )
+ {
+ ZYppCommitPolicy policy;
+ policy.restrictToMedia( medianr_r ).dryRun( dry_run );
+ return commit( policy );
+ }
+
public:
/** */
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ZYppCommit.h
+ *
+*/
+#ifndef ZYPP_ZYPPCOMMIT_H
+#define ZYPP_ZYPPCOMMIT_H
+
+#include <iosfwd>
+
+#include "zypp/ZYppCommitPolicy.h"
+#include "zypp/ZYppCommitResult.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_ZYPPCOMMIT_H
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ZYppCommitPolicy.cc
+ *
+*/
+
+#include <iostream>
+
+#include "zypp/ZYppCommitPolicy.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ std::ostream & operator<<( std::ostream & str, const ZYppCommitPolicy & obj )
+ {
+ str << "CommitPolicy(";
+ if ( obj.restrictToMedia() )
+ str << " restrictToMedia:" << obj.restrictToMedia();
+ if ( obj.dryRun() )
+ str << " dryRun" << obj.restrictToMedia();
+ return str << " )";
+ }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ZYppCommitPolicy.h
+ *
+*/
+#ifndef ZYPP_ZYPPCOMMITPOLICY_H
+#define ZYPP_ZYPPCOMMITPOLICY_H
+
+#include <iosfwd>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ZYppCommitPolicy
+ //
+ /** */
+ class ZYppCommitPolicy
+ {
+ public:
+ ZYppCommitPolicy()
+ : _restrictToMedia( 0 )
+ , _dryRun( false )
+ {}
+
+ public:
+ unsigned restrictToMedia() const
+ { return _restrictToMedia; }
+
+ bool dryRun() const
+ { return _dryRun; }
+
+ public:
+ /** Restrict commit to a certain media number
+ * \deprecated
+ */
+ ZYppCommitPolicy & restrictToMedia( unsigned mediaNr_r )
+ { _restrictToMedia = mediaNr_r; return *this; }
+
+ /** Process all media (default) */
+ ZYppCommitPolicy & allMedia()
+ { return restrictToMedia( 0 ); }
+
+ /** Set dry run (default: false) */
+ ZYppCommitPolicy & dryRun( bool yesNo_r = true )
+ { _dryRun = yesNo_r; return *this; }
+
+ private:
+ unsigned _restrictToMedia;
+ bool _dryRun;
+
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates ZYppCommitPolicy Stream output. */
+ std::ostream & operator<<( std::ostream & str, const ZYppCommitPolicy & obj );
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_ZYPPCOMMITPOLICY_H
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ZYppCommitResult.cc
+ *
+*/
+
+#include <iostream>
+
+#include "zypp/ZYppCommitResult.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ std::ostream & operator<<( std::ostream & str, const ZYppCommitResult & obj )
+ {
+ str << "CommitResult " << obj._result
+ << " (errors " << obj._errors.size()
+ << ", remaining " << obj._remaining.size()
+ << ", srcremaining " << obj._srcremaining.size()
+ << ")";
+ return str;
+ }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
#include <iosfwd>
#include <list>
-#include "zypp/ZYpp.h"
#include "zypp/PoolItem.h"
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//
- // CLASS NAME : ZYpp::CommitResult
+ // CLASS NAME : ZYppCommitResult
//
/** Result returned from ZYpp::commit.
* \see \ref ZYpp::commit
* \todo document fields.
*/
- struct ZYpp::CommitResult
+ struct ZYppCommitResult
{
- CommitResult()
- : _result(0)
- { }
+ ZYppCommitResult()
+ : _result(0)
+ {}
typedef std::list<PoolItem_Ref> PoolItemList;
};
///////////////////////////////////////////////////////////////////
+ /** \relates ZYppCommitResult Stream output. */
+ std::ostream & operator<<( std::ostream & str, const ZYppCommitResult & obj );
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
}
- int TargetImpl::commit( ResPool pool_r, unsigned int medianr,
- TargetImpl::PoolItemList & errors_r, TargetImpl::PoolItemList & remaining_r,
- TargetImpl::PoolItemList & srcremaining_r, bool dry_run )
- {
- MIL << "TargetImpl::commit(<pool>, " << medianr << ")" << endl;
- errors_r.clear();
- remaining_r.clear();
- srcremaining_r.clear();
+ ZYppCommitResult TargetImpl::commit( ResPool pool_r, const ZYppCommitPolicy & policy_r )
+ {
+ MIL << "TargetImpl::commit(<pool>, " << policy_r << ")" << endl;
+ ZYppCommitResult result;
+#warning Commit does not provide ZYppCommitResult::_errors
TargetImpl::PoolItemList to_uninstall;
TargetImpl::PoolItemList to_install;
TargetImpl::PoolItemList to_srcinstall;
getResolvablesToInsDel( pool_r, to_uninstall, to_install, to_srcinstall );
- if ( medianr ) {
- MIL << "Restrict to media number " << medianr << endl;
+ if ( policy_r.restrictToMedia() ) {
+ MIL << "Restrict to media number " << policy_r.restrictToMedia() << endl;
}
- commit (to_uninstall, dry_run);
+ commit (to_uninstall, policy_r );
- if (medianr == 0) { // commit all
- remaining_r = commit( to_install, dry_run );
- srcremaining_r = commit( to_srcinstall, dry_run );
+ if (policy_r.restrictToMedia() == 0) { // commit all
+ result._remaining = commit( to_install, policy_r );
+ result._srcremaining = commit( to_srcinstall, policy_r );
}
else
{
{
Resolvable::constPtr res( it->resolvable() );
Package::constPtr pkg( asKind<Package>(res) );
- if (pkg && medianr != pkg->mediaId()) // check medianr for packages only
+ if (pkg && policy_r.restrictToMedia() != pkg->mediaId()) // check medianr for packages only
{
XXX << "Package " << *pkg << ", wrong media " << pkg->mediaId() << endl;
- remaining_r.push_back( *it );
+ result._remaining.push_back( *it );
}
else
{
current_install.push_back( *it );
}
}
- TargetImpl::PoolItemList bad = commit( current_install, dry_run );
- remaining_r.insert(remaining_r.end(), bad.begin(), bad.end());
+ TargetImpl::PoolItemList bad = commit( current_install, policy_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 && medianr != pkg->mediaId()) // check medianr for packages only
+ if (pkg && policy_r.restrictToMedia() != pkg->mediaId()) // check medianr for packages only
{
XXX << "Package " << *pkg << ", wrong media " << pkg->mediaId() << endl;
- srcremaining_r.push_back( *it );
+ result._srcremaining.push_back( *it );
}
else {
current_srcinstall.push_back( *it );
}
}
- bad = commit( current_srcinstall, dry_run );
- srcremaining_r.insert(srcremaining_r.end(), bad.begin(), bad.end());
+ bad = commit( current_srcinstall, policy_r );
+ result._srcremaining.insert(result._srcremaining.end(), bad.begin(), bad.end());
}
- return to_install.size() - remaining_r.size();
+
+
+ result._result = (to_install.size() - result._remaining.size());
+ return result;
}
TargetImpl::PoolItemList
- TargetImpl::commit( const TargetImpl::PoolItemList & items_r, bool dry_run )
+ TargetImpl::commit( const TargetImpl::PoolItemList & items_r,
+ const ZYppCommitPolicy & policy_r )
{
TargetImpl::PoolItemList remaining;
- MIL << "TargetImpl::commit(<list>" << (dry_run?", dry_run" : "") << ")" << endl;
+ MIL << "TargetImpl::commit(<list>" << policy_r << ")" << endl;
bool abort = false;
try {
progress.tryLevel( target::rpm::InstallResolvableReport::RPM );
if (p->installOnly()) flags |= rpm::RpmDb::RPMINST_NOUPGRADE;
- if (dry_run) flags |= rpm::RpmDb::RPMINST_TEST;
+ if (policy_r.dryRun()) flags |= rpm::RpmDb::RPMINST_TEST;
rpm().installPackage( localfile, flags );
if( progress.aborted() )
catch (Exception & excpt_r) {
ZYPP_CAUGHT(excpt_r);
WAR << "Install failed, retrying with --nodeps" << endl;
- if (dry_run) {
+ if (policy_r.dryRun()) {
WAR << "dry run failed" << endl;
abort = true;
progress.disconnect();
}
}
if (success
- && !dry_run)
+ && !policy_r.dryRun())
{
it->status().setTransact( false, ResStatus::USER );
}
RpmRemovePackageReceiver progress( it->resolvable() );
progress.connect();
unsigned flags = rpm::RpmDb::RPMINST_NODEPS;
- if (dry_run) flags |= rpm::RpmDb::RPMINST_TEST;
+ if (policy_r.dryRun()) flags |= rpm::RpmDb::RPMINST_TEST;
try {
rpm().removePackage( p, flags );
}
ZYPP_CAUGHT( excpt_r );
}
if (success
- && !dry_run)
+ && !policy_r.dryRun())
{
it->status().setTransact( false, ResStatus::USER );
}
progress.disconnect();
}
}
- else if (!dry_run) // other resolvables
+ else if (!policy_r.dryRun()) // other resolvables
{
if ( isStorageEnabled() )
{
#include "zypp/base/PtrTypes.h"
#include "zypp/ResStore.h"
#include "zypp/PoolItem.h"
+#include "zypp/ZYppCommit.h"
#include "zypp/Pathname.h"
#include "zypp/media/MediaAccess.h"
/** The root set for this target */
Pathname root() const;
- /** Commit changes in the pool
- media = 0 means any/all medias
- media > 0 means limit commits to this media */
- int commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r, bool dry_run = false );
+ /** Commit changes in the pool */
+ ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
+
+ ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
+ PoolItemList & errors_r,
+ PoolItemList & remaining_r,
+ PoolItemList & srcremaining_r,
+ bool dry_run = false )
+ {
+ ZYppCommitPolicy policy;
+ policy.restrictToMedia( medianr ).dryRun( dry_run );
+ ZYppCommitResult res = commit( pool_r, policy );
+ errors_r.swap( res._errors );
+ remaining_r.swap( res._remaining );
+ srcremaining_r.swap( res._srcremaining );
+ return res._result;
+ }
/** enables the storage target */
bool isStorageEnabled() const;
/** Commit ordered changes
return uncommitted ones (due to error) */
- PoolItemList commit( const PoolItemList & items_r, bool dry_run = false );
+ PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r );
/** Overload to realize stream output. */
virtual std::ostream & dumpOn( std::ostream & str ) const
#include "zypp/zypp_detail/ZYppImpl.h"
#include "zypp/detail/ResImplTraits.h"
#include "zypp/solver/detail/Helper.h"
+#include "zypp/target/TargetImpl.h"
+#include "zypp/ZYpp.h"
#include "zypp/NVRAD.h"
#include "zypp/Language.h"
#include "zypp/DiskUsageCounter.h"
MIL << "initializing keyring..." << std::endl;
//_keyring = new KeyRing(homePath() + Pathname("/keyring/all"), homePath() + Pathname("/keyring/trusted"));
_keyring = new KeyRing();
-
+
struct utsname buf;
if (uname (&buf) < 0) {
ERR << "Can't determine system architecture" << endl;
// commit
/** \todo Remove workflow from target, lot's of it could be done here,
- * and target used for transact. */
- ZYpp::CommitResult ZYppImpl::commit( int medianr_r, bool dry_run )
+ * and target used for transact. */
+ ZYppCommitResult ZYppImpl::commit( const ZYppCommitPolicy & policy_r )
{
- MIL << "Attempt to commit (medianr " << medianr_r << ")" << endl;
+ MIL << "Attempt to commit (" << policy_r << ")" << endl;
if (! _target)
ZYPP_THROW( Exception("Target not initialized.") );
- ZYpp::CommitResult res;
-
- // must redirect to Target::Impl. This kind of commit should not be
- // in the Target interface.
-
- res._result = _target->commit( pool(), medianr_r,
- res._errors, res._remaining, res._srcremaining, dry_run );
+ ZYppCommitResult res = _target->_pimpl->commit( pool(), policy_r );
- if (!dry_run) {
+ if (! policy_r.dryRun() ) {
// reload new status from target
-
removeInstalledResolvables();
addResolvables( _target->resolvables(), true );
}
- MIL << "Commit (medianr " << medianr_r << ") returned: "
- << res._result
- << " (errors " << res._errors.size()
- << ", remaining " << res._remaining.size()
- << ", srcremaining " << res._srcremaining.size()
- << ")" << endl;
-
+ MIL << "Commit (" << policy_r << ") returned: "
+ << res << endl;
return res;
}
#include "zypp/Resolver.h"
#include "zypp/Locale.h"
#include "zypp/KeyRing.h"
-#include "zypp/ZYppCommitResult.h"
+#include "zypp/ZYppCommit.h"
+#include "zypp/DiskUsageCounter.h"
///////////////////////////////////////////////////////////////////
namespace zypp
void finishTarget();
/** Commit changes and transactions. */
- ZYpp::CommitResult commit( int medianr_r, bool dry_run = false );
+ ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
public:
/** \todo Signal locale change. */