[zypp-commit] r7129 - in /trunk/libzypp-bindings/examples/perl: ./ test.pl
![](https://seccdn.libravatar.org/avatar/e7c205f48fdce0f43c5bc29fbac34d48.jpg?s=120&d=mm&r=g)
Author: haass Date: Thu Sep 6 17:01:07 2007 New Revision: 7129 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7129&view=rev Log: perl-example how to readout the pdb-db and start a solver-run Added: trunk/libzypp-bindings/examples/perl/ trunk/libzypp-bindings/examples/perl/test.pl Added: trunk/libzypp-bindings/examples/perl/test.pl URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/perl/test.pl?rev=7129&view=auto ============================================================================== --- trunk/libzypp-bindings/examples/perl/test.pl (added) +++ trunk/libzypp-bindings/examples/perl/test.pl Thu Sep 6 17:01:07 2007 @@ -0,0 +1,62 @@ +use zypp; +use rpdbtozypp; + +$z = zyppc::ZYppFactory_instance(); +$zypp = $z->getZYpp; +$pdb = rpdbtozypp::PdbToZypp->new; +print "Package to install: "; +$ipkg = <STDIN>; +chomp($ipkg); +print "Importing packages from pdb!\n\n"; +print "This may take a while, please be patient!\n"; +$pdb->readOut; +$store = $pdb->getStore; +$zypp->addResolvables($store); + +$pool = $zypp->pool; +$it_b = $pool->begin; +$it_e = $pool->end; + +$checker = 0; + +print "Looking for package...!\n"; +while ($pool->iterator_equal($it_b, $pool->end) ne 1){ + $pkg = $pool->iterator_value($it_b); + $test = $pkg->resolvable; + $it_b = $pool->iterator_incr($it_b); + if($test->name eq $ipkg){ + print "Package found!\n"; + $tmp = $pkg->status; + $tmp->setToBeInstalledUser; + $checker = 1; + $it_b = $it_e; + } +} +if($checker eq 0){ + print "Package not in pdb!\n"; + print "Check spelling!\n"; + exit; +} + +$resolver = zypp::Resolver->new($pool); + +$it_b = $pool->begin; +if($resolver->resolvePool ne 1){ + print "Unable to solve the pool!!!\n"; + print "Problem Description: "; + $problems = $resolver->problemDescription; + foreach $problem (@$problems){ + print $problem, "\n"; + } +}else{ + print "These packages has to be installed: \n"; +# while ($it_b ne $pool->end){ + while ($pool->iterator_equal($it_b, $pool->end) ne 1){ + $pkg = $pool->iterator_value($it_b); + $it_b = $pool->iterator_incr($it_b); + $test = $pkg->resolvable; + if($pkg->status->isToBeInstalled eq 1){ + print $test->name, "\n"; + } + } +} -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
haass@svn.opensuse.org