tools/go.rb in machinery-tool-1.23.1 vs tools/go.rb in machinery-tool-1.24.0

- old
+ new

@@ -1,8 +1,8 @@ # encoding:utf-8 -# Copyright (c) 2013-2016 SUSE LLC +# Copyright (c) 2013-2019 SUSE LLC # # This program is free software; you can redistribute it and/or # modify it under the terms of version 3 of the GNU General Public License as # published by the Free Software Foundation. # @@ -19,33 +19,30 @@ # This class is used to build the helper binaries with Go class Go def archs - @archs ||= case - when version <= 1.4 + @archs ||= if Gem::Version.new(version) <= Gem::Version.new("1.4") ["i686", "x86_64"].include?(local_arch) ? [local_arch] : [] - when version == 1.6 && suse_package_includes_s390? - ["i686", "x86_64", "ppc64le", "ppc64", "s390x", "armv6l", "armv7l", "aarch64"] - when version <= 1.6 - ["i686", "x86_64", "ppc64le", "ppc64", "armv6l", "armv7l", "aarch64"] - when version >= 1.7 - ["i686", "x86_64", "ppc64le", "ppc64", "s390x", "armv6l", "armv7l", "aarch64"] + elsif Gem::Version.new(version) == Gem::Version.new("1.6") && suse_package_includes_s390? + ["i686", "x86_64", "ppc64le", "ppc64", "s390x", "armv7l", "aarch64"] + elsif Gem::Version.new(version) <= Gem::Version.new("1.6") + ["i686", "x86_64", "ppc64le", "ppc64", "armv7l", "aarch64"] + elsif Gem::Version.new(version) >= Gem::Version.new("1.7") + ["i686", "x86_64", "ppc64le", "ppc64", "s390x", "armv7l", "aarch64"] end end def build if archs.count == 1 - arch = archs.first - puts("Building machinery-helper for architecture #{arch}.") - system("go build -o machinery-helper-#{arch}") + single_arch = archs.first + puts("Building machinery-helper for architecture #{single_arch}.") + system("go build -o machinery-helper-#{single_arch}") else archs.each do |arch| puts("Building machinery-helper for architecture #{arch}.") - system( - "env GOOS=linux #{compile_options(arch)} go build -o machinery-helper-#{arch}" - ) + system("env GOOS=linux #{compile_options(arch)} go build -o machinery-helper-#{arch}") end end end def available? @@ -61,11 +58,11 @@ end private def version - @version ||= run_go_version[/go(\d+.\d)/, 1].to_f + @version ||= run_go_version[/go(\d+.\d+)/, 1] end def suse_package_includes_s390? File.exist?("/usr/share/go/src/cmd/asm/internal/arch/s390x.go") end @@ -79,14 +76,11 @@ when "i686" additional_options = " GO386=387" "386" when "aarch64" "arm64" - when "armv6l" - additional_options = " GOARM=6" - "arm" when "armv7l" - additional_options = " GOARM=7" + additional_options = " GOARM=6" "arm" else arch end