From 09a3a08cafea84917c2a82d43c190890ca2e8e0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 24 Sep 2006 12:47:08 +0700 Subject: [PATCH] Using GGem#ebuild_name to standardize gem names --- depatom.rb | 8 ++++++-- ebuild.rb | 9 +++++++-- g-gem.rb | 11 +++++++++-- portage.rb | 7 ++++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/depatom.rb b/depatom.rb index 9095aa7..c321800 100644 --- a/depatom.rb +++ b/depatom.rb @@ -11,9 +11,13 @@ class DependencyAtom PACKAGE_NAME_RE = /[a-zA-Z0-9_-]+/ attr_reader :package_name, :version, :version_ext, - :prefix, :prefix_ext, :postfix, :origin + :prefix, :prefix_ext, :postfix, :origin, + :gem_name - def initialize(str) + # if convert is true, use GGem.ebuild_name() to convert the name + def initialize(str, convert = true) + @gem_name = str + str = GGem.ebuild_name(str) if convert == true @origin = str @prefix_ext, str = $&, $' if /^#{PREFIX_EXT_RE}/ === str @prefix, str = $&, $' if /^#{PREFIX_RE}/ === str diff --git a/ebuild.rb b/ebuild.rb index d502540..1dae935 100644 --- a/ebuild.rb +++ b/ebuild.rb @@ -18,8 +18,12 @@ class Ebuild @spec = spec end + def ebuild_name + GGem.ebuild_name(spec.name) + end + def file_path - File.expand_path(File.join(Portage.rubydev_overlay, spec.name, "#{spec.full_name}#{EXTENSION}")) + File.expand_path(File.join(Portage.rubydev_overlay, ebuild_name, "#{ebuild_name}-#{spec.version}#{EXTENSION}")) end def dirname @@ -43,7 +47,7 @@ class Ebuild def src_uri uri = spec.fetched_from if spec.respond_to? :fetched_from - spec.local? ? "#{uri}/${P}.gem" : "#{uri}/gems/${P}.gem" + (spec.local? ? "#{uri}/" : "#{uri}/gems/") + (ebuild_name == spec.name ? "${P}.gem" : "${MY_P}.gem") end def license @@ -80,6 +84,7 @@ class Ebuild inherit ruby gems USE_RUBY="ruby18" +MY_P="#{spec.name}-${PV}" DESCRIPTION=#{(summary.capitalize.chomp('.')+'.').inspect} HOMEPAGE=#{homepage.inspect} SRC_URI=#{src_uri.inspect} diff --git a/g-gem.rb b/g-gem.rb index 5c84c66..68d2d73 100644 --- a/g-gem.rb +++ b/g-gem.rb @@ -68,7 +68,7 @@ module GGem end # don't specify --generate, continue digest and emerge if options[:generate] == false - cmd = 'emerge '+ARGV.join(' ') + cmd = 'emerge '+gen_opts(options)+' '+spec_groups.map{|specs| GGem.ebuild_name(specs[0].name)}.join(' ') puts cmd if options[:verbose] system(cmd) end @@ -83,7 +83,7 @@ module GGem def get_specs(pkg) specs = [] - navigate(pkg.package_name,pkg.gem_requirement) { |spec| specs << spec } + navigate(pkg.gem_name,pkg.gem_requirement) { |spec| specs << spec } specs.reverse end @@ -129,6 +129,13 @@ module GGem true end + def gen_opts(opts) + excludes = [:mass_generate, :generate] + opts.keys.map do |key| + opts[key] == true && !excludes.member?(key) ? "--#{key}" : '' + end.join(' ') + end + def parse_opts(argv) opts = { :pretend => false, diff --git a/portage.rb b/portage.rb index d6b99a6..e649327 100644 --- a/portage.rb +++ b/portage.rb @@ -46,14 +46,15 @@ class Portage end def ebuild_exists(name, gem_version) - portage_dir = File.join(@portage_dev_ruby,name) - overlay_dir = File.join(@rubydev_overlay,name) + ename = GGem.ebuild_name(name) + portage_dir = File.join(@portage_dev_ruby,ename) + overlay_dir = File.join(@rubydev_overlay,ename) version_requirement = gem_version.is_a?(Gem::Version::Requirement) ? gem_version : Gem::Version::Requirement.new(gem_version || ">= 0") ebuilds = Dir.glob(File.join(portage_dir,'*.ebuild')) + Dir.glob(File.join(overlay_dir,'*.ebuild')) return false if ebuilds.empty? ebuilds.map! {|e| File.basename(e).gsub(/\.ebuild$/,'') } satisfied_ebuild = ebuilds.find do |e| - dep_atom = DependencyAtom.new('='+e) + dep_atom = DependencyAtom.new('='+e, false) version = Gem::Version.create(dep_atom.version) version_requirement.satisfied_by?(version) end -- 2.11.4.GIT