use xz archive only on supported platform (#144)

as title

Co-authored-by: Alexey Terentyev <axifnx@gmail.com>
Reviewed-on: https://gitea.com/gitea/homebrew-gitea/pulls/144
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Co-committed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
This commit is contained in:
Alexey 〒erentyev 2021-10-09 12:23:39 +08:00 committed by Lunny Xiao
parent 910936873b
commit d4a33300f2
6 changed files with 92 additions and 20 deletions

View File

@ -19,7 +19,11 @@ for bin in ${binaries};do
file_url="https://dl.gitea.io/${bin}/${version}"
for os in ${supported_os}; do
sha256_file="${bin}-${version}-${os}.xz.sha256"
sha256_file="${bin}-${version}-${os}"
if [ "$os" != "linux-386" -a "$os" != "linux-arm64" ]; then
sha256_file="${sha256_file}.xz"
fi
sha256_file="${sha256_file}.sha256"
sha256=$(curl -sL "${file_url}/${sha256_file}" | awk '{print$1}')
sed -r "s/^(\s+when \"${os}\" then).*/\1 \"${sha256}\"/" -i "${file}"
done

View File

@ -3,7 +3,7 @@ class Changelog < Formula
homepage "https://gitea.com/gitea/changelog"
version "master"
os = OS.mac? ? "darwin-10.6" : "linux"
os = OS.mac? ? "darwin-10.12" : "linux"
arch = case Hardware::CPU.arch
when :i386 then "386"
when :x86_64 then "amd64"
@ -13,15 +13,28 @@ class Changelog < Formula
end
@@filename = "changelog-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/changelog-tool/#{version}/#{@@filename}.xz"
@@url = "https://dl.gitea.io/changelog-tool/#{version}/#{@@filename}"
@@using = :nounzip
if os == "darwin-10.12" || arch == "amd64"
@@url += ".xz"
@@using = nil
depends_on "xz"
end
@@sha256 = %x[ curl -sL #{@@url}.sha256 ].split.first
url @@url
sha256 @@sha256
url @@url,
using: @@using
bottle :unneeded
def install
filename = Changelog.class_variable_get("@@filename")
if stable.using.blank?
filename = Changelog.class_variable_get("@@filename")
else
filename = downloader.cached_location
end
bin.install filename => "changelog"
end

View File

@ -13,16 +13,29 @@ class GiteaHead < Formula
end
@@filename = "gitea-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/gitea/#{version}/#{@@filename}.xz"
@@url = "https://dl.gitea.io/gitea/#{version}/#{@@filename}"
@@using = :nounzip
if os == "darwin-10.12" || arch == "amd64"
@@url += ".xz"
@@using = nil
depends_on "xz"
end
@@sha256 = %x[ curl -sL #{@@url}.sha256 ].split.first
url @@url
sha256 @@sha256
url @@url,
using: @@using
conflicts_with "gitea", because: "both install gitea binaries"
bottle :unneeded
def install
filename = GiteaHead.class_variable_get("@@filename")
if stable.using.blank?
filename = GiteaHead.class_variable_get("@@filename")
else
filename = downloader.cached_location
end
bin.install filename => "gitea"
end

View File

@ -13,24 +13,37 @@ class Gitea < Formula
end
@@filename = "gitea-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/gitea/#{version}/#{@@filename}.xz"
@@url = "https://dl.gitea.io/gitea/#{version}/#{@@filename}"
@@using = :nounzip
if os == "darwin-10.12" || arch == "amd64"
@@url += ".xz"
@@using = nil
depends_on "xz"
end
@@sha256 = case "#{os}-#{arch}"
when "linux-386" then "98d1fde4d9085ca9fec04ac491e17a4b371e8f7b8de631770944715a0e911616"
when "linux-386" then "acbdeee908fa7f2be7dd2dd46123f82101875f7c48b1de15e67215a906f720d8" # binary
when "linux-amd64" then "c9ba0e981ef46245bfe13a074e8fb9410981909dcd3abb471345a7b9ceabd574"
when "linux-arm64" then "e865b914eb84dde8bd64a86a60066ad5c61bba3a2a15e4b03ec6048efd0b45d6"
when "linux-arm64" then "0383a074b6a2b2d3db7940f6359df89e9bfe90b5d526e9dd80243b5cb8b9f857" # binary
when "darwin-10.12-amd64" then "ba67f009856da4ddba29e65b8adbf7be0c2d8de39d70572641342b9e7532c93e"
when "darwin-10.12-arm64" then "367e2e1b98828e26910cb1701845a6fba4183954337107a0967a08f551986e33"
else
raise "gitea: Unsupported system #{os}-#{arch}"
end
url @@url
sha256 @@sha256
url @@url,
using: @@using
conflicts_with "gitea-head", because: "both install gitea binaries"
bottle :unneeded
def install
filename = Gitea.class_variable_get("@@filename")
if stable.using.blank?
filename = Gitea.class_variable_get("@@filename")
else
filename = downloader.cached_location
end
bin.install filename => "gitea"
end

View File

@ -5,6 +5,7 @@ class TeaHead < Formula
os = OS.mac? ? "darwin" : "linux"
arch = case Hardware::CPU.arch
when :i386 then "386"
when :x86_64 then "amd64"
when :arm64 then "arm64"
else
@ -12,16 +13,29 @@ class TeaHead < Formula
end
@@filename = "tea-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/tea/#{version}/#{@@filename}.xz"
@@url = "https://dl.gitea.io/tea/#{version}/#{@@filename}"
@@using = :nounzip
if os == "darwin" || arch == "amd64"
@@url += ".xz"
@@using = nil
depends_on "xz"
end
@@sha256 = %x[ curl -sL #{@@url}.sha256 ].split.first
url @@url
sha256 @@sha256
url @@url,
using: @@using
conflicts_with "tea", because: "both install tea binaries"
bottle :unneeded
def install
filename = TeaHead.class_variable_get("@@filename")
if stable.using.blank?
filename = TeaHead.class_variable_get("@@filename")
else
filename = downloader.cached_location
end
bin.install filename => "tea"
end

23
tea.rb
View File

@ -5,6 +5,7 @@ class Tea < Formula
os = OS.mac? ? "darwin" : "linux"
arch = case Hardware::CPU.arch
when :i386 then "386"
when :x86_64 then "amd64"
when :arm64 then "arm64"
else
@ -12,23 +13,37 @@ class Tea < Formula
end
@@filename = "tea-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/tea/#{version}/#{@@filename}.xz"
@@url = "https://dl.gitea.io/tea/#{version}/#{@@filename}"
@@using = :nounzip
if os == "darwin" || arch == "amd64"
@@url += ".xz"
@@using = nil
depends_on "xz"
end
@@sha256 = case "#{os}-#{arch}"
when "linux-386" then "c006b38d6cbede7c3932bb762df1a06fa485e6c2af03d736bd3fa304a60376ba" # binary
when "linux-amd64" then "29976cc605f0da406efdc010d4a63ff225f990ebb49efe9f54ecf5c5796e771e"
when "linux-arm64" then "55d5fc581c98abadfef9c9bea1f8e7f9d82552632272147a0e8ca9dfe27b0f82"
when "linux-arm64" then "f85754008200f4ce3a1de50f77eb72d4960fffd069d19c0655376357a70a5226" # binary
when "darwin-amd64" then "8d9aaef2c9e851759a575892d5af8dd2130f0b9c5705189572a282f812126a48"
when "darwin-arm64" then "50c14a8bee6df16483eb370dc5491e85db3a0f1a21c8d3790e0b4be0531cf6bd"
else
raise "tea: Unsupported system #{os}-#{arch}"
end
url @@url
sha256 @@sha256
url @@url,
using: @@using
conflicts_with "tea-head", because: "both install tea binaries"
bottle :unneeded
def install
filename = Tea.class_variable_get("@@filename")
if stable.using.blank?
filename = Tea.class_variable_get("@@filename")
else
filename = downloader.cached_location
end
bin.install filename => "tea"
end