Class: Gem::Portage::Ebuild
- Extended by:
- Forwardable
- Defined in:
- lib/g-gem/ebuild.rb,
lib/g-gem/ebuild.rb
Constant Summary collapse
- DEFAULT_PORTDIR =
portdir || "/usr/local/portage"
- DEFAULT_CATEGORY =
Gem::Portage::Utils::ConfigFile.new[:RUBYGEMS_CATEGORY] || "dev-ruby"
- DEFAULT_INSTALL_DIR =
::Gem.dir
- EXTENSION =
".ebuild"- COMMANDS =
%w(help setup clean fetch digest unpack compile test preinst install postinst qmerge merge unmerge prerm postrm config package rpm generate)
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#install_dir ⇒ Object
Returns the value of attribute install_dir.
-
#license ⇒ Object
Returns the value of attribute license.
-
#portdir ⇒ Object
Returns the value of attribute portdir.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
- #basename(include_extension = true) ⇒ Object
- #content ⇒ Object
- #depend ⇒ Object
- #digest_file ⇒ Object
- #dirname ⇒ Object
- #disable_test_phase ⇒ Object
- #enable_test_phase ⇒ Object
- #execute(*commands) ⇒ Object
- #exists? ⇒ Boolean
- #gem_command_args ⇒ Object
- #gem_src ⇒ Object
-
#initialize(spec, portdir = nil, category = nil) ⇒ Ebuild
constructor
A new instance of Ebuild.
- #iuse ⇒ Object
- #keywords ⇒ Object
- #local_fetch_command ⇒ Object
- #local_gentoo_mirror ⇒ Object
- #src_uri ⇒ Object
- #test_phase_enabled? ⇒ Boolean
- #write ⇒ Object (also: #generate)
Constructor Details
#initialize(spec, portdir = nil, category = nil) ⇒ Ebuild
Returns a new instance of Ebuild.
36 37 38 39 40 |
# File 'lib/g-gem/ebuild.rb', line 36 def initialize(spec, portdir=nil, category=nil) @portdir = DEFAULT_PORTDIR @category = DEFAULT_CATEGORY @spec = spec end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
34 35 36 |
# File 'lib/g-gem/ebuild.rb', line 34 def category @category end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
33 34 35 |
# File 'lib/g-gem/ebuild.rb', line 33 def file_path @file_path end |
#install_dir ⇒ Object
Returns the value of attribute install_dir.
34 35 36 |
# File 'lib/g-gem/ebuild.rb', line 34 def install_dir @install_dir end |
#license ⇒ Object
Returns the value of attribute license.
34 35 36 |
# File 'lib/g-gem/ebuild.rb', line 34 def license @license end |
#portdir ⇒ Object
Returns the value of attribute portdir.
34 35 36 |
# File 'lib/g-gem/ebuild.rb', line 34 def portdir @portdir end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
33 34 35 |
# File 'lib/g-gem/ebuild.rb', line 33 def spec @spec end |
Instance Method Details
#basename(include_extension = true) ⇒ Object
51 52 53 |
# File 'lib/g-gem/ebuild.rb', line 51 def basename(include_extension=true) File.basename(file_path, (EXTENSION unless include_extension) ) end |
#content ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/g-gem/ebuild.rb', line 148 def content require 'date' doc = (" # Copyright 1999-\#{Date.today.year} Gentoo Foundation\n # Distributed under the terms of the GNU General Public License v2\n #\n # \#{spec.full_name}.ebuild was auto-generated on \#{Date.today}\n # by g-gem and rubygems using a gemspec dated \#{spec.date.to_s} from\n # \#{spec.fetched_from}\n # \n inherit ruby gems\n \n DESCRIPTION=\#{description.inspect}\n \n HOMEPAGE=\#{homepage.inspect}\n\n USERUBY=\"ruby18\"\n \n SLOT=\"0\"\n \n # Please see the homepage for licensing issues\n # at it's current state g-gem cannot detect gemspec's license\n LICENSE=\#{license.inspect}\n # Auto detected architecture keyword\n # Modify this if you intend to distribute this ebuild to other architectures\n KEYWORDS=\#{keywords.inspect}\n \n IUSE=\#{iuse.inspect}\n # Dependencies obtained from the gemspec (only other gems)\n DEPEND=\#{depend.inspect.gsub('\\n', \"\\n\")}\n \n \#{\"# FETCHCOMMAND=\"+local_fetch_command.inspect if local?}\n SRC_URI=\#{src_uri.inspect}\n \n GEMSARGS=\#{gem_command_args.inspect}\n \n gems_location() {\n # Installation directory from the gem command\n export GEMSDIR=\#{install_dir.inspect}\n # Actually gems.eclass unconditionally searches the gem in ${DISTDIR}\n export GEM_SRC=\#{gem_src.inspect}\n }\n \n # TODO: support gems_src_compile for have-to-be-compiled gems\n # TODO: support test stage for gems\n \n gems_src_install() {\n gems_location\n dodir ${GEMSDIR}\n gem install ${GEM_SRC} -v ${PV} -l -i ${D}/${GEMSDIR} ${GEMSARGS} || die \"gem install failed\"\n if [ -d ${D}/${GEMSDIR}/bin ] ; then\n exeinto /usr/bin\n for exe in ${D}/${GEMSDIR}/bin/* ; do\n doexe ${exe}\n done\n fi\n }\n \n EBUILD\nend\n").head_indented |
#depend ⇒ Object
142 143 144 145 146 |
# File 'lib/g-gem/ebuild.rb', line 142 def depend spec.dependencies.inject("virtual/ruby\ndev-ruby/rubygems") do |s, d| s + "\n" + DependencyAtom.from_gem_dependency(d, category).to_s end end |
#digest_file ⇒ Object
90 91 92 |
# File 'lib/g-gem/ebuild.rb', line 90 def digest_file File.join(dirname, "files", "digest-#{basename(false)}") end |
#dirname ⇒ Object
47 48 49 |
# File 'lib/g-gem/ebuild.rb', line 47 def dirname File.dirname(file_path) end |
#disable_test_phase ⇒ Object
128 129 130 |
# File 'lib/g-gem/ebuild.rb', line 128 def disable_test_phase @test_phase = false end |
#enable_test_phase ⇒ Object
124 125 126 |
# File 'lib/g-gem/ebuild.rb', line 124 def enable_test_phase @test_phase = true end |
#execute(*commands) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/g-gem/ebuild.rb', line 75 def execute(*commands) raise "Invalid emerge command" unless (commands - COMMANDS).empty? callcc do |c| if spec.local? ENV.with(:FETCHCOMMAND => local_fetch_command, :GENTOO_MIRRORS => local_gentoo_mirror) do c.call end end end generate if commands.delete('generate') raise "Missing #{file_path}" unless exists? system("ebuild #{file_path} #{commands.join(' ')}") unless commands.empty? end |
#exists? ⇒ Boolean
55 56 57 |
# File 'lib/g-gem/ebuild.rb', line 55 def exists? File.exists? file_path end |
#gem_command_args ⇒ Object
136 137 138 139 140 |
# File 'lib/g-gem/ebuild.rb', line 136 def gem_command_args args = [] # %w(--no-portage) args << "--test" if test_phase_enabled? args.join(' ') end |
#gem_src ⇒ Object
103 104 105 106 |
# File 'lib/g-gem/ebuild.rb', line 103 def gem_src return spec.fetched_from if spec.local? "${DISTDIR}/${P}" end |
#iuse ⇒ Object
120 121 122 |
# File 'lib/g-gem/ebuild.rb', line 120 def iuse "#{'doc' if spec.has_rdoc}" end |
#keywords ⇒ Object
116 117 118 |
# File 'lib/g-gem/ebuild.rb', line 116 def keywords Gem::Portage::Utils::ConfigFile[:ARCH] end |
#local_fetch_command ⇒ Object
67 68 69 |
# File 'lib/g-gem/ebuild.rb', line 67 def local_fetch_command "cp -Lvgf --target-directory \${DISTDIR} \${URI}" end |
#local_gentoo_mirror ⇒ Object
71 72 73 |
# File 'lib/g-gem/ebuild.rb', line 71 def local_gentoo_mirror File.dirname(spec.fetched_from) if spec.local? end |
#src_uri ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/g-gem/ebuild.rb', line 94 def src_uri uri = spec.fetched_from if spec.respond_to? :fetched_from case uri when /gems.rubyforge.org/ "#{uri}/gems/#{spec.full_name}.gem" else; uri end end |
#test_phase_enabled? ⇒ Boolean
132 133 134 |
# File 'lib/g-gem/ebuild.rb', line 132 def test_phase_enabled? @test_phase end |
#write ⇒ Object Also known as: generate
59 60 61 62 63 64 |
# File 'lib/g-gem/ebuild.rb', line 59 def write require 'fileutils' dir = File.dirname(file_path) FileUtils.mkdir_p(dir) unless File.directory?(dir) File.open(file_path, 'w') { |f| f.write(content) } end |