13 package Repo::generic;
16 my ($class, $alias, $type, $attr) = @_;
17 my $r = { %{$attr || {}} };
18 $r->{'alias'} = $alias;
20 return bless $r, $class;
25 my $chksum = solv::Chksum->new($solv::REPOKEY_TYPE_SHA256);
27 return $chksum->raw();
30 sub calc_cookie_file {
31 my ($self, $filename) = @_;
32 my $chksum = solv::Chksum->new($solv::REPOKEY_TYPE_SHA256);
34 $chksum->add_stat($filename);
35 return $chksum->raw();
39 my ($self, $ext) = @_;
40 my $path = $self->{'alias'};
42 $path .= $ext ? "_$ext.solvx" : '.solv';
44 return "/var/cache/solv/$path";
48 my ($self, $pool) = @_;
49 $self->{'handle'} = $pool->add_repo($self->{'alias'});
50 $self->{'handle'}->{'appdata'} = $self;
51 $self->{'handle'}->{'priority'} = 99 - $self->{'priority'};
52 my $dorefresh = $self->{'autorefresh'};
54 my @s = stat($self->cachepath());
55 $dorefresh = 0 if @s && time() - $s[9] < $self->{'metadata_expire'};
57 $self->{'cookie'} = '';
58 if (!$dorefresh && $self->usecachedrepo()) {
59 print "repo: '$self->{'alias'}' cached\n";
62 return $self->load_if_changed();
74 my ($self, $file, $uncompress, $chksum, $markincomplete) = @_;
75 if (!$self->{'baseurl'}) {
76 print "$self->{'alias'}: no baseurl\n";
79 my $url = $self->{'baseurl'};
82 open(my $f, '+>', undef) || die;
83 fcntl($f, Fcntl::F_SETFD, 0);
84 my $st = system('curl', '-f', '-s', '-L', '-o', "/dev/fd/".fileno($f), '--', $url);
85 if (POSIX::lseek(fileno($f), 0, POSIX::SEEK_END) == 0 && ($st == 0 || !$chksum)) {
88 POSIX::lseek(fileno($f), 0, POSIX::SEEK_SET);
90 print "$file: download error #$st\n";
91 $self->{'incomplete'} = 1 if $markincomplete;
95 my $fchksum = solv::Chksum->new($chksum->{'type'});
96 $fchksum->add_fd(fileno($f));
97 if ($fchksum != $chksum) {
98 print "$file: checksum error\n";
99 $self->{'incomplete'} = 1 if $markincomplete;
104 return solv::xfopen_dup($file, fileno($f));
106 return solv::xfopen_dup(undef, fileno($f));
111 my ($self, $ext, $mark) = @_;
112 my $cookie = $ext ? $self->{'extcookie'} : $self->{'cookie'};
113 my $handle = $self->{'handle'};
114 my $cachepath = $self->cachepath($ext);
116 if (sysopen(my $f, $cachepath, POSIX::O_RDONLY)) {
117 sysseek($f, -32, Fcntl::SEEK_END);
119 return undef if sysread($f, $fcookie, 32) != 32;
120 return undef if $cookie && $fcookie ne $cookie;
121 if ($self->{'type'} ne 'system' && !$ext) {
122 sysseek($f, -32 * 2, Fcntl::SEEK_END);
123 return undef if sysread($f, $fextcookie, 32) != 32;
125 sysseek($f, 0, Fcntl::SEEK_SET);
126 my $fd = solv::xfopen_dup(undef, fileno($f));
127 my $flags = $ext ? $solv::Repo::REPO_USE_LOADING|$solv::Repo::REPO_EXTEND_SOLVABLES : 0;
128 $flags |= $solv::Repo::REPO_LOCALPOOL if $ext && $ext ne 'DL';
129 if (!$self->{'handle'}->add_solv($fd, $flags)) {
134 $self->{'cookie'} = $fcookie unless $ext;
135 $self->{'extcookie'} = $fextcookie if $fextcookie;
136 utime undef, undef, $f if $mark;
144 my $chksum = solv::Chksum->new($solv::REPOKEY_TYPE_SHA256);
145 $chksum->add($self->{'cookie'});
150 my $extcookie = $chksum->raw();
151 substr($extcookie, 0, 1) = chr(1) if ord(substr($extcookie, 0, 1)) == 0;
152 $self->{'extcookie'} = $extcookie;
155 sub writecachedrepo {
156 my ($self, $ext, $info) = @_;
157 mkdir("/var/cache/solv", 0755) unless -d "/var/cache/solv";
160 ($f, $tmpname) = File::Temp::tempfile(".newsolv-XXXXXX", 'DIR' => '/var/cache/solv');
164 my $ff = solv::xfopen_dup(undef, fileno($f));
166 $self->{'handle'}->write($ff);
170 $self->{'handle'}->write_first_repodata($ff);
173 if ($self->{'type'} ne 'system' && !$ext) {
174 $self->genextcookie($f) unless $self->{'extcookie'};
175 syswrite($f, $self->{'extcookie'});
177 syswrite($f, $ext ? $self->{'extcookie'} : $self->{'cookie'});
179 if ($self->{'handle'}->iscontiguous()) {
180 $f = solv::xfopen($tmpname);
183 $self->{'handle'}->empty();
184 die("internal error, cannot reload solv file\n") unless $self->{'handle'}->add_solv($f, $solv::Repo::SOLV_ADD_NO_STUBS);
186 $info->extend_to_repo();
187 $info->add_solv($f, $solv::Repo::REPO_EXTEND_SOLVABLES);
192 rename($tmpname, $self->cachepath($ext));
197 our @ISA = ('Repo::generic');
200 my ($self, $what) = @_;
201 my $di = $self->{'handle'}->Dataiterator($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_TYPE, $what, $solv::Dataiterator::SEARCH_STRING);
202 $di->prepend_keyname($solv::REPOSITORY_REPOMD);
204 my $dp = $d->parentpos();
205 my $filename = $dp->lookup_str($solv::REPOSITORY_REPOMD_LOCATION);
206 next unless $filename;
207 my $chksum = $dp->lookup_checksum($solv::REPOSITORY_REPOMD_CHECKSUM);
209 print "no $filename file checksum!\n";
210 return (undef, undef);
212 return ($filename, $chksum);
214 return (undef, undef);
218 my ($self, $repodata, $what, $ext) = @_;
219 my ($filename, $chksum) = $self->find($what);
220 ($filename, $chksum) = $self->find('prestodelta') if !$filename && $what eq 'deltainfo';
221 return unless $filename;
222 my $handle = $repodata->new_handle();
223 $repodata->set_poolstr($handle, $solv::REPOSITORY_REPOMD_TYPE, $what);
224 $repodata->set_str($handle, $solv::REPOSITORY_REPOMD_LOCATION, $filename);
225 $repodata->set_checksum($handle, $solv::REPOSITORY_REPOMD_CHECKSUM, $chksum);
227 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOSITORY_DELTAINFO);
228 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_FLEXARRAY);
229 } elsif ($ext eq 'FL') {
230 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_FILELIST);
231 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRSTRARRAY);
233 $repodata->add_flexarray($solv::SOLVID_META, $solv::REPOSITORY_EXTERNAL, $handle);
238 my $repodata = $self->{'handle'}->add_repodata(0);
239 $self->add_ext($repodata, 'deltainfo', 'DL');
240 $self->add_ext($repodata, 'filelists', 'FL');
241 $repodata->internalize();
245 my ($self, $repodata) = @_;
246 my $repomdtype = $repodata->lookup_str($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_TYPE);
248 if ($repomdtype eq 'filelists') {
250 } elsif ($repomdtype eq 'deltainfo') {
255 print("[$self->{'alias'}:$ext: ");
257 if ($self->usecachedrepo($ext)) {
262 my $filename = $repodata->lookup_str($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_LOCATION);
263 my $filechksum = $repodata->lookup_checksum($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_CHECKSUM);
264 my $f = $self->download($filename, 1, $filechksum);
267 $self->{'handle'}->add_rpmmd($f, 'FL', $solv::Repo::REPO_USE_LOADING|$solv::Repo::REPO_EXTEND_SOLVABLES);
268 } elsif ($ext eq 'FL') {
269 $self->{'handle'}->add_deltainfoxml($f, $solv::Repo::REPO_USE_LOADING);
272 $self->writecachedrepo($ext, $repodata);
276 sub load_if_changed {
278 print "rpmmd repo '$self->{'alias'}': ";
280 my $f = $self->download("repodata/repomd.xml");
282 print "no repomd.xml file, skipped\n";
283 $self->{'handle'}->free(1);
284 delete $self->{'handle'};
287 $self->{'cookie'} = $self->calc_cookie_fp($f);
288 if ($self->usecachedrepo(undef, 1)) {
293 $self->{'handle'}->add_repomdxml($f, 0);
296 my ($filename, $filechksum) = $self->find('primary');
298 $f = $self->download($filename, 1, $filechksum, 1);
300 $self->{'handle'}->add_rpmmd($f, undef, 0);
303 return undef if $self->{'incomplete'};
305 ($filename, $filechksum) = $self->find('updateinfo');
307 $f = $self->download($filename, 1, $filechksum, 1);
309 $self->{'handle'}->add_updateinfoxml($f, 0);
314 $self->writecachedrepo() unless $self->{'incomplete'};
315 $self->{'handle'}->create_stubs();
319 package Repo::susetags;
321 our @ISA = ('Repo::generic');
324 my ($self, $what) = @_;
326 my $di = $self->{'handle'}->Dataiterator($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME, $what, $solv::Dataiterator::SEARCH_STRING);
327 $di->prepend_keyname($solv::SUSETAGS_FILE);
329 my $dp = $d->parentpos();
330 my $chksum = $dp->lookup_checksum($solv::SUSETAGS_FILE_CHECKSUM);
331 return ($what, $chksum);
333 return (undef, undef);
337 $solv::SOLVABLE_SUMMARY => $solv::REPOKEY_TYPE_STR,
338 $solv::SOLVABLE_DESCRIPTION => $solv::REPOKEY_TYPE_STR,
339 $solv::SOLVABLE_EULA => $solv::REPOKEY_TYPE_STR,
340 $solv::SOLVABLE_MESSAGEINS => $solv::REPOKEY_TYPE_STR,
341 $solv::SOLVABLE_MESSAGEDEL => $solv::REPOKEY_TYPE_STR,
342 $solv::SOLVABLE_CATEGORY => $solv::REPOKEY_TYPE_ID,
346 my ($self, $repodata, $what, $ext) = @_;
347 my ($filename, $chksum) = $self->find($what);
348 my $handle = $repodata->new_handle();
349 $repodata->set_str($handle, $solv::SUSETAGS_FILE_NAME, $filename);
350 $repodata->set_checksum($handle, $solv::SUSETAGS_FILE_CHECKSUM, $chksum);
352 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOSITORY_DELTAINFO);
353 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_FLEXARRAY);
354 } elsif ($ext eq 'DU') {
355 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_DISKUSAGE);
356 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRNUMNUMARRAY);
357 } elsif ($ext eq 'FL') {
358 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_FILELIST);
359 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRSTRARRAY);
361 for my $langid (sort {$a <=> $b} keys %langtags) {
362 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $self->{'handle'}->{'pool'}->id2langid($langid, $ext, 1));
363 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $langtags{$langid});
366 $repodata->add_flexarray($solv::SOLVID_META, $solv::REPOSITORY_EXTERNAL, $handle);
371 my $repodata = $self->{'handle'}->add_repodata(0);
372 my $di = $self->{'handle'}->Dataiterator($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME, undef, 0);
373 $di->prepend_keyname($solv::SUSETAGS_FILE);
375 my $filename = $d->str();
376 next unless $filename && $filename =~ /^packages\.(..)(?:\..*)$/;
377 next if $1 eq 'en' || $1 eq 'gz';
378 $self->add_ext($repodata, $filename, $1);
380 $repodata->internalize();
384 my ($self, $repodata) = @_;
385 my $filename = $repodata->lookup_str($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME);
386 my $ext = substr($filename, 9, 2);
387 print("[$self->{'alias'}:$ext: ");
389 if ($self->usecachedrepo($ext)) {
394 my $defvendorid = $self->{'handle'}->lookup_id($solv::SOLVID_META, $solv::SUSETAGS_DEFAULTVENDOR);
395 my $descrdir = $self->{'handle'}->lookup_str($solv::SOLVID_META, $solv::SUSETAGS_DESCRDIR) || 'suse/setup/descr';
396 my $filechksum = $repodata->lookup_checksum($solv::SOLVID_META, $solv::SUSETAGS_FILE_CHECKSUM);
397 my $f = $self->download("$descrdir/$filename", 1, $filechksum);
399 $self->{'handle'}->add_susetags($f, $defvendorid, $ext, $solv::Repo::REPO_USE_LOADING|$solv::Repo::REPO_EXTEND_SOLVABLES);
401 $self->writecachedrepo($ext, $repodata);
405 sub load_if_changed {
407 print "susetags repo '$self->{'alias'}': ";
409 my $f = $self->download("content");
411 print "no content file, skipped\n";
412 $self->{'handle'}->free(1);
413 delete $self->{'handle'};
416 $self->{'cookie'} = $self->calc_cookie_fp($f);
417 if ($self->usecachedrepo(undef, 1)) {
422 $self->{'handle'}->add_content($f, 0);
425 my $defvendorid = $self->{'handle'}->lookup_id($solv::SOLVID_META, $solv::SUSETAGS_DEFAULTVENDOR);
426 my $descrdir = $self->{'handle'}->lookup_str($solv::SOLVID_META, $solv::SUSETAGS_DESCRDIR) || 'suse/setup/descr';
427 my ($filename, $filechksum) = $self->find('packages.gz');
428 ($filename, $filechksum) = $self->find('packages') unless $filename;
430 $f = $self->download("$descrdir/$filename", 1, $filechksum, 1);
432 $self->{'handle'}->add_susetags($f, $defvendorid, undef, $solv::Repo::REPO_NO_INTERNALIZE|$solv::Repo::SUSETAGS_RECORD_SHARES);
434 ($filename, $filechksum) = $self->find('packages.en.gz');
435 ($filename, $filechksum) = $self->find('packages.en') unless $filename;
437 $f = $self->download("$descrdir/$filename", 1, $filechksum, 1);
439 $self->{'handle'}->add_susetags($f, $defvendorid, undef, $solv::Repo::REPO_NO_INTERNALIZE|$solv::Repo::REPO_REUSE_REPODATA|$solv::Repo::REPO_EXTEND_SOLVABLES);
443 $self->{'handle'}->internalize();
447 $self->writecachedrepo() unless $self->{'incomplete'};
448 $self->{'handle'}->create_stubs();
452 package Repo::unknown;
454 our @ISA = ('Repo::generic');
457 my ($self, $pool) = @_;
458 print "unsupported repo '$self->{'alias'}': skipped\n";
462 package Repo::system;
464 our @ISA = ('Repo::generic');
467 my ($self, $pool) = @_;
469 $self->{'handle'} = $pool->add_repo($self->{'alias'});
470 $self->{'handle'}->{'appdata'} = $self;
471 $pool->{'installed'} = $self->{'handle'};
472 print "rpm database: ";
473 $self->{'cookie'} = $self->calc_cookie_file('/var/lib/rpm/Packages');
474 if ($self->usecachedrepo()) {
479 if (defined(&solv::Repo::add_products)) {
480 $self->{'handle'}->add_products("/etc/products.d", $solv::Repo::REPO_NO_INTERNALIZE);
482 $self->{'handle'}->add_rpmdb(undef, $solv::Repo::REPO_REUSE_REPODATA);
483 $self->writecachedrepo();
491 my $repo = $repodata->{'repo'}->{'appdata'};
492 return $repo ? $repo->load_ext($repodata) : 0;
495 die("Usage: p5solv COMMAND [ARGS]\n") unless @ARGV;
496 my $cmd = shift @ARGV;
497 $cmd = 'list' if $cmd eq 'li';
498 $cmd = 'install' if $cmd eq 'in';
499 $cmd = 'erase' if $cmd eq 'rm';
500 $cmd = 'verify' if $cmd eq 've';
501 $cmd = 'search' if $cmd eq 'se';
505 if (-d '/etc/zypp/repos.d') {
506 @reposdirs = ( '/etc/zypp/repos.d' );
508 @reposdirs = ( '/etc/yum/repos.d' );
510 for my $reposdir (@reposdirs) {
511 next unless -d $reposdir;
512 next unless opendir(DIR, $reposdir);
513 for my $reponame (sort(grep {/\.repo$/} readdir(DIR))) {
514 my $cfg = new Config::IniFiles('-file' => "$reposdir/$reponame");
515 for my $alias ($cfg->Sections()) {
516 my $repoattr = {'alias' => $alias, 'enabled' => 0, 'priority' => 99, 'autorefresh' => 1, 'type' => 'rpm-md', 'metadata_expire' => 900};
517 for my $p ($cfg->Parameters($alias)) {
518 $repoattr->{$p} = $cfg->val($alias, $p);
521 if ($repoattr->{'type'} eq 'rpm-md') {
522 $repo = Repo::rpmmd->new($alias, 'repomd', $repoattr);
523 } elsif ($repoattr->{'type'} eq 'yast2') {
524 $repo = Repo::susetags->new($alias, 'susetags', $repoattr);
526 $repo = Repo::unknown->new($alias, 'unknown', $repoattr);
533 my $pool = solv::Pool->new();
534 $pool->setarch((POSIX::uname())[4]);
535 $pool->set_loadcallback(\&load_stub);
537 my $sysrepo = Repo::system->new('@System', 'system');
538 $sysrepo->load($pool);
539 for my $repo (@repos) {
540 $repo->load($pool) if $repo->{'enabled'};
543 if ($cmd eq 'search') {
545 my $di = $pool->Dataiterator(0, $solv::SOLVABLE_NAME, $ARGV[0], $solv::Dataiterator::SEARCH_SUBSTRING | $solv::Dataiterator::SEARCH_NOCASE);
547 $matches{$d->{'solvid'}} = 1;
549 for my $solvid (sort keys %matches) {
550 my $s = $pool->{'solvables'}->[$solvid];
551 print "- ".$s->str()." [$s->{'repo'}->{'name'}] ".$s->lookup_str($solv::SOLVABLE_SUMMARY)."\n";
556 my @addedprovides = $pool->addfileprovides_queue();
557 $pool->createwhatprovides();
560 for my $arg (@ARGV) {
561 my $flags = $solv::Selection::SELECTION_NAME | $solv::Selection::SELECTION_PROVIDES | $solv::Selection::SELECTION_GLOB;
563 $flags |= $solv::Selection::SELECTION_FILELIST;
564 $flags |= $solv::Selection::SELECTION_INSTALLED_ONLY if $cmd eq 'erase';
566 my $sel = $pool->select($arg, $flags);
567 if ($sel->isempty()) {
568 $sel = $pool->select($arg, $flags | $solv::Selection::SELECTION_NOCASE);
569 print "[ignoring case for '$arg']\n" unless $sel->isempty();
571 die("nothing matches '$arg'\n") if $sel->isempty();
572 print "[using file list match for '$arg']\n" if $sel->flags() & $solv::Selection::SELECTION_FILELIST;
573 print "[using capability match for '$arg']\n" if $sel->flags() & $solv::Selection::SELECTION_PROVIDES;
574 push @jobs, $sel->jobs(0);
576 if (!@jobs && ($cmd eq 'up' || $cmd eq 'dup' || $cmd eq 'verify')) {
577 my $sel = $pool->Selection();
578 $sel->addsimple($solv::Job::SOLVER_SOLVABLE_ALL, 0);
579 push @jobs, $sel->jobs(0);
582 if ($cmd eq 'list' || $cmd eq 'info') {
583 die("no package matched.\n") unless @jobs;
584 for my $job (@jobs) {
585 for my $s ($job->solvables()) {
586 if ($cmd eq 'info') {
587 printf "Name: %s\n", $s->str();
588 printf "Repo: %s\n", $s->{'repo'}->{'name'};
589 printf "Summary: %s\n", $s->lookup_str($solv::SOLVABLE_SUMMARY);
590 my $str = $s->lookup_str($solv::SOLVABLE_URL);
591 printf "Url: %s\n", $str if $str;
592 $str = $s->lookup_str($solv::SOLVABLE_LICENSE);
593 printf "License: %s\n", $str if $str;
594 printf "Description:\n%s\n", $s->lookup_str($solv::SOLVABLE_DESCRIPTION);
596 printf " - %s [%s]\n", $s->str(), $s->{'repo'}->{'name'};
597 printf " %s\n", $s->lookup_str($solv::SOLVABLE_SUMMARY);
604 if ($cmd eq 'install' || $cmd eq 'erase' || $cmd eq 'up' || $cmd eq 'dup' || $cmd eq 'verify') {
605 die("no package matched.\n") unless @jobs;
606 for my $job (@jobs) {
608 if ($job->{'how'} == $solv::Job::SOLVER_SOLVABLE_ALL || grep {$_->isinstalled()} $job->solvables()) {
609 $job->{'how'} |= $solv::Job::SOLVER_UPDATE;
611 $job->{'how'} |= $solv::Job::SOLVER_INSTALL;
613 } elsif ($cmd eq 'install') {
614 $job->{'how'} |= $solv::Job::SOLVER_INSTALL;
615 } elsif ($cmd eq 'erase') {
616 $job->{'how'} |= $solv::Job::SOLVER_ERASE;
617 } elsif ($cmd eq 'dup') {
618 $job->{'how'} |= $solv::Job::SOLVER_DISTUPGRADE;
619 } elsif ($cmd eq 'verify') {
620 $job->{'how'} |= $solv::Job::SOLVER_VERIFY;
625 $solver = $pool->Solver();
626 $solver->set_flag($solv::Solver::SOLVER_FLAG_SPLITPROVIDES, 1);
627 $solver->set_flag($solv::Solver::SOLVER_FLAG_ALLOW_UNINSTALL, 1) if $cmd eq 'erase';
628 my @problems = $solver->solve(\@jobs);
629 last unless @problems;
630 for my $problem (@problems) {
631 print "Problem $problem->{'id'}/".@problems.":\n";
632 my $r = $problem->findproblemrule();
634 print $ri->problemstr()."\n";
635 my @solutions = $problem->solutions();
636 for my $solution (@solutions) {
637 print " Solution $solution->{'id'}:\n";
638 for my $element ($solution->elements(1)) {
639 print " - ".$element->str()."\n";
645 print "Please choose a solution: ";
648 last if $sol eq 's' || $sol eq 'q' || ($sol =~ /^\d+$/ && $sol >= 1 && $sol <= @solutions);
651 exit(1) if $sol eq 'q';
652 my $solution = $solutions[$sol - 1];
653 for my $element ($solution->elements()) {
654 my $newjob = $element->Job();
655 if ($element->{'type'} == $solv::Solver::SOLVER_SOLUTION_JOB) {
656 $jobs[$element->{'jobidx'}] = $newjob;
658 push @jobs, $newjob if $newjob && !grep {$_ == $newjob} @jobs;
663 my $trans = $solver->transaction();
665 if ($trans->isempty()) {
666 print "Nothing to do.\n";
669 print "\nTransaction summary:\n\n";
670 for my $c ($trans->classify()) {
671 if ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_ERASE) {
672 print "$c->{'count'} erased packages:\n";
673 } elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_INSTALL) {
674 print "$c->{'count'} installed packages:\n";
675 } elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_REINSTALLED) {
676 print "$c->{'count'} reinstalled packages:\n";
677 } elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_DOWNGRADED) {
678 print "$c->{'count'} downgraded packages:\n";
679 } elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_CHANGED) {
680 print "$c->{'count'} changed packages:\n";
681 } elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_UPGRADED) {
682 print "$c->{'count'} upgraded packages:\n";
683 } elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_VENDORCHANGE) {
684 printf "$c->{'count'} vendor changes from '%s' to '%s':\n", $pool->id2str($c->{'fromid'}), $pool->id2str($c->{'toid'});
685 } elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_ARCHCHANGE) {
686 printf "$c->{'count'} arch changes from '%s' to '%s':\n", $pool->id2str($c->{'fromid'}), $pool->id2str($c->{'toid'});
690 for my $p ($c->solvables()) {
691 if ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_UPGRADED || $c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_DOWNGRADED) {
692 my $other = $trans->othersolvable($p);
693 printf " - %s -> %s\n", $p->str(), $other->str();
695 printf " - %s\n", $p->str();
700 printf "install size change: %d K\n\n", $trans->calc_installsizechange();
702 print("OK to continue (y/n)? ");
706 exit(1) if $yn eq 'n';
708 my @newpkgs = $trans->newpackages();
711 my $downloadsize = 0;
712 $downloadsize += $_->lookup_num($solv::SOLVABLE_DOWNLOADSIZE) for @newpkgs;
713 printf "Downloading %d packages, %d K\n", scalar(@newpkgs), $downloadsize;
714 for my $p (@newpkgs) {
715 my $repo = $p->{'repo'}->{'appdata'};
716 my ($location, $medianr) = $p->lookup_location();
717 next unless $location;
718 if ($repo->{'type'} eq 'susetags') {
719 $location = ($repo->{'handle'}->lookup_str($solv::SOLVID_META, $solv::SUSETAGS_DATADIR) || 'suse') ."/$location";
721 my $chksum = $p->lookup_checksum($solv::SOLVABLE_CHECKSUM);
722 my $f = $repo->download($location, 0, $chksum);
723 die("\n$repo->{'alias'}: $location not found in repository\n") unless $f;
724 $newpkgsfps{$p->{'id'}} = $f;
730 print "Committing transaction:\n\n";
732 for my $p ($trans->steps()) {
733 my $steptype = $trans->steptype($p, $solv::Transaction::SOLVER_TRANSACTION_RPM_ONLY);
734 if ($steptype == $solv::Transaction::SOLVER_TRANSACTION_ERASE) {
735 print "erase ".$p->str()."\n";
736 next unless $p->lookup_num($solv::RPM_RPMDBID);
737 my $evr = $p->{'evr'};
738 $evr =~ s/^[0-9]+://; # strip epoch
739 system('rpm', '-e', '--nodeps', '--nodigest', '--nosignature', "$p->{'name'}-$evr.$p->{'arch'}") && die("rpm failed: $?\n");
740 } elsif ($steptype == $solv::Transaction::SOLVER_TRANSACTION_INSTALL || $steptype == $solv::Transaction::SOLVER_TRANSACTION_MULTIINSTALL) {
741 print "install ".$p->str()."\n";
742 my $f = $newpkgsfps{$p->{'id'}};
743 my $mode = $steptype == $solv::Transaction::SOLVER_TRANSACTION_INSTALL ? '-U' : '-i';
744 system('rpm', $mode, '--force', '--nodeps', '--nodigest', '--nosignature', "/dev/fd/".solv::xfileno($f)) && die("rpm failed: $?\n");
746 delete $newpkgsfps{$p->{'id'}};