lib/mixlib/install/backend/bintray.rb in mixlib-install-1.1.0 vs lib/mixlib/install/backend/bintray.rb in mixlib-install-1.2.0

- old
+ new

@@ -79,11 +79,11 @@ # Get latest version for product/channel # # @return [String] latest version value # def latest_version - result = bintray_get("#{options.channel}/#{options.product_name}/versions/_latest") + result = bintray_get("#{options.channel}/#{bintray_product_name}/versions/_latest") result["name"] end # # Get artifacts for a given version, channel and product_name @@ -91,15 +91,15 @@ # @return [Array<ArtifactInfo>] Array of info about found artifacts # def available_artifacts version = options.latest_version? ? latest_version : options.product_version begin - results = bintray_get("#{options.channel}/#{options.product_name}/versions/#{version}/files") + results = bintray_get("#{options.channel}/#{bintray_product_name}/versions/#{version}/files") rescue Net::HTTPServerException => e if e.message =~ /404 "Not Found"/ raise VersionNotFound, - "Specified version (#{version}) not found for #{options.product_name} in #{options.channel} channel." + "Specified version (#{version}) not found for #{bintray_product_name} in #{options.channel} channel." else raise end end @@ -117,44 +117,10 @@ results.map! { |a| create_artifact(a) } windows_artifact_fixup!(results) end - # On windows, if we do not have a native 64-bit package available - # in the discovered artifacts, we will make 32-bit artifacts available - # for 64-bit architecture. - def windows_artifact_fixup!(artifacts) - new_artifacts = [ ] - native_artifacts = [ ] - - artifacts.each do |r| - next if r.platform != "windows" - - # Store all native 64-bit artifacts and clone 32-bit artifacts to - # be used as 64-bit. - case r.architecture - when "i386" - new_artifacts << r.clone_with(architecture: "x86_64") - when "x86_64" - native_artifacts << r.clone - else - puts "Unknown architecture '#{r.architecture}' for windows." - end - end - - # Now discard the cloned artifacts if we find an equivalent native - # artifact - native_artifacts.each do |r| - new_artifacts.delete_if do |x| - x.platform_version == r.platform_version - end - end - - # add the remaining cloned artifacts to the original set - artifacts += new_artifacts - end - # # Creates an instance of ArtifactInfo # # @param artifact_map # { @@ -237,33 +203,10 @@ architecture: architecture, } end # - # Normalizes platform and platform_version information that we receive - # from bintray. There are a few entries that we historically published - # that we need to normalize. They are: - # * solaris -> solaris2 & 10 -> 5.10 for solaris. - # - # @param [String] platform - # @param [String] platform_version - # - # @return Array<String> [platform, platform_version] - def normalize_platform(platform, platform_version) - if platform == "solaris" - platform = "solaris2" - - # Here platform_version is set to either 10 or 11 and we would like - # to normalize that to 5.10 and 5.11. - - platform_version = "5.#{platform_version}" - end - - [platform, platform_version] - end - - # # Determines the architecture for which a file is published from from # filename. # # We determine the architecture based on the filename of the artifact # since architecture the artifact is published for is not available @@ -288,10 +231,12 @@ "i386" elsif %w{ powerpc }.fuzzy_include?(filename) "powerpc" elsif %w{ sparc sun4u sun4v }.fuzzy_include?(filename) "sparc" + elsif %w{ s390x }.fuzzy_include?(filename) + "s390x" # Note that ppc64le should come before ppc64 otherwise our search # will think ppc64le matches ppc64. Ubuntu also calls it ppc64el. elsif %w{ ppc64le ppc64el }.fuzzy_include?(filename) "ppc64le" elsif %w{ ppc64 }.fuzzy_include?(filename) @@ -328,9 +273,24 @@ elsif filename.end_with?(".solaris2.5.9.solaris") "sparc" else raise UnknownArchitecture, "architecture can not be determined for '#{filename}'" + end + end + + private + + # + # This is a temporary workaround until we move to the unified backend + # for all channels. Some products are published to Bintray using their + # Omnibus project name as opposed to their mixlib-install product key. + # + def bintray_product_name + if %w{automate}.include?(options.product_name) + PRODUCT_MATRIX.lookup(options.product_name).omnibus_project + else + options.product_name end end end end end