Class: Omnibus::Project
- Inherits:
-
Object
- Object
- Omnibus::Project
- Includes:
- Cleanroom, Digestable, Logging, NullArgumentable, Sugarable, Util
- Defined in:
- lib/omnibus/project.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
-
#build_git_revision(val = NULL) ⇒ Object
Set or retrieve the git revision of the omnibus project being built.
-
#build_iteration(val = NULL) ⇒ Fixnum
Set or retrieve the build iteration of the project.
-
#build_version(val = NULL, &block) ⇒ String
Set or retrieve the version of the project.
-
#compress(id, &block) ⇒ Object
Add or override a customization for the compressor with the given
id
. -
#config_file(val) ⇒ Array<String>
Add a config file.
-
#conflict(val) ⇒ Array<String>
Add to the list of packages this one conflicts with.
-
#default_root ⇒ String
The default root where a project should be installed.
-
#dependency(val) ⇒ Array<String>
Add a software dependency.
-
#description(val = NULL) ⇒ String
Set or retrieve the project description.
-
#exclude(pattern) ⇒ Array<String>
Add a new exclusion pattern for a list of files or folders to exclude when making the package.
-
#extra_package_file(val) ⇒ Array<String>
Add other files or dirs outside of
install_dir
. -
#files_path ⇒ String
Path to the
/files
directory in the omnibus project. -
#friendly_name(val = NULL) ⇒ String
Set or retrieve a friendly name for the project.
-
#homepage(val = NULL) ⇒ String
[Required] Set or retrive the package homepage.
-
#install_dir(val = NULL) ⇒ String
[Required] Set or retrieve the path at which the project should be installed by the generated package.
-
#json_manifest_path(path = NULL) ⇒ String
Location of json-formated version manifest, written at at the end of the build.
-
#license(val = NULL) ⇒ String
Set or retrieve the #license of the project.
-
#license_file(val = NULL) ⇒ String
Set or retrieve the location of the #license_file of the project.
-
#license_file_path(path = NULL) ⇒ String
Location of license file that omnibus will create and that will contain the information about the license of the project plus the details about the licenses of the software components included in the project.
-
#maintainer(val = NULL) ⇒ String
[Required] Set or retrieve the the package maintainer.
-
#name(val = NULL) ⇒ String
[Required] Set or retrieve the name of the project.
-
#ohai ⇒ Ohai
A proxy method to the underlying Ohai system.
-
#override(name, val = NULL) ⇒ Hash
Set or retrieve the overrides hash for one piece of software being overridden.
-
#package(id, &block) ⇒ Object
Add or override a customization for the packager with the given
id
. -
#package_group(val = NULL) ⇒ String
Set or retrieve the group the package should install as.
-
#package_name(val = NULL) ⇒ String
Set or retrieve the package name of the project.
-
#package_scripts_path(arg = NULL) ⇒ String
The path to the package scripts directory for this project.
-
#package_user(val = NULL) ⇒ String
Set or retrieve the user the package should install as.
-
#replace(val = NULL) ⇒ String
Add to the list of packages this one replaces.
-
#resources_path(val = NULL) ⇒ String
Set or retrieve the path to the resources on disk for use in packagers.
-
#runtime_dependency(val) ⇒ Array<String>
Add a package that is a runtime dependency of this project.
-
#text_manifest_path(path = NULL) ⇒ String
Location of text-formatted manifest.
Public API collapse
-
#<=>(other) ⇒ 1, ...
Comparator for two projects (
name
). -
#==(other) ⇒ true, false
(also: #eql?)
Determine if two projects are identical.
- #build ⇒ Object
-
#build_me ⇒ Object
Download and build the project.
-
#build_version_dsl ⇒ BuildVersionDSL
The DSL for this build version.
-
#built_manifest ⇒ Object
Generate a version manifest of the loaded software sources.
- #compress_me ⇒ Object
-
#compressor ⇒ ~Compressor::Base
Instantiate a new instance of the best compressor for this system.
-
#compressors ⇒ Hash<Symbol, Array<Proc>>
The list of compressors, in the following format:.
-
#config_files ⇒ Array<String>
The list of config files for this software.
-
#conflicts ⇒ Array<String>
The list of things this project conflicts with.
-
#culprit ⇒ Software?
The software definition which dirtied this project.
-
#dependencies ⇒ Array<String>
The list of software dependencies for this project.
-
#dependency?(software) ⇒ true, false
Indicates whether the given
software
is defined as a software component of this project. -
#dirty!(software) ⇒ true, false
Dirty the cache for this project.
-
#dirty? ⇒ true, false
Determine if the cache for this project is dirty.
- #download ⇒ Object
-
#exclusions ⇒ Array<String>
The list of exclusions for this project.
-
#extra_package_files(val = NULL) ⇒ Array<String>
The list of files and directories used to build this project.
-
#filepath ⇒ String?
The path (on disk) where this project came from.
-
#hash ⇒ Fixnum
The unique “hash” for this project.
-
#library ⇒ Library
The library for this Omnibus project.
-
#load_dependencies ⇒ true
Recursively load all the dependencies for this project.
-
#overrides ⇒ Hash
Retrieve the list of overrides for all software being overridden.
- #package_me ⇒ Object
-
#packagers ⇒ Hash<Symbol, Array<Proc>>
The list of packagers, in the following format:.
-
#packagers_for_system ⇒ [~Packager::Base]
Instantiate new instances of the best packagers for this system.
-
#replaces ⇒ Array<String>
The list of things this project replaces with.
- #restore_complete_build ⇒ Object
-
#runtime_dependencies ⇒ Array<String>
The list of software dependencies for this project.
-
#shasum ⇒ String
The unique SHA256 for this project.
-
#softwares ⇒ Array<Omnibus::Software>
Cache the build order so we don’t re-compute.
- #write_json_manifest ⇒ Object
-
#write_text_manifest ⇒ Object
Writes a text manifest to the text_manifest_path.
Class Method Summary collapse
- .load(name, manifest = nil) ⇒ Project
-
.reset! ⇒ Object
Reset cached project information.
Instance Method Summary collapse
-
#initialize(filepath = nil, manifest = nil) ⇒ Project
constructor
A new instance of Project.
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(filepath = nil, manifest = nil) ⇒ Project
Returns a new instance of Project.
80 81 82 83 |
# File 'lib/omnibus/project.rb', line 80 def initialize(filepath = nil, manifest = nil) @filepath = filepath @manifest = manifest end |
Instance Attribute Details
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
71 72 73 |
# File 'lib/omnibus/project.rb', line 71 def manifest @manifest end |
Class Method Details
.load(name, manifest = nil) ⇒ Project
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/omnibus/project.rb', line 33 def load(name, manifest = nil) loaded_projects[name] ||= begin filepath = Omnibus.project_path(name) if filepath.nil? raise MissingProject.new(name) else log.internal(log_key) do "Loading project `#{name}' from `#{filepath}'." end end instance = new(filepath, manifest) instance.evaluate_file(filepath) instance.load_dependencies instance end end |
.reset! ⇒ Object
Reset cached project information.
55 56 57 |
# File 'lib/omnibus/project.rb', line 55 def reset! @loaded_projects = nil end |
Instance Method Details
#<=>(other) ⇒ 1, ...
Comparator for two projects (name
)
1037 1038 1039 |
# File 'lib/omnibus/project.rb', line 1037 def <=>(other) name <=> other.name end |
#==(other) ⇒ true, false Also known as: eql?
Determine if two projects are identical.
1209 1210 1211 |
# File 'lib/omnibus/project.rb', line 1209 def ==(other) hash == other.hash end |
#build ⇒ Object
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 |
# File 'lib/omnibus/project.rb', line 1075 def build FileUtils.rm_rf(install_dir) FileUtils.mkdir_p(install_dir) Licensing.create_incrementally(self) do |license_collector| softwares.each do |software| software.build_me([license_collector]) end # If nothing has dirtied the cache, checkout the last cache dir restore_complete_build unless dirty? end write_json_manifest write_text_manifest HealthCheck.run!(self) package_me compress_me end |
#build_git_revision(val = NULL) ⇒ Object
Set or retrieve the git revision of the omnibus project being built.
If not set by the user, and the current workding directory is a git directory, it will return the revision of the current working directory.
394 395 396 397 398 399 400 |
# File 'lib/omnibus/project.rb', line 394 def build_git_revision(val = NULL) if null?(val) @build_git_revision ||= get_local_revision else @build_git_revision = val end end |
#build_iteration(val = NULL) ⇒ Fixnum
Set or retrieve the build iteration of the project. Defaults to 1
if not otherwise set.
415 416 417 418 419 420 421 |
# File 'lib/omnibus/project.rb', line 415 def build_iteration(val = NULL) if null?(val) @build_iteration || 1 else @build_iteration = val end end |
#build_me ⇒ Object
Download and build the project. Preserved for backwards compatibility.
1125 1126 1127 1128 1129 |
# File 'lib/omnibus/project.rb', line 1125 def build_me # Download all softwares in parallel download build end |
#build_version(val = NULL, &block) ⇒ String
Set or retrieve the version of the project.
When using the :git
source, by default the output format of the build_version
is semver. This can be modified using the :output_format
parameter to any of the methods of BuildVersion
. For example:
build version do
source :git, from_dependency: 'chef'
output_format :git_describe
end
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/omnibus/project.rb', line 368 def build_version(val = NULL, &block) if block && !null?(val) raise Error, "You cannot specify additional parameters to " \ "#build_version when a block is given!" end if block @build_version_dsl = BuildVersionDSL.new(&block) else if null?(val) @build_version_dsl.build_version else @build_version_dsl = BuildVersionDSL.new(val) end end end |
#build_version_dsl ⇒ BuildVersionDSL
The DSL for this build version.
971 972 973 |
# File 'lib/omnibus/project.rb', line 971 def build_version_dsl @build_version_dsl end |
#built_manifest ⇒ Object
Generate a version manifest of the loaded software sources.
1055 1056 1057 1058 1059 1060 1061 1062 |
# File 'lib/omnibus/project.rb', line 1055 def built_manifest log.info(log_key) { "Building version manifest" } m = Omnibus::Manifest.new(build_version, build_git_revision, license) softwares.each do |software| m.add(software.name, software.manifest_entry) end m end |
#compress(id, &block) ⇒ Object
Add or override a customization for the compressor with the given id
. When given multiple blocks with the same id
, they are evaluated _in order_, so the last block evaluated will take precedence over the previous ones.
If multiple compress
blocks are specified, the “most prefered” one for the current system will be used.
466 467 468 469 470 471 472 |
# File 'lib/omnibus/project.rb', line 466 def compress(id, &block) if block compressors[id] << block else compressors[id] << Proc.new {} end end |
#compress_me ⇒ Object
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
# File 'lib/omnibus/project.rb', line 1165 def compress_me destination = File.("pkg", Config.project_root) # Create the destination directory unless File.directory?(destination) FileUtils.mkdir_p(destination) end # Evaluate any compressor-specific blocks, in order. compressors[compressor.id].each do |block| compressor.evaluate(&block) end # Run the actual compressor compressor.run! # Copy the compressed package and metadata back into the workspace, if it # exists package_path = File.join(Config.package_dir, compressor.package_name) if File.file?(package_path) FileUtils.cp(package_path, destination) FileUtils.cp("#{package_path}.metadata.json", destination) end end |
#compressor ⇒ ~Compressor::Base
Instantiate a new instance of the best compressor for this system.
962 963 964 |
# File 'lib/omnibus/project.rb', line 962 def compressor @compressor ||= Compressor.for_current_system(compressors.keys).new(self) end |
#compressors ⇒ Hash<Symbol, Array<Proc>>
The list of compressors, in the following format:
{
id: [#<Proc:0x001>, #<Proc:0x002>],
# ...
}
953 954 955 |
# File 'lib/omnibus/project.rb', line 953 def compressors @compressors ||= Hash.new { |h, k| h[k] = [] } end |
#config_file(val) ⇒ Array<String>
Add a config file.
659 660 661 662 |
# File 'lib/omnibus/project.rb', line 659 def config_file(val) config_files << val config_files.dup end |
#config_files ⇒ Array<String>
The list of config files for this software.
858 859 860 |
# File 'lib/omnibus/project.rb', line 858 def config_files @config_files ||= [] end |
#conflict(val) ⇒ Array<String>
Add to the list of packages this one conflicts with.
322 323 324 325 |
# File 'lib/omnibus/project.rb', line 322 def conflict(val) conflicts << val conflicts.dup end |
#conflicts ⇒ Array<String>
The list of things this project conflicts with.
887 888 889 |
# File 'lib/omnibus/project.rb', line 887 def conflicts @conflicts ||= [] end |
#culprit ⇒ Software?
The software definition which dirtied this project.
1019 1020 1021 |
# File 'lib/omnibus/project.rb', line 1019 def culprit @culprit end |
#default_root ⇒ String
The default root where a project should be installed. On Windows-based systems, this value defaults to C:
. On non-Windows systems, this value defaults to /opt
.
198 199 200 201 202 203 204 |
# File 'lib/omnibus/project.rb', line 198 def default_root if windows? "C:" else "/opt" end end |
#dependencies ⇒ Array<String>
The list of software dependencies for this project. These is the software that comprises your project, and is distinct from runtime dependencies.
838 839 840 |
# File 'lib/omnibus/project.rb', line 838 def dependencies @dependencies ||= [] end |
#dependency(val) ⇒ Array<String>
Add a software dependency.
Note that this is a *build time* dependency. If you need to specify an external dependency that is required at runtime, see #runtime_dependency instead.
601 602 603 604 |
# File 'lib/omnibus/project.rb', line 601 def dependency(val) dependencies << val dependencies.dup end |
#dependency?(software) ⇒ true, false
Indicates whether the given software
is defined as a software component of this project.
984 985 986 987 |
# File 'lib/omnibus/project.rb', line 984 def dependency?(software) name = software.is_a?(Software) ? software.name : software dependencies.include?(name) end |
#description(val = NULL) ⇒ String
Set or retrieve the project description.
279 280 281 282 283 284 285 |
# File 'lib/omnibus/project.rb', line 279 def description(val = NULL) if null?(val) @description || "The full stack of #{name}" else @description = val end end |
#dirty!(software) ⇒ true, false
Dirty the cache for this project. This can be called by other projects, install path cache, or software definitions to invalidate the cache for this project.
1008 1009 1010 1011 1012 |
# File 'lib/omnibus/project.rb', line 1008 def dirty!(software) raise ProjectAlreadyDirty.new(self) if culprit @culprit = software end |
#dirty? ⇒ true, false
Determine if the cache for this project is dirty.
1028 1029 1030 |
# File 'lib/omnibus/project.rb', line 1028 def dirty? !!culprit end |
#download ⇒ Object
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
# File 'lib/omnibus/project.rb', line 1064 def download # Setting abort_on_exception to false because it was causing # errors by shutting down the main thread when encountering a cache miss # in S3 and falling back to the internal source repo ThreadPool.new(Config.workers, false) do |pool| softwares.each do |software| pool.schedule { software.fetch } end end end |
#exclude(pattern) ⇒ Array<String>
Add a new exclusion pattern for a list of files or folders to exclude when making the package.
641 642 643 644 |
# File 'lib/omnibus/project.rb', line 641 def exclude(pattern) exclusions << pattern exclusions.dup end |
#exclusions ⇒ Array<String>
The list of exclusions for this project.
905 906 907 |
# File 'lib/omnibus/project.rb', line 905 def exclusions @exclusions ||= [] end |
#extra_package_file(val) ⇒ Array<String>
Add other files or dirs outside of install_dir
. These files retain their relative paths inside the scratch directory:
/path/to/foo.txt #=> /tmp/package/path/to/foo.txt
681 682 683 684 |
# File 'lib/omnibus/project.rb', line 681 def extra_package_file(val) extra_package_files << val extra_package_files.dup end |
#extra_package_files(val = NULL) ⇒ Array<String>
The list of files and directories used to build this project.
867 868 869 |
# File 'lib/omnibus/project.rb', line 867 def extra_package_files(val = NULL) @extra_package_files ||= [] end |
#filepath ⇒ String?
The path (on disk) where this project came from. Warning: this can be nil
if a project was dynamically created!
848 849 850 |
# File 'lib/omnibus/project.rb', line 848 def filepath @filepath end |
#files_path ⇒ String
Path to the /files
directory in the omnibus project. This directory can contain arbitrary files used by the project.
217 218 219 |
# File 'lib/omnibus/project.rb', line 217 def files_path File.("#{Config.project_root}/files") end |
#friendly_name(val = NULL) ⇒ String
Set or retrieve a friendly name for the project. This defaults to the capitalized name if not specified.
127 128 129 130 131 132 133 |
# File 'lib/omnibus/project.rb', line 127 def friendly_name(val = NULL) if null?(val) @friendly_name || name.capitalize else @friendly_name = val end end |
#hash ⇒ Fixnum
The unique “hash” for this project.
1198 1199 1200 |
# File 'lib/omnibus/project.rb', line 1198 def hash shasum.hash end |
#homepage(val = NULL) ⇒ String
[Required] Set or retrive the package homepage.
259 260 261 262 263 264 265 |
# File 'lib/omnibus/project.rb', line 259 def homepage(val = NULL) if null?(val) @homepage || raise(MissingRequiredAttribute.new(self, :homepage, "https://www.getchef.com")) else @homepage = val end end |
#install_dir(val = NULL) ⇒ String
[Required] Set or retrieve the path at which the project should be installed by the generated package.
Even on Windows-based systems, this path should be the Unix-like path, since that’s what Ruby expects. In the event ++ is used as a file separator, it will be replaced with /
. This method also attempts to remove duplicate slashes which might be caused as a result of string interpolation.
178 179 180 181 182 183 184 |
# File 'lib/omnibus/project.rb', line 178 def install_dir(val = NULL) if null?(val) @install_dir || raise(MissingRequiredAttribute.new(self, :install_dir, "/opt/chef")) else @install_dir = val.tr('\\', "/").squeeze("/").chomp("/") # rubocop:disable Style/StringLiterals end end |
#json_manifest_path(path = NULL) ⇒ String
Location of json-formated version manifest, written at at the end of the build. If no path is specified install_dir
/version-manifest.json is used.
774 775 776 777 778 779 780 |
# File 'lib/omnibus/project.rb', line 774 def json_manifest_path(path = NULL) if null?(path) @json_manifest_path || File.join(install_dir, "version-manifest.json") else @json_manifest_path = path end end |
#library ⇒ Library
The library for this Omnibus project.
994 995 996 |
# File 'lib/omnibus/project.rb', line 994 def library @library ||= Library.new(self) end |
#license(val = NULL) ⇒ String
Set or retrieve the #license of the project.
711 712 713 714 715 716 717 |
# File 'lib/omnibus/project.rb', line 711 def license(val = NULL) if null?(val) @license || "Unspecified" else @license = val end end |
#license_file(val = NULL) ⇒ String
Set or retrieve the location of the #license_file of the project. It can either be a relative path inside the project source directory or a URL.
734 735 736 737 738 739 740 |
# File 'lib/omnibus/project.rb', line 734 def license_file(val = NULL) if null?(val) @license_file else @license_file = val end end |
#license_file_path(path = NULL) ⇒ String
Location of license file that omnibus will create and that will contain the information about the license of the project plus the details about the licenses of the software components included in the project.
If no path is specified install_dir/LICENSE is used.
755 756 757 758 759 760 761 |
# File 'lib/omnibus/project.rb', line 755 def license_file_path(path = NULL) if null?(path) @license_file_path || File.join(install_dir, "LICENSE") else @license_file_path = File.join(install_dir, path) end end |
#load_dependencies ⇒ true
Recursively load all the dependencies for this project.
820 821 822 823 824 825 826 |
# File 'lib/omnibus/project.rb', line 820 def load_dependencies dependencies.each do |dependency| Software.load(self, dependency, manifest) end true end |
#maintainer(val = NULL) ⇒ String
[Required] Set or retrieve the the package maintainer.
236 237 238 239 240 241 242 |
# File 'lib/omnibus/project.rb', line 236 def maintainer(val = NULL) if null?(val) @maintainer || raise(MissingRequiredAttribute.new(self, :maintainer, "Chef Software, Inc.")) else @maintainer = val end end |
#name(val = NULL) ⇒ String
[Required] Set or retrieve the name of the project.
106 107 108 109 110 111 112 |
# File 'lib/omnibus/project.rb', line 106 def name(val = NULL) if null?(val) @name || raise(MissingRequiredAttribute.new(self, :name, "hamlet")) else @name = val end end |
#ohai ⇒ Ohai
A proxy method to the underlying Ohai system.
695 696 697 |
# File 'lib/omnibus/project.rb', line 695 def ohai Ohai end |
#override(name, val = NULL) ⇒ Hash
Set or retrieve the overrides hash for one piece of software being overridden. Calling it as a setter does not merge hash entries and it will set all the overrides for a given software definition.
512 513 514 515 516 517 518 |
# File 'lib/omnibus/project.rb', line 512 def override(name, val = NULL) if null?(val) overrides[name.to_sym] else overrides[name.to_sym] = val end end |
#overrides ⇒ Hash
Retrieve the list of overrides for all software being overridden.
914 915 916 |
# File 'lib/omnibus/project.rb', line 914 def overrides @overrides ||= {} end |
#package(id, &block) ⇒ Object
Add or override a customization for the packager with the given id
. When given multiple blocks with the same id
, they are evaluated _in order_, so the last block evaluated will take precedence over the previous ones.
437 438 439 440 441 442 443 |
# File 'lib/omnibus/project.rb', line 437 def package(id, &block) unless block raise InvalidValue.new(:package, "have a block") end packagers[id] << block end |
#package_group(val = NULL) ⇒ String
537 538 539 540 541 542 543 |
# File 'lib/omnibus/project.rb', line 537 def package_group(val = NULL) if null?(val) @package_group || Ohai["root_group"] || "root" else @package_group = val end end |
#package_me ⇒ Object
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 |
# File 'lib/omnibus/project.rb', line 1134 def package_me destination = File.("pkg", Config.project_root) # Create the destination directory unless File.directory?(destination) FileUtils.mkdir_p(destination) end packagers_for_system.each do |packager| # Evaluate any packager-specific blocks, in order. packagers[packager.id].each do |block| packager.evaluate(&block) end if packager.skip_packager log.info(log_key) { "Skipping #{packager.id} per project configuration." } next end # Run the actual packager packager.run! # Copy the generated package and metadata back into the workspace package_path = File.join(Config.package_dir, packager.package_name) FileUtils.cp(package_path, destination, preserve: true) FileUtils.cp("#{package_path}.metadata.json", destination, preserve: true) end end |
#package_name(val = NULL) ⇒ String
Set or retrieve the package name of the project. Defaults to the package name defaults to the project name.
148 149 150 151 152 153 154 |
# File 'lib/omnibus/project.rb', line 148 def package_name(val = NULL) if null?(val) @package_name || name else @package_name = val end end |
#package_scripts_path(arg = NULL) ⇒ String
The path to the package scripts directory for this project. These are optional scripts that can be bundled into the resulting package for running at various points in the package management lifecycle.
These scripts and their names vary with operating system.
575 576 577 578 579 580 581 |
# File 'lib/omnibus/project.rb', line 575 def package_scripts_path(arg = NULL) if null?(arg) @package_scripts_path || "#{Config.project_root}/package-scripts/#{name}" else @package_scripts_path = File.(arg) end end |
#package_user(val = NULL) ⇒ String
Set or retrieve the user the package should install as. This varies with operating system, and may be ignored if the underlying packager does not support it.
Defaults to “root”.
490 491 492 493 494 495 496 |
# File 'lib/omnibus/project.rb', line 490 def package_user(val = NULL) if null?(val) @package_user || "root" else @package_user = val end end |
#packagers ⇒ Hash<Symbol, Array<Proc>>
The list of packagers, in the following format:
{
id: [#<Proc:0x001>, #<Proc:0x002>],
# ...
}
929 930 931 |
# File 'lib/omnibus/project.rb', line 929 def packagers @packagers ||= Hash.new { |h, k| h[k] = [] } end |
#packagers_for_system ⇒ [~Packager::Base]
Instantiate new instances of the best packagers for this system.
938 939 940 |
# File 'lib/omnibus/project.rb', line 938 def packagers_for_system @packagers_for_system ||= Packager.for_current_system.map { |p| p.new(self) } end |
#replace(val = NULL) ⇒ String
Add to the list of packages this one replaces.
This should only be used when renaming a package and obsoleting the old name of the package. **Setting this to the same name as package_name will cause RPM upgrades to fail.**
303 304 305 306 |
# File 'lib/omnibus/project.rb', line 303 def replace(val = NULL) replaces << val replaces.dup end |
#replaces ⇒ Array<String>
The list of things this project replaces with.
896 897 898 |
# File 'lib/omnibus/project.rb', line 896 def replaces @replaces ||= [] end |
#resources_path(val = NULL) ⇒ String
Set or retrieve the path to the resources on disk for use in packagers.
557 558 559 560 561 562 563 |
# File 'lib/omnibus/project.rb', line 557 def resources_path(val = NULL) if null?(val) @resources_path || "#{Config.project_root}/resources/#{name}" else @resources_path = File.(val) end end |
#restore_complete_build ⇒ Object
1095 1096 1097 1098 1099 1100 |
# File 'lib/omnibus/project.rb', line 1095 def restore_complete_build if Config.use_git_caching log.info(log_key) { "Cache not dirtied, restoring last marker" } GitCache.new(softwares.last).restore_from_cache end end |
#runtime_dependencies ⇒ Array<String>
The list of software dependencies for this project.
These is the software that is used at runtime for your project.
878 879 880 |
# File 'lib/omnibus/project.rb', line 878 def runtime_dependencies @runtime_dependencies ||= [] end |
#runtime_dependency(val) ⇒ Array<String>
Add a package that is a runtime dependency of this project.
This is distinct from a build-time dependency, which should correspond to a software definition.
622 623 624 625 |
# File 'lib/omnibus/project.rb', line 622 def runtime_dependency(val) runtime_dependencies << val runtime_dependencies.dup end |
#shasum ⇒ String
The unique SHA256 for this project.
A project is defined by its name, its build_version, its install_dir, and any overrides (as JSON). Additionally, if provided, the actual file contents are included in the SHA to ensure uniqueness.
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 |
# File 'lib/omnibus/project.rb', line 1223 def shasum @shasum ||= begin digest = Digest::SHA256.new update_with_string(digest, name) update_with_string(digest, install_dir) 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 |
#softwares ⇒ Array<Omnibus::Software>
Cache the build order so we don’t re-compute
1046 1047 1048 |
# File 'lib/omnibus/project.rb', line 1046 def softwares @softwares ||= library.build_order end |
#text_manifest_path(path = NULL) ⇒ String
Location of text-formatted manifest. (install_dir
/version-manifest.txt if none is provided)
This manifest uses the same format used by the ‘version-manifest’ software definition in omnibus-software.
795 796 797 798 799 800 801 |
# File 'lib/omnibus/project.rb', line 795 def text_manifest_path(path = NULL) if null?(path) @text_manifest_path || File.join(install_dir, "version-manifest.txt") else @text_manifest_path = path end end |
#write_json_manifest ⇒ Object
1102 1103 1104 1105 1106 |
# File 'lib/omnibus/project.rb', line 1102 def write_json_manifest File.open(json_manifest_path, "w") do |f| f.write(FFI_Yajl::Encoder.encode(built_manifest.to_hash, pretty: true)) end end |
#write_text_manifest ⇒ Object
Writes a text manifest to the text_manifest_path. This uses the same method as the “version-manifest” software definition in omnibus-software.
1113 1114 1115 1116 1117 1118 1119 |
# File 'lib/omnibus/project.rb', line 1113 def write_text_manifest File.open(text_manifest_path, "w") do |f| f.puts "#{name} #{build_version}" f.puts "" f.puts Omnibus::Reports.pretty_version_map(self) end end |