aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-04 22:13:33 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-04 22:13:33 +0000
commit913279cc629ab079a1d9a1adcdbdf574330733d8 (patch)
tree59b1d28bf736f5d9fee59a9c199525345eadd99b
parentdb949a7a09484b44445cb832e48bc8f6d90fc636 (diff)
downloadpaludis-913279cc629ab079a1d9a1adcdbdf574330733d8.tar.gz
paludis-913279cc629ab079a1d9a1adcdbdf574330733d8.tar.xz
(ruby) Make find_unused_distfiles.rb work again.
-rwxr-xr-x[-rw-r--r--]ruby/demos/find_unused_distfiles.rb37
1 files changed, 23 insertions, 14 deletions
diff --git a/ruby/demos/find_unused_distfiles.rb b/ruby/demos/find_unused_distfiles.rb
index e55c026..65f106c 100644..100755
--- a/ruby/demos/find_unused_distfiles.rb
+++ b/ruby/demos/find_unused_distfiles.rb
@@ -54,19 +54,32 @@ end
env = Paludis::EnvironmentMaker.instance.make_from_spec env_spec
+def collect_filenames(env, parts, id, spec)
+ case spec
+ when Paludis::AllDepSpec
+ spec.each { | item | collect_filenames(env, parts, id, item) }
+ when Paludis::UseDepSpec
+ spec.each { | item | collect_filenames(env, parts, id, item) } if
+ env.query_use(spec.flag, id) ^ spec.inverse?
+ when Paludis::FetchableURIDepSpec
+ parts[spec.filename] = true
+ when Paludis::URILabelsDepSpec
+ # don't need to do anything
+ else
+ raise "Unexpected DepSpec class #{spec.class} in #{id}"
+ end
+end
+
# build up a list of all src_uri things that're used by installed packages
parts = Hash.new
env.package_database.repositories.each do | repo |
- repo.installed_interface or next
+ repo.some_ids_might_support_action(Paludis::SupportsInstalledActionTest.new) or next
repo.category_names.each do | cat |
repo.package_names(cat).each do | pkg |
- repo.version_specs(pkg).each do | ver |
- src_uri = repo.version_metadata(pkg, ver).src_uri_string
- src_uri or next
- src_uri.split(/\s+/).each do | part |
- part =~ %r~/~ or next
- parts[part.sub(%r~^.*/~, "")] = true
- end
+ repo.package_ids(pkg).each do | id |
+ id.supports_action(Paludis::SupportsInstalledActionTest.new) or next
+ collect_filenames(env, parts, id, id.fetches_key.value) if
+ id.fetches_key && id.fetches_key.value
end
end
end
@@ -75,12 +88,8 @@ end
# figure out a list of places where distfiles can be found
distdirs = []
env.package_database.repositories.each do | repo |
- repo.info(false).sections.each do | info_section |
- info_section.kvs.each do | key, value |
- key == "distdir" or next
- distdirs << value unless distdirs.member? value
- end
- end
+ key = repo['distdir'] or next
+ distdirs << key.value unless distdirs.member? key.value
end
# display each unused distfile