Method: Pkg::Config.platform_data

Defined in:
lib/packaging/config.rb

.platform_dataObject

For each platform we ship for, find paths to its artifact and repo_config (if applicable). This is to be consumed by beaker and later replaced with our metadata service.



76
77
78
79
80
81
82
83
84
85
86
87
88
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/packaging/config.rb', line 76

def platform_data
  # Return nil if something is not right..
  return nil unless self.project && self.ref &&
                    Pkg::Util::Net.check_host_ssh([self.builds_server]).empty?

  dir = "/opt/jenkins-builds/#{self.project}/#{self.ref}"
  cmd = "if [ -s \"#{dir}/artifacts\" ]; then cd #{dir};" \
        "find ./artifacts -mindepth 2 -type f; fi"
  artifacts, = Pkg::Util::Net.remote_execute(
    self.builds_server,
               cmd,
               { capture_output: true }
  )

  artifacts = artifacts.split("\n")
  data = {}
  artifacts.each do |artifact|
    # We need to preserve the original tag to make sure we look for
    # fedora repo configs in the 1.10.x branch of puppet-agent in
    # the correct place. For 5.x and 6.x release streams the f prefix
    # has been removed and so tag will equal original_tag
    original_tag = Pkg::Paths.tag_from_artifact_path(artifact)
    fail "Error: unrecognized artifact \"#{artifact}\"" if original_tag.nil?

    # Remove the f-prefix from the fedora platform tag keys so that
    # beaker can rely on consistent keys once we rip out the f for good
    tag = original_tag.sub('fedora-f', 'fedora-')

    data[tag] ||= {}

    platform, version, arch = Pkg::Platforms.parse_platform_tag(tag)
    package_format = Pkg::Platforms.get_attribute(tag, :package_format)

    # Skip this if it's an unversioned MSI. We create these to help
    # beaker install the msi without having to know any version
    # information, but we should report the versioned artifact in
    # platform_data
    next if platform =~ /^windows.*$/ &&
            File.basename(artifact) == "#{self.project}-#{arch}.#{package_format}"

    # Sometimes we have source or debug packages. We don't want to save
    # these paths in favor of the artifact paths.
    if platform == 'solaris'
      next if version == '10' && File.extname(artifact) != '.gz'
      next if version == '11' && File.extname(artifact) != '.p5p'
    elsif File.extname(artifact) != ".#{package_format}"
      next
    end

    # Don't want to include debian debug packages
    next if /-dbgsym/.match(File.basename(artifact))

    if /#{self.project}-[a-z]+/.match(File.basename(artifact))
      add_additional_artifact(data, tag, artifact.sub('artifacts/', ''))
      next
    end

    case package_format
    when 'deb'
      repo_config = "../repo_configs/deb/pl-#{self.project}-#{self.ref}-" \
                    "#{Pkg::Platforms.get_attribute(tag, :codename)}.list"
    when 'rpm'
      # Using original_tag here to not break legacy fedora repo targets
      unless tag.include? 'aix'
        repo_config = "../repo_configs/rpm/pl-#{self.project}-" \
                      "#{self.ref}-#{original_tag}.repo"
      end
    when 'svr4', 'ips', 'dmg', 'msi'
      # No repo_configs for these platforms, so do nothing.
    else
      fail "Error: Unknown package format: '#{package_format}'. Maybe update PLATFORM_INFO?"
    end

    # handle the case where there are multiple artifacts but the artifacts are not
    # named based on project name (e.g. puppet-enterprise-vanagon).
    # In this case, the first one will get set as the artifact, everything else
    # will be in the additional artifacts
    if data[tag][:artifact].nil?
      data[tag][:artifact] = artifact.sub('artifacts/', '')
      data[tag][:repo_config] = repo_config
    else
      add_additional_artifact(data, tag, artifact.sub('artifacts/', ''))
    end
  end
  return data
end