From 4aabd6b5532daf73b9347ae36d789b83cd9bc191 Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Mon, 12 Jul 2021 23:30:03 +0000 Subject: [PATCH] Allow Raspberry Pi builds on Graviton See merge request gitlab-org/omnibus-gitlab!5442 --- config/software/grafana.rb | 3 ++- config/software/libffi.rb | 2 ++ config/software/libgcrypt.rb | 6 ++++-- config/software/openssl.rb | 3 +++ config/software/ruby.rb | 1 + gitlab-ci-config/dev-gitlab-org.yml | 4 ++-- lib/gitlab/ohai_helper.rb | 10 +++++++++- 7 files changed, 23 insertions(+), 6 deletions(-) diff --git a/config/software/grafana.rb b/config/software/grafana.rb index 8e9f64e824..e53a15346d 100644 --- a/config/software/grafana.rb +++ b/config/software/grafana.rb @@ -15,6 +15,7 @@ # require "#{Omnibus::Config.project_root}/lib/gitlab/version" +require "#{Omnibus::Config.project_root}/lib/gitlab/ohai_helper.rb" name 'grafana' version = Gitlab::Version.new('grafana', '7.5.5') @@ -26,7 +27,7 @@ license_file 'NOTICE.md' skip_transitive_dependency_licensing true -arch, sha = if ohai['platform'] == 'raspbian' && /armv/.match?(ohai['kernel']['machine']) +arch, sha = if OhaiHelper.raspberry_pi? %w[armv7 13a5fde5651d75b8ec560b52b6c7eccfda997015077f2a9ff3bbdb2709938def] elsif /aarch64/.match?(ohai['kernel']['machine']) %w[arm64 cd65cd84c38c7a43afeb0b1895e97a7b4f3203340be2da070a6dee75ead3fdfe] diff --git a/config/software/libffi.rb b/config/software/libffi.rb index 5c3dd0e27d..f718e51fbb 100644 --- a/config/software/libffi.rb +++ b/config/software/libffi.rb @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +require "#{Omnibus::Config.project_root}/lib/gitlab/ohai_helper.rb" name 'libffi' @@ -46,6 +47,7 @@ build do if version == '3.2.1' patch source: 'libffi-3.2.1-disable-multi-os-directory.patch', plevel: 1, env: env configure_command << '--disable-multi-os-directory' + configure_command << "--build=#{OhaiHelper.gcc_target}" if OhaiHelper.raspberry_pi? end end diff --git a/config/software/libgcrypt.rb b/config/software/libgcrypt.rb index e4ffc9bc3d..f7306c40e8 100644 --- a/config/software/libgcrypt.rb +++ b/config/software/libgcrypt.rb @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +require "#{Omnibus::Config.project_root}/lib/gitlab/ohai_helper.rb" name 'libgcrypt' default_version '1.9.3' @@ -31,8 +32,9 @@ relative_path "libgcrypt-#{version}" build do env = with_standard_compiler_flags(with_embedded_path) - command './configure ' \ - "--prefix=#{install_dir}/embedded --disable-doc", env: env + configure_options = ["--prefix=#{install_dir}/embedded", "--disable-doc"] + configure_options += %w(host build).map { |w| "--#{w}=#{OhaiHelper.gcc_target}" } if OhaiHelper.raspberry_pi? + configure(*configure_options, env: env) make "-j #{workers}", env: env make 'install', env: env diff --git a/config/software/openssl.rb b/config/software/openssl.rb index 26f67a01b0..2b8f03de91 100644 --- a/config/software/openssl.rb +++ b/config/software/openssl.rb @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +require "#{Omnibus::Config.project_root}/lib/gitlab/ohai_helper.rb" name 'openssl' @@ -84,6 +85,8 @@ build do # With gcc > 4.3 on s390x there is an error building # with inline asm enabled './Configure linux64-s390x -DOPENSSL_NO_INLINE_ASM' + elsif OhaiHelper.raspberry_pi? + './Configure linux-generic32' else './config' end diff --git a/config/software/ruby.rb b/config/software/ruby.rb index 5f60bee854..678d27a5d4 100644 --- a/config/software/ruby.rb +++ b/config/software/ruby.rb @@ -202,6 +202,7 @@ build do elsif windows? configure_command << ' debugflags=-g' else + configure_command << %w(host target build).map { |w| "--#{w}=#{OhaiHelper.gcc_target}" } if OhaiHelper.raspberry_pi? configure_command << "--with-opt-dir=#{install_dir}/embedded" end diff --git a/gitlab-ci-config/dev-gitlab-org.yml b/gitlab-ci-config/dev-gitlab-org.yml index bc132ff636..4d71534294 100644 --- a/gitlab-ci-config/dev-gitlab-org.yml +++ b/gitlab-ci-config/dev-gitlab-org.yml @@ -368,7 +368,7 @@ variables: NO_SOURCEMAPS: "true" tags: - - docker-rpi-builder + - docker-arm-builder <<: *dev-ce-branch-only-except-nightly artifacts: *package-artifacts retry: 1 @@ -410,7 +410,7 @@ variables: NO_SOURCEMAPS: "true" tags: - - docker-rpi-builder + - docker-arm-builder <<: *dev-ce-tag-only ### This stage is used for uploading packages diff --git a/lib/gitlab/ohai_helper.rb b/lib/gitlab/ohai_helper.rb index 422f775b8c..e6ed11a91d 100644 --- a/lib/gitlab/ohai_helper.rb +++ b/lib/gitlab/ohai_helper.rb @@ -128,7 +128,7 @@ class OhaiHelper def ohai @ohai ||= Ohai::System.new.tap do |oh| - oh.all_plugins(['platform']) + oh.all_plugins(['platform', 'languages']) end.data end @@ -159,5 +159,13 @@ class OhaiHelper # Any Arm (32-bit or 64-bit) (armhf? || arm64?) end + + def raspberry_pi? + os_platform == 'raspbian' + end + + def gcc_target + ohai['languages']['c']['gcc']['target'] + end end end -- GitLab