aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-05 04:07:53 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-05 04:07:53 +0000
commit6c5c4c849def5acb018682129810008dd97ad5b7 (patch)
tree672c39ea382e8a4a8aa181d0a9f202212be76f63
parentea238e640663c2beacf0bf26feceacb4061da619 (diff)
downloadpaludis-6c5c4c849def5acb018682129810008dd97ad5b7.tar.gz
paludis-6c5c4c849def5acb018682129810008dd97ad5b7.tar.xz
FAIL
-rwxr-xr-xruby/demos/find_unused_distfiles.rb107
-rw-r--r--ruby/metadata_key.cc15
-rw-r--r--ruby/package_id_TEST.rb3
3 files changed, 30 insertions, 95 deletions
diff --git a/ruby/demos/find_unused_distfiles.rb b/ruby/demos/find_unused_distfiles.rb
index 84e0cec..813d962 100755
--- a/ruby/demos/find_unused_distfiles.rb
+++ b/ruby/demos/find_unused_distfiles.rb
@@ -8,22 +8,15 @@ Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
Paludis::Log.instance.program_name = $0
opts = GetoptLong.new(
- [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
- [ '--version', '-V', GetoptLong::NO_ARGUMENT ],
- [ '--log-level', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--environment', '-E', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--size-limit', '-s', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--time-limit', '-t', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--mirror-repository', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--mirror-distdir', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--write-cache-dir', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--master-repository-dir', GetoptLong::REQUIRED_ARGUMENT ])
-
-env_spec = nil
-size_limit = time_limit = nil
-mirror_repository = mirror_distdir = nil
-write_cache_dir = master_repository_dir = "/var/empty"
-
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
+ [ '--version', '-V', GetoptLong::NO_ARGUMENT ],
+ [ '--log-level', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--environment', '-E', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--size-limit', '-s', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--time-limit', '-t', GetoptLong::REQUIRED_ARGUMENT ])
+
+env_spec = ""
+size_limit = time_limit = nil
opts.each do | opt, arg |
case opt
when '--help'
@@ -38,11 +31,6 @@ opts.each do | opt, arg |
puts
puts " --size-limit limit Don't delete anything bigger than limit (number followed by one of g, m, k, b)"
puts " --time-limit limit Don't delete anything newer than limit (number followed by one of h, d, w, m, y)"
- puts
- puts " --mirror-repository In mirror mode, the location of the ebuild repository"
- puts " --mirror-distdir In mirror mode, the location of the downloaded files"
- puts " --write-cache-dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
- puts " --master-repository-dir Use the specified location for the master repository"
exit 0
when '--version'
@@ -96,61 +84,22 @@ opts.each do | opt, arg |
exit 1
end
- when '--mirror-repository'
- mirror_repository = arg
- when '--mirror-distdir'
- mirror_distdir = arg
-
- when '--write-cache-dir'
- write_cache_dir = arg
- when '--master-repository-dir'
- master_repository_dir = arg
-
end
end
-if mirror_repository.nil? ^ mirror_distdir.nil? then
- puts "Must specify neither or both of --mirror-repository and --mirror-distdir"
- exit 1
-end
-if mirror_repository && env_spec then
- puts "Can't use --environment in mirror mode"
- exit 1
-end
-
-if mirror_repository then
- $env = Paludis::NoConfigEnvironment.new(mirror_repository, write_cache_dir, master_repository_dir)
- relevant_packages = Paludis::Query::Repository.new(env.main_repository.name)
- $banned_labels = { } # XXX
-else
- $env = Paludis::EnvironmentMaker.instance.make_from_spec(env_spec || "")
- relevant_packages = Paludis::Query::SupportsInstalledAction.new
- $banned_labels = { }
-end
+env = Paludis::EnvironmentMaker.instance.make_from_spec env_spec
-def collect_filenames(parts, id, label, spec)
+def collect_filenames(env, parts, id, spec)
case spec
-
when Paludis::AllDepSpec
- new_label = label.dup
- spec.each do | item |
- collect_filenames(parts, id, new_label, item)
- end
-
+ spec.each { | item | collect_filenames(env, parts, id, item) }
when Paludis::UseDepSpec
- if $env.query_use(spec.flag, id) ^ spec.inverse? then
- new_label = label.dup
- spec.each do | item |
- collect_filenames(parts, id, new_label, item)
- end
- end
-
+ 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 unless banned_labels[label[0]]
-
+ parts[spec.filename] = true
when Paludis::URILabelsDepSpec
- label[0] = spec.to_s # XXX
-
+ # don't need to do anything
else
raise "Unexpected DepSpec class #{spec.class} in #{id}"
end
@@ -158,20 +107,24 @@ end
# build up a list of all src_uri things that're used by installed packages
parts = Hash.new
-$env.package_database.query(relevant_packages, Paludis::QueryOrder::Whatever) do | id |
- collect_filenames(parts, id, [id.fetches_key.initial_label], id.fetches_key.value) if
- id.fetches_key && id.fetches_key.value
+env.package_database.repositories.each do | repo |
+ 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.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
end
# figure out a list of places where distfiles can be found
distdirs = []
-if mirror_distdir then
- distdirs << mirror_distdir
-else
- $env.package_database.repositories.each do | repo |
- key = repo['distdir'] or next
- distdirs << key.value unless distdirs.member? key.value
- end
+env.package_database.repositories.each do | repo |
+ key = repo['distdir'] or next
+ distdirs << key.value unless distdirs.member? key.value
end
# display each unused distfile
diff --git a/ruby/metadata_key.cc b/ruby/metadata_key.cc
index 89e086a..7557559 100644
--- a/ruby/metadata_key.cc
+++ b/ruby/metadata_key.cc
@@ -342,20 +342,6 @@ namespace
}
};
- /*
- * call-seq:
- * initial_label -> String
- *
- * Return a String that represents the initial label to use when
- * deciding the behaviour of individual items in the heirarchy.
- */
- VALUE
- metadata_fetchable_uri_spec_tree_key_initial_label(VALUE self)
- {
- tr1::shared_ptr<const MetadataKey> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
- return rb_str_new2(stringify(*(tr1::static_pointer_cast<const MetadataSpecTreeKey<FetchableURISpecTree> >(*self_ptr))->initial_label()).c_str());
- }
VALUE
repository_mask_info_mask_file(VALUE self)
@@ -533,7 +519,6 @@ namespace
*/
c_metadata_fetchable_uri_spec_tree_key = rb_define_class_under(paludis_module(), "MetadataFetchableURISpecTreeKey", c_metadata_key);
rb_define_method(c_metadata_fetchable_uri_spec_tree_key, "value", RUBY_FUNC_CAST((&SpecTreeValue<FetchableURISpecTree>::fetch)), 0);
- rb_define_method(c_metadata_fetchable_uri_spec_tree_key, "initial_label", RUBY_FUNC_CAST(&metadata_fetchable_uri_spec_tree_key_initial_label), 0);
/*
* Document-class: Paludis::MetadataSimpleURISpecTreeKey
diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb
index 465cfa5..1647d39 100644
--- a/ruby/package_id_TEST.rb
+++ b/ruby/package_id_TEST.rb
@@ -266,9 +266,6 @@ module Paludis
def test_fetches_key
assert_kind_of MetadataFetchableURISpecTreeKey, pid_testrepo.fetches_key
assert_kind_of AllDepSpec, pid_testrepo.fetches_key.value
- assert_respond_to pid_testrepo.fetches_key, :initial_label
- assert_kind_of String, pid_testrepo.fetches_key.initial_label
- assert_equal "URIMirrorsThenListedLabel", pid_testrepo.fetches_key.initial_label
end
end