diff options
author | Michael Schroeder <mls@suse.de> | 2011-03-16 15:43:30 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2011-03-16 15:43:30 +0100 |
commit | 599d0bd65d76938be2966da17983ee0e36a0fb5a (patch) | |
tree | 8b6724e1fba40418aac7f480fa2ed030c074db9a /examples | |
parent | ac76b149f7950e0d9c187a53186a8d5c8d6cc534 (diff) | |
download | libsolv-599d0bd65d76938be2966da17983ee0e36a0fb5a.tar.gz libsolv-599d0bd65d76938be2966da17983ee0e36a0fb5a.tar.bz2 libsolv-599d0bd65d76938be2966da17983ee0e36a0fb5a.zip |
- finish rbsolv repository handling
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/p5solv | 2 | ||||
-rwxr-xr-x | examples/pysolv | 4 | ||||
-rwxr-xr-x | examples/rbsolv | 100 | ||||
-rw-r--r-- | examples/solv.i | 2 |
4 files changed, 101 insertions, 7 deletions
diff --git a/examples/p5solv b/examples/p5solv index a1bf8ad..2519d2d 100755 --- a/examples/p5solv +++ b/examples/p5solv @@ -185,7 +185,7 @@ sub writecachedrepo { die("internal error, cannot reload solv file\n") unless $self->{'handle'}->add_solv($f, $solv::Repo::SOLV_ADD_NO_STUBS); } else { $info->extend_to_repo(); - $info->read_solv_flags($f, $solv::Repo::REPO_EXTEND_SOLVABLES); + $info->add_solv($f, $solv::Repo::REPO_EXTEND_SOLVABLES); } solv::xfclose($f); } diff --git a/examples/pysolv b/examples/pysolv index f2f78be..e75c2b9 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -278,7 +278,7 @@ class repo_generic(dict): # info.write() has written the data info.extend_to_repo() # LOCALPOOL does not help as pool already contains all ids - info.read_solv_flags(nf, Repo.REPO_EXTEND_SOLVABLES) + info.add_solv(nf, Repo.REPO_EXTEND_SOLVABLES) solv.xfclose(nf) os.rename(tmpname, self.cachepath(ext)) except IOError, e: @@ -290,7 +290,7 @@ class repo_generic(dict): return if 'handle' not in self: return - if not self.handle.nsolvables: + if self.handle.isempty(): return # make sure there's just one real repodata with extensions repodata = self.handle.first_repodata() diff --git a/examples/rbsolv b/examples/rbsolv index 6c8afbe..b119763 100755 --- a/examples/rbsolv +++ b/examples/rbsolv @@ -179,6 +179,19 @@ class Repo_generic end f.syswrite(ext ? @extcookie : @cookie) f.close(false) + if @handle.iscontiguous? + sf = Solv::xfopen(f.path) + if sf + if !ext + @handle.empty() + abort("internal error, cannot reload solv file") unless @handle.add_solv(sf, Solv::Repo::SOLV_ADD_NO_STUBS) + else + info.extend_to_repo() + info.add_solv(sf, Solv::Repo::REPO_EXTEND_SOLVABLES) + end + Solv::xfclose(sf) + end + end File.rename(f.path, cachepath(ext)) f.unlink return true @@ -187,6 +200,19 @@ class Repo_generic end end + def updateaddedprovides(addedprovides) + return if @incomplete + return unless @handle && !@handle.isempty? + repodata = @handle.first_repodata() + return unless repodata + oldaddedprovides = repodata.lookup_idarray(Solv::SOLVID_META, Solv::REPOSITORY_ADDEDFILEPROVIDES) + return if (oldaddedprovides | addedprovides) == oldaddedprovides + for id in addedprovides + repodata.add_idarray(Solv::SOLVID_META, Solv::REPOSITORY_ADDEDFILEPROVIDES, id) + end + repodata.internalize() + writecachedrepo(nil, repodata) + end end class Repo_rpmmd < Repo_generic @@ -365,11 +391,73 @@ class Repo_susetags < Repo_generic 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 + repodata.add_flexarray(Solv::SOLVID_META, Solv::REPOSITORY_EXTERNAL, h) + end + def add_exts repodata = @handle.add_repodata(0) + di = @handle.Dataiterator(Solv::SOLVID_META, Solv::SUSETAGS_FILE_NAME, nil, 0) + di.prepend_keyname(Solv::SUSETAGS_FILE) + for d in di + filename = d.match_str + next unless filename && filename =~ /^packages\.(..)(?:\..*)$/ + next if $1 == 'en' || $1 == 'gz' + add_ext(repodata, filename, $1) + end repodata.internalize() end + def load_ext(repodata) + filename = repodata.lookup_str(Solv::SOLVID_META, Solv::SUSETAGS_FILE_NAME) + ext = filename[9,2] + print "[#{@name}:#{ext}: " + STDOUT.flush + if usecachedrepo(ext) + puts "cached]\n" + return true + end + puts "fetching]\n" + defvendorid = @handle.lookup_id(Solv::SOLVID_META, Solv::SUSETAGS_DEFAULTVENDOR) + descrdir = @handle.lookup_str(Solv::SOLVID_META, Solv::SUSETAGS_DESCRDIR) + descrdir = "suse/setup/descr" unless descrdir + filechksum = repodata.lookup_checksum(Solv::SOLVID_META, Solv::SUSETAGS_FILE_CHECKSUM) + f = download("#{descrdir}/#{filename}", true, filechksum) + return false unless f + @handle.add_susetags(f, defvendorid, ext, Solv::Repo::REPO_USE_LOADING|Solv::Repo::REPO_EXTEND_SOLVABLES) + Solv::xfclose(f) + writecachedrepo(ext, repodata) + return true + end + end class Repo_unknown < Repo_generic @@ -518,7 +606,7 @@ def mkjobs_filelist(pool, cmd, arg) di.skip_solvable() end return [] if matches.empty? - puts "[using file list match for '#{arg}'" + puts "[using file list match for '#{arg}']" if matches.length > 1 return [ pool.Job(Solv::Job::SOLVER_SOLVABLE_ONE_OF, pool.towhatprovides(matches)) ] else @@ -594,8 +682,14 @@ if cmd == 'search' exit end -pool.addfileprovides -pool.createwhatprovides +addedprovides = pool.addfileprovides_ids() +if !addedprovides.empty? + sysrepo.updateaddedprovides(addedprovides) + for repo in repos + repo.updateaddedprovides(addedprovides) + end +end +pool.createwhatprovides() jobs = [] for arg in args diff --git a/examples/solv.i b/examples/solv.i index fd38fdb..15a737b 100644 --- a/examples/solv.i +++ b/examples/solv.i @@ -2088,7 +2088,7 @@ rb_eval_string( void write(FILE *fp) { repodata_write($self->repo->repodata + $self->id, fp, repo_write_stdkeyfilter, 0); } - bool read_solv_flags(FILE *fp, int flags = 0) { + bool add_solv(FILE *fp, int flags = 0) { Repodata *data = $self->repo->repodata + $self->id; int r, oldstate = data->state; data->state = REPODATA_LOADING; |