aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-05-28 09:55:40 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-05-28 09:55:40 +0000
commitb8cc1f18652e2c39f4c7cad5e322e13f4686ed21 (patch)
treec770211d09a7535d0ed8d5ae7c9b972e65a61e5f
parent1989fc0a15669359f8be07d1a1e2db5ec76aefb1 (diff)
downloadpaludis-b8cc1f18652e2c39f4c7cad5e322e13f4686ed21.tar.gz
paludis-b8cc1f18652e2c39f4c7cad5e322e13f4686ed21.tar.xz
(ruby) Support ${ROOT} in find_unmanaged_distfiles.rb.
-rw-r--r--ruby/demos/find_unmanaged_files.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/ruby/demos/find_unmanaged_files.rb b/ruby/demos/find_unmanaged_files.rb
index 2f1c5c5..990027f 100644
--- a/ruby/demos/find_unmanaged_files.rb
+++ b/ruby/demos/find_unmanaged_files.rb
@@ -8,7 +8,7 @@ include Paludis
Log.instance.log_level = LogLevel::Warning
Log.instance.program_name = $0
-def get_contents(repo, files)
+def get_contents(repo, files, root)
in_contents= []
repo.category_names do |cat|
repo.package_names(cat) do |pkg|
@@ -17,8 +17,8 @@ def get_contents(repo, files)
contents.each do |entry|
next if entry.kind_of? ContentsMiscEntry
files.each do |file|
- if entry.name[0,file.length] == file
- in_contents << entry.name
+ if (root + entry.name)[0,file.length] == file
+ in_contents << root + entry.name
break;
end
end
@@ -74,6 +74,10 @@ opts.each do | opt, arg |
end
end
+env = Paludis::EnvironmentMaker.instance.make_from_spec env_spec
+db = env.package_database
+root = env.root[-1] == ?/ ? env.root.chop : env.root
+
files = []
if ARGV.empty?
@@ -85,6 +89,10 @@ else
puts "#{file} is not a directory."
exit 1
end
+ unless file == root or file[0,root.length + 1] == root + "/"
+ puts "#{file} is not under ${ROOT} (#{root}/)"
+ exit 1
+ end
files << (file[-1] == ?/ ? file.chop : file)
end
end
@@ -92,12 +100,9 @@ end
in_fs = []
Find.find(*files) {|file| in_fs << file}
-env = Paludis::EnvironmentMaker.instance.make_from_spec env_spec
-db = env.package_database
-
db.repositories do |repo|
next unless repo.format == 'vdb'
- in_fs-= get_contents(repo, files)
+ in_fs-= get_contents(repo, files, root)
end
puts in_fs