From f915816b854e00e07e35472bf70c89892c5115ec Mon Sep 17 00:00:00 2001 From: Norwin Date: Mon, 21 Jun 2021 20:02:57 +0800 Subject: [PATCH] tea: enable arm64 architecture (#130) We have builds for arm64 since https://gitea.com/gitea/tea/pulls/360. Reviewed-on: https://gitea.com/gitea/homebrew-gitea/pulls/130 Reviewed-by: Andrew Thornton Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Norwin Co-committed-by: Norwin --- tea.rb | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tea.rb b/tea.rb index 106c629..5d21089 100644 --- a/tea.rb +++ b/tea.rb @@ -4,16 +4,33 @@ class Tea < Formula homepage "https://gitea.com/gitea/tea" head "https://gitea.com/gitea/tea.git" + def self.bin_filename(version) + os = OS.mac? ? "darwin" : "linux" + + arch = case Hardware::CPU.arch + when :x86_64 then "amd64" + when :arm64 then "arm64" + else + raise "tea: Unsupported system architecture #{Hardware::CPU.arch}" + end + + "tea-#{version}-#{os}-#{arch}" + end + + def self.bin_url(version) + "https://dl.gitea.io/tea/#{version}/#{bin_filename(version)}" + end + stable do version "0.7.0" - url "https://dl.gitea.io/tea/#{version}/tea-#{version}-darwin-amd64" - sha256 `curl -sL https://dl.gitea.io/tea/#{version}/tea-#{version}-darwin-amd64.sha256`.split(" ").first + url Tea.bin_url(version) + sha256 `curl -sL ${url}.sha256`.split(" ").first end head do version "master" - url "https://dl.gitea.io/tea/master/tea-master-darwin-amd64" - sha256 `curl -sL https://dl.gitea.io/tea/master/tea-master-darwin-amd64.sha256`.split(" ").first + url Tea.bin_url(version) + sha256 `curl -sL ${url}.sha256`.split(" ").first end head do @@ -40,7 +57,7 @@ class Tea < Formula bin.install "#{buildpath}/tea" => "tea" else - bin.install "#{buildpath}/tea-#{version}-darwin-amd64" => "tea" + bin.install "#{buildpath}/#{Tea.bin_filename(version)}" => "tea" end end end