Class: Omnibus::Software
- Inherits:
-
Object
- Object
- Omnibus::Software
- Includes:
- Cleanroom, Digestable, Logging, NullArgumentable, Sugarable, Util
- Defined in:
- lib/omnibus/software.rb
Constant Summary
Constants included from Util
Constants included from NullArgumentable
Instance Attribute Summary collapse
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
DSL methods collapse
-
#bin_dirs(val = NULL) ⇒ Array<String>
Sets the bin_dirs where this software installs bins.
-
#build(&block) ⇒ Proc
Define a series of Builder DSL commands that are executed to build the software.
-
#build_dir ⇒ String
The path where the software will be built.
-
#default_version(val = NULL) ⇒ String
Set or retrieve the #default_version of the software to build.
-
#dependency(val) ⇒ Array<String>
Add a software dependency to this software.
-
#dependency_licenses(val = NULL) ⇒ Array<Hash>
Set or retrieve licensing information of the dependencies.
-
#description(val = NULL) ⇒ String
Sets the description of the software.
-
#embedded_bin(bin) ⇒ String
Returns the platform safe full path under embedded/bin directory to the given binary.
-
#install_dir ⇒ String
The directory where this software is installed on disk.
- #internal_source(val = NULL) ⇒ Object
- #internal_source_set? ⇒ Boolean
-
#lib_dirs(val = NULL) ⇒ Array<String>
Sets the lib_dirs where this software installs libs.
-
#license(val = NULL) ⇒ String
Set or retrieve the #license of the software to build.
-
#license_file(file) ⇒ String
Set or retrieve the location of a #license_file of the software.
-
#maintainer(val = NULL) ⇒ String
Sets the maintainer of the software.
-
#name(val = NULL) ⇒ String
[Required] Sets or retreives the name of the software.
-
#ohai ⇒ Ohai
A proxy method to the underlying Ohai system.
-
#prepend_path(*paths) ⇒ String
A PATH variable format string representing the current PATH with the given path prepended.
-
#project ⇒ Project
The project that created this software.
-
#project_dir ⇒ String
The path where the extracted software lives.
-
#project_file ⇒ Object
deprecated
Deprecated.
There is no replacement for this DSL method
-
#relative_path(val = NULL) ⇒ String
The path relative to fetch_dir where relevant project files are stored.
-
#skip_transitive_dependency_licensing(val = NULL) ⇒ Boolean
Skip collecting licenses of transitive dependencies for this software.
-
#source(val = NULL) ⇒ Hash
Set or retrieve the source for the software.
-
#version(val = NULL, &block) ⇒ String, Proc
Evaluate a block only if the version matches.
-
#whitelist_file(file) ⇒ Array<String>
Add a file to the healthcheck whitelist.
-
#with_embedded_path(env = {}) ⇒ Hash
A PATH variable format string representing the current PATH with the project’s embedded/bin directory prepended.
-
#with_standard_compiler_flags(env = {}, opts = {}) ⇒ Hash
Add standard compiler flags to the environment hash to produce omnibus binaries (correct RPATH, etc).
Public API collapse
-
#builder ⇒ Builder
The builder object for this software definition.
-
#dependencies ⇒ Array<String>
The list of software dependencies for this software.
-
#fetch ⇒ true, false
Fetch the software definition using the appropriate fetcher.
-
#filepath ⇒ String?
The path (on disk) where this software came from.
-
#license_files ⇒ Array<String>
The list of license files for this software.
-
#load_dependencies ⇒ true
Recursively load all the dependencies for this software.
-
#overridden? ⇒ true, false
Determine if this software version overridden externally, relative to the version declared within the software DSL file?.
-
#overrides ⇒ Hash
The repo-level and project-level overrides for the software.
- #to_manifest_entry ⇒ Object
-
#whitelist_files ⇒ Array<String>
The list of files to ignore in the healthcheck.
Class Method Summary collapse
- .load(project, name, manifest) ⇒ Software
-
.reset! ⇒ Object
Reset cached software information.
Instance Method Summary collapse
-
#<=>(other) ⇒ 1, ...
Compare two software projects (by name).
-
#==(other) ⇒ true, false
(also: #eql?)
Determine if two softwares are identical.
-
#build_me(build_wrappers = []) ⇒ true
Build the software package.
-
#fetch_dir(val = NULL) ⇒ String
Path to where any source is extracted to.
-
#fetcher ⇒ Fetcher
The fetcher for this software.
-
#hash ⇒ Fixnum
The unique “hash” for this software.
-
#initialize(project, filepath = nil, manifest = nil) ⇒ Software
constructor
Create a new software object.
- #manifest_entry ⇒ Object
-
#real_version ⇒ Object
This is the real version if one exists (nil if there’s no real version).
-
#shasum ⇒ String
The unique SHA256 for this sofware definition.
-
#source_type ⇒ Symbol
The type of source specified for this software defintion.
-
#version_for_cache ⇒ Object
Returns the version to be used in cache.
- #version_guid ⇒ Object
Methods included from Util
#compiler_safe_path, #copy_file, #create_directory, #create_file, #create_link, included, #path_key, #remove_directory, #remove_file, #retry_block, #shellout, #shellout!, #windows_safe_path
Methods included from Sugarable
Methods included from NullArgumentable
Methods included from Logging
Methods included from Digestable
#digest, #digest_directory, included
Constructor Details
#initialize(project, filepath = nil, manifest = nil) ⇒ Software
Create a new software object.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/omnibus/software.rb', line 95 def initialize(project, filepath = nil, manifest = nil) unless project.is_a?(Project) raise ArgumentError, "`project' must be a kind of `Omnibus::Project', but was `#{project.class.inspect}'!" end # Magical methods @filepath = filepath @project = project @manifest = manifest # Overrides @overrides = NULL end |
Instance Attribute Details
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
81 82 83 |
# File 'lib/omnibus/software.rb', line 81 def manifest @manifest end |
Class Method Details
.load(project, name, manifest) ⇒ Software
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/omnibus/software.rb', line 32 def load(project, name, manifest) loaded_softwares["#{project.name}:#{name}"] ||= begin filepath = Omnibus.software_path(name) if filepath.nil? raise MissingSoftware.new(name) else log.internal(log_key) do "Loading software `#{name}' from `#{filepath}' using overrides from #{project.name}." end end instance = new(project, filepath, manifest) instance.evaluate_file(filepath) instance.load_dependencies # Add the loaded component to the library project.library.component_added(instance) instance end end |
.reset! ⇒ Object
Reset cached software information.
58 59 60 |
# File 'lib/omnibus/software.rb', line 58 def reset! @loaded_softwares = nil end |
Instance Method Details
#<=>(other) ⇒ 1, ...
Compare two software projects (by name).
125 126 127 |
# File 'lib/omnibus/software.rb', line 125 def <=>(other) name <=> other.name end |
#==(other) ⇒ true, false Also known as: eql?
Determine if two softwares are identical.
1166 1167 1168 |
# File 'lib/omnibus/software.rb', line 1166 def ==(other) hash == other.hash end |
#bin_dirs(val = NULL) ⇒ Array<String>
Sets the bin_dirs where this software installs bins.
219 220 221 222 223 224 225 |
# File 'lib/omnibus/software.rb', line 219 def bin_dirs(val = NULL) if null?(val) @bin_dirs || [windows_safe_path("#{install_dir}/bin"), windows_safe_path("#{install_dir}/embedded/bin")] else @bin_dirs = val end end |
#build(&block) ⇒ Proc
Define a series of Builder DSL commands that are executed to build the software.
673 674 675 |
# File 'lib/omnibus/software.rb', line 673 def build(&block) builder.evaluate(&block) end |
#build_dir ⇒ String
The path where the software will be built.
643 644 645 |
# File 'lib/omnibus/software.rb', line 643 def build_dir File.("#{Config.build_dir}/#{project.name}") end |
#build_me(build_wrappers = []) ⇒ true
Build the software package. If git caching is turned on (see Config#use_git_caching), the build is restored according to the documented restoration procedure in the git cache. If the build cannot be restored (if the tag does not exist), the actual build steps are executed.
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 |
# File 'lib/omnibus/software.rb', line 1119 def build_me(build_wrappers = []) if Config.use_git_caching if !real_version log.info(log_key) do "Forcing a build because resolved version is nil" end execute_build(build_wrappers) project.dirty!(self) unless project.dirty? # omnibus can only be mildly dirty elsif project.dirty? log.info(log_key) do "Building because `#{project.culprit.name}' dirtied the cache" end execute_build(build_wrappers) elsif git_cache.restore log.info(log_key) { "Restored from cache" } else log.info(log_key) { "Could not restore from cache" } execute_build(build_wrappers) project.dirty!(self) end else log.debug(log_key) { "Forcing build because git caching is off" } execute_build(build_wrappers) end project.build_version_dsl.resolve(self) true end |
#builder ⇒ Builder
The builder object for this software definition.
908 909 910 |
# File 'lib/omnibus/software.rb', line 908 def builder @builder ||= Builder.new(self) end |
#default_version(val = NULL) ⇒ String
Set or retrieve the #default_version of the software to build.
404 405 406 407 408 409 410 |
# File 'lib/omnibus/software.rb', line 404 def default_version(val = NULL) if null?(val) @version else @version = val end end |
#dependencies ⇒ Array<String>
The list of software dependencies for this software. These is the software that comprises your software, and is distinct from runtime dependencies.
949 950 951 |
# File 'lib/omnibus/software.rb', line 949 def dependencies @dependencies ||= [] end |
#dependency(val) ⇒ Array<String>
Add a software dependency to this software.
261 262 263 264 |
# File 'lib/omnibus/software.rb', line 261 def dependency(val) dependencies << val dependencies.dup end |
#dependency_licenses(val = NULL) ⇒ Array<Hash>
Set or retrieve licensing information of the dependencies. The information set is not validated or inspected. It is directly
passed to LicenseScout.
dependency_licenses [
{
dependency_name: "logstash-output-websocket",
dependency_manager: "logstash_plugin",
license: "Apache-2.0",
license_file: [
"relative/path/to/license/file",
"https://download.elastic.co/logstash/LICENSE"
]
},
...
]
497 498 499 500 501 502 503 |
# File 'lib/omnibus/software.rb', line 497 def dependency_licenses(val = NULL) if null?(val) @dependency_licenses || nil else @dependency_licenses = Array(val) end end |
#description(val = NULL) ⇒ String
Sets the description of the software.
178 179 180 181 182 183 184 |
# File 'lib/omnibus/software.rb', line 178 def description(val = NULL) if null?(val) @description else @description = val end end |
#embedded_bin(bin) ⇒ String
Returns the platform safe full path under embedded/bin directory to the given binary
843 844 845 |
# File 'lib/omnibus/software.rb', line 843 def (bin) windows_safe_path("#{install_dir}/embedded/bin/#{bin}") end |
#fetch ⇒ true, false
Fetch the software definition using the appropriate fetcher. This may fetch the software from a local path location, git location, or download the software from a remote URL (HTTP(s)/FTP)
930 931 932 933 934 935 936 937 |
# File 'lib/omnibus/software.rb', line 930 def fetch if fetcher.fetch_required? fetcher.fetch true else false end end |
#fetch_dir(val = NULL) ⇒ String
Path to where any source is extracted to.
Files in a source directory are staged underneath here. Files from a url are fetched and extracted here. Look outside this directory at your own peril.
1024 1025 1026 1027 1028 1029 1030 |
# File 'lib/omnibus/software.rb', line 1024 def fetch_dir(val = NULL) if null?(val) @fetch_dir || File.("#{Config.source_dir}/#{name}") else @fetch_dir = val end end |
#fetcher ⇒ Fetcher
The fetcher for this software
This is where we handle all the crazy back-compat on relative_path. All fetchers in omnibus 4 use relative_path incorrectly. net_fetcher was the only one to use to sensibly, and even then only if fetch_dir was Config.source_dir and the source was an archive. Therefore, to not break everyone ever, we will still pass project_dir for all other fetchers. There is still one issue where other omnibus software (such as the appbundler dsl) currently assume that fetch_dir the same as source_dir. Therefore, we make one extra concession - when relative_path is set in a software definition to be the same as name (a very common scenario), we land the source into the fetch directory instead of project_dir. This is to avoid fiddling with the appbundler dsl until it gets sorted out.
1072 1073 1074 1075 1076 1077 1078 1079 |
# File 'lib/omnibus/software.rb', line 1072 def fetcher @fetcher ||= if source_type == :url && File.basename(source[:url], "?*").end_with?(*NetFetcher::ALL_EXTENSIONS) Fetcher.fetcher_class_for_source(source).new(manifest_entry, fetch_dir, build_dir) else Fetcher.fetcher_class_for_source(source).new(manifest_entry, project_dir, build_dir) end end |
#filepath ⇒ String?
The path (on disk) where this software came from. Warning: this can be nil
if a software was dynamically created!
979 980 981 |
# File 'lib/omnibus/software.rb', line 979 def filepath @filepath end |
#hash ⇒ Fixnum
The unique “hash” for this software.
1155 1156 1157 |
# File 'lib/omnibus/software.rb', line 1155 def hash shasum.hash end |
#install_dir ⇒ String
The directory where this software is installed on disk.
656 657 658 |
# File 'lib/omnibus/software.rb', line 656 def install_dir @project.install_dir end |
#internal_source(val = NULL) ⇒ Object
380 381 382 383 384 385 386 387 388 389 |
# File 'lib/omnibus/software.rb', line 380 def internal_source(val = NULL) unless val.is_a?(Hash) raise InvalidValue.new(:internal_source, "be a kind of `Hash', but was `#{val.class.inspect}'") end if Config.use_internal_sources val[:internal] = true source(val) end end |
#internal_source_set? ⇒ Boolean
376 377 378 |
# File 'lib/omnibus/software.rb', line 376 def internal_source_set? @source && @source[:internal] == true end |
#lib_dirs(val = NULL) ⇒ Array<String>
Sets the lib_dirs where this software installs libs.
239 240 241 242 243 244 245 |
# File 'lib/omnibus/software.rb', line 239 def lib_dirs(val = NULL) if null?(val) @lib_dirs || [windows_safe_path("#{install_dir}/embedded/lib")] else @lib_dirs = val end end |
#license(val = NULL) ⇒ String
Set or retrieve the #license of the software to build.
424 425 426 427 428 429 430 |
# File 'lib/omnibus/software.rb', line 424 def license(val = NULL) if null?(val) @license || "Unspecified" else @license = val end end |
#license_file(file) ⇒ String
Set or retrieve the location of a #license_file of the software. It can either be a relative path inside the source package or a URL.
447 448 449 450 |
# File 'lib/omnibus/software.rb', line 447 def license_file(file) license_files << file license_files.dup end |
#license_files ⇒ Array<String>
The list of license files for this software
969 970 971 |
# File 'lib/omnibus/software.rb', line 969 def license_files @license_files ||= [] end |
#load_dependencies ⇒ true
Recursively load all the dependencies for this software.
895 896 897 898 899 900 901 |
# File 'lib/omnibus/software.rb', line 895 def load_dependencies dependencies.each do |dependency| Software.load(project, dependency, manifest) end true end |
#maintainer(val = NULL) ⇒ String
Sets the maintainer of the software. Currently this is for human consumption only and the tool doesn’t do anything with it.
199 200 201 202 203 204 205 |
# File 'lib/omnibus/software.rb', line 199 def maintainer(val = NULL) if null?(val) @maintainer else @description = val end end |
#manifest_entry ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/omnibus/software.rb', line 110 def manifest_entry @manifest_entry ||= if manifest log.info(log_key) { "Using user-supplied manifest entry for #{name}" } manifest.entry_for(name) else log.info(log_key) { "Resolving manifest entry for #{name}" } to_manifest_entry end end |
#name(val = NULL) ⇒ String
[Required] Sets or retreives the name of the software.
158 159 160 161 162 163 164 |
# File 'lib/omnibus/software.rb', line 158 def name(val = NULL) if null?(val) @name || raise(MissingRequiredAttribute.new(self, :name, "libxslt")) else @name = val end end |
#ohai ⇒ Ohai
A proxy method to the underlying Ohai system.
874 875 876 |
# File 'lib/omnibus/software.rb', line 874 def ohai Ohai end |
#overridden? ⇒ true, false
Determine if this software version overridden externally, relative to the version declared within the software DSL file?
1005 1006 1007 1008 |
# File 'lib/omnibus/software.rb', line 1005 def overridden? # NOTE: using instance variables to bypass accessors that enforce overrides @overrides.key?(:version) && (@overrides[:version] != @version) end |
#overrides ⇒ Hash
The repo-level and project-level overrides for the software.
988 989 990 991 992 993 994 995 996 |
# File 'lib/omnibus/software.rb', line 988 def overrides if null?(@overrides) # lazily initialized because we need the 'name' to be parsed first @overrides = {} @overrides = project.overrides[name.to_sym].dup if project.overrides[name.to_sym] end @overrides end |
#prepend_path(*paths) ⇒ String
A PATH variable format string representing the current PATH with the given path prepended. The correct path separator for the platform is used to join the paths.
857 858 859 860 861 862 863 |
# File 'lib/omnibus/software.rb', line 857 def prepend_path(*paths) path_values = Array(paths) path_values << ENV[path_key] separator = File::PATH_SEPARATOR || ":" path_values.join(separator) end |
#project ⇒ Project
The project that created this software.
140 141 142 |
# File 'lib/omnibus/software.rb', line 140 def project @project end |
#project_dir ⇒ String
The path where the extracted software lives. All build commands associated with this software definition are run for under this path.
Why is it called project_dir when this is a software definition, I hear you cry. Because history and reasons. This really is a location underneath the global omnibus source directory that you have focused into using relative_path above.
These are not the only files your project fetches. They are merely the files that your project cares about. A source tarball may contain more directories that are not under your project_dir.
633 634 635 |
# File 'lib/omnibus/software.rb', line 633 def project_dir File.("#{fetch_dir}/#{relative_path}") end |
#project_file ⇒ Object
There is no replacement for this DSL method
The path to the downloaded file from a NetFetcher.
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 |
# File 'lib/omnibus/software.rb', line 683 def project_file if fetcher && fetcher.is_a?(NetFetcher) log.deprecated(log_key) do "project_file (DSL). This is a property of the NetFetcher and will " \ "not be publically exposed in the next major release. In general, " \ "you should not be using this method in your software definitions " \ "as it is an internal implementation detail of the NetFetcher. If " \ "you disagree with this statement, you should open an issue on the " \ "Omnibus repository on GitHub an explain your use case. For now, " \ "I will return the path to the downloaded file on disk, but please " \ "rethink the problem you are trying to solve :)." end fetcher.downloaded_file else log.warn(log_key) do "Cannot retrieve a `project_file' for software `#{name}'. This " \ "attribute is actually an internal representation that is unique " \ "to the NetFetcher class and requires the use of a `source' " \ "attribute that is declared using a `:url' key. For backwards-" \ "compatability, I will return `nil', but this is most likely not " \ "your desired behavior." end nil end end |
#real_version ⇒ Object
This is the real version if one exists (nil if there’s no real version)
1038 1039 1040 |
# File 'lib/omnibus/software.rb', line 1038 def real_version @real_version ||= fetcher.version_for_cache || version end |
#relative_path(val = NULL) ⇒ String
The path relative to fetch_dir where relevant project files are stored. This applies to all sources.
Any command executed in the build step are run after cwd-ing into this path. The default is to stay at the top level of fetch_dir where the source tar-ball/git repo/file/directory has been staged.
Due to back-compat reasons, relative_path works completely differently for anything other than tar-balls/archives. In those situations, the source is checked out rooted at relative_path instead ‘cause reasons. TODO: Fix this in omnibus 6.
609 610 611 612 613 614 615 |
# File 'lib/omnibus/software.rb', line 609 def relative_path(val = NULL) if null?(val) @relative_path || "." else @relative_path = val end end |
#shasum ⇒ String
The unique SHA256 for this sofware definition.
A software is defined by its parent project’s shasum, its own name, its version_for_cache, and any overrides (as JSON). Additionally, if provided, the actual file contents are included in the SHA to ensure uniqueness.
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 |
# File 'lib/omnibus/software.rb', line 1180 def shasum @shasum ||= begin digest = Digest::SHA256.new update_with_string(digest, project.shasum) update_with_string(digest, builder.shasum) update_with_string(digest, name) update_with_string(digest, version_for_cache) update_with_string(digest, FFI_Yajl::Encoder.encode(overrides)) if filepath && File.exist?(filepath) update_with_file_contents(digest, filepath) else update_with_string(digest, "<DYNAMIC>") end digest.hexdigest end end |
#skip_transitive_dependency_licensing(val = NULL) ⇒ Boolean
Skip collecting licenses of transitive dependencies for this software
464 465 466 467 468 469 470 |
# File 'lib/omnibus/software.rb', line 464 def skip_transitive_dependency_licensing(val = NULL) if null?(val) @skip_transitive_dependency_licensing || false else @skip_transitive_dependency_licensing = val end end |
#source(val = NULL) ⇒ Hash
Set or retrieve the source for the software.
Only used in net_fetcher:
Only used in path_fetcher:
Only used in git_fetcher:
If multiple checksum types are provided, only the strongest will be used.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/omnibus/software.rb', line 327 def source(val = NULL) unless null?(val) unless val.is_a?(Hash) raise InvalidValue.new(:source, "be a kind of `Hash', but was `#{val.class.inspect}'") end val = canonicalize_source(val) extra_keys = val.keys - [ :git, :file, :path, :url, # fetcher types :md5, :sha1, :sha256, :sha512, # hash type - common to all fetchers :cookie, :warning, :unsafe, :extract, :cached_name, :authorization, :internal, # used by net_fetcher :options, # used by path_fetcher :submodules # used by git_fetcher ] unless extra_keys.empty? raise InvalidValue.new(:source, "only include valid keys. Invalid keys: #{extra_keys.inspect}") end duplicate_keys = val.keys & %i{git file path url} unless duplicate_keys.size < 2 raise InvalidValue.new(:source, "not include duplicate keys. Duplicate keys: #{duplicate_keys.inspect}") end if Config.use_internal_sources && val[:url] if internal_source_set? && val[:internal].nil? # We only want to replace the hash types here hash_types = %i{md5 sha1 sha256 sha512} val.each_key do |key| val.delete(key) unless hash_types.include?(key) end end @source ||= {} @source.merge!(val) else @source ||= {} @source.merge!(val) end end override = canonicalize_source(overrides[:source]) apply_overrides(:source, override) end |
#source_type ⇒ Symbol
The type of source specified for this software defintion.
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 |
# File 'lib/omnibus/software.rb', line 1086 def source_type if source if source[:url] :url elsif source[:git] :git elsif source[:file] :file elsif source[:path] :path end else :project_local end end |
#to_manifest_entry ⇒ Object
912 913 914 915 916 917 918 919 920 |
# File 'lib/omnibus/software.rb', line 912 def to_manifest_entry Omnibus::ManifestEntry.new(name, { source_type: source_type, described_version: version, locked_version: Fetcher.resolve_version(version, source), locked_source: source, license: license, }) end |
#version(val = NULL, &block) ⇒ String, Proc
Evaluate a block only if the version matches.
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/omnibus/software.rb', line 521 def version(val = NULL, &block) final_version = apply_overrides(:version) if block_given? if val.equal?(NULL) raise InvalidValue.new(:version, "pass a block when given a version argument") else if val == final_version # # Unfortunately we need to make a specific logic here for license files. # We support multiple calls `license_file` and we support overriding the # license files inside a version block. We can not differentiate whether # `license_file` is being called from a version block or not. So we need # to check if the license files are being overridden during the call to # block. # # If so we use the new set, otherwise we restore the old license files. # current_license_files = @license_files @license_files = [] yield new_license_files = @license_files if new_license_files.empty? @license_files = current_license_files end end end end return if final_version.nil? begin ChefUtils::VersionString.new(final_version) rescue ArgumentError log.warn(log_key) do "Version #{final_version} for software #{name} was not parseable. " \ "Comparison methods such as #satisfies? will not be available for this version." end final_version end end |
#version_for_cache ⇒ Object
Returns the version to be used in cache.
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 |
# File 'lib/omnibus/software.rb', line 1043 def version_for_cache @version_for_cache ||= if real_version real_version else log.warn(log_key) do "No version given! Git caching disabled." \ end "0.0.0" end end |
#version_guid ⇒ Object
see comments on Fetcher#without_caching_for
1033 1034 1035 |
# File 'lib/omnibus/software.rb', line 1033 def version_guid fetcher.version_guid end |
#whitelist_file(file) ⇒ Array<String>
Add a file to the healthcheck whitelist.
580 581 582 583 584 |
# File 'lib/omnibus/software.rb', line 580 def whitelist_file(file) file = Regexp.new(file) unless file.is_a?(Regexp) whitelist_files << file whitelist_files.dup end |
#whitelist_files ⇒ Array<String>
The list of files to ignore in the healthcheck.
958 959 960 |
# File 'lib/omnibus/software.rb', line 958 def whitelist_files @whitelist_files ||= [] end |
#with_embedded_path(env = {}) ⇒ Hash
A PATH variable format string representing the current PATH with the project’s embedded/bin directory prepended. The correct path separator for the platform is used to join the paths.
827 828 829 830 831 |
# File 'lib/omnibus/software.rb', line 827 def (env = {}) paths = ["#{install_dir}/bin", "#{install_dir}/embedded/bin"] path_value = prepend_path(paths) env.merge(path_key => path_value) end |
#with_standard_compiler_flags(env = {}, opts = {}) ⇒ Hash
Add standard compiler flags to the environment hash to produce omnibus binaries (correct RPATH, etc).
Supported options:
:aix => :use_gcc force using gcc/g++ compilers on aix
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
# File 'lib/omnibus/software.rb', line 724 def with_standard_compiler_flags(env = {}, opts = {}) env ||= {} opts ||= {} compiler_flags = case Ohai["platform"] when "aix" { "CC" => "xlc_r -q64", "CXX" => "xlC_r -q64", "CFLAGS" => "-q64 -I#{install_dir}/embedded/include -D_LARGE_FILES -O", "LDFLAGS" => "-q64 -L#{install_dir}/embedded/lib -Wl,-blibpath:#{install_dir}/embedded/lib:/usr/lib:/lib", "LD" => "ld -b64", "OBJECT_MODE" => "64", "ARFLAGS" => "-X64 cru", } when "solaris2" { "CC" => "gcc -m64 -static-libgcc", "LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib -static-libgcc", "CFLAGS" => "-I#{install_dir}/embedded/include -O2", } when "freebsd" { "CC" => "clang", "CXX" => "clang++", "LDFLAGS" => "-L#{install_dir}/embedded/lib -Wl,-rpath,#{install_dir}/embedded/lib", "CFLAGS" => "-I#{install_dir}/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector", } when "windows" arch_flag = windows_arch_i386? ? "-m32" : "-m64" opt_flag = windows_arch_i386? ? "-march=i686" : "-march=x86-64" { "LDFLAGS" => "-L#{install_dir}/embedded/lib #{arch_flag} -fno-lto", # We do not wish to enable SSE even though we target i686 because # of a stack alignment issue with some libraries. We have not # exactly ascertained the cause but some compiled library/binary # violates gcc's assumption that the stack is going to be 16-byte # aligned which is just fine as long as one is pushing 32-bit # values from general purpose registers but stuff hits the fan as # soon as gcc emits aligned SSE xmm register spills which generate # GPEs and terminate the application very rudely with very little # to debug with. "CFLAGS" => "-I#{install_dir}/embedded/include #{arch_flag} -O3 #{opt_flag}", } else { "LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib", "CFLAGS" => "-I#{install_dir}/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector", } end # merge LD_RUN_PATH into the environment. most unix distros will fall # back to this if there is no LDFLAGS passed to the linker that sets # the rpath. the LDFLAGS -R or -Wl,-rpath will override this, but in # some cases software may drop our LDFLAGS or think it knows better # and edit them, and we *really* want the rpath setting and do know # better. in that case LD_RUN_PATH will probably survive whatever # edits the configure script does extra_linker_flags = { "LD_RUN_PATH" => "#{install_dir}/embedded/lib", } if solaris2? = "-R#{install_dir}/embedded/lib" if platform_version.satisfies?("<= 5.10") # in order to provide compatibility for earlier versions of libc on solaris 10, # we need to specify a mapfile that restricts the version of system libraries # used. See http://docs.oracle.com/cd/E23824_01/html/819-0690/chapter5-1.html # for more information # use the mapfile if it exists, otherwise ignore it mapfile_path = File.(Config.solaris_linker_mapfile, Config.project_root) << " -M #{mapfile_path}" if File.exist?(mapfile_path) end # solaris linker can also use LD_OPTIONS, so we throw the kitchen sink against # the linker, to find every way to make it use our rpath. This is also required # to use the aforementioned mapfile. extra_linker_flags["LD_OPTIONS"] = end env.merge(compiler_flags) .merge(extra_linker_flags). # always want to favor pkg-config from embedded location to not hose # configure scripts which try to be too clever and ignore our explicit # CFLAGS and LDFLAGS in favor of pkg-config info merge({ "PKG_CONFIG_PATH" => "#{install_dir}/embedded/lib/pkgconfig" }). # Set default values for CXXFLAGS and CPPFLAGS. merge("CXXFLAGS" => compiler_flags["CFLAGS"]) .merge("CPPFLAGS" => compiler_flags["CFLAGS"]) .merge("OMNIBUS_INSTALL_DIR" => install_dir) end |