Bump to libzypp-bindings 0.7.4
[platform/upstream/libzypp-bindings.git] / examples / perl / list_target_resolvables.pl
1 use zypp;
2
3 $z = zyppc::ZYppFactory_instance();
4 $zypp = $z->getZYpp;
5
6 $t = $zypp->initializeTarget(zypp::Pathname->new("/"));
7
8 my $repoManager = zypp::RepoManager::new();
9 my $repos = zypp::RepoManager::knownRepositories($repoManager);
10
11 foreach $repo ( @{$repos} ) {
12         if ( $repo->enabled() ) {
13                 print("Caching repo: ".$repo->name."\n");
14                 if ( ! zypp::RepoManager::isCached($repoManager,$repo) ) {
15                         print("Rebuilding cache for: ".$repo->name."\n");
16                         zypp::RepoManager::buildCache($repoManager,$repo);
17                 }
18                 zypp::RepoManager::loadFromCache($repoManager,$repo);
19         }
20 }
21
22 $store = $zypp->pool;
23
24 $it_b = $store->cBegin;
25 $it_e = $store->cEnd;
26
27 while ($store->iterator_equal($it_b, $it_e) ne 1){
28    $pkg = $store->iterator_value($it_b);
29    print $pkg->kind->asString, " ", $pkg->name, " ", $pkg->edition->asString;
30    print $pkg->arch->string, "\n";
31    print "  Summary: ", $pkg->summary, "\n";
32    print "  Size: ", $pkg->installSize->asString, "\n";
33    print "  Vendor: ", $pkg->vendor->asString, "\n";
34    print "  BuildTime: ", $pkg->buildtime->asString, "\n";
35    $it_b = $store->iterator_incr($it_b);
36
37    $deps = $pkg->dep($zyppc::Dep_PROVIDES);
38
39    $it_b2 = $deps->cBegin;
40
41    while($deps->iterator_equal($it_b2, $deps->cEnd) ne 1){
42       $dep = $deps->iterator_value($it_b2);
43       print "Provides: ", $dep->asString, "\n";
44       $it_b2 = $deps->iterator_incr($it_b2);
45    }
46    print "\n";
47    
48 }