module Pkg::Platforms
Constants
- DEBIAN_SOURCE_FORMATS
- PLATFORM_INFO
Each element in this hash
Public Instance Methods
@return [Array] An Array of Strings, containing all the package formats
and source package formats defined in Pkg::Platforms
# File lib/packaging/platforms.rb, line 368 def all_supported_package_formats fmts = formats source_fmts = PLATFORM_INFO.flat_map do |_, p| p.collect do |_, r| r[:source_package_formats] end end (fmts + source_fmts).flatten.compact.uniq.to_set.sort end
Given a debian codename, return the arches that we build for that codename
# File lib/packaging/platforms.rb, line 407 def arches_for_codename(codename, include_source = false) platform, version = codename_to_platform_version(codename) arches_for_platform_version(platform, version, include_source) end
Given a platform and version, return the arches that we build for that platform
# File lib/packaging/platforms.rb, line 424 def arches_for_platform_version(platform, version, include_source = false) platform_architectures = get_attribute_for_platform_version(platform, version, :architectures) # get_attribute_for_platform_version will raise an exception if the attribute # isn't found. We don't want this to be a fatal error, we just want to append # the source architecture if it's found source_architecture = [] if include_source begin source_architecture = Array(get_attribute_for_platform_version(platform, version, :source_architecture)) rescue end end return (platform_architectures + source_architecture).flatten end
@method by_deb
@return [Array] An Array of Strings, containing all platforms
that use .deb packages
Helper meta-method to return all platforms that use .deb packages @scope class
# File lib/packaging/platforms.rb, line 500 def by_deb by_package_format('deb') end
@method by_rpm
@return [Array] An Array of Strings, containing all platforms
that use .rpm packages
Helper meta-method to return all platforms that use .rpm packages @scope class
# File lib/packaging/platforms.rb, line 509 def by_rpm by_package_format('rpm') end
Given a debian platform and version, return the codename that corresponds to the set
# File lib/packaging/platforms.rb, line 402 def codename_for_platform_version(platform, version) get_attribute_for_platform_version(platform, version, :codename) end
Given a debian codename, return the platform and version it corresponds to
# File lib/packaging/platforms.rb, line 391 def codename_to_platform_version(codename) PLATFORM_INFO.each do |platform, platform_versions| platform_versions.each do |version, info| return [platform, version] if info[:codename] && codename == info[:codename] end end raise "Unable to find a platform and version for '#{codename}'" end
@param platform [String] Optional, the platform to list all codenames for.
Defaults to 'deb'
@return [Array] An Array of Strings, containing all of the codenames
defined for a given Platform
# File lib/packaging/platforms.rb, line 383 def codenames(platform = 'deb') releases = by_package_format(platform).flat_map do |p| PLATFORM_INFO[p].values.collect { |r| r[:codename] } end releases.sort end
@return [Array] An Array of Strings, containing all of the package
formats defined in Pkg::Platforms
# File lib/packaging/platforms.rb, line 357 def formats fmts = PLATFORM_INFO.flat_map do |_, p| p.collect do |_, r| r[:package_format] end end fmts.to_set.sort end
Return a supported platform tag for the given platform, not caring about version or architecture
# File lib/packaging/platforms.rb, line 489 def generic_platform_tag(platform) version = versions_for_platform(platform).first arch = arches_for_platform_version(platform, version).first return "#{platform}-#{version}-#{arch}" end
@param platform_tag [String] May be either the two or three unit string
that corresponds to a platform in the form of platform-version or platform-version-arch
@param attribute_name [String, Symbol] The name of the requested attribute @return [String, Array] the contents of the requested attribute
# File lib/packaging/platforms.rb, line 332 def get_attribute(platform_tag, attribute_name) info = platform_lookup(platform_tag) raise "#{platform_tag} doesn't have information about #{attribute_name} available" unless info.key?(attribute_name) info[attribute_name] end
# File lib/packaging/platforms.rb, line 338 def get_attribute_for_platform_version(platform, version, attribute_name) info = PLATFORM_INFO[platform][version] raise "#{platform_tag} doesn't have information about #{attribute_name} available" unless info.key?(attribute_name) info[attribute_name] end
# File lib/packaging/platforms.rb, line 452 def package_format_for_tag(platform_tag) get_attribute(platform_tag, :package_format) end
@param platform_tag [String] May be either the two or three unit string
that corresponds to a platform in the form of platform-version or platform-version-arch.
@return [Array] An array of three elements: the platform name, the platform
version, and the architecture. If the architecture was not included in the original platform tag, then nil is returned in place of the architecture
# File lib/packaging/platforms.rb, line 283 def parse_platform_tag(platform_tag) platform_elements = platform_tag.split('-') # Look for platform. This is probably the only place where we have to look # for a combination of elements rather than a single element platform = (platform_elements & supported_platforms).first codename = (platform_elements & codenames).first # This is probably a bad assumption, but I'm assuming if we find a codename, # that's more reliable as it's less likely to give us a false match if codename platform, version = codename_to_platform_version(codename) end # There's a possibility that the platform name has a dash in it, in which # case, our assumption that it's an element of the above array is false, # since it would be a combination of elements in that array platform ||= supported_platforms.find { |p| platform_tag =~ /#{p}-/ } version ||= (platform_elements & versions_for_platform(platform)).first # For platform names with a dash in them, because everything is special supported_arches = arches_for_platform_version(platform, version, true) architecture = platform_tag.sub(/^(#{platform}-#{version}|#{codename})-?/, '') fail unless supported_arches.include?(architecture) || architecture.empty? # AIX uses 'ppc' as its architecture in paths and file names architecture = 'ppc' if platform == 'aix' return [platform, version, architecture] rescue raise "Could not verify that '#{platform_tag}' is a valid tag" end
@param platform_tag [String] May be either the two or three unit string
that corresponds to a platform in the form of platform-version or platform-version-arch
@return [Hash] The hash of data associated with the given platform version
# File lib/packaging/platforms.rb, line 322 def platform_lookup(platform_tag) platform, version, _ = parse_platform_tag(platform_tag) PLATFORM_INFO[platform][version] end
# File lib/packaging/platforms.rb, line 460 def signature_format_for_platform_version(platform, version) get_attribute_for_platform_version(platform, version, :signature_format) end
# File lib/packaging/platforms.rb, line 456 def signature_format_for_tag(platform_tag) get_attribute(platform_tag, :signature_format) end
# File lib/packaging/platforms.rb, line 464 def source_architecture_for_platform_tag(platform_tag) get_attribute(platform_tag, :source_architecture) end
# File lib/packaging/platforms.rb, line 468 def source_package_formats_for_platform_tag(platform_tag) get_attribute(platform_tag, :source_package_formats) end
@return [Array] An array of Strings, containing all of the supported
platforms as defined in PLATFORM_INFO
# File lib/packaging/platforms.rb, line 264 def supported_platforms PLATFORM_INFO.keys end
@return [Array] An Array of Strings, containing all the supported
versions for the given platform
# File lib/packaging/platforms.rb, line 270 def versions_for_platform(platform) PLATFORM_INFO[platform].keys rescue raise "No information found for '#{platform}'" end
Private Instance Methods
@private List platforms that use a given package format @param format [String] The name of the packaging format to filter on @return [Array] An Array of Strings, containing all platforms that
use <format> for their packages
# File lib/packaging/platforms.rb, line 348 def by_package_format(format) PLATFORM_INFO.keys.select do |key| formats = PLATFORM_INFO[key].values.collect { |v| v[:package_format] } formats.include? format end end