Module: Pkg::Platforms
- Included in:
- Paths
- Defined in:
- lib/packaging/platforms.rb
Constant Summary collapse
- DEBIAN_SOURCE_FORMATS =
['debian.tar.gz', 'orig.tar.gz', 'dsc', 'changes']
- PLATFORM_INFO =
Each element in this hash
{ 'aix' => { '6.1' => { architectures: ['power'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], repo: false, }, '7.1' => { architectures: ['power'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], repo: false, }, }, 'cisco-wrlinux' => { '5' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '7' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, }, 'cumulus' => { '2.2' => { codename: 'cumulus', architectures: ['amd64'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, }, 'debian' => { '7' => { codename: 'wheezy', architectures: ['amd64', 'i386'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, '8' => { codename: 'jessie', architectures: ['amd64', 'i386', 'powerpc'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, '9' => { codename: 'stretch', architectures: ['amd64', 'i386'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, '10' => { codename: 'buster', architectures: ['amd64', 'i386'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, }, 'el' => { '5' => { architectures: ['x86_64', 'i386'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v3', repo: true, }, '6' => { architectures: ['x86_64', 'i386', 's390x'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '7' => { architectures: ['x86_64', 's390x', 'ppc64le', 'aarch64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '8' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, } }, 'eos' => { '4' => { architectures: ['i386'], package_format: 'swix', repo: false, }, }, 'fedora' => { 'f25' => { architectures: ['x86_64', 'i386'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, 'f26' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, 'f27' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, 'f28' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '25' => { architectures: ['x86_64', 'i386'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '26' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '27' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '28' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '29' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, }, 'osx' => { '10.10' => { architectures: ['x86_64'], package_format: 'dmg', repo: false, }, '10.11' => { architectures: ['x86_64'], package_format: 'dmg', repo: false, }, '10.12' => { architectures: ['x86_64'], package_format: 'dmg', repo: false, }, '10.13' => { architectures: ['x86_64'], package_format: 'dmg', repo: false, }, '10.14' => { architectures: ['x86_64'], package_format: 'dmg', repo: false, }, }, 'redhatfips' => { '7' => { architectures: ['x86_64'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v3', repo: true, } }, 'sles' => { '11' => { architectures: ['x86_64', 'i386', 's390x'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v3', repo: true, }, '12' => { architectures: ['x86_64', 's390x', 'ppc64le'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, '15' => { architectures: ['x86_64', 'ppc64le'], source_architecture: 'SRPMS', package_format: 'rpm', source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, }, }, 'solaris' => { '10' => { architectures: ['i386', 'sparc'], package_format: 'svr4', repo: false, }, '11' => { architectures: ['i386', 'sparc'], package_format: 'ips', repo: false, }, }, 'ubuntu' => { '14.04' => { codename: 'trusty', architectures: ['amd64', 'i386'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, '16.04' => { codename: 'xenial', architectures: ['amd64', 'i386', 'ppc64el'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, '18.04' => { codename: 'bionic', architectures: ['amd64', 'ppc64el'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, '18.10' => { codename: 'cosmic', architectures: ['amd64', 'ppc64el'], source_architecture: 'source', package_format: 'deb', source_package_formats: DEBIAN_SOURCE_FORMATS, repo: true, }, }, 'windows' => { '2012' => { architectures: ['x86', 'x64'], package_format: 'msi', repo: false, } }, }.freeze
Class Method Summary collapse
-
.all_supported_package_formats ⇒ Array
An Array of Strings, containing all the package formats and source package formats defined in Pkg::Platforms.
-
.arches_for_codename(codename, include_source = false) ⇒ Object
Given a debian codename, return the arches that we build for that codename.
-
.arches_for_platform_version(platform, version, include_source = false) ⇒ Object
Given a platform and version, return the arches that we build for that platform.
-
.by_deb ⇒ Array
Helper meta-method to return all platforms that use .deb packages.
-
.by_package_format(format) ⇒ Array
An Array of Strings, containing all platforms that use <format> for their packages.
-
.by_rpm ⇒ Array
Helper meta-method to return all platforms that use .rpm packages.
-
.codename_for_platform_version(platform, version) ⇒ Object
Given a debian platform and version, return the codename that corresponds to the set.
-
.codename_to_platform_version(codename) ⇒ Object
Given a debian codename, return the platform and version it corresponds to.
-
.codename_to_tags(codename) ⇒ Object
Given a codename, return an array of associated tags.
-
.codenames(platform = 'deb') ⇒ Array
An Array of Strings, containing all of the codenames defined for a given Platform.
-
.formats ⇒ Array
An Array of Strings, containing all of the package formats defined in Pkg::Platforms.
-
.generic_platform_tag(platform) ⇒ Object
Return a supported platform tag for the given platform, not caring about version or architecture.
-
.get_attribute(platform_tag, attribute_name) ⇒ String, Array
The contents of the requested attribute.
- .get_attribute_for_platform_version(platform, version, attribute_name) ⇒ Object
- .package_format_for_tag(platform_tag) ⇒ Object
-
.parse_platform_tag(platform_tag) ⇒ Array
An array of three elements: the platform name, the platform version, and the architecture.
-
.platform_lookup(platform_tag) ⇒ Hash
The hash of data associated with the given platform version.
-
.platform_tags ⇒ Object
Returns an array of all currently valid platform tags.
-
.platform_tags_for_package_format(format) ⇒ Object
Return an array of platform tags associated with a given package format.
- .signature_format_for_platform_version(platform, version) ⇒ Object
- .signature_format_for_tag(platform_tag) ⇒ Object
- .source_architecture_for_platform_tag(platform_tag) ⇒ Object
- .source_package_formats_for_platform_tag(platform_tag) ⇒ Object
-
.supported_platforms ⇒ Array
An array of Strings, containing all of the supported platforms as defined in PLATFORM_INFO.
-
.versions_for_platform(platform) ⇒ Array
An Array of Strings, containing all the supported versions for the given platform.
Class Method Details
.all_supported_package_formats ⇒ Array
Returns An Array of Strings, containing all the package formats and source package formats defined in Pkg::Platforms.
443 444 445 446 447 448 449 450 451 452 |
# File 'lib/packaging/platforms.rb', line 443 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 |
.arches_for_codename(codename, include_source = false) ⇒ Object
Given a debian codename, return the arches that we build for that codename
482 483 484 485 |
# File 'lib/packaging/platforms.rb', line 482 def arches_for_codename(codename, include_source = false) platform, version = codename_to_platform_version(codename) arches_for_platform_version(platform, version, include_source) end |
.arches_for_platform_version(platform, version, include_source = false) ⇒ Object
Given a platform and version, return the arches that we build for that platform
499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/packaging/platforms.rb', line 499 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 |
.by_deb ⇒ Array
Helper meta-method to return all platforms that use .deb packages
575 576 577 |
# File 'lib/packaging/platforms.rb', line 575 def by_deb by_package_format('deb') end |
.by_package_format(format) ⇒ Array
Returns An Array of Strings, containing all platforms that use <format> for their packages.
423 424 425 426 427 428 |
# File 'lib/packaging/platforms.rb', line 423 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 |
.by_rpm ⇒ Array
Helper meta-method to return all platforms that use .rpm packages
584 585 586 |
# File 'lib/packaging/platforms.rb', line 584 def by_rpm by_package_format('rpm') end |
.codename_for_platform_version(platform, version) ⇒ Object
Given a debian platform and version, return the codename that corresponds to the set
477 478 479 |
# File 'lib/packaging/platforms.rb', line 477 def codename_for_platform_version(platform, version) get_attribute_for_platform_version(platform, version, :codename) end |
.codename_to_platform_version(codename) ⇒ Object
Given a debian codename, return the platform and version it corresponds to
466 467 468 469 470 471 472 473 |
# File 'lib/packaging/platforms.rb', line 466 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 |
.codename_to_tags(codename) ⇒ Object
Given a codename, return an array of associated tags
488 489 490 491 492 493 494 495 |
# File 'lib/packaging/platforms.rb', line 488 def (codename) = [] platform, version = codename_to_platform_version(codename) arches_for_codename(codename).each do |arch| << "#{platform}-#{version}-#{arch}" end end |
.codenames(platform = 'deb') ⇒ Array
Returns An Array of Strings, containing all of the codenames defined for a given Platform.
458 459 460 461 462 463 |
# File 'lib/packaging/platforms.rb', line 458 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 |
.formats ⇒ Array
Returns An Array of Strings, containing all of the package formats defined in Pkg::Platforms.
432 433 434 435 436 437 438 439 |
# File 'lib/packaging/platforms.rb', line 432 def formats fmts = PLATFORM_INFO.flat_map do |_, p| p.collect do |_, r| r[:package_format] end end fmts.to_set.sort end |
.generic_platform_tag(platform) ⇒ Object
Return a supported platform tag for the given platform, not caring about version or architecture
564 565 566 567 568 |
# File 'lib/packaging/platforms.rb', line 564 def generic_platform_tag(platform) version = versions_for_platform(platform).first arch = arches_for_platform_version(platform, version).first return "#{platform}-#{version}-#{arch}" end |
.get_attribute(platform_tag, attribute_name) ⇒ String, Array
Returns the contents of the requested attribute.
407 408 409 410 411 |
# File 'lib/packaging/platforms.rb', line 407 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 |
.get_attribute_for_platform_version(platform, version, attribute_name) ⇒ Object
413 414 415 416 417 |
# File 'lib/packaging/platforms.rb', line 413 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 |
.package_format_for_tag(platform_tag) ⇒ Object
527 528 529 |
# File 'lib/packaging/platforms.rb', line 527 def package_format_for_tag(platform_tag) get_attribute(platform_tag, :package_format) end |
.parse_platform_tag(platform_tag) ⇒ Array
Returns 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.
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/packaging/platforms.rb', line 358 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 |
.platform_lookup(platform_tag) ⇒ Hash
Returns The hash of data associated with the given platform version.
397 398 399 400 |
# File 'lib/packaging/platforms.rb', line 397 def platform_lookup(platform_tag) platform, version, _ = parse_platform_tag(platform_tag) PLATFORM_INFO[platform][version] end |
.platform_tags ⇒ Object
Returns an array of all currently valid platform tags
515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/packaging/platforms.rb', line 515 def = [] PLATFORM_INFO.each do |platform, platform_versions| platform_versions.each do |version, info| info[:architectures].each do |arch| << "#{platform}-#{version}-#{arch}" end end end end |
.platform_tags_for_package_format(format) ⇒ Object
Return an array of platform tags associated with a given package format
548 549 550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/packaging/platforms.rb', line 548 def (format) = [] PLATFORM_INFO.each do |platform, platform_versions| platform_versions.each do |version, info| info[:architectures].each do |architecture| if info[:package_format] == format << "#{platform}-#{version}-#{architecture}" end end end end end |
.signature_format_for_platform_version(platform, version) ⇒ Object
535 536 537 |
# File 'lib/packaging/platforms.rb', line 535 def signature_format_for_platform_version(platform, version) get_attribute_for_platform_version(platform, version, :signature_format) end |
.signature_format_for_tag(platform_tag) ⇒ Object
531 532 533 |
# File 'lib/packaging/platforms.rb', line 531 def signature_format_for_tag(platform_tag) get_attribute(platform_tag, :signature_format) end |
.source_architecture_for_platform_tag(platform_tag) ⇒ Object
539 540 541 |
# File 'lib/packaging/platforms.rb', line 539 def source_architecture_for_platform_tag(platform_tag) get_attribute(platform_tag, :source_architecture) end |
.source_package_formats_for_platform_tag(platform_tag) ⇒ Object
543 544 545 |
# File 'lib/packaging/platforms.rb', line 543 def source_package_formats_for_platform_tag(platform_tag) get_attribute(platform_tag, :source_package_formats) end |
.supported_platforms ⇒ Array
Returns An array of Strings, containing all of the supported platforms as defined in PLATFORM_INFO.
339 340 341 |
# File 'lib/packaging/platforms.rb', line 339 def supported_platforms PLATFORM_INFO.keys end |
.versions_for_platform(platform) ⇒ Array
Returns An Array of Strings, containing all the supported versions for the given platform.
345 346 347 348 349 |
# File 'lib/packaging/platforms.rb', line 345 def versions_for_platform(platform) PLATFORM_INFO[platform].keys rescue raise "No information found for '#{platform}'" end |