aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-07-04 19:22:51 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-07-04 19:22:51 +0000
commit4aeaa7c57332c125252f7b4e73f891ab95c6f20d (patch)
treeaa5d319f2faa77ce17273aac80de6dc86ee9ed87
parent9477dea7d5b04da4e12ad3088c26baf31c17c771 (diff)
downloadpaludis-4aeaa7c57332c125252f7b4e73f891ab95c6f20d.tar.gz
paludis-4aeaa7c57332c125252f7b4e73f891ab95c6f20d.tar.xz
(ruby) Fix fixable demos.
-rw-r--r--ruby/demos/check_linkage.rb15
-rw-r--r--ruby/demos/find_unmanaged_files.rb7
-rw-r--r--ruby/demos/latest_stable.rb31
-rw-r--r--ruby/demos/version_spec_distributions.rb38
4 files changed, 50 insertions, 41 deletions
diff --git a/ruby/demos/check_linkage.rb b/ruby/demos/check_linkage.rb
index 8ca4ebd..0fa6f3f 100644
--- a/ruby/demos/check_linkage.rb
+++ b/ruby/demos/check_linkage.rb
@@ -142,7 +142,7 @@ prelim_search_dirs_mask = (ENV["SEARCH_DIRS_MASK"] || "").split
# XXX make.conf / paludis/bashrc ?
-if File.stat("/etc/revdep-rebuild").directory? then
+if File.directory? '/etc/revdep-rebuild' then
Dir["/etc/revdep-rebuild/[^.#]*[^~]"].sort.each do | filename |
vars = read_shell_vars filename
prelim_ld_library_mask += (vars["LD_LIBRARY_MASK"] || "").split
@@ -196,13 +196,13 @@ status "Checking linkage for package-manager installed files"
files = { }
directories = { }
env.package_database.repositories.each do | repo |
- (repo.installed_interface and repo.contents_interface) or next
+ repo.installed_interface or next
repo.category_names.each do | cat |
repo.package_names(cat).each do | pkg |
- repo.version_specs(pkg).each do | ver |
- package = Paludis::PackageDatabaseEntry.new(pkg, ver, repo.name)
- repo.contents(pkg, ver).entries.each do | entry |
+ repo.package_ids(pkg).each do | package |
+ next if package.contents_key.nil?
+ package.contents_key.value.entries.each do | entry |
entry.kind_of? Paludis::ContentsFileEntry or next
eligible?(entry.name) or next
(entry.name =~ /\.(la|so|so\..*)$/ or executable(entry.name)) or next
@@ -236,14 +236,13 @@ end
puts if verbose
broken.each do | x |
- puts " * " + x.to_s
+ puts " * " + x.canonical_form(Paludis::PackageIDCanonicalForm::Full)
end
status "Finding merge targets"
specs = broken.map do | owner |
- slot = env.package_database.fetch_repository(owner.repository).version_metadata(owner.name, owner.version).slot
- Paludis::PackageDepSpec.new("=" + owner.name + "-" + owner.version.to_s + ":" + slot, Paludis::PackageDepSpecParseMode::Permissive)
+ "=" + owner.name + "-" + owner.version.to_s + ":" + owner.slot
end
if specs.empty?
diff --git a/ruby/demos/find_unmanaged_files.rb b/ruby/demos/find_unmanaged_files.rb
index 990027f..048bf8a 100644
--- a/ruby/demos/find_unmanaged_files.rb
+++ b/ruby/demos/find_unmanaged_files.rb
@@ -12,8 +12,9 @@ def get_contents(repo, files, root)
in_contents= []
repo.category_names do |cat|
repo.package_names(cat) do |pkg|
- repo.version_specs(pkg) do |ver|
- contents = repo.contents(pkg,ver)
+ repo.package_ids(pkg) do |pid|
+ next if pid.contents_key.nil?
+ contents = pid.contents_key.value
contents.each do |entry|
next if entry.kind_of? ContentsMiscEntry
files.each do |file|
@@ -101,7 +102,7 @@ in_fs = []
Find.find(*files) {|file| in_fs << file}
db.repositories do |repo|
- next unless repo.format == 'vdb'
+ next if repo.installed_interface.nil?
in_fs-= get_contents(repo, files, root)
end
diff --git a/ruby/demos/latest_stable.rb b/ruby/demos/latest_stable.rb
index cf89837..3ea470a 100644
--- a/ruby/demos/latest_stable.rb
+++ b/ruby/demos/latest_stable.rb
@@ -14,10 +14,12 @@ opts = GetoptLong.new(
[ '--version', '-V', GetoptLong::NO_ARGUMENT ],
[ '--log-level', GetoptLong::REQUIRED_ARGUMENT ],
[ '--repository-dir', '-D', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--write-cache-dir', GetoptLong::REQUIRED_ARGUMENT ])
+ [ '--write-cache-dir', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--master-repository-dir', GetoptLong::REQUIRED_ARGUMENT ])
repository_dir = Dir.pwd
write_cache_dir = '/var/empty'
+master_repository_dir = '/var/empty'
opts.each do | opt, arg |
case opt
@@ -25,12 +27,13 @@ opts.each do | opt, arg |
puts "Usage: " + $0 + " [options] keyword1 keyword2 ...."
puts
puts "Options:"
- puts " --help Display a help message"
- puts " --version Display program version"
+ puts " --help Display a help message"
+ puts " --version Display program version"
puts
- puts " --log-level level Set log level (debug, qa, warning, silent)"
- puts " --repository-dir dir Repository directory to use (defaults to .)"
- puts " --write-cache-dir dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
+ puts " --log-level level Set log level (debug, qa, warning, silent)"
+ puts " --repository-dir dir Repository directory to use (defaults to .)"
+ puts " --write-cache-dir dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
+ puts " --master-repository-dir dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
exit 0
when '--version'
@@ -58,6 +61,9 @@ opts.each do | opt, arg |
when '--write-cache-dir'
write_cache_dir = arg
+ when '--master-repository-dir'
+ master_repository_dir = arg
+
end
end
@@ -67,18 +73,17 @@ if ARGV.empty?
end
keywords = ARGV;
-env = NoConfigEnvironment.new(repository_dir, write_cache_dir)
+env = NoConfigEnvironment.new(repository_dir, write_cache_dir, master_repository_dir)
def check_one_package(env, search_keywords, repo, pkg)
results = {}
- repo.version_specs(pkg).each do |ver|
- md = repo.version_metadata(pkg, ver)
- next if md.ebuild_interface.nil?
- keywords = md.keywords.split(/\s+/)
+ repo.package_ids(pkg).each do |pid|
+ next if pid.keywords_key.nil?
+ keywords = pid.keywords_key.value
search_keywords.each do |keyword|
if keywords.include? keyword
results[keyword] ||= {}
- results[keyword][md.slot] = ver
+ results[keyword][pid.slot] = pid.version
end
end
end
@@ -96,7 +101,7 @@ def check_one_package(env, search_keywords, repo, pkg)
end
env.package_database.repositories.each do |repo|
- next if repo.name == 'virtuals'
+ next if repo.virtuals_interface.nil?
repo.category_names.each do |cat|
repo.package_names(cat).each do |pkg|
check_one_package(env, keywords, repo, pkg)
diff --git a/ruby/demos/version_spec_distributions.rb b/ruby/demos/version_spec_distributions.rb
index 1e62660..acee247 100644
--- a/ruby/demos/version_spec_distributions.rb
+++ b/ruby/demos/version_spec_distributions.rb
@@ -28,10 +28,8 @@ class Distribution
def add_repository repo
repo.category_names.each do | cat |
repo.package_names(cat).each do | pkg |
- versions = repo.version_specs(pkg)
- unless versions.empty?
- add_version versions.last
- end
+ pids = repo.package_ids(pkg)
+ add_version pids.last.version unless pids.empty?
end
end
end
@@ -66,16 +64,18 @@ class Distribution
end
opts = GetoptLong.new(
- [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
- [ '--version', '-V', GetoptLong::NO_ARGUMENT ],
- [ '--log-level', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--repository-dir', '-D', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--image', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--write-cache-dir', GetoptLong::REQUIRED_ARGUMENT ])
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
+ [ '--version', '-V', GetoptLong::NO_ARGUMENT ],
+ [ '--log-level', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--repository-dir', '-D', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--image', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--write-cache-dir', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--master-repository-dir', GetoptLong::REQUIRED_ARGUMENT ])
output_image = nil
repository_dir = Dir.getwd
write_cache_dir = '/var/empty'
+master_repository_dir = '/var/empty'
opts.each do | opt, arg |
case opt
@@ -83,14 +83,15 @@ opts.each do | opt, arg |
puts "Usage: " + $0 + " [options]"
puts
puts "Options:"
- puts " --help Display a help message"
- puts " --version Display program version"
+ puts " --help Display a help message"
+ puts " --version Display program version"
puts
- puts " --log-level level Set log level (debug, qa, warning, silent)"
- puts " --repository-dir dir Set repository directory (default: cwd)"
- puts " --write-cache-dir dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
+ puts " --log-level level Set log level (debug, qa, warning, silent)"
+ puts " --repository-dir dir Set repository directory (default: cwd)"
+ puts " --write-cache-dir dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
+ puts " --master-repository-dir dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
puts
- puts " --image foo.png Output as the specified image rather than as text"
+ puts " --image foo.png Output as the specified image rather than as text"
exit 0
when '--version'
@@ -118,6 +119,9 @@ opts.each do | opt, arg |
when '--write-cache-dir'
write_cache_dir = arg
+ when '--master-repository-dir'
+ master_repository_dir = arg
+
when '--image'
output_image = arg
@@ -125,7 +129,7 @@ opts.each do | opt, arg |
end
distribution = Distribution.new
-env = Paludis::NoConfigEnvironment.new repository_dir, write_cache_dir
+env = Paludis::NoConfigEnvironment.new repository_dir, write_cache_dir, master_repository_dir
env.package_database.repositories.each do | repo |
distribution.add_repository repo
end