$chksum->add("1.1");
$chksum->add($cookie);
$chksum->add_fstat(fileno($f));
- my $extcookie = $chksum->raw();
- substr($extcookie, 0, 1) = chr(1) if ord(substr($extcookie, 0, 1)) == 0;
- return $extcookie;
+ return $chksum->raw();
}
sub cachepath {
my $dorefresh = $self->{autorefresh};
if ($dorefresh) {
my @s = stat($self->cachepath());
- $dorefresh = 0 if @s && ($self->{'metadata_expire'} == -1 || time() - $s[9] < $self->{'metadata_expire'});
+ $dorefresh = 0 if @s && ($self->{metadata_expire} == -1 || time() - $s[9] < $self->{metadata_expire});
}
$self->{cookie} = '';
+ $self->{extcookie} = '';
if (!$dorefresh && $self->usecachedrepo()) {
print "repo: '$self->{alias}' cached\n";
return 1;
$url =~ s!/$!!;
$url .= "/$file";
open(my $f, '+>', undef) || die;
- fcntl($f, Fcntl::F_SETFD, 0);
+ fcntl($f, Fcntl::F_SETFD, 0); # turn off CLOEXEC
my $st = system('curl', '-f', '-s', '-L', '-o', "/dev/fd/" . fileno($f), '--', $url);
if (POSIX::lseek(fileno($f), 0, POSIX::SEEK_END) == 0 && ($st == 0 || !$chksum)) {
return undef;
}
sub writecachedrepo {
- my ($self, $ext, $info) = @_;
+ my ($self, $ext, $repodata) = @_;
return if $self->{incomplete};
mkdir("/var/cache/solv", 0755) unless -d "/var/cache/solv";
my ($f, $tmpname);
return unless $f;
chmod 0444, $f;
my $ff = solv::xfopen_fd(undef, fileno($f));
- if (!$info) {
+ if (!$repodata) {
$self->{handle}->write($ff);
} elsif ($ext) {
- $info->write($ff);
+ $repodata->write($ff);
} else {
$self->{handle}->write_first_repodata($ff);
}
if ($f) {
if (!$ext) {
$self->{handle}->empty();
- die("internal error, cannot reload solv file\n") unless $self->{handle}->add_solv($f, $solv::Repo::SOLV_ADD_NO_STUBS);
+ die("internal error, cannot reload solv file\n") unless $self->{handle}->add_solv($f, $repodata ? 0 : $solv::Repo::SOLV_ADD_NO_STUBS);
} else {
- $info->extend_to_repo();
+ $repodata->extend_to_repo();
my $flags = $solv::Repo::REPO_EXTEND_SOLVABLES;
$flags |= $solv::Repo::REPO_LOCALPOOL if $ext ne 'DL';
- $info->add_solv($f, $flags);
+ $repodata->add_solv($f, $flags);
}
}
}
return '';
}
+my %langtags = (
+ $solv::SOLVABLE_SUMMARY => $solv::REPOKEY_TYPE_STR,
+ $solv::SOLVABLE_DESCRIPTION => $solv::REPOKEY_TYPE_STR,
+ $solv::SOLVABLE_EULA => $solv::REPOKEY_TYPE_STR,
+ $solv::SOLVABLE_MESSAGEINS => $solv::REPOKEY_TYPE_STR,
+ $solv::SOLVABLE_MESSAGEDEL => $solv::REPOKEY_TYPE_STR,
+ $solv::SOLVABLE_CATEGORY => $solv::REPOKEY_TYPE_ID,
+);
+
+sub add_ext_keys {
+ my ($self, $ext, $repodata, $handle) = @_;
+ if ($ext eq 'DL') {
+ $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOSITORY_DELTAINFO);
+ $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_FLEXARRAY);
+ } elsif ($ext eq 'DU') {
+ $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_DISKUSAGE);
+ $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRNUMNUMARRAY);
+ } elsif ($ext eq 'FL') {
+ $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_FILELIST);
+ $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRSTRARRAY);
+ } else {
+ for my $langid (sort { $a <=> $b } keys %langtags) {
+ $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $self->{handle}->{pool}->id2langid($langid, $ext, 1));
+ $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $langtags{$langid});
+ }
+ }
+}
+
package Repo::rpmmd;
our @ISA = ('Repo::generic');
sub find {
my ($self, $what) = @_;
- my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_TYPE, $what, $solv::Dataiterator::SEARCH_STRING);
+ my $di = $self->{handle}->Dataiterator_meta($solv::REPOSITORY_REPOMD_TYPE, $what, $solv::Dataiterator::SEARCH_STRING);
$di->prepend_keyname($solv::REPOSITORY_REPOMD);
for my $d (@$di) {
my $dp = $d->parentpos();
$repodata->set_poolstr($handle, $solv::REPOSITORY_REPOMD_TYPE, $what);
$repodata->set_str($handle, $solv::REPOSITORY_REPOMD_LOCATION, $filename);
$repodata->set_checksum($handle, $solv::REPOSITORY_REPOMD_CHECKSUM, $chksum);
- if ($ext eq 'DL') {
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOSITORY_DELTAINFO);
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_FLEXARRAY);
- } elsif ($ext eq 'FL') {
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_FILELIST);
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRSTRARRAY);
- }
+ $self->add_ext_keys($ext, $repodata, $handle);
$repodata->add_flexarray($solv::SOLVID_META, $solv::REPOSITORY_EXTERNAL, $handle);
}
sub add_exts {
my ($self) = @_;
my $repodata = $self->{handle}->add_repodata(0);
+ $repodata->extend_to_repo();
$self->add_ext($repodata, 'deltainfo', 'DL');
$self->add_ext($repodata, 'filelists', 'FL');
$repodata->internalize();
sub find {
my ($self, $what) = @_;
- my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME, $what, $solv::Dataiterator::SEARCH_STRING);
+ my $di = $self->{handle}->Dataiterator_meta($solv::SUSETAGS_FILE_NAME, $what, $solv::Dataiterator::SEARCH_STRING);
$di->prepend_keyname($solv::SUSETAGS_FILE);
for my $d (@$di) {
my $dp = $d->parentpos();
return (undef, undef);
}
-my %langtags = (
- $solv::SOLVABLE_SUMMARY => $solv::REPOKEY_TYPE_STR,
- $solv::SOLVABLE_DESCRIPTION => $solv::REPOKEY_TYPE_STR,
- $solv::SOLVABLE_EULA => $solv::REPOKEY_TYPE_STR,
- $solv::SOLVABLE_MESSAGEINS => $solv::REPOKEY_TYPE_STR,
- $solv::SOLVABLE_MESSAGEDEL => $solv::REPOKEY_TYPE_STR,
- $solv::SOLVABLE_CATEGORY => $solv::REPOKEY_TYPE_ID,
-);
sub add_ext {
my ($self, $repodata, $what, $ext) = @_;
my ($filename, $chksum) = $self->find($what);
+ return unless $filename;
my $handle = $repodata->new_handle();
$repodata->set_str($handle, $solv::SUSETAGS_FILE_NAME, $filename);
$repodata->set_checksum($handle, $solv::SUSETAGS_FILE_CHECKSUM, $chksum);
- if ($ext eq 'DL') {
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOSITORY_DELTAINFO);
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_FLEXARRAY);
- } elsif ($ext eq 'DU') {
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_DISKUSAGE);
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRNUMNUMARRAY);
- } elsif ($ext eq 'FL') {
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::SOLVABLE_FILELIST);
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $solv::REPOKEY_TYPE_DIRSTRARRAY);
- } else {
- for my $langid (sort { $a <=> $b } keys %langtags) {
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $self->{handle}->{pool}->id2langid($langid, $ext, 1));
- $repodata->add_idarray($handle, $solv::REPOSITORY_KEYS, $langtags{$langid});
- }
- }
+ $self->add_ext_keys($ext, $repodata, $handle);
$repodata->add_flexarray($solv::SOLVID_META, $solv::REPOSITORY_EXTERNAL, $handle);
}
sub add_exts {
my ($self) = @_;
my $repodata = $self->{handle}->add_repodata(0);
- my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME, undef, 0);
+ my $di = $self->{handle}->Dataiterator_meta($solv::SUSETAGS_FILE_NAME, undef, 0);
$di->prepend_keyname($solv::SUSETAGS_FILE);
for my $d (@$di) {
my $filename = $d->str();
die("Usage: p5solv COMMAND [ARGS]\n") unless @ARGV;
my $cmd = shift @ARGV;
-my %cmdabbrev = ( 'li' => 'list', 'in' => 'install', 'rm' => 'erase',
+my %cmdabbrev = ( 'ls' => 'list', 'in' => 'install', 'rm' => 'erase',
've' => 'verify', 'se' => 'search' );
$cmd = $cmdabbrev{$cmd} if $cmdabbrev{$cmd};
}
for my $reposdir (@reposdirs) {
next unless -d $reposdir;
- local *DIR;
- next unless opendir(DIR, $reposdir);
- for my $reponame (sort(grep {/\.repo$/} readdir(DIR))) {
+ my $dir;
+ next unless opendir($dir, $reposdir);
+ for my $reponame (sort(grep {/\.repo$/} readdir($dir))) {
my $cfg = new Config::IniFiles('-file' => "$reposdir/$reponame");
for my $alias ($cfg->Sections()) {
my $repoattr = {'alias' => $alias, 'enabled' => 0, 'priority' => 99, 'autorefresh' => 1, 'type' => 'rpm-md', 'metadata_expire' => 900};
if ($cmd eq 'search') {
$pool->createwhatprovides();
my $sel = $pool->Selection();
- my $di = $pool->Dataiterator(0, $solv::SOLVABLE_NAME, $ARGV[0], $solv::Dataiterator::SEARCH_SUBSTRING | $solv::Dataiterator::SEARCH_NOCASE);
+ my $di = $pool->Dataiterator($solv::SOLVABLE_NAME, $ARGV[0], $solv::Dataiterator::SEARCH_SUBSTRING | $solv::Dataiterator::SEARCH_NOCASE);
for my $d (@$di) {
$sel->add_raw($solv::Job::SOLVER_SOLVABLE, $d->{solvid});
}
$pool->addfileprovides();
$pool->createwhatprovides();
+$pool->set_namespaceproviders($solv::NAMESPACE_LANGUAGE, $pool->Dep('de'), 1);
my @jobs;
for my $arg (@ARGV) {
print "[ignoring case for '$arg']\n" unless $sel->isempty();
}
die("nothing matches '$arg'\n") if $sel->isempty();
- print "[using file list match for '$arg']\n" if $sel->flags() & $solv::Selection::SELECTION_FILELIST;
- print "[using capability match for '$arg']\n" if $sel->flags() & $solv::Selection::SELECTION_PROVIDES;
+ print "[using file list match for '$arg']\n" if $sel->{flags} & $solv::Selection::SELECTION_FILELIST;
+ print "[using capability match for '$arg']\n" if $sel->{flags} & $solv::Selection::SELECTION_PROVIDES;
push @jobs, $sel->jobs($cmdactionmap{$cmd});
}
last unless @problems;
for my $problem (@problems) {
print "Problem $problem->{id}/".@problems.":\n";
- my $r = $problem->findproblemrule();
- my $ri = $r->info();
- print $ri->problemstr()."\n";
+ print $problem->str()."\n";
my @solutions = $problem->solutions();
for my $solution (@solutions) {
print " Solution $solution->{id}:\n";
exit(1) if $yn eq 'n' || $yn eq 'q';
}
-my @newpkgs = $trans->newpackages();
+my @newpkgs = $trans->newsolvables();
my %newpkgsfps;
if (@newpkgs) {
my $downloadsize = 0;
$downloadsize += $_->lookup_num($solv::SOLVABLE_DOWNLOADSIZE) for @newpkgs;
- printf "Downloading %d packages, %d K\n", scalar(@newpkgs), $downloadsize;
+ printf "Downloading %d packages, %d K\n", scalar(@newpkgs), $downloadsize / 1024;
for my $p (@newpkgs) {
my $repo = $p->{repo}->{appdata};
my ($location) = $p->lookup_location();
print "install ".$p->str()."\n";
my $f = $newpkgsfps{$p->{id}};
my $mode = $steptype == $solv::Transaction::SOLVER_TRANSACTION_INSTALL ? '-U' : '-i';
+ $f->cloexec(0);
system('rpm', $mode, '--force', '--nodeps', '--nodigest', '--nosignature', "/dev/fd/".$f->fileno()) && die("rpm failed: $?\n");
delete $newpkgsfps{$p->{id}};
}