Class: Vanagon::Platform
- Inherits:
-
Object
- Object
- Vanagon::Platform
- Includes:
- HashableAttributes, Utilities
- Defined in:
- lib/vanagon/extensions/hashable.rb,
lib/vanagon/platform.rb,
lib/vanagon/platform/deb.rb,
lib/vanagon/platform/dsl.rb,
lib/vanagon/platform/osx.rb,
lib/vanagon/platform/rpm.rb,
lib/vanagon/platform/rpm/aix.rb,
lib/vanagon/platform/rpm/eos.rb,
lib/vanagon/platform/rpm/wrl.rb,
lib/vanagon/platform/windows.rb,
lib/vanagon/platform/rpm/sles.rb,
lib/vanagon/platform/solaris_10.rb,
lib/vanagon/platform/solaris_11.rb
Overview
Vanagon classes generally don’t implement JSON or Hash functionality so those need to be monkey-patched for useful inspection.
Defined Under Namespace
Classes: DEB, DSL, OSX, RPM, Solaris10, Solaris11, Windows
Constant Summary collapse
- PLATFORM_REGEX =
Platform names currently contain some information about the platform. Fields within the name are delimited by the ‘-’ character, and this regex can be used to extract those fields.
/^(.*)-(.*)-(.*)$/.freeze
- VERSION_REGEX =
/^([=<>]+)\s*([^<>=]*)$/.freeze
Instance Attribute Summary collapse
-
#abs_resource_name ⇒ Object
Always-Be-Scheduling engine specific.
-
#architecture ⇒ String
Sets and gets the architecture of the platform.
-
#aws_ami ⇒ Object
AWS engine specific.
-
#aws_instance_type ⇒ Object
Returns the value of attribute aws_instance_type.
-
#aws_key ⇒ Object
Returns the value of attribute aws_key.
-
#aws_key_name ⇒ Object
Returns the value of attribute aws_key_name.
-
#aws_region ⇒ Object
Returns the value of attribute aws_region.
-
#aws_shutdown_behavior ⇒ Object
Returns the value of attribute aws_shutdown_behavior.
-
#aws_subnet_id ⇒ Object
Returns the value of attribute aws_subnet_id.
-
#aws_user_data ⇒ Object
Returns the value of attribute aws_user_data.
-
#aws_vpc_id ⇒ Object
Returns the value of attribute aws_vpc_id.
-
#build_dependencies ⇒ Object
Stores an Array of OpenStructs, each representing a complete command to be run to install external the needed toolchains and build dependencies for a given target platform.
-
#build_hosts ⇒ Object
Hardware engine specific.
-
#cflags ⇒ Object
Hold a string containing the values that a given platform should use when a Makefile is run - resolves to the CFLAGS and LDFLAGS variables.
-
#codename ⇒ Object
this is Debian/Ubuntu specific.
-
#copy ⇒ Object
Each of these holds the path or name of the command in question, e.g.
-
#cross_compiled ⇒ Object
Determines if a platform should be treated as cross-compiled or natively compiled.
-
#defaultdir ⇒ Object
Where does a given platform’s init system expect to find something resembling ‘defaults’ files.
-
#dist ⇒ String
Get the value of @dist, or derive it from the value of @os_name and @os_version.
-
#docker_image ⇒ Object
Docker engine specific.
-
#docker_run_args ⇒ Object
Returns the value of attribute docker_run_args.
-
#environment ⇒ Object
The overall Environment that a given platform should pass to each component.
-
#find ⇒ Object
Returns the value of attribute find.
-
#install ⇒ Object
Returns the value of attribute install.
-
#ldflags ⇒ Object
Returns the value of attribute ldflags.
-
#make ⇒ Object
Returns the value of attribute make.
-
#mktemp ⇒ Object
Returns the value of attribute mktemp.
-
#name ⇒ Object
Basic generic information related to a given instance of Platform.
-
#num_cores ⇒ Object
A string, containing the script that will be executed on the remote build target to determine how many CPU cores are available on that platform.
-
#os_name ⇒ String
Sets and gets the name of the operating system for the platform.
-
#os_version ⇒ String
Sets and gets the version of the operating system for the platform.
-
#output_dir(target_repo = "") ⇒ String
Get the output dir for packages.
-
#package_type ⇒ Object
The name of the sort of package type that a given platform expects, e.g.
-
#patch ⇒ Object
Returns the value of attribute patch.
-
#platform_triple ⇒ Object
Returns the value of attribute platform_triple.
-
#provisioning ⇒ Object
Stores an Array of Strings, which will be passed in as a shell script as part of the provisioning step for a given build target.
-
#rpmbuild ⇒ Object
This is RedHat/EL/Fedora/SLES specific.
-
#sed ⇒ Object
Returns the value of attribute sed.
-
#servicedir ⇒ Object
Where does a given platform expect to find init scripts/service files? e.g.
-
#servicetype ⇒ Object
The name of the sort of init system that a given platform uses.
-
#servicetypes ⇒ Object
Array of OpenStructs containing the servicetype and the corresponding servicedir.
-
#settings ⇒ Object
Freeform Hash of leftover settings.
-
#shasum ⇒ Object
Returns the value of attribute shasum.
-
#shell ⇒ Object
rubocop:disable Lint/DuplicateMethods.
-
#sort ⇒ Object
Returns the value of attribute sort.
-
#source_output_dir(target_repo = "") ⇒ String
Get the source dir for packages.
-
#ssh_port ⇒ Object
Generic engine.
-
#tar ⇒ Object
Returns the value of attribute tar.
-
#target_user ⇒ Object
Username to use when connecting to a build target.
-
#use_docker_exec ⇒ Object
Returns the value of attribute use_docker_exec.
-
#valid_operators ⇒ Object
Returns the value of attribute valid_operators.
-
#vmpooler_template ⇒ Object
VMpooler engine specific.
Class Method Summary collapse
-
.load_platform(name, configdir) ⇒ Vanagon::Platform
Loads a given platform from the configdir.
Instance Method Summary collapse
-
#[](key) ⇒ Object
This allows instance variables to be accessed using the hash lookup syntax.
-
#add_build_repository(*args) ⇒ Object
Generic adder for build repositories.
-
#add_group(user) ⇒ String
Generate the scripts required to add a group to the package generated.
-
#add_user(user) ⇒ String
Generate the scripts required to add a user to the package generated.
-
#generate_compiled_archive(project) ⇒ Object
Save the generic compiled archive and relevant metadata as packaging output.
-
#get_service_dir(servicetype = '') ⇒ Object
Get configured service dir (added through plat.servicedir, or plat.servicetype ‘foo’, servicedir: ‘bar’).
-
#get_service_types ⇒ Object
Get all configured service types (added through plat.servicetype).
-
#initialize(name) ⇒ Vanagon::Platform
constructor
Platform constructor.
-
#is_aix? ⇒ true, false
Utility matcher to determine is the platform is an aix variety.
-
#is_cisco_wrlinux? ⇒ true, false
Utility matcher to determine is the platform is a cisco-wrlinux variety.
-
#is_cross_compiled? ⇒ true, false
Utility matcher to determine if the platform is a cross-compiled variety.
-
#is_cross_compiled_linux? ⇒ true, false
Utility matcher to determine if the platform is a cross-compiled Linux variety.
-
#is_deb? ⇒ true, false
Utility matcher to determine is the platform is a debian variety.
-
#is_debian? ⇒ true, false
Utility matcher to determine is the platform is a debian variety.
-
#is_el8? ⇒ true, false
Utility matcher to determine if the platform is of an EL 8 variety.
-
#is_el? ⇒ true, false
Utility matcher to determine is the platform is an enterprise linux variety.
-
#is_eos? ⇒ true, false
Utility matcher to determine is the platform is an eos variety.
-
#is_fedora? ⇒ true, false
Utility matcher to determine is the platform is a fedora variety.
-
#is_fips? ⇒ true, false
Utility matcher to determine if the platform is a FIPS platform.
-
#is_huaweios? ⇒ true, false
Utility matcher to determine is the platform is a HuaweiOS variety.
-
#is_linux? ⇒ true, false
Utility matcher to determine is the platform is a linux variety.
-
#is_macos? ⇒ true, false
Utility matcher to determine if the platform is a macos or osx variety is_osx is a deprecated method that calls is_macos We still match for osx currently but this will change.
-
#is_osx? ⇒ true, false
deprecated
Deprecated.
Please use is_macos? instead
-
#is_rpm? ⇒ true, false
Utility matcher to determine is the platform is a redhat variety or uses rpm under the hood.
-
#is_sles? ⇒ true, false
Utility matcher to determine is the platform is a sles variety.
-
#is_solaris? ⇒ true, false
Utility matcher to determine is the platform is a solaris variety.
-
#is_ubuntu? ⇒ true, false
Utility matcher to determine is the platform is a ubuntu variety.
-
#is_unix? ⇒ true, false
Utility matcher to determine is the platform is a unix variety.
-
#is_windows? ⇒ true, false
Utility matcher to determine is the platform is a windows variety.
-
#package_override(project, var) ⇒ Object
Pass in a packaging override.
-
#provision_with(command) ⇒ Object
Set the command to turn the target machine into a builder for vanagon.
- #validate_operator(operator_string) ⇒ Object
-
#version_munger(version_string, default: '=') ⇒ Object
version strings for dependencies, conflicts, replaces, etc need some munging based on platform.
Methods included from HashableAttributes
Methods included from Utilities
#erb_file, #erb_string, #ex, #find_program_on_path, #get_md5sum, #get_sum, #http_request, #http_request_code, #http_request_generic, #local_command, #remote_ssh_command, #retry_with_timeout, #rsync_from, #rsync_to, #ssh_command
Constructor Details
#initialize(name) ⇒ Vanagon::Platform
Platform constructor. Takes just the name. Also sets the @name, @os_name, @os_version and @architecture instance attributes as a side effect
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/vanagon/platform.rb', line 226 def initialize(name) # rubocop:disable Metrics/AbcSize @name = name @settings = {} @os_name = os_name @os_version = os_version @architecture = architecture @ssh_port = 22 # Environments are like Hashes but with specific constraints # around their keys and values. @environment = Vanagon::Environment.new @provisioning = [] @install ||= "install" @mktemp ||= "mktemp -d -p /var/tmp" @target_user ||= "root" @find ||= "find" @sed ||= "sed" @sort ||= "sort" @copy ||= "cp" @shasum ||= "sha1sum" @use_docker_exec = false # Our first attempt at defining metadata about a platform @cross_compiled ||= false @valid_operators ||= ['<', '>', '<=', '>=', '='] @servicetypes = [] end |
Instance Attribute Details
#abs_resource_name ⇒ Object
Always-Be-Scheduling engine specific
114 115 116 |
# File 'lib/vanagon/platform.rb', line 114 def abs_resource_name @abs_resource_name end |
#architecture ⇒ String
Sets and gets the architecture of the platform. Also has the side effect of setting the @architecture instance attribute
315 316 317 |
# File 'lib/vanagon/platform.rb', line 315 def architecture @architecture end |
#aws_ami ⇒ Object
AWS engine specific
125 126 127 |
# File 'lib/vanagon/platform.rb', line 125 def aws_ami @aws_ami end |
#aws_instance_type ⇒ Object
Returns the value of attribute aws_instance_type.
131 132 133 |
# File 'lib/vanagon/platform.rb', line 131 def aws_instance_type @aws_instance_type end |
#aws_key ⇒ Object
Returns the value of attribute aws_key.
130 131 132 |
# File 'lib/vanagon/platform.rb', line 130 def aws_key @aws_key end |
#aws_key_name ⇒ Object
Returns the value of attribute aws_key_name.
128 129 130 |
# File 'lib/vanagon/platform.rb', line 128 def aws_key_name @aws_key_name end |
#aws_region ⇒ Object
Returns the value of attribute aws_region.
129 130 131 |
# File 'lib/vanagon/platform.rb', line 129 def aws_region @aws_region end |
#aws_shutdown_behavior ⇒ Object
Returns the value of attribute aws_shutdown_behavior.
127 128 129 |
# File 'lib/vanagon/platform.rb', line 127 def aws_shutdown_behavior @aws_shutdown_behavior end |
#aws_subnet_id ⇒ Object
Returns the value of attribute aws_subnet_id.
133 134 135 |
# File 'lib/vanagon/platform.rb', line 133 def aws_subnet_id @aws_subnet_id end |
#aws_user_data ⇒ Object
Returns the value of attribute aws_user_data.
126 127 128 |
# File 'lib/vanagon/platform.rb', line 126 def aws_user_data @aws_user_data end |
#aws_vpc_id ⇒ Object
Returns the value of attribute aws_vpc_id.
132 133 134 |
# File 'lib/vanagon/platform.rb', line 132 def aws_vpc_id @aws_vpc_id end |
#build_dependencies ⇒ Object
Stores an Array of OpenStructs, each representing a complete command to be run to install external the needed toolchains and build dependencies for a given target platform.
75 76 77 |
# File 'lib/vanagon/platform.rb', line 75 def build_dependencies @build_dependencies end |
#build_hosts ⇒ Object
Hardware engine specific
111 112 113 |
# File 'lib/vanagon/platform.rb', line 111 def build_hosts @build_hosts end |
#cflags ⇒ Object
Hold a string containing the values that a given platform should use when a Makefile is run - resolves to the CFLAGS and LDFLAGS variables. This should be changed to take advantage of the Environment, so that we can better leverage Make’s Implicit Variables.
It should also be extended to support CXXFLAGS and CPPFLAGS ASAP.
65 66 67 |
# File 'lib/vanagon/platform.rb', line 65 def cflags @cflags end |
#codename ⇒ Object
this is Debian/Ubuntu specific
24 25 26 |
# File 'lib/vanagon/platform.rb', line 24 def codename @codename end |
#copy ⇒ Object
Each of these holds the path or name of the command in question, e.g. ‘copy = “/usr/local/bin/gcp”`, or `copy = “cp”`
46 47 48 |
# File 'lib/vanagon/platform.rb', line 46 def copy @copy end |
#cross_compiled ⇒ Object
Determines if a platform should be treated as cross-compiled or natively compiled.
93 94 95 |
# File 'lib/vanagon/platform.rb', line 93 def cross_compiled @cross_compiled end |
#defaultdir ⇒ Object
Where does a given platform’s init system expect to find something resembling ‘defaults’ files. Most likely to apply to Linux systems that use SysV-ish, upstart, or systemd init systems.
42 43 44 |
# File 'lib/vanagon/platform.rb', line 42 def defaultdir @defaultdir end |
#dist ⇒ String
Get the value of @dist, or derive it from the value of @os_name and @os_version. This is relatively RPM specific but ‘#codename’ is defined in Platform, and that’s just as Deb/Ubuntu specific. All of the accessors in the top-level Platform namespace should be refactored, but #dist will live here for now.
291 292 293 |
# File 'lib/vanagon/platform.rb', line 291 def dist @dist ||= @os_name.tr('-', '_') + @os_version end |
#docker_image ⇒ Object
Docker engine specific
120 121 122 |
# File 'lib/vanagon/platform.rb', line 120 def docker_image @docker_image end |
#docker_run_args ⇒ Object
Returns the value of attribute docker_run_args.
121 122 123 |
# File 'lib/vanagon/platform.rb', line 121 def docker_run_args @docker_run_args end |
#environment ⇒ Object
The overall Environment that a given platform should pass to each component
70 71 72 |
# File 'lib/vanagon/platform.rb', line 70 def environment @environment end |
#find ⇒ Object
Returns the value of attribute find.
47 48 49 |
# File 'lib/vanagon/platform.rb', line 47 def find @find end |
#install ⇒ Object
Returns the value of attribute install.
48 49 50 |
# File 'lib/vanagon/platform.rb', line 48 def install @install end |
#ldflags ⇒ Object
Returns the value of attribute ldflags.
66 67 68 |
# File 'lib/vanagon/platform.rb', line 66 def ldflags @ldflags end |
#make ⇒ Object
Returns the value of attribute make.
49 50 51 |
# File 'lib/vanagon/platform.rb', line 49 def make @make end |
#mktemp ⇒ Object
Returns the value of attribute mktemp.
50 51 52 |
# File 'lib/vanagon/platform.rb', line 50 def mktemp @mktemp end |
#name ⇒ Object
Basic generic information related to a given instance of Platform. e.g. The name we call it, the platform triplet (name-version-arch), etc.
19 20 21 |
# File 'lib/vanagon/platform.rb', line 19 def name @name end |
#num_cores ⇒ Object
A string, containing the script that will be executed on the remote build target to determine how many CPU cores are available on that platform. Vanagon will use that count to determine how many build threads should be initialized for compilations.
105 106 107 |
# File 'lib/vanagon/platform.rb', line 105 def num_cores @num_cores end |
#os_name ⇒ String
Sets and gets the name of the operating system for the platform. Also has the side effect of setting the @os_name instance attribute
299 300 301 |
# File 'lib/vanagon/platform.rb', line 299 def os_name @os_name end |
#os_version ⇒ String
Sets and gets the version of the operating system for the platform. Also has the side effect of setting the @os_version instance attribute
307 308 309 |
# File 'lib/vanagon/platform.rb', line 307 def os_version @os_version end |
#output_dir(target_repo = "") ⇒ String
Get the output dir for packages. If the output_dir was defined already (by the platform config) then don’t change it.
78 79 80 |
# File 'lib/vanagon/platform.rb', line 78 def output_dir @output_dir end |
#package_type ⇒ Object
The name of the sort of package type that a given platform expects, e.g. msi, rpm,
29 30 31 |
# File 'lib/vanagon/platform.rb', line 29 def package_type @package_type end |
#patch ⇒ Object
Returns the value of attribute patch.
51 52 53 |
# File 'lib/vanagon/platform.rb', line 51 def patch @patch end |
#platform_triple ⇒ Object
Returns the value of attribute platform_triple.
20 21 22 |
# File 'lib/vanagon/platform.rb', line 20 def platform_triple @platform_triple end |
#provisioning ⇒ Object
Stores an Array of Strings, which will be passed in as a shell script as part of the provisioning step for a given build target
89 90 91 |
# File 'lib/vanagon/platform.rb', line 89 def provisioning @provisioning end |
#rpmbuild ⇒ Object
This is RedHat/EL/Fedora/SLES specific
52 53 54 |
# File 'lib/vanagon/platform.rb', line 52 def rpmbuild @rpmbuild end |
#sed ⇒ Object
Returns the value of attribute sed.
53 54 55 |
# File 'lib/vanagon/platform.rb', line 53 def sed @sed end |
#servicedir ⇒ Object
Where does a given platform expect to find init scripts/service files? e.g. /etc/init.d, /usr/lib/systemd/system
35 36 37 |
# File 'lib/vanagon/platform.rb', line 35 def servicedir @servicedir end |
#servicetype ⇒ Object
The name of the sort of init system that a given platform uses
32 33 34 |
# File 'lib/vanagon/platform.rb', line 32 def servicetype @servicetype end |
#servicetypes ⇒ Object
Array of OpenStructs containing the servicetype and the corresponding servicedir
38 39 40 |
# File 'lib/vanagon/platform.rb', line 38 def servicetypes @servicetypes end |
#settings ⇒ Object
Freeform Hash of leftover settings
136 137 138 |
# File 'lib/vanagon/platform.rb', line 136 def settings @settings end |
#shasum ⇒ Object
Returns the value of attribute shasum.
56 57 58 |
# File 'lib/vanagon/platform.rb', line 56 def shasum @shasum end |
#shell ⇒ Object
rubocop:disable Lint/DuplicateMethods
98 99 100 |
# File 'lib/vanagon/platform.rb', line 98 def shell @shell end |
#sort ⇒ Object
Returns the value of attribute sort.
54 55 56 |
# File 'lib/vanagon/platform.rb', line 54 def sort @sort end |
#source_output_dir(target_repo = "") ⇒ String
Get the source dir for packages. Don’t change it if it was already defined by the platform config. Defaults to output_dir unless specified otherwise (RPM specifies this)
defined at the project level
81 82 83 |
# File 'lib/vanagon/platform.rb', line 81 def source_output_dir @source_output_dir end |
#ssh_port ⇒ Object
Generic engine
108 109 110 |
# File 'lib/vanagon/platform.rb', line 108 def ssh_port @ssh_port end |
#tar ⇒ Object
Returns the value of attribute tar.
55 56 57 |
# File 'lib/vanagon/platform.rb', line 55 def tar @tar end |
#target_user ⇒ Object
Username to use when connecting to a build target
84 85 86 |
# File 'lib/vanagon/platform.rb', line 84 def target_user @target_user end |
#use_docker_exec ⇒ Object
Returns the value of attribute use_docker_exec.
122 123 124 |
# File 'lib/vanagon/platform.rb', line 122 def use_docker_exec @use_docker_exec end |
#valid_operators ⇒ Object
Returns the value of attribute valid_operators.
138 139 140 |
# File 'lib/vanagon/platform.rb', line 138 def valid_operators @valid_operators end |
#vmpooler_template ⇒ Object
VMpooler engine specific
117 118 119 |
# File 'lib/vanagon/platform.rb', line 117 def vmpooler_template @vmpooler_template end |
Class Method Details
.load_platform(name, configdir) ⇒ Vanagon::Platform
Loads a given platform from the configdir
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/vanagon/platform.rb', line 153 def self.load_platform(name, configdir) platfile = File.join(configdir, "#{name}.rb") dsl = Vanagon::Platform::DSL.new(name) dsl.instance_eval(File.read(platfile), platfile, 1) dsl._platform rescue StandardError => e VanagonLogger.error "Error loading platform '#{name}' using '#{platfile}':" VanagonLogger.error(e) VanagonLogger.error e.backtrace.join("\n") raise e end |
Instance Method Details
#[](key) ⇒ Object
This allows instance variables to be accessed using the hash lookup syntax
259 260 261 262 263 |
# File 'lib/vanagon/platform.rb', line 259 def [](key) if instance_variable_get("@#{key}") instance_variable_get("@#{key}") end end |
#add_build_repository(*args) ⇒ Object
Generic adder for build repositories
489 490 491 492 493 494 495 |
# File 'lib/vanagon/platform.rb', line 489 def add_build_repository(*args) if self.respond_to?(:add_repository) self.provision_with self.send(:add_repository, *args) else raise Vanagon::Error, "Adding a build repository not defined for #{name}" end end |
#add_group(user) ⇒ String
Generate the scripts required to add a group to the package generated. This will also update the group if it has changed.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/vanagon/platform.rb', line 170 def add_group(user) cmd_args = ["'#{user.group}'"] cmd_args.unshift '--system' if user.is_system groupadd_args = cmd_args.join "\s" groupmod_args = (cmd_args - ["--system"]).join "\s" return <<-HERE.undent if getent group '#{user.group}' > /dev/null 2>&1; then /usr/sbin/groupmod #{groupmod_args} else /usr/sbin/groupadd #{groupadd_args} fi HERE end |
#add_user(user) ⇒ String
Generate the scripts required to add a user to the package generated. This will also update the user if it has changed.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/vanagon/platform.rb', line 191 def add_user(user) # rubocop:disable Metrics/AbcSize cmd_args = ["'#{user.name}'"] cmd_args.unshift "--home '#{user.homedir}'" if user.homedir if user.shell cmd_args.unshift "--shell '#{user.shell}'" elsif user.is_system cmd_args.unshift "--shell '/usr/sbin/nologin'" end cmd_args.unshift "--gid '#{user.group}'" if user.group cmd_args.unshift '--system' if user.is_system # Collapse the cmd_args array into a string that can be used # as an argument to `useradd` useradd_args = cmd_args.join "\s" # Collapse the cmd_args array into a string that can be used # as an argument to `usermod`; If this is a system account, # then specify it as such for user addition only (strip # --system from usermod_args) usermod_args = (cmd_args - ["--system"]).join "\s" return <<-HERE.undent if getent passwd '#{user.name}' > /dev/null 2>&1; then /usr/sbin/usermod #{usermod_args} else /usr/sbin/useradd #{useradd_args} fi HERE end |
#generate_compiled_archive(project) ⇒ Object
Save the generic compiled archive and relevant metadata as packaging output. This will include a json file with all of the components/versions that were built and a bill of materials when relevant. The archive will be a gzipped tarball.
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
# File 'lib/vanagon/platform.rb', line 504 def generate_compiled_archive(project) name_and_version = "#{project.name}-#{project.version}" name_and_version_and_platform = "#{name_and_version}.#{name}" name_and_platform = "#{project.name}.#{name}" final_archive = "output/#{name_and_version_and_platform}.tar.gz" archive_directory = "#{project.name}-archive" # previously, we weren't properly handling the case of custom BOM paths. # If we have a custom BOM path, during Makefile execution, the top-level # BOM is moved to the custom path. So, when cleaning up BOMs for non-custom # paths we just want to remove the BOM at the top level of the tarball. # But, if we have a custom BOM path we want to move it back to where it # was prior to the Makefile execution so we can preserve it as an artifact # but not leave it to conflict if it's installed in the same custom path # as a project using this archive. bill_of_materials_command = 'rm -f bill-of-materials' if project.bill_of_materials bill_of_materials_command = "mv .#{project.bill_of_materials.path}/bill-of-materials ../.." end [ "mkdir output", "mkdir #{archive_directory}", "gunzip -c #{name_and_version}.tar.gz | '#{tar}' -C #{archive_directory} -xf -", "rm #{name_and_version}.tar.gz", "cd #{archive_directory}/#{name_and_version}; #{bill_of_materials_command}; #{tar} cf ../../#{name_and_version_and_platform}.tar *", "gzip -9c #{name_and_version_and_platform}.tar > #{name_and_version_and_platform}.tar.gz", "cp build_metadata.#{name_and_platform}.json output/#{name_and_version_and_platform}.json", "cp bill-of-materials output/#{name_and_version_and_platform}-bill-of-materials ||:", "cp #{name_and_version_and_platform}.tar.gz output", "#{shasum} #{final_archive} > #{final_archive}.sha1" ] end |
#get_service_dir(servicetype = '') ⇒ Object
Get configured service dir (added through plat.servicedir, or plat.servicetype ‘foo’, servicedir: ‘bar’)
586 587 588 589 590 591 592 593 594 595 596 597 |
# File 'lib/vanagon/platform.rb', line 586 def get_service_dir(servicetype = '') if @servicetypes.empty? return @servicedir end servicedir = @servicetypes.select { |s| s.servicetype.include?(servicetype) }.flat_map(&:servicedir).compact if servicedir.size > 1 raise Vanagon::Error, "You can only have one service dir for each service type. Found '#{servicedir.join(',')}' for service type #{servicetype}" end servicedir.first end |
#get_service_types ⇒ Object
Get all configured service types (added through plat.servicetype)
573 574 575 576 577 578 579 580 581 |
# File 'lib/vanagon/platform.rb', line 573 def get_service_types if @servicetypes.any? @servicetypes.flat_map(&:servicetype).compact elsif @servicetype [@servicetype] else [] end end |
#is_aix? ⇒ true, false
Utility matcher to determine is the platform is an aix variety
387 388 389 |
# File 'lib/vanagon/platform.rb', line 387 def is_aix? return !!@name.match(/^aix-.*$/) end |
#is_cisco_wrlinux? ⇒ true, false
Utility matcher to determine is the platform is a cisco-wrlinux variety
otherwise
410 411 412 |
# File 'lib/vanagon/platform.rb', line 410 def is_cisco_wrlinux? return !!@name.match(/^cisco-wrlinux-.*$/) end |
#is_cross_compiled? ⇒ true, false
Utility matcher to determine if the platform is a cross-compiled variety
463 464 465 |
# File 'lib/vanagon/platform.rb', line 463 def is_cross_compiled? return @cross_compiled end |
#is_cross_compiled_linux? ⇒ true, false
Utility matcher to determine if the platform is a cross-compiled Linux variety. Many of the customizations needed to cross-compile for Linux are similar, so it’s useful to group them together vs. other cross-compiled OSes.
472 473 474 |
# File 'lib/vanagon/platform.rb', line 472 def is_cross_compiled_linux? return (is_cross_compiled? && is_linux?) end |
#is_deb? ⇒ true, false
Utility matcher to determine is the platform is a debian variety
322 323 324 |
# File 'lib/vanagon/platform.rb', line 322 def is_deb? return !!@name.match(/^(debian|ubuntu|cumulus|huaweios)-.*$/) end |
#is_debian? ⇒ true, false
Utility matcher to determine is the platform is a debian variety
373 374 375 |
# File 'lib/vanagon/platform.rb', line 373 def is_debian? return !!@name.match(/^debian-.*$/) end |
#is_el8? ⇒ true, false
Utility matcher to determine if the platform is of an EL 8 variety
345 346 347 |
# File 'lib/vanagon/platform.rb', line 345 def is_el8? return !!@name.match(/^(el|redhat|redhatfips)-8.*$/) end |
#is_el? ⇒ true, false
Utility matcher to determine is the platform is an enterprise linux variety
338 339 340 |
# File 'lib/vanagon/platform.rb', line 338 def is_el? return !!@name.match(/^(el|redhat|redhatfips)-.*$/) end |
#is_eos? ⇒ true, false
Utility matcher to determine is the platform is an eos variety
394 395 396 |
# File 'lib/vanagon/platform.rb', line 394 def is_eos? return !!@name.match(/^eos-.*$/) end |
#is_fedora? ⇒ true, false
Utility matcher to determine is the platform is a fedora variety
366 367 368 |
# File 'lib/vanagon/platform.rb', line 366 def is_fedora? return !!@name.match(/^fedora-.*$/) end |
#is_fips? ⇒ true, false
Utility matcher to determine if the platform is a FIPS platform
352 353 354 |
# File 'lib/vanagon/platform.rb', line 352 def is_fips? return @name.include?('fips') end |
#is_huaweios? ⇒ true, false
Utility matcher to determine is the platform is a HuaweiOS variety
401 402 403 |
# File 'lib/vanagon/platform.rb', line 401 def is_huaweios? return !!@name.match(/^huaweios-.*$/) end |
#is_linux? ⇒ true, false
Utility matcher to determine is the platform is a linux variety
456 457 458 |
# File 'lib/vanagon/platform.rb', line 456 def is_linux? return (!is_windows? && !is_unix?) end |
#is_macos? ⇒ true, false
Utility matcher to determine if the platform is a macos or osx variety is_osx is a deprecated method that calls is_macos We still match for osx currently but this will change
428 429 430 |
# File 'lib/vanagon/platform.rb', line 428 def is_macos? !!(@name =~ /^macos-.*$/ || @name =~ /^osx-.*$/) end |
#is_osx? ⇒ true, false
Please use is_macos? instead
Utility matcher to determine if the platform is an osx variety
418 419 420 421 |
# File 'lib/vanagon/platform.rb', line 418 def is_osx? VanagonLogger.info "is_osx? is a deprecated method, please use #is_macos? instead." is_macos? end |
#is_rpm? ⇒ true, false
Utility matcher to determine is the platform is a redhat variety or uses rpm under the hood
under the hood, false otherwise
331 332 333 |
# File 'lib/vanagon/platform.rb', line 331 def is_rpm? return !!@name.match(/^(aix|cisco-wrlinux|el|eos|fedora|sles|redhat|redhatfips)-.*$/) end |
#is_sles? ⇒ true, false
Utility matcher to determine is the platform is a sles variety
359 360 361 |
# File 'lib/vanagon/platform.rb', line 359 def is_sles? return !!@name.match(/^sles-.*$/) end |
#is_solaris? ⇒ true, false
Utility matcher to determine is the platform is a solaris variety
435 436 437 |
# File 'lib/vanagon/platform.rb', line 435 def is_solaris? return !!@name.match(/^solaris-.*$/) end |
#is_ubuntu? ⇒ true, false
Utility matcher to determine is the platform is a ubuntu variety
380 381 382 |
# File 'lib/vanagon/platform.rb', line 380 def is_ubuntu? return !!@name.match(/^ubuntu-.*$/) end |
#is_unix? ⇒ true, false
Utility matcher to determine is the platform is a unix variety
442 443 444 |
# File 'lib/vanagon/platform.rb', line 442 def is_unix? return !!@name.match(/^(solaris|aix|osx)-.*$/) end |
#is_windows? ⇒ true, false
Utility matcher to determine is the platform is a windows variety
449 450 451 |
# File 'lib/vanagon/platform.rb', line 449 def is_windows? return !!@name.match(/^windows.*$/) end |
#package_override(project, var) ⇒ Object
Pass in a packaging override. This needs to be implemented for each individual platform so that this input ends up in the right place.
481 482 483 |
# File 'lib/vanagon/platform.rb', line 481 def package_override(project, var) fail "I don't know how to set package overrides for #{name}, teach me?" end |
#provision_with(command) ⇒ Object
Set the command to turn the target machine into a builder for vanagon
541 542 543 544 |
# File 'lib/vanagon/platform.rb', line 541 def provision_with(command) provisioning << command provisioning.flatten! end |
#validate_operator(operator_string) ⇒ Object
567 568 569 |
# File 'lib/vanagon/platform.rb', line 567 def validate_operator(operator_string) valid_operators.include?(operator_string) end |
#version_munger(version_string, default: '=') ⇒ Object
version strings for dependencies, conflicts, replaces, etc need some munging based on platform.
553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/vanagon/platform.rb', line 553 def version_munger(version_string, default: '=') match = version_string.match(VERSION_REGEX) if match.nil? VanagonLogger.info "Passing a version without an operator is deprecated!" operator = default version = version_string end operator ||= match[1] version ||= match[2] fail "Operator '#{operator}' is invalid" unless validate_operator(operator) "#{operator} #{version}" end |