13 package Repo::generic;
16 my ($class, $alias, $type, $attr) = @_;
17 my $r = { %{$attr || {}} };
20 return bless $r, $class;
25 my $chksum = solv::Chksum->new($solv::REPOKEY_TYPE_SHA256);
28 return $chksum->raw();
31 sub calc_cookie_file {
32 my ($self, $filename) = @_;
33 my $chksum = solv::Chksum->new($solv::REPOKEY_TYPE_SHA256);
35 $chksum->add_stat($filename);
36 return $chksum->raw();
40 my ($self, $f, $cookie) = @_;
41 my $chksum = solv::Chksum->new($solv::REPOKEY_TYPE_SHA256);
43 $chksum->add($cookie);
44 $chksum->add_fstat(fileno($f));
45 my $extcookie = $chksum->raw();
46 substr($extcookie, 0, 1) = chr(1) if ord(substr($extcookie, 0, 1)) == 0;
51 my ($self, $ext) = @_;
52 my $path = $self->{alias};
54 $path .= $ext ? "_$ext.solvx" : '.solv';
56 return "/var/cache/solv/$path";
60 my ($self, $pool) = @_;
61 $self->{handle} = $pool->add_repo($self->{alias});
62 $self->{handle}->{appdata} = $self;
63 $self->{handle}->{priority} = 99 - $self->{priority};
64 my $dorefresh = $self->{autorefresh};
66 my @s = stat($self->cachepath());
67 $dorefresh = 0 if @s && ($self->{metadata_expire} == -1 || time() - $s[9] < $self->{metadata_expire});
70 if (!$dorefresh && $self->usecachedrepo()) {
71 print "repo: '$self->{alias}' cached\n";
82 my ($self, $file, $uncompress, $chksum, $markincomplete) = @_;
83 if (!$self->{baseurl}) {
84 print "$self->{alias}: no baseurl\n";
87 my $url = $self->{baseurl};
90 open(my $f, '+>', undef) || die;
91 fcntl($f, Fcntl::F_SETFD, 0);
92 my $st = system('curl', '-f', '-s', '-L', '-o', "/dev/fd/" . fileno($f), '--', $url);
93 if (POSIX::lseek(fileno($f), 0, POSIX::SEEK_END) == 0 && ($st == 0 || !$chksum)) {
96 POSIX::lseek(fileno($f), 0, POSIX::SEEK_SET);
98 print "$file: download error #$st\n";
99 $self->{incomplete} = 1 if $markincomplete;
103 my $fchksum = solv::Chksum->new($chksum->{type});
104 $fchksum->add_fd(fileno($f));
105 if ($fchksum != $chksum) {
106 print "$file: checksum error\n";
107 $self->{incomplete} = 1 if $markincomplete;
112 return solv::xfopen_fd($file, fileno($f));
114 return solv::xfopen_fd(undef, fileno($f));
119 my ($self, $ext, $mark) = @_;
120 my $cookie = $ext ? $self->{extcookie} : $self->{cookie};
121 my $cachepath = $self->cachepath($ext);
123 if (sysopen(my $f, $cachepath, POSIX::O_RDONLY)) {
124 sysseek($f, -32, Fcntl::SEEK_END);
126 return undef if sysread($f, $fcookie, 32) != 32;
127 return undef if $cookie && $fcookie ne $cookie;
128 if ($self->{type} ne 'system' && !$ext) {
129 sysseek($f, -32 * 2, Fcntl::SEEK_END);
130 return undef if sysread($f, $fextcookie, 32) != 32;
132 sysseek($f, 0, Fcntl::SEEK_SET);
133 my $fd = solv::xfopen_fd(undef, fileno($f));
134 my $flags = $ext ? $solv::Repo::REPO_USE_LOADING|$solv::Repo::REPO_EXTEND_SOLVABLES : 0;
135 $flags |= $solv::Repo::REPO_LOCALPOOL if $ext && $ext ne 'DL';
136 if (!$self->{handle}->add_solv($fd, $flags)) {
139 $self->{cookie} = $fcookie unless $ext;
140 $self->{extcookie} = $fextcookie if $fextcookie;
141 utime undef, undef, $f if $mark;
147 sub writecachedrepo {
148 my ($self, $ext, $info) = @_;
149 return if $self->{incomplete};
150 mkdir("/var/cache/solv", 0755) unless -d "/var/cache/solv";
153 ($f, $tmpname) = File::Temp::tempfile(".newsolv-XXXXXX", 'DIR' => '/var/cache/solv');
157 my $ff = solv::xfopen_fd(undef, fileno($f));
159 $self->{handle}->write($ff);
163 $self->{handle}->write_first_repodata($ff);
165 undef $ff; # also flushes
166 if ($self->{type} ne 'system' && !$ext) {
167 $self->{extcookie} ||= $self->calc_cookie_ext($f, $self->{cookie});
168 syswrite($f, $self->{extcookie});
170 syswrite($f, $ext ? $self->{extcookie} : $self->{cookie});
172 if ($self->{handle}->iscontiguous()) {
173 $f = solv::xfopen($tmpname);
176 $self->{handle}->empty();
177 die("internal error, cannot reload solv file\n") unless $self->{handle}->add_solv($f, $solv::Repo::SOLV_ADD_NO_STUBS);
179 $info->extend_to_repo();
180 my $flags = $solv::Repo::REPO_EXTEND_SOLVABLES;
181 $flags |= $solv::Repo::REPO_LOCALPOOL if $ext ne 'DL';
182 $info->add_solv($f, $flags);
186 rename($tmpname, $self->cachepath($ext));
196 our @ISA = ('Repo::generic');
199 my ($self, $what) = @_;
200 my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_TYPE, $what, $solv::Dataiterator::SEARCH_STRING);
201 $di->prepend_keyname($solv::REPOSITORY_REPOMD);
203 my $dp = $d->parentpos();
204 my $filename = $dp->lookup_str($solv::REPOSITORY_REPOMD_LOCATION);
205 next unless $filename;
206 my $chksum = $dp->lookup_checksum($solv::REPOSITORY_REPOMD_CHECKSUM);
208 print "no $filename file checksum!\n";
209 return (undef, undef);
211 return ($filename, $chksum);
213 return (undef, undef);
217 my ($self, $repodata, $what, $ext) = @_;
218 my ($filename, $chksum) = $self->find($what);
219 ($filename, $chksum) = $self->find('prestodelta') if !$filename && $what eq 'deltainfo';
220 return unless $filename;
221 my $handle = $repodata->new_handle();
222 $repodata->set_poolstr($handle, $solv::REPOSITORY_REPOMD_TYPE, $what);
223 $repodata->set_str($handle, $solv::REPOSITORY_REPOMD_LOCATION, $filename);
224 $repodata->set_checksum($handle, $solv::REPOSITORY_REPOMD_CHECKSUM, $chksum);
226 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOSITORY_DELTAINFO);
227 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_FLEXARRAY);
228 } elsif ($ext eq 'FL') {
229 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_FILELIST);
230 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRSTRARRAY);
232 $repodata->add_flexarray($solv::SOLVID_META, $solv::REPOSITORY_EXTERNAL, $handle);
237 my $repodata = $self->{handle}->add_repodata(0);
238 $self->add_ext($repodata, 'deltainfo', 'DL');
239 $self->add_ext($repodata, 'filelists', 'FL');
240 $repodata->internalize();
244 my ($self, $repodata) = @_;
245 my $repomdtype = $repodata->lookup_str($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_TYPE);
247 if ($repomdtype eq 'filelists') {
249 } elsif ($repomdtype eq 'deltainfo') {
254 print("[$self->{alias}:$ext: ");
256 if ($self->usecachedrepo($ext)) {
261 my $filename = $repodata->lookup_str($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_LOCATION);
262 my $filechksum = $repodata->lookup_checksum($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_CHECKSUM);
263 my $f = $self->download($filename, 1, $filechksum);
266 $self->{handle}->add_rpmmd($f, 'FL', $solv::Repo::REPO_USE_LOADING|$solv::Repo::REPO_EXTEND_SOLVABLES|$solv::Repo::REPO_LOCALPOOL);
267 } elsif ($ext eq 'DL') {
268 $self->{handle}->add_deltainfoxml($f, $solv::Repo::REPO_USE_LOADING);
270 $self->writecachedrepo($ext, $repodata);
275 my ($self, $pool) = @_;
276 return 1 if $self->Repo::generic::load($pool);
277 print "rpmmd repo '$self->{alias}': ";
279 my $f = $self->download("repodata/repomd.xml");
281 print "no repomd.xml file, skipped\n";
282 $self->{handle}->free(1);
283 delete $self->{handle};
286 $self->{cookie} = $self->calc_cookie_fp($f);
287 if ($self->usecachedrepo(undef, 1)) {
291 $self->{handle}->add_repomdxml($f, 0);
293 my ($filename, $filechksum) = $self->find('primary');
295 $f = $self->download($filename, 1, $filechksum, 1);
297 $self->{handle}->add_rpmmd($f, undef, 0);
299 return undef if $self->{incomplete};
301 ($filename, $filechksum) = $self->find('updateinfo');
303 $f = $self->download($filename, 1, $filechksum, 1);
305 $self->{handle}->add_updateinfoxml($f, 0);
309 $self->writecachedrepo();
310 $self->{handle}->create_stubs();
314 package Repo::susetags;
316 our @ISA = ('Repo::generic');
319 my ($self, $what) = @_;
321 my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME, $what, $solv::Dataiterator::SEARCH_STRING);
322 $di->prepend_keyname($solv::SUSETAGS_FILE);
324 my $dp = $d->parentpos();
325 my $chksum = $dp->lookup_checksum($solv::SUSETAGS_FILE_CHECKSUM);
326 return ($what, $chksum);
328 return (undef, undef);
332 $solv::SOLVABLE_SUMMARY => $solv::REPOKEY_TYPE_STR,
333 $solv::SOLVABLE_DESCRIPTION => $solv::REPOKEY_TYPE_STR,
334 $solv::SOLVABLE_EULA => $solv::REPOKEY_TYPE_STR,
335 $solv::SOLVABLE_MESSAGEINS => $solv::REPOKEY_TYPE_STR,
336 $solv::SOLVABLE_MESSAGEDEL => $solv::REPOKEY_TYPE_STR,
337 $solv::SOLVABLE_CATEGORY => $solv::REPOKEY_TYPE_ID,
341 my ($self, $repodata, $what, $ext) = @_;
342 my ($filename, $chksum) = $self->find($what);
343 my $handle = $repodata->new_handle();
344 $repodata->set_str($handle, $solv::SUSETAGS_FILE_NAME, $filename);
345 $repodata->set_checksum($handle, $solv::SUSETAGS_FILE_CHECKSUM, $chksum);
347 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOSITORY_DELTAINFO);
348 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_FLEXARRAY);
349 } elsif ($ext eq 'DU') {
350 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_DISKUSAGE);
351 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRNUMNUMARRAY);
352 } elsif ($ext eq 'FL') {
353 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_FILELIST);
354 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRSTRARRAY);
356 for my $langid (sort { $a <=> $b } keys %langtags) {
357 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $self->{handle}->{pool}->id2langid($langid, $ext, 1));
358 $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $langtags{$langid});
361 $repodata->add_flexarray($solv::SOLVID_META, $solv::REPOSITORY_EXTERNAL, $handle);
366 my $repodata = $self->{handle}->add_repodata(0);
367 my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME, undef, 0);
368 $di->prepend_keyname($solv::SUSETAGS_FILE);
370 my $filename = $d->str();
371 next unless $filename && $filename =~ /^packages\.(..)(?:\..*)$/;
372 next if $1 eq 'en' || $1 eq 'gz';
373 $self->add_ext($repodata, $filename, $1);
375 $repodata->internalize();
379 my ($self, $repodata) = @_;
380 my $filename = $repodata->lookup_str($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME);
381 my $ext = substr($filename, 9, 2);
382 print("[$self->{alias}:$ext: ");
384 if ($self->usecachedrepo($ext)) {
389 my $defvendorid = $self->{handle}->{meta}->lookup_id($solv::SUSETAGS_DEFAULTVENDOR);
390 my $descrdir = $self->{handle}->{meta}->lookup_str($solv::SUSETAGS_DESCRDIR) || 'suse/setup/descr';
391 my $filechksum = $repodata->lookup_checksum($solv::SOLVID_META, $solv::SUSETAGS_FILE_CHECKSUM);
392 my $f = $self->download("$descrdir/$filename", 1, $filechksum);
394 my $flags = $solv::Repo::REPO_USE_LOADING|$solv::Repo::REPO_EXTEND_SOLVABLES;
395 $flags |= $solv::Repo::REPO_LOCALPOOL if $ext ne 'DL';
396 $self->{handle}->add_susetags($f, $defvendorid, $ext, $flags);
397 $self->writecachedrepo($ext, $repodata);
402 my ($self, $pool) = @_;
403 return 1 if $self->Repo::generic::load($pool);
404 print "susetags repo '$self->{alias}': ";
406 my $f = $self->download("content");
408 print "no content file, skipped\n";
409 $self->{handle}->free(1);
410 delete $self->{handle};
413 $self->{cookie} = $self->calc_cookie_fp($f);
414 if ($self->usecachedrepo(undef, 1)) {
418 $self->{handle}->add_content($f, 0);
420 my $defvendorid = $self->{handle}->{meta}->lookup_id($solv::SUSETAGS_DEFAULTVENDOR);
421 my $descrdir = $self->{handle}->{meta}->lookup_str($solv::SUSETAGS_DESCRDIR) || 'suse/setup/descr';
422 my ($filename, $filechksum) = $self->find('packages.gz');
423 ($filename, $filechksum) = $self->find('packages') unless $filename;
425 $f = $self->download("$descrdir/$filename", 1, $filechksum, 1);
427 $self->{handle}->add_susetags($f, $defvendorid, undef, $solv::Repo::REPO_NO_INTERNALIZE|$solv::Repo::SUSETAGS_RECORD_SHARES);
428 ($filename, $filechksum) = $self->find('packages.en.gz');
429 ($filename, $filechksum) = $self->find('packages.en') unless $filename;
431 $f = $self->download("$descrdir/$filename", 1, $filechksum, 1);
433 $self->{handle}->add_susetags($f, $defvendorid, undef, $solv::Repo::REPO_NO_INTERNALIZE|$solv::Repo::REPO_REUSE_REPODATA|$solv::Repo::REPO_EXTEND_SOLVABLES);
436 $self->{handle}->internalize();
440 $self->writecachedrepo();
441 $self->{handle}->create_stubs();
447 return ($self->{handle}->{meta}->lookup_str($solv::SUSETAGS_DATADIR) || 'suse') . '/';
450 package Repo::unknown;
452 our @ISA = ('Repo::generic');
456 print "unsupported repo '$self->{alias}': skipped\n";
460 package Repo::system;
462 our @ISA = ('Repo::generic');
465 my ($self, $pool) = @_;
467 $self->{handle} = $pool->add_repo($self->{alias});
468 $self->{handle}->{appdata} = $self;
469 $pool->{installed} = $self->{handle};
470 print "rpm database: ";
471 $self->{cookie} = $self->calc_cookie_file('/var/lib/rpm/Packages');
472 if ($self->usecachedrepo()) {
477 if (defined(&solv::Repo::add_products)) {
478 $self->{handle}->add_products("/etc/products.d", $solv::Repo::REPO_NO_INTERNALIZE);
480 my $f = solv::xfopen($self->cachepath());
481 $self->{handle}->add_rpmdb_reffp($f, $solv::Repo::REPO_REUSE_REPODATA);
482 $self->writecachedrepo();
490 my $repo = $repodata->{repo}->{appdata};
491 return $repo ? $repo->load_ext($repodata) : 0;
494 die("Usage: p5solv COMMAND [ARGS]\n") unless @ARGV;
495 my $cmd = shift @ARGV;
496 my %cmdabbrev = ( 'ls' => 'list', 'in' => 'install', 'rm' => 'erase',
497 've' => 'verify', 'se' => 'search' );
498 $cmd = $cmdabbrev{$cmd} if $cmdabbrev{$cmd};
501 'install' => $solv::Job::SOLVER_INSTALL,
502 'erase' => $solv::Job::SOLVER_ERASE,
503 'up' => $solv::Job::SOLVER_UPDATE,
504 'dup' => $solv::Job::SOLVER_DISTUPGRADE,
505 'verify' => $solv::Job::SOLVER_VERIFY,
512 if (-d '/etc/zypp/repos.d') {
513 @reposdirs = ( '/etc/zypp/repos.d' );
515 @reposdirs = ( '/etc/yum/repos.d' );
517 for my $reposdir (@reposdirs) {
518 next unless -d $reposdir;
520 next unless opendir($dir, $reposdir);
521 for my $reponame (sort(grep {/\.repo$/} readdir($dir))) {
522 my $cfg = new Config::IniFiles('-file' => "$reposdir/$reponame");
523 for my $alias ($cfg->Sections()) {
524 my $repoattr = {'alias' => $alias, 'enabled' => 0, 'priority' => 99, 'autorefresh' => 1, 'type' => 'rpm-md', 'metadata_expire' => 900};
525 for my $p ($cfg->Parameters($alias)) {
526 $repoattr->{$p} = $cfg->val($alias, $p);
529 if ($repoattr->{type} eq 'rpm-md') {
530 $repo = Repo::rpmmd->new($alias, 'repomd', $repoattr);
531 } elsif ($repoattr->{type} eq 'yast2') {
532 $repo = Repo::susetags->new($alias, 'susetags', $repoattr);
534 $repo = Repo::unknown->new($alias, 'unknown', $repoattr);
541 my $pool = solv::Pool->new();
543 $pool->set_loadcallback(\&load_stub);
545 my $sysrepo = Repo::system->new('@System', 'system');
546 $sysrepo->load($pool);
547 for my $repo (@repos) {
548 $repo->load($pool) if $repo->{enabled};
551 if ($cmd eq 'search') {
552 $pool->createwhatprovides();
553 my $sel = $pool->Selection();
554 my $di = $pool->Dataiterator(0, $solv::SOLVABLE_NAME, $ARGV[0], $solv::Dataiterator::SEARCH_SUBSTRING | $solv::Dataiterator::SEARCH_NOCASE);
556 $sel->add_raw($solv::Job::SOLVER_SOLVABLE, $d->{solvid});
558 for my $s ($sel->solvables()) {
559 print "- ".$s->str()." [$s->{repo}->{name}]: ".$s->lookup_str($solv::SOLVABLE_SUMMARY)."\n";
564 die("unknown command '$cmd'\n") unless defined $cmdactionmap{$cmd};
566 $pool->addfileprovides();
567 $pool->createwhatprovides();
570 for my $arg (@ARGV) {
571 my $flags = $solv::Selection::SELECTION_NAME | $solv::Selection::SELECTION_PROVIDES | $solv::Selection::SELECTION_GLOB;
572 $flags |= $solv::Selection::SELECTION_CANON | $solv::Selection::SELECTION_DOTARCH | $solv::Selection::SELECTION_REL;
574 $flags |= $solv::Selection::SELECTION_FILELIST;
575 $flags |= $solv::Selection::SELECTION_INSTALLED_ONLY if $cmd eq 'erase';
577 my $sel = $pool->select($arg, $flags);
578 if ($sel->isempty()) {
579 $sel = $pool->select($arg, $flags | $solv::Selection::SELECTION_NOCASE);
580 print "[ignoring case for '$arg']\n" unless $sel->isempty();
582 die("nothing matches '$arg'\n") if $sel->isempty();
583 print "[using file list match for '$arg']\n" if $sel->flags() & $solv::Selection::SELECTION_FILELIST;
584 print "[using capability match for '$arg']\n" if $sel->flags() & $solv::Selection::SELECTION_PROVIDES;
585 push @jobs, $sel->jobs($cmdactionmap{$cmd});
588 if (!@jobs && ($cmd eq 'up' || $cmd eq 'dup' || $cmd eq 'verify')) {
589 my $sel = $pool->Selection_all();
590 push @jobs, $sel->jobs($cmdactionmap{$cmd});
593 die("no package matched.\n") unless @jobs;
595 if ($cmd eq 'list' || $cmd eq 'info') {
596 for my $job (@jobs) {
597 for my $s ($job->solvables()) {
598 if ($cmd eq 'info') {
599 printf "Name: %s\n", $s->str();
600 printf "Repo: %s\n", $s->{repo}->{name};
601 printf "Summary: %s\n", $s->lookup_str($solv::SOLVABLE_SUMMARY);
602 my $str = $s->lookup_str($solv::SOLVABLE_URL);
603 printf "Url: %s\n", $str if $str;
604 $str = $s->lookup_str($solv::SOLVABLE_LICENSE);
605 printf "License: %s\n", $str if $str;
606 printf "Description:\n%s\n", $s->lookup_str($solv::SOLVABLE_DESCRIPTION);
608 printf " - %s [%s]\n", $s->str(), $s->{repo}->{name};
609 printf " %s\n", $s->lookup_str($solv::SOLVABLE_SUMMARY);
616 # up magic, turn into install if nothing matches
617 for my $job (@jobs) {
618 $job->{how} ^= $solv::Job::SOLVER_UPDATE ^ $solv::Job::SOLVER_INSTALL if $cmd eq 'up' && $job->isemptyupdate();
621 my $solver = $pool->Solver();
622 $solver->set_flag($solv::Solver::SOLVER_FLAG_SPLITPROVIDES, 1);
623 $solver->set_flag($solv::Solver::SOLVER_FLAG_ALLOW_UNINSTALL, 1) if $cmd eq 'erase';
626 my @problems = $solver->solve(\@jobs);
627 last unless @problems;
628 for my $problem (@problems) {
629 print "Problem $problem->{id}/".@problems.":\n";
630 my $r = $problem->findproblemrule();
632 print $ri->problemstr()."\n";
633 my @solutions = $problem->solutions();
634 for my $solution (@solutions) {
635 print " Solution $solution->{id}:\n";
636 for my $element ($solution->elements(1)) {
637 print " - ".$element->str()."\n";
643 print "Please choose a solution: ";
646 last if $sol eq 's' || $sol eq 'q' || ($sol =~ /^\d+$/ && $sol >= 1 && $sol <= @solutions);
649 exit(1) if $sol eq 'q';
650 my $solution = $solutions[$sol - 1];
651 for my $element ($solution->elements()) {
652 my $newjob = $element->Job();
653 if ($element->{type} == $solv::Solver::SOLVER_SOLUTION_JOB) {
654 $jobs[$element->{jobidx}] = $newjob;
656 push @jobs, $newjob if $newjob && !grep {$_ == $newjob} @jobs;
662 my $trans = $solver->transaction();
664 if ($trans->isempty()) {
665 print "Nothing to do.\n";
669 print "\nTransaction summary:\n\n";
670 for my $c ($trans->classify($solv::Transaction::SOLVER_TRANSACTION_SHOW_OBSOLETES|$solv::Transaction::SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE)) {
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", $c->{fromstr}, $c->{tostr};
685 } elsif ($c->{type} == $solv::Transaction::SOLVER_TRANSACTION_ARCHCHANGE) {
686 printf "$c->{count} arch changes from '%s' to '%s':\n", $c->{fromstr}, $c->{tostr};
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();
703 print("OK to continue (y/n)? ");
707 exit(1) if $yn eq 'n' || $yn eq 'q';
710 my @newpkgs = $trans->newsolvables();
713 my $downloadsize = 0;
714 $downloadsize += $_->lookup_num($solv::SOLVABLE_DOWNLOADSIZE) for @newpkgs;
715 printf "Downloading %d packages, %d K\n", scalar(@newpkgs), $downloadsize;
716 for my $p (@newpkgs) {
717 my $repo = $p->{repo}->{appdata};
718 my ($location) = $p->lookup_location();
719 next unless $location;
720 $location = $repo->packagespath() . $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;
731 print "Committing transaction:\n\n";
733 for my $p ($trans->steps()) {
734 my $steptype = $trans->steptype($p, $solv::Transaction::SOLVER_TRANSACTION_RPM_ONLY);
735 if ($steptype == $solv::Transaction::SOLVER_TRANSACTION_ERASE) {
736 print "erase ".$p->str()."\n";
737 next unless $p->lookup_num($solv::RPM_RPMDBID);
739 $evr =~ s/^[0-9]+://; # strip epoch
740 system('rpm', '-e', '--nodeps', '--nodigest', '--nosignature', "$p->{name}-$evr.$p->{arch}") && die("rpm failed: $?\n");
741 } elsif ($steptype == $solv::Transaction::SOLVER_TRANSACTION_INSTALL || $steptype == $solv::Transaction::SOLVER_TRANSACTION_MULTIINSTALL) {
742 print "install ".$p->str()."\n";
743 my $f = $newpkgsfps{$p->{id}};
744 my $mode = $steptype == $solv::Transaction::SOLVER_TRANSACTION_INSTALL ? '-U' : '-i';
745 system('rpm', $mode, '--force', '--nodeps', '--nodigest', '--nosignature', "/dev/fd/".$f->fileno()) && die("rpm failed: $?\n");
746 delete $newpkgsfps{$p->{id}};