}
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');
$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);
}
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 $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);
}
else:
# compatibility to c code
if ord(extcookie[0]) == 0:
- extcookie[0] = chr(1)
+ extcookie = chr(1) + extcookie[1:]
return extcookie
def cachepath(self, ext = None):
return False
return True
- def writecachedrepo(self, ext, info=None):
+ def writecachedrepo(self, ext, repodata=None):
if 'incomplete' in self:
return
tmpname = None
os.fchmod(fd, 0o444)
f = os.fdopen(fd, 'wb+')
f = solv.xfopen_fd(None, f.fileno())
- if not info:
+ if not repodata:
self.handle.write(f)
elif ext:
- info.write(f)
- else: # rewrite_repos case
+ repodata.write(f)
+ else: # rewrite_repos case, do not write stubs
self.handle.write_first_repodata(f)
f.flush()
if self.type != 'system' and not ext:
if 'extcookie' not in self:
self['extcookie'] = self.calc_cookie_ext(f, self['cookie'])
- os.write(f.fileno(), self['extcookie'])
+ f.write(self['extcookie'])
if not ext:
- os.write(f.fileno(), self['cookie'])
+ f.write(self['cookie'])
else:
- os.write(f.fileno(), self['extcookie'])
+ f.write(self['extcookie'])
f.close
if self.handle.iscontiguous():
# switch to saved repo to activate paging and save memory
if not ext:
# main repo
self.handle.empty()
- if not self.handle.add_solv(nf, solv.Repo.SOLV_ADD_NO_STUBS):
+ flags = solv.Repo.SOLV_ADD_NO_STUBS
+ if repodata:
+ flags = 0 # rewrite repos case, recreate stubs
+ if not self.handle.add_solv(nf, flags):
sys.exit("internal error, cannot reload solv file")
else:
# extension repodata
# need to extend to repo boundaries, as this is how
- # info.write() has written the data
- info.extend_to_repo()
+ # repodata.write() has written the data
+ repodata.extend_to_repo()
flags = solv.Repo.REPO_EXTEND_SOLVABLES
if ext != 'DL':
flags |= solv.Repo.REPO_LOCALPOOL
- info.add_solv(nf, flags)
+ repodata.add_solv(nf, flags)
os.rename(tmpname, self.cachepath(ext))
except (OSError, IOError):
if tmpname:
def packagespath(self):
return ''
+ def add_ext_keys(self, ext, repodata, handle):
+ if ext == 'DU':
+ repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.SOLVABLE_DISKUSAGE)
+ repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.REPOKEY_TYPE_DIRNUMNUMARRAY)
+ elif ext == 'FL':
+ repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.SOLVABLE_FILELIST)
+ repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.REPOKEY_TYPE_DIRSTRARRAY)
+ else:
+ for langtag, langtagtype in [
+ (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)
+ ]:
+ repodata.add_idarray(handle, solv.REPOSITORY_KEYS, self.handle.pool.id2langid(langtag, ext, 1))
+ repodata.add_idarray(handle, solv.REPOSITORY_KEYS, langtagtype)
+
+
class repo_repomd(repo_generic):
def load(self, pool):
if super(repo_repomd, self).load(pool):
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 == 'DL':
- repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.REPOSITORY_DELTAINFO)
- repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.REPOKEY_TYPE_FLEXARRAY)
- elif ext == '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)
def add_exts(self):
repodata.set_str(handle, solv.SUSETAGS_FILE_NAME, filename)
if chksum:
repodata.set_checksum(handle, solv.SUSETAGS_FILE_CHECKSUM, chksum)
- if ext == 'DU':
- repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.SOLVABLE_DISKUSAGE)
- repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.REPOKEY_TYPE_DIRNUMNUMARRAY)
- elif ext == 'FL':
- repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.SOLVABLE_FILELIST)
- repodata.add_idarray(handle, solv.REPOSITORY_KEYS, solv.REPOKEY_TYPE_DIRSTRARRAY)
- else:
- for langtag, langtagtype in [
- (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)
- ]:
- repodata.add_idarray(handle, solv.REPOSITORY_KEYS, self.handle.pool.id2langid(langtag, ext, 1))
- repodata.add_idarray(handle, solv.REPOSITORY_KEYS, langtagtype)
+ self.add_ext_keys(ext, repodata, handle)
repodata.add_flexarray(solv.SOLVID_META, solv.REPOSITORY_EXTERNAL, handle)
def add_exts(self):
return true
end
- def writecachedrepo(ext, info = nil)
+ def writecachedrepo(ext, repodata = nil)
return if @incomplete
begin
Dir::mkdir("/var/cache/solv", 0755) unless FileTest.directory?("/var/cache/solv")
f = Tempfile.new('.newsolv-', '/var/cache/solv')
f.chmod(0444)
sf = Solv::xfopen_fd('', f.fileno)
- if !info
+ if !repodata
@handle.write(sf)
elsif ext
- info.write(sf)
+ repodata.write(sf)
else
@handle.write_first_repodata(sf)
end
if sf
if !ext
@handle.empty()
- abort("internal error, cannot reload solv file") unless @handle.add_solv(sf, Solv::Repo::SOLV_ADD_NO_STUBS)
+ abort("internal error, cannot reload solv file") unless @handle.add_solv(sf, repodata ? 0 : Solv::Repo::SOLV_ADD_NO_STUBS)
else
- info.extend_to_repo()
+ repodata.extend_to_repo()
flags = Solv::Repo::REPO_EXTEND_SOLVABLES
flags |= Solv::Repo::REPO_LOCALPOOL if ext != 'DL'
- info.add_solv(sf, flags)
+ repodata.add_solv(sf, flags)
end
sf.close
end
def packagespath()
return ''
end
+
+ @@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,
+ }
+
+ def add_ext_keys(ext, repodata, h)
+ if ext == 'DL'
+ repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOSITORY_DELTAINFO)
+ repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_FLEXARRAY)
+ elsif ext == 'DU'
+ repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::SOLVABLE_DISKUSAGE)
+ repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_DIRNUMNUMARRAY)
+ elsif ext == 'FL'
+ repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::SOLVABLE_FILELIST)
+ repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_DIRSTRARRAY)
+ else
+ @@langtags.sort.each do |langid, langtype|
+ repodata.add_idarray(h, Solv::REPOSITORY_KEYS, @handle.pool.id2langid(langid, ext, true))
+ repodata.add_idarray(h, Solv::REPOSITORY_KEYS, langtype)
+ end
+ end
+ end
end
class Repo_rpmmd < Repo_generic
repodata.set_poolstr(h, Solv::REPOSITORY_REPOMD_TYPE, what)
repodata.set_str(h, Solv::REPOSITORY_REPOMD_LOCATION, filename)
repodata.set_checksum(h, Solv::REPOSITORY_REPOMD_CHECKSUM, filechksum)
- if ext == 'DL'
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOSITORY_DELTAINFO)
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_FLEXARRAY)
- elsif ext == 'FL'
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::SOLVABLE_FILELIST)
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_DIRSTRARRAY)
- end
+ add_ext_keys(ext, repodata, h)
repodata.add_flexarray(Solv::SOLVID_META, Solv::REPOSITORY_EXTERNAL, h)
end
return true
end
- @@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,
- }
-
def add_ext(repodata, what, ext)
(filename, filechksum) = find(what)
h = repodata.new_handle()
repodata.set_str(h, Solv::SUSETAGS_FILE_NAME, filename)
repodata.set_checksum(h, Solv::SUSETAGS_FILE_CHECKSUM, filechksum)
- if ext == 'DL'
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOSITORY_DELTAINFO)
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_FLEXARRAY)
- elsif ext == 'DU'
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::SOLVABLE_DISKUSAGE)
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_DIRNUMNUMARRAY)
- elsif ext == 'FL'
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::SOLVABLE_FILELIST)
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_DIRSTRARRAY)
- else
- @@langtags.sort.each do |langid, langtype|
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, @handle.pool.id2langid(langid, ext, true))
- repodata.add_idarray(h, Solv::REPOSITORY_KEYS, langtype)
- end
- end
+ add_ext_keys(ext, repodata, h)
repodata.add_flexarray(Solv::SOLVID_META, Solv::REPOSITORY_EXTERNAL, h)
end
end
f = Solv::xfopen(cachepath())
@handle.add_rpmdb_reffp(f, Solv::Repo::REPO_REUSE_REPODATA)
- f.close
+ f.close if f
writecachedrepo(nil)
return true
end
return $ff
}
-proc repo_generic_add_ext_key {selfName repodata h ext} {
+proc repo_generic_add_ext_keys {selfName ext repodata h} {
upvar $selfName self
if {$ext eq "DL"} {
$repodata add_idarray $h $solv::REPOSITORY_KEYS $solv::REPOSITORY_DELTAINFO
$repodata set_poolstr $h $solv::REPOSITORY_REPOMD_TYPE $what
$repodata set_str $h $solv::REPOSITORY_REPOMD_LOCATION [lindex $where 0]
$repodata set_checksum $h $solv::REPOSITORY_REPOMD_CHECKSUM [lindex $where 1]
- repo_generic_add_ext_key self $repodata $h $ext
+ repo_generic_add_ext_keys self $ext $repodata $h
$repodata add_flexarray $solv::SOLVID_META $solv::REPOSITORY_EXTERNAL $h
}
return 0
}
set self(cookie) [repo_calc_cookie_fp self $f]
- if [repo_usecachedrepo self] {
+ if [repo_usecachedrepo self "-" 1] {
puts "cached"
return 1
}
set h [$repodata new_handle]
$repodata set_str $h $solv::SUSETAGS_FILE_NAME [lindex $where 0]
$repodata set_checksum $h $solv::SUSETAGS_FILE_CHECKSUM [lindex $where 1]
- repo_generic_add_ext_key self $repodata $h $ext
+ repo_generic_add_ext_keys self $ext $repodata $h
$repodata add_flexarray $solv::SOLVID_META $solv::REPOSITORY_EXTERNAL $h
}
return 0
}
set self(cookie) [repo_calc_cookie_fp self $f]
- if [repo_usecachedrepo self] {
+ if [repo_usecachedrepo self "-" 1] {
puts "cached"
return 1
}