--- /dev/null
+#! /usr/bin/python
+
+import os, sys, types, string, re
+
+try:
+ import zypp
+except ImportError:
+ print 'Dummy Import Error: Unable to import zypp bindings'
+
+print 'Reading repositories...'
+
+Z = zypp.ZYppFactory_instance().getZYpp()
+
+Z.initializeTarget( zypp.Pathname("/") )
+Z.addResolvables( Z.target().resolvables(), True )
+
+repoManager = zypp.RepoManager()
+repos = repoManager.knownRepositories()
+
+for repo in repos:
+ if repo.enabled() and repo.autorefresh():
+ try:
+ repoManager.refreshMetadata(repo, zypp.RepoManager.RefreshIfNeeded) # or RefreshIfNeeded == 0
+ except:
+ repoManager.buildCache( repo )
+
+ Z.addResolvables( repoManager.createFromCache( repo ).resolvables())
+
+Z.applyLocks()
+Z.resolver().establishPool();
+
+#
+# Does not to check and apply updates for the update stack first.
+#
+print 'List Upadtes:'
+for item in Z.pool().byKindIterator(zypp.KindOfPatch()):
+ if item.status().isInstalled():
+ continue
+ if item.status().isNeeded():
+ if not item.status().setTransact( True, zypp.ResStatus.USER ):
+ raise "Error set transact: %s" % item
+ resolvable = zypp.asKindPatch( item )
+ print '%s | %s-%s | %s | %s' % (resolvable.repository().info().alias(), resolvable.name(), resolvable.edition(), resolvable.category(), item.status() )
+
+if not Z.resolver().resolvePool():
+ raise "Solver Error"
+
+for item in Z.pool():
+ if item.status().transacts():
+ print item
+
+#
+# dryRun!
+#
+policy = zypp.ZYppCommitPolicy()
+policy.dryRun( True )
+policy.syncPoolAfterCommit( False )
+
+result = Z.commit( policy )
+print result
Z = zypp.ZYppFactory_instance().getZYpp()
Z.initializeTarget( zypp.Pathname("/") )
+Z.addResolvables( Z.target().resolvables(), True )
repoManager = zypp.RepoManager()
repos = repoManager.knownRepositories()
Z.addResolvables( repoManager.createFromCache( repo ).resolvables())
-Z.addResolvables( Z.target().resolvables(), True )
-
-# currently not swigged
Z.applyLocks()
Z.resolver().establishPool();
-print 'List Upadtes:'
+print 'List Updates:'
for item in Z.pool().byKindIterator(zypp.KindOfPatch()):
if item.status().isNeeded():
resolvable = zypp.asKindPatch( item )
print '%s | %s-%s | %s | %s' % (resolvable.repository().info().alias(), resolvable.name(), resolvable.edition(), resolvable.category(), item.status() )
-
str << *self;
return str.str();
}
-}
\ No newline at end of file
+}
%template(ResObject_constPtr) intrusive_ptr<const ResObject>;
%template(ResObject_Ptr) intrusive_ptr<ResObject>;
+// Common definitions for all Resolvable types
+// - *_Ptr and *_constPtr
+// - isKind* to test whether a ResObject/PoolItem is
+// of a specific kind.
+// - asKind* to convert a ResObject/PoolItem into a
+// specific *_constPtr.
%define %STUFF(X)
typedef intrusive_ptr<const X> X##_constPtr;
typedef intrusive_ptr<X> X##_Ptr;
{ return isKind<X>( p ); }
inline bool isKind##X( const PoolItem & p )
{ return isKind<X>( p.resolvable() ); }
-
inline X::constPtr asKind##X( const Resolvable::constPtr & p )
{ return asKind<X>( p ); }
inline X::constPtr asKind##X( const PoolItem & p )
{ return asKind<X>( p.resolvable() ); }
}
+
#if defined(SWIGPYTHON)
%pythoncode
{
* list of kind:source resolvables remaining (due to wrong media)
**/
PoolItemList _srcremaining;
- };
\ No newline at end of file
+ };
+
+%extend ZYppCommitResult
+{
+ std::string asString() const
+ {
+ std::ostringstream str;
+ str << *self;
+ return str.str();
+ }
+}