Class: Vanagon::Component
- Inherits:
-
Object
- Object
- Vanagon::Component
- Includes:
- HashableAttributes
- Defined in:
- lib/vanagon/component.rb,
lib/vanagon/component/dsl.rb,
lib/vanagon/component/rules.rb,
lib/vanagon/component/source.rb,
lib/vanagon/extensions/hashable.rb,
lib/vanagon/component/source/git.rb,
lib/vanagon/component/source/http.rb,
lib/vanagon/component/source/local.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#build ⇒ Object
Returns the value of attribute build.
-
#build_dir ⇒ Object
Returns the value of attribute build_dir.
-
#build_requires ⇒ Object
Returns the value of attribute build_requires.
-
#check ⇒ Object
Returns the value of attribute check.
-
#cleanup_source ⇒ Object
Returns the value of attribute cleanup_source.
-
#configure ⇒ Object
Returns the value of attribute configure.
-
#conflicts ⇒ Object
Returns the value of attribute conflicts.
-
#directories ⇒ Object
Returns the value of attribute directories.
-
#dirname ⇒ Object
Returns the value of attribute dirname.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#extract_with ⇒ Object
Returns the value of attribute extract_with.
-
#files ⇒ Set
readonly
Retrieve all items from @files not marked as configuration files.
-
#install ⇒ Object
Returns the value of attribute install.
-
#license ⇒ Object
Returns the value of attribute license.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#patches ⇒ Object
Returns the value of attribute patches.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#postinstall_actions ⇒ Object
Returns the value of attribute postinstall_actions.
-
#postremove_actions ⇒ Object
Returns the value of attribute postremove_actions.
-
#preinstall_actions ⇒ Object
Returns the value of attribute preinstall_actions.
-
#preremove_actions ⇒ Object
Returns the value of attribute preremove_actions.
-
#provides ⇒ Object
Returns the value of attribute provides.
-
#replaces ⇒ Object
Returns the value of attribute replaces.
-
#requires ⇒ Object
Returns the value of attribute requires.
-
#service ⇒ Object
Returns the value of attribute service.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#source ⇒ Object
Returns the value of attribute source.
-
#sources ⇒ Object
Returns the value of attribute sources.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.load_component(name, configdir, settings, platform) ⇒ Vanagon::Component
Loads a given component from the configdir.
Instance Method Summary collapse
-
#add_file(file) ⇒ Set?
Adds the given file to the list of files and returns @files.
-
#configfiles ⇒ Set
Retrieve all items from @files explicitly marked as configuration files.
-
#delete_file(file) ⇒ Set?
Deletes the given file from the list of files and returns @files.
-
#get_build_dir ⇒ Object
Expands the build directory.
-
#get_environment ⇒ String
Prints the environment in a way suitable for use in a Makefile or shell script.
-
#get_patches(workdir) ⇒ Object
Fetches patches if any are provided for the project.
-
#get_source(workdir) ⇒ Object
Fetches the primary source for the component.
-
#get_sources(workdir) ⇒ Object
Fetches secondary sources for the component.
-
#initialize(name, settings, platform) ⇒ Vanagon::Component
constructor
Component constructor.
- #rules(project, platform) ⇒ Object
Methods included from HashableAttributes
Constructor Details
#initialize(name, settings, platform) ⇒ Vanagon::Component
Component constructor.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/vanagon/component.rb', line 44 def initialize(name, settings, platform) # rubocop:disable Metrics/AbcSize @name = name @settings = settings @platform = platform @options = {} @build_requires = [] @requires = [] @configure = [] @install = [] @build = [] @check = [] @patches = [] @files = Set.new @directories = [] @replaces = [] @provides = [] @conflicts = [] @environment = {} @sources = [] @preinstall_actions = [] @postinstall_actions = [] @preremove_actions = [] @postremove_actions = [] end |
Instance Attribute Details
#build ⇒ Object
Returns the value of attribute build.
10 11 12 |
# File 'lib/vanagon/component.rb', line 10 def build @build end |
#build_dir ⇒ Object
Returns the value of attribute build_dir.
11 12 13 |
# File 'lib/vanagon/component.rb', line 11 def build_dir @build_dir end |
#build_requires ⇒ Object
Returns the value of attribute build_requires.
11 12 13 |
# File 'lib/vanagon/component.rb', line 11 def build_requires @build_requires end |
#check ⇒ Object
Returns the value of attribute check.
10 11 12 |
# File 'lib/vanagon/component.rb', line 10 def check @check end |
#cleanup_source ⇒ Object
Returns the value of attribute cleanup_source.
13 14 15 |
# File 'lib/vanagon/component.rb', line 13 def cleanup_source @cleanup_source end |
#configure ⇒ Object
Returns the value of attribute configure.
10 11 12 |
# File 'lib/vanagon/component.rb', line 10 def configure @configure end |
#conflicts ⇒ Object
Returns the value of attribute conflicts.
13 14 15 |
# File 'lib/vanagon/component.rb', line 13 def conflicts @conflicts end |
#directories ⇒ Object
Returns the value of attribute directories.
13 14 15 |
# File 'lib/vanagon/component.rb', line 13 def directories @directories end |
#dirname ⇒ Object
Returns the value of attribute dirname.
11 12 13 |
# File 'lib/vanagon/component.rb', line 11 def dirname @dirname end |
#environment ⇒ Object
Returns the value of attribute environment.
11 12 13 |
# File 'lib/vanagon/component.rb', line 11 def environment @environment end |
#extract_with ⇒ Object
Returns the value of attribute extract_with.
11 12 13 |
# File 'lib/vanagon/component.rb', line 11 def extract_with @extract_with end |
#files ⇒ Set (readonly)
Retrieve all items from @files not marked as configuration files
10 |
# File 'lib/vanagon/component.rb', line 10 attr_accessor :name, :version, :source, :url, :configure, :build, :check, :install |
#install ⇒ Object
Returns the value of attribute install.
10 11 12 |
# File 'lib/vanagon/component.rb', line 10 def install @install end |
#license ⇒ Object
Returns the value of attribute license.
15 16 17 |
# File 'lib/vanagon/component.rb', line 15 def license @license end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/vanagon/component.rb', line 10 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/vanagon/component.rb', line 12 def @options end |
#patches ⇒ Object
Returns the value of attribute patches.
12 13 14 |
# File 'lib/vanagon/component.rb', line 12 def patches @patches end |
#platform ⇒ Object
Returns the value of attribute platform.
12 13 14 |
# File 'lib/vanagon/component.rb', line 12 def platform @platform end |
#postinstall_actions ⇒ Object
Returns the value of attribute postinstall_actions.
14 15 16 |
# File 'lib/vanagon/component.rb', line 14 def postinstall_actions @postinstall_actions end |
#postremove_actions ⇒ Object
Returns the value of attribute postremove_actions.
15 16 17 |
# File 'lib/vanagon/component.rb', line 15 def postremove_actions @postremove_actions end |
#preinstall_actions ⇒ Object
Returns the value of attribute preinstall_actions.
14 15 16 |
# File 'lib/vanagon/component.rb', line 14 def preinstall_actions @preinstall_actions end |
#preremove_actions ⇒ Object
Returns the value of attribute preremove_actions.
15 16 17 |
# File 'lib/vanagon/component.rb', line 15 def preremove_actions @preremove_actions end |
#provides ⇒ Object
Returns the value of attribute provides.
13 14 15 |
# File 'lib/vanagon/component.rb', line 13 def provides @provides end |
#replaces ⇒ Object
Returns the value of attribute replaces.
13 14 15 |
# File 'lib/vanagon/component.rb', line 13 def replaces @replaces end |
#requires ⇒ Object
Returns the value of attribute requires.
12 13 14 |
# File 'lib/vanagon/component.rb', line 12 def requires @requires end |
#service ⇒ Object
Returns the value of attribute service.
12 13 14 |
# File 'lib/vanagon/component.rb', line 12 def service @service end |
#settings ⇒ Object
Returns the value of attribute settings.
12 13 14 |
# File 'lib/vanagon/component.rb', line 12 def settings @settings end |
#source ⇒ Object
Returns the value of attribute source.
10 11 12 |
# File 'lib/vanagon/component.rb', line 10 def source @source end |
#sources ⇒ Object
Returns the value of attribute sources.
14 15 16 |
# File 'lib/vanagon/component.rb', line 14 def sources @sources end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/vanagon/component.rb', line 10 def url @url end |
#version ⇒ Object
Returns the value of attribute version.
10 11 12 |
# File 'lib/vanagon/component.rb', line 10 def version @version end |
Class Method Details
.load_component(name, configdir, settings, platform) ⇒ Vanagon::Component
Loads a given component from the configdir
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vanagon/component.rb', line 25 def self.load_component(name, configdir, settings, platform) compfile = File.join(configdir, "#{name}.rb") code = File.read(compfile) dsl = Vanagon::Component::DSL.new(name, settings, platform) dsl.instance_eval(code, __FILE__, __LINE__) dsl._component rescue => e puts "Error loading project '#{name}' using '#{compfile}':" puts e puts e.backtrace.join("\n") raise e end |
Instance Method Details
#add_file(file) ⇒ Set?
Adds the given file to the list of files and returns @files.
74 75 76 |
# File 'lib/vanagon/component.rb', line 74 def add_file(file) @files.add file end |
#configfiles ⇒ Set
Retrieve all items from @files explicitly marked as configuration files
99 100 101 |
# File 'lib/vanagon/component.rb', line 99 def configfiles @files.select(&:configfile?) end |
#delete_file(file) ⇒ Set?
Deletes the given file from the list of files and returns @files.
85 86 87 |
# File 'lib/vanagon/component.rb', line 85 def delete_file(file) @files.delete_if { |this_file| this_file.path == file } end |
#get_build_dir ⇒ Object
Expands the build directory
131 132 133 134 135 136 137 |
# File 'lib/vanagon/component.rb', line 131 def get_build_dir if @build_dir File.join(@dirname, @build_dir) else @dirname end end |
#get_environment ⇒ String
Prints the environment in a way suitable for use in a Makefile or shell script.
165 166 167 168 169 170 171 172 |
# File 'lib/vanagon/component.rb', line 165 def get_environment if @environment.empty? ":" else env = @environment.map { |key, value| %(#{key}="#{value}") } "export #{env.join(' ')}" end end |
#get_patches(workdir) ⇒ Object
Fetches patches if any are provided for the project.
153 154 155 156 157 158 159 |
# File 'lib/vanagon/component.rb', line 153 def get_patches(workdir) unless @patches.empty? patchdir = File.join(workdir, "patches") FileUtils.mkdir_p(patchdir) FileUtils.cp(@patches.map(&:path), patchdir) end end |
#get_source(workdir) ⇒ Object
Fetches the primary source for the component. As a side effect, also sets @extract_with, @dirname and @version for the component for use in the makefile template
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/vanagon/component.rb', line 108 def get_source(workdir) if @url @source = Vanagon::Component::Source.source(@url, @options, workdir) @source.fetch @source.verify @extract_with = @source.respond_to?(:extract) ? @source.extract(@platform.tar) : ':' @cleanup_source = @source.cleanup if @source.respond_to?(:cleanup) @dirname = @source.dirname # Git based sources probably won't set the version, so we load it if it hasn't been already set @version ||= @source.version else warn "No source given for component '#{@name}'" # If there is no source, we don't want to try to change directories, so we just change to the current directory. @dirname = './' # If there is no source, there is nothing to do to extract @extract_with = ':' end end |
#get_sources(workdir) ⇒ Object
Fetches secondary sources for the component. These are just dumped into the workdir currently.
142 143 144 145 146 147 148 |
# File 'lib/vanagon/component.rb', line 142 def get_sources(workdir) @sources.each do |source| cur_source = Vanagon::Component::Source.source(source.url, { :ref => source.ref, :sum => source.sum }, workdir) cur_source.fetch cur_source.verify end end |