Module: Pkg::Paths
- Includes:
- Platforms
- Defined in:
- lib/packaging/paths.rb
Overview
Utilities surrounding the appropriate paths associated with a platform This includes both reporting the correct path and divining the platform tag associated with a variety of paths
rubocop:disable Metrics/ModuleLength
Constant Summary
Constants included from Platforms
Pkg::Platforms::DEBIAN_SOURCE_FORMATS, Pkg::Platforms::PLATFORM_INFO
Class Method Summary collapse
- .arch_from_artifact_path(platform, version, path) ⇒ Object
-
.artifacts_base_path_and_link_path(platform_tag, path_prefix = 'artifacts') ⇒ Object
TODO: please please please clean this up This is so terrible.
-
.artifacts_path(platform_tag, path_prefix = 'artifacts') ⇒ Object
TODO: please please please clean this up This is so terrible.
- .link_name ⇒ Object
- .repo_config_path(platform_tag) ⇒ Object
-
.repo_name ⇒ Object
Assign repo name If we are shipping development/beta/non-final packages, they should be shipped to the development/beta/non-final repo, if there is one defined.
- .repo_path(platform_tag, options = { :legacy => false }) ⇒ Object
-
.tag_from_artifact_path(path) ⇒ Object
Given a path to an artifact, divine the appropriate platform tag associated with the artifact and path.
Methods included from Platforms
all_supported_package_formats, arches_for_codename, arches_for_platform_version, by_deb, by_package_format, by_rpm, codename_for_platform_version, codename_to_platform_version, codename_to_tags, codenames, formats, generic_platform_tag, get_attribute, get_attribute_for_platform_version, package_format_for_tag, parse_platform_tag, platform_lookup, platform_tags, platform_tags_for_package_format, signature_format_for_platform_version, signature_format_for_tag, source_architecture_for_platform_tag, source_package_formats_for_platform_tag, supported_platforms, versions_for_platform
Class Method Details
.arch_from_artifact_path(platform, version, path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/packaging/paths.rb', line 11 def arch_from_artifact_path(platform, version, path) arches = Pkg::Platforms.arches_for_platform_version(platform, version) # First check if it's a source package source_formats = Pkg::Platforms.get_attribute_for_platform_version(platform, version, :source_package_formats) if source_formats.find { |fmt| path =~ /#{fmt}$/ } return Pkg::Platforms.get_attribute_for_platform_version(platform, version, :source_architecture) end arches.find { |a| path.include?(a) } || arches[0] rescue arches.find { |a| path.include?(a) } || arches[0] end |
.artifacts_base_path_and_link_path(platform_tag, path_prefix = 'artifacts') ⇒ Object
TODO: please please please clean this up This is so terrible. I really dislike it. But in order to maintain backward compatibility, we need to maintain these path differences between PC1 and everything else. Once we stop shipping things to PC1, we can remove all the PC1 specific cases. That's likely to not happen until the current LTS (2016.4) is EOL'd. Hopefully also we do not choose to further change these path structures, as it is no bueno. --MAS 2017-08-16
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/packaging/paths.rb', line 89 def artifacts_base_path_and_link_path(platform_tag, path_prefix = 'artifacts') platform, version, architecture = Pkg::Platforms.parse_platform_tag(platform_tag) package_format = Pkg::Platforms.package_format_for_tag(platform_tag) case package_format when 'rpm' if repo_name == 'PC1' [File.join(path_prefix, platform, version, repo_name), nil] else [File.join(path_prefix, repo_name), link_name.nil? ? nil : File.join(path_prefix, link_name)] end when 'swix' if repo_name == 'PC1' [File.join(path_prefix, platform, version, repo_name), nil] else [File.join(path_prefix, platform, repo_name), link_name.nil? ? nil : File.join(path_prefix, platform, link_name)] end when 'deb' [File.join(path_prefix, Pkg::Platforms.get_attribute(platform_tag, :codename), repo_name), link_name.nil? ? nil : File.join(path_prefix, Pkg::Platforms.get_attribute(platform_tag, :codename), link_name)] when 'svr4', 'ips' if repo_name == 'PC1' [File.join(path_prefix, 'solaris', repo_name, version), nil] else [File.join(path_prefix, 'solaris', repo_name), link_name.nil? ? nil : File.join(path_prefix, 'solaris', link_name)] end when 'dmg' if repo_name == 'PC1' [File.join(path_prefix, 'mac', version, repo_name), nil] else [File.join(path_prefix, 'mac', repo_name), link_name.nil? ? nil : File.join(path_prefix, 'mac', link_name)] end when 'msi' if repo_name == 'PC1' [File.join(path_prefix, 'windows'), nil] else [File.join(path_prefix, 'windows', repo_name), link_name.nil? ? nil : File.join(path_prefix, 'windows', link_name)] end else raise "Not sure where to find packages with a package format of '#{package_format}'" end end |
.artifacts_path(platform_tag, path_prefix = 'artifacts') ⇒ Object
TODO: please please please clean this up This is so terrible. I really dislike it. But in order to maintain backward compatibility, we need to maintain these path differences between PC1 and everything else. Once we stop shipping things to PC1, we can remove all the PC1 specific cases. That's likely to not happen until the current LTS (2016.4) is EOL'd. Hopefully also we do not choose to further change these path structures, as it is no bueno. --MAS 2017-08-16
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/packaging/paths.rb', line 140 def artifacts_path(platform_tag, path_prefix = 'artifacts') base_path, _ = artifacts_base_path_and_link_path(platform_tag, path_prefix) platform, version, architecture = Pkg::Platforms.parse_platform_tag(platform_tag) package_format = Pkg::Platforms.package_format_for_tag(platform_tag) case package_format when 'rpm' if repo_name == 'PC1' File.join(base_path, architecture) else File.join(base_path, platform, version, architecture) end when 'swix' if repo_name == 'PC1' File.join(base_path, architecture) else File.join(base_path, version, architecture) end when 'deb' base_path when 'svr4', 'ips' if repo_name == 'PC1' base_path else File.join(base_path, version) end when 'dmg' if repo_name == 'PC1' File.join(base_path, architecture) else File.join(base_path, version, architecture) end when 'msi' base_path else raise "Not sure where to find packages with a package format of '#{package_format}'" end end |
.link_name ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/packaging/paths.rb', line 73 def link_name if Pkg::Util::Version.final? Pkg::Config.repo_link_target || nil else Pkg::Config.nonfinal_repo_link_target || nil end end |
.repo_config_path(platform_tag) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/packaging/paths.rb', line 222 def repo_config_path(platform_tag) package_format = Pkg::Platforms.package_format_for_tag(platform_tag) case package_format when 'rpm' # rpm/pl-puppet-agent-1.2.5-el-5-i386.repo for example File.join('repo_configs', 'rpm', "*#{platform_tag}*.repo") when 'deb' # deb/pl-puppet-agent-1.2.5-jessie.list File.join('repo_configs', 'deb', "*#{Pkg::Platforms.get_attribute(platform_tag, :codename)}*.list") when 'msi', 'swix', 'dmg', 'svr4', 'ips' nil else raise "Not sure what to do with a package format of '#{package_format}'" end end |
.repo_name ⇒ Object
Assign repo name If we are shipping development/beta/non-final packages, they should be shipped to the development/beta/non-final repo, if there is one defined. Otherwise, default to the final repo name. We use this for more than just shipping to the final repos, so we need this to not fail.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/packaging/paths.rb', line 61 def repo_name if Pkg::Util::Version.final? Pkg::Config.repo_name || "" else if Pkg::Config.nonfinal_repo_name Pkg::Config.nonfinal_repo_name else Pkg::Config.repo_name || "" end end end |
.repo_path(platform_tag, options = { :legacy => false }) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 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 220 |
# File 'lib/packaging/paths.rb', line 179 def repo_path(platform_tag, = { :legacy => false }) repo_target = repo_name # in legacy packaging methods, there was no consistent way to determine the # repo name. There were separate variables for apt_repo_name and # yum_repo_name. At times, either or both of these were unset, and they had # different defaults. So, for legacy automation we need to just use a splat # and globbing to find our packages. repo_target = '**' if [:legacy] platform, version, arch = Pkg::Platforms.parse_platform_tag(platform_tag) package_format = Pkg::Platforms.package_format_for_tag(platform_tag) case package_format when 'rpm', 'swix' if [:legacy] File.join('repos', platform, version, repo_target, arch) else File.join('repos', repo_target, platform, version, arch) end when 'deb' File.join('repos', 'apt', Pkg::Platforms.get_attribute(platform_tag, :codename), 'pool', repo_target) when 'svr4', 'ips' if [:legacy] File.join('repos', 'solaris', version, repo_target) else File.join('repos', 'solaris', repo_target, version) end when 'dmg' if [:legacy] File.join('repos', 'apple', version, repo_target, arch) else File.join('repos', 'mac', repo_target, version, arch) end when 'msi' if [:legacy] File.join('repos', 'windows') else File.join('repos', 'windows', repo_target) end else raise "Not sure what to do with a package format of '#{package_format}'" end end |
.tag_from_artifact_path(path) ⇒ Object
Given a path to an artifact, divine the appropriate platform tag associated with the artifact and path
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/packaging/paths.rb', line 26 def tag_from_artifact_path(path) platform = Pkg::Platforms.supported_platforms.find { |p| path =~ /(\/|\.)#{p}[^\.]/ } codename = Pkg::Platforms.codenames.find { |c| path =~ /\/#{c}/ } if codename platform, version = Pkg::Platforms.codename_to_platform_version(codename) end version = '2012' if platform == 'windows' version ||= Pkg::Platforms.versions_for_platform(platform).find { |v| path =~ /#{platform}(\/|-)?#{v}/ } arch = arch_from_artifact_path(platform, version, path) return "#{platform}-#{version}-#{arch}" rescue fmt = Pkg::Platforms.all_supported_package_formats.find { |ext| path =~ /#{ext}$/ } # We need to make sure this is actually a file, and not simply a path file_ext = File.extname(path) # Fail if we do not have a file extension or if that file extension is one # that is platform specific raise "Cannot determine tag from #{path}" if fmt || file_ext.empty? # Return nil otherwise, assuming that is a file type that is not tied to a # specific platform return nil end |