Class: Vanagon::Project
- Inherits:
-
Object
- Object
- Vanagon::Project
- Includes:
- Utilities
- Defined in:
- lib/vanagon/project.rb,
lib/vanagon/project/dsl.rb
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#bill_of_materials ⇒ Object
Returns the value of attribute bill_of_materials.
-
#cleanup ⇒ Object
Returns the value of attribute cleanup.
-
#components ⇒ Object
Returns the value of attribute components.
-
#configdir ⇒ Object
Returns the value of attribute configdir.
-
#description ⇒ Object
Returns the value of attribute description.
-
#directories ⇒ Object
Returns the value of attribute directories.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#license ⇒ Object
Returns the value of attribute license.
-
#name ⇒ Object
Returns the value of attribute name.
-
#noarch ⇒ Object
Returns the value of attribute noarch.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#provides ⇒ Object
Returns the value of attribute provides.
-
#release ⇒ Object
Returns the value of attribute release.
-
#replaces ⇒ Object
Returns the value of attribute replaces.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#requires ⇒ Object
Returns the value of attribute requires.
-
#retry_count ⇒ Object
Returns the value of attribute retry_count.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user ⇒ Object
Returns the value of attribute user.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
-
#version ⇒ Object
Returns the value of attribute version.
-
#version_file ⇒ Object
Returns the value of attribute version_file.
Class Method Summary collapse
-
.load_project(name, configdir, platform, include_components = []) ⇒ Vanagon::Project
Loads a given project from the configdir.
Instance Method Summary collapse
-
#fetch_sources(workdir) ⇒ Object
Collects all sources and patches into the provided workdir.
-
#generate_bill_of_materials ⇒ Array
Generate a bill-of-materials: a listing of the components and their versions in the current project.
-
#generate_package ⇒ String, Array
Ascertain how to build a package for the current platform.
-
#generate_packaging_artifacts(workdir) ⇒ Object
Generate any required files to build a package for this project on the current platform into the provided workdir.
-
#get_configfiles ⇒ Array
Collects any configfiles supplied by components.
-
#get_directories ⇒ Array
Collects any directories declared by the project and components.
-
#get_files ⇒ Array
Collects any additional files supplied by components.
-
#get_postinstall_actions(pkg_state) ⇒ String
Collects the postinstall packaging actions for the project and it’s components for the specified packaging state.
-
#get_postremove_actions(pkg_state) ⇒ String
Collects the postremove packaging actions for the project and it’s components for the specified packaging state.
-
#get_preinstall_actions(pkg_state) ⇒ String
Collects the preinstall packaging actions for the project and it’s components for the specified packaging state.
-
#get_preremove_actions(pkg_state) ⇒ String
Collects the preremove packaging actions for the project and it’s components for the specified packaging state.
-
#get_provides ⇒ Array
Collects all of the provides for the project and its components.
-
#get_replaces ⇒ Array
Collects all of the replacements for the project and its components.
-
#get_requires ⇒ Array
Collects all of the requires for both the project and its components.
-
#get_root_directories ⇒ Array
Gets the highest level directories declared by the project.
-
#get_service(name) ⇒ @component.service obj
Grabs a specific service based on which name is passed in note that if the name is wrong or there was no will return nil.
-
#get_services ⇒ Array
Get any services registered by components in the project.
-
#get_tarball_files ⇒ Array
Generate a list of all files and directories to be included in a tarball for the project.
-
#has_services? ⇒ True, False
Simple utility for determining if the components in the project declare any services.
-
#initialize(name, platform) ⇒ Vanagon::Project
constructor
Project constructor.
-
#list_component_dependencies(component) ⇒ Array
Return a list of the build_dependencies that are satisfied by an internal component.
-
#make_bill_of_materials(workdir) ⇒ String
Generates a bill-of-materials and writes the contents to the workdir for use in building the project.
-
#make_makefile(workdir) ⇒ String
Evaluates the makefile template and writes the contents to the workdir for use in building the project.
-
#method_missing(method, *args) ⇒ Object
Magic getter to retrieve settings in the project.
-
#pack_tarball_command ⇒ String
Method to generate the command to create a tarball of the project.
-
#package_name ⇒ String
Get the package name for the project on the current platform.
Methods included from Utilities
#erb_file, #erb_string, #ex, #find_program_on_path, #get_md5sum, #get_sum, #git, #git_version, #http_request, #is_git_repo?, #local_command, #remote_ssh_command, #retry_with_timeout, #rsync_from, #rsync_to, #ssh_command
Constructor Details
#initialize(name, platform) ⇒ Vanagon::Project
Project constructor. Takes just the name. Also sets the @name and @platform, and initializes @components, @directories and @settings.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vanagon/project.rb', line 43 def initialize(name, platform) @name = name @components = [] @requires = [] @directories = [] @settings = {} @platform = platform @release = "1" @replaces = [] @provides = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Magic getter to retrieve settings in the project
56 57 58 59 60 |
# File 'lib/vanagon/project.rb', line 56 def method_missing(method, *args) if @settings.has_key?(method) return @settings[method] end end |
Instance Attribute Details
#bill_of_materials ⇒ Object
Returns the value of attribute bill_of_materials.
14 15 16 |
# File 'lib/vanagon/project.rb', line 14 def bill_of_materials @bill_of_materials end |
#cleanup ⇒ Object
Returns the value of attribute cleanup.
13 14 15 |
# File 'lib/vanagon/project.rb', line 13 def cleanup @cleanup end |
#components ⇒ Object
Returns the value of attribute components.
10 11 12 |
# File 'lib/vanagon/project.rb', line 10 def components @components end |
#configdir ⇒ Object
Returns the value of attribute configdir.
10 11 12 |
# File 'lib/vanagon/project.rb', line 10 def configdir @configdir end |
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/vanagon/project.rb', line 11 def description @description end |
#directories ⇒ Object
Returns the value of attribute directories.
11 12 13 |
# File 'lib/vanagon/project.rb', line 11 def directories @directories end |
#homepage ⇒ Object
Returns the value of attribute homepage.
12 13 14 |
# File 'lib/vanagon/project.rb', line 12 def homepage @homepage end |
#identifier ⇒ Object
Returns the value of attribute identifier.
12 13 14 |
# File 'lib/vanagon/project.rb', line 12 def identifier @identifier end |
#license ⇒ Object
Returns the value of attribute license.
11 12 13 |
# File 'lib/vanagon/project.rb', line 11 def license @license end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/vanagon/project.rb', line 10 def name @name end |
#noarch ⇒ Object
Returns the value of attribute noarch.
12 13 14 |
# File 'lib/vanagon/project.rb', line 12 def noarch @noarch end |
#platform ⇒ Object
Returns the value of attribute platform.
10 11 12 |
# File 'lib/vanagon/project.rb', line 10 def platform @platform end |
#provides ⇒ Object
Returns the value of attribute provides.
13 14 15 |
# File 'lib/vanagon/project.rb', line 13 def provides @provides end |
#release ⇒ Object
Returns the value of attribute release.
13 14 15 |
# File 'lib/vanagon/project.rb', line 13 def release @release end |
#replaces ⇒ Object
Returns the value of attribute replaces.
13 14 15 |
# File 'lib/vanagon/project.rb', line 13 def replaces @replaces end |
#repo ⇒ Object
Returns the value of attribute repo.
12 13 14 |
# File 'lib/vanagon/project.rb', line 12 def repo @repo end |
#requires ⇒ Object
Returns the value of attribute requires.
12 13 14 |
# File 'lib/vanagon/project.rb', line 12 def requires @requires end |
#retry_count ⇒ Object
Returns the value of attribute retry_count.
14 15 16 |
# File 'lib/vanagon/project.rb', line 14 def retry_count @retry_count end |
#settings ⇒ Object
Returns the value of attribute settings.
10 11 12 |
# File 'lib/vanagon/project.rb', line 10 def settings @settings end |
#timeout ⇒ Object
Returns the value of attribute timeout.
14 15 16 |
# File 'lib/vanagon/project.rb', line 14 def timeout @timeout end |
#user ⇒ Object
Returns the value of attribute user.
12 13 14 |
# File 'lib/vanagon/project.rb', line 12 def user @user end |
#vendor ⇒ Object
Returns the value of attribute vendor.
11 12 13 |
# File 'lib/vanagon/project.rb', line 11 def vendor @vendor end |
#version ⇒ Object
Returns the value of attribute version.
11 12 13 |
# File 'lib/vanagon/project.rb', line 11 def version @version end |
#version_file ⇒ Object
Returns the value of attribute version_file.
13 14 15 |
# File 'lib/vanagon/project.rb', line 13 def version_file @version_file end |
Class Method Details
.load_project(name, configdir, platform, include_components = []) ⇒ Vanagon::Project
Loads a given project from the configdir
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vanagon/project.rb', line 24 def self.load_project(name, configdir, platform, include_components = []) projfile = File.join(configdir, "#{name}.rb") code = File.read(projfile) dsl = Vanagon::Project::DSL.new(name, platform, include_components) dsl.instance_eval(code, __FILE__, __LINE__) dsl._project rescue => e puts "Error loading project '#{name}' using '#{projfile}':" puts e puts e.backtrace.join("\n") raise e end |
Instance Method Details
#fetch_sources(workdir) ⇒ Object
Collects all sources and patches into the provided workdir
65 66 67 68 69 70 71 72 |
# File 'lib/vanagon/project.rb', line 65 def fetch_sources(workdir) @components.each do |component| component.get_source(workdir) # Fetch secondary sources component.get_sources(workdir) component.get_patches(workdir) end end |
#generate_bill_of_materials ⇒ Array
Generate a bill-of-materials: a listing of the components and their versions in the current project
262 263 264 |
# File 'lib/vanagon/project.rb', line 262 def generate_bill_of_materials @components.map { |comp| "#{comp.name} #{comp.version}" }.sort end |
#generate_package ⇒ String, Array
Ascertain how to build a package for the current platform
312 313 314 |
# File 'lib/vanagon/project.rb', line 312 def generate_package @platform.generate_package(self) end |
#generate_packaging_artifacts(workdir) ⇒ Object
Generate any required files to build a package for this project on the current platform into the provided workdir
320 321 322 |
# File 'lib/vanagon/project.rb', line 320 def generate_packaging_artifacts(workdir) @platform.generate_packaging_artifacts(workdir, @name, binding) end |
#get_configfiles ⇒ Array
Collects any configfiles supplied by components
198 199 200 |
# File 'lib/vanagon/project.rb', line 198 def get_configfiles @components.map(&:configfiles).flatten.uniq end |
#get_directories ⇒ Array
Collects any directories declared by the project and components
205 206 207 208 209 210 |
# File 'lib/vanagon/project.rb', line 205 def get_directories dirs = [] dirs.push @directories dirs.push @components.map(&:directories).flatten dirs.flatten.uniq end |
#get_files ⇒ Array
Collects any additional files supplied by components
77 78 79 80 81 82 |
# File 'lib/vanagon/project.rb', line 77 def get_files files = [] files.push @version_file if @version_file files.push @components.map(&:files).flatten files.flatten.uniq end |
#get_postinstall_actions(pkg_state) ⇒ String
Collects the postinstall packaging actions for the project and it’s components for the specified packaging state
154 155 156 157 158 159 160 161 |
# File 'lib/vanagon/project.rb', line 154 def get_postinstall_actions(pkg_state) scripts = @components.map(&:postinstall_actions).flatten.compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts) if scripts.empty? return ':' else return scripts.join("\n") end end |
#get_postremove_actions(pkg_state) ⇒ String
Collects the postremove packaging actions for the project and it’s components for the specified packaging state
186 187 188 189 190 191 192 193 |
# File 'lib/vanagon/project.rb', line 186 def get_postremove_actions(pkg_state) scripts = @components.map(&:postremove_actions).flatten.compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts) if scripts.empty? return ':' else return scripts.join("\n") end end |
#get_preinstall_actions(pkg_state) ⇒ String
Collects the preinstall packaging actions for the project and it’s components for the specified packaging state
137 138 139 140 141 142 143 144 |
# File 'lib/vanagon/project.rb', line 137 def get_preinstall_actions(pkg_state) scripts = @components.map(&:preinstall_actions).flatten.compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts) if scripts.empty? return ':' else return scripts.join("\n") end end |
#get_preremove_actions(pkg_state) ⇒ String
Collects the preremove packaging actions for the project and it’s components for the specified packaging state
170 171 172 173 174 175 176 177 |
# File 'lib/vanagon/project.rb', line 170 def get_preremove_actions(pkg_state) scripts = @components.map(&:preremove_actions).flatten.compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts) if scripts.empty? return ':' else return scripts.join("\n") end end |
#get_provides ⇒ Array
Collects all of the provides for the project and its components
123 124 125 126 127 128 |
# File 'lib/vanagon/project.rb', line 123 def get_provides provides = [] provides.push @provides.flatten provides.push @components.map(&:provides).flatten provides.flatten.uniq end |
#get_replaces ⇒ Array
Collects all of the replacements for the project and its components
97 98 99 100 101 102 |
# File 'lib/vanagon/project.rb', line 97 def get_replaces replaces = [] replaces.push @replaces.flatten replaces.push @components.map(&:replaces).flatten replaces.flatten.uniq end |
#get_requires ⇒ Array
Collects all of the requires for both the project and its components
87 88 89 90 91 92 |
# File 'lib/vanagon/project.rb', line 87 def get_requires req = [] req << @components.map(&:requires).flatten req << @requires req.flatten.uniq end |
#get_root_directories ⇒ Array
Gets the highest level directories declared by the project
215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/vanagon/project.rb', line 215 def get_root_directories dirs = get_directories.map { |dir| dir.path.split('/') } dirs.sort! { |dir1, dir2| dir1.length <=> dir2.length } ret_dirs = [] dirs.each do |dir| unless ret_dirs.include?(dir.first(dir.length - 1).join('/')) ret_dirs << dir.join('/') end end ret_dirs end |
#get_service(name) ⇒ @component.service obj
Grabs a specific service based on which name is passed in note that if the name is wrong or there was no will return nil
111 112 113 114 115 116 117 118 |
# File 'lib/vanagon/project.rb', line 111 def get_service(name) @components.each do |component| if component.name == name return component.service end end return nil end |
#get_services ⇒ Array
Get any services registered by components in the project
231 232 233 |
# File 'lib/vanagon/project.rb', line 231 def get_services @components.map(&:service).flatten.compact end |
#get_tarball_files ⇒ Array
Generate a list of all files and directories to be included in a tarball for the project
247 248 249 250 251 252 253 254 255 256 |
# File 'lib/vanagon/project.rb', line 247 def get_tarball_files files = ['file-list', 'bill-of-materials'] files.push get_files.map(&:path) files.push get_configfiles.map(&:path) if @platform.is_windows? files.flatten.map { |f| "$$(cygpath --mixed --long-name '#{f}')" } else files.flatten end end |
#has_services? ⇒ True, False
Simple utility for determining if the components in the project declare any services
239 240 241 |
# File 'lib/vanagon/project.rb', line 239 def has_services? !get_services.empty? end |
#list_component_dependencies(component) ⇒ Array
Return a list of the build_dependencies that are satisfied by an internal component
298 299 300 |
# File 'lib/vanagon/project.rb', line 298 def list_component_dependencies(component) component.build_requires.select { |dep| @components.map(&:name).include?(dep) } end |
#make_bill_of_materials(workdir) ⇒ String
Generates a bill-of-materials and writes the contents to the workdir for use in building the project
290 291 292 |
# File 'lib/vanagon/project.rb', line 290 def make_bill_of_materials(workdir) File.open(File.join(workdir, 'bill-of-materials'), 'w') { |f| f.puts(generate_bill_of_materials.join("\n")) } end |
#make_makefile(workdir) ⇒ String
Evaluates the makefile template and writes the contents to the workdir for use in building the project
281 282 283 |
# File 'lib/vanagon/project.rb', line 281 def make_makefile(workdir) erb_file(File.join(VANAGON_ROOT, "resources/Makefile.erb"), File.join(workdir, "Makefile")) end |
#pack_tarball_command ⇒ String
Method to generate the command to create a tarball of the project
269 270 271 272 273 274 |
# File 'lib/vanagon/project.rb', line 269 def pack_tarball_command tar_root = "#{@name}-#{@version}" ["mkdir -p '#{tar_root}'", %('#{@platform.tar}' -cf - -T "#{get_tarball_files.join('" "')}" | ( cd '#{tar_root}/'; '#{@platform.tar}' xfp -)), %('#{@platform.tar}' -cf - #{tar_root}/ | gzip -9c > #{tar_root}.tar.gz)].join("\n\t") end |
#package_name ⇒ String
Get the package name for the project on the current platform
305 306 307 |
# File 'lib/vanagon/project.rb', line 305 def package_name @platform.package_name(self) end |