Fix homebrew tap by removing head and shipping compiled binaries #136

Merged
techknowlogick merged 1 commits from markkrj/homebrew-gitea:fix-brew-tap into master 2021-06-29 18:00:18 +00:00
5 changed files with 143 additions and 100 deletions

27
bump_version.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
binaries="tea gitea"
for bin in ${binaries};do
file="${bin}.rb"
case "$bin" in
tea)
git_url="https://gitea.com/gitea/tea"
supported_os="linux-386 linux-amd64 linux-arm64 darwin-amd64";;
gitea)
git_url="https://github.com/go-gitea/gitea"
supported_os="linux-386 linux-amd64 linux-arm64 darwin-10.12-amd64 darwin-10.12-arm64";;
*)
>&2 echo "Error: unrecognized binary ($bin)"
exit 1;;
esac
latest=$(curl -sL -o /dev/null -w %{url_effective} "${git_url}/releases/latest")
version="${latest##*/v}"
file_url="https://dl.gitea.io/${bin}/${version}"
for os in ${supported_os}; do
sha256_file="${bin}-${version}-${os}.xz.sha256"
sha256=$(curl -sL "${file_url}/${sha256_file}" | awk '{print$1}')
sed -r "s/^(\s+when \"${os}\" then).*/\1 \"${sha256}\"/" -i "${file}"
done
sed -r "s/^(\s+version).*/\1 \"${version}\"/" -i "${file}"
done

32
gitea-head.rb Normal file
View File

@ -0,0 +1,32 @@
class GiteaHead < Formula
desc "Git with a cup of tea, painless self-hosted git service"
homepage "https://gitea.io"
version "main"
os = OS.mac? ? "darwin-10.12" : "linux"
arch = case Hardware::CPU.arch
when :i386 then "386"
when :x86_64 then "amd64"
when :arm64 then "arm64"
else
raise "gitea: Unsupported system architecture #{Hardware::CPU.arch}"
end
@@filename = "gitea-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/gitea/#{version}/#{@@filename}.xz"
@@sha256 = %x[ curl -sL #{@@url}.sha256 ].split.first
url @@url
sha256 @@sha256
conflicts_with "gitea", because: "both install gitea binaries"
bottle :unneeded
def install
filename = GiteaHead.class_variable_get("@@filename")
bin.install filename => "gitea"
end
test do
system "#{bin}/gitea", "--version"
end
end

View File

@ -1,58 +1,37 @@
class Gitea < Formula
homepage "https://github.com/go-gitea/gitea"
desc "Git with a cup of tea, painless self-hosted git service"
homepage "https://gitea.io"
version "1.14.3"
def self.bin_filename(version)
os = OS.mac? ? "darwin-10.12" : "linux"
os = OS.mac? ? "darwin-10.12" : "linux"
arch = case Hardware::CPU.arch
when :i386 then "386"
when :x86_64 then "amd64"
when :arm64 then "arm64"
else
raise "gitea: Unsupported system architecture #{Hardware::CPU.arch}"
end
arch = case Hardware::CPU.arch
when :i386 then "386"
when :x86_64 then "amd64"
when :arm64 then "arm64"
else
raise "Gitea: Unsupported system architecture #{Hardware::CPU.arch}"
end
@@filename = "gitea-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/gitea/#{version}/#{@@filename}.xz"
@@sha256 = case "#{os}-#{arch}"
when "linux-386" then "c34f9c6cc5150334b2d85b0db319e035c93abf380c545e7561f5472089d320ed"
when "linux-amd64" then "38d358d135e37aac6c783fe1f6ebe97fd29782b5c1f69d15418d746d41aa6ab9"
when "linux-arm64" then "0a4751b54f3a89db1f5cb488da0d6eb80b92c559400fe8369a4a8f1ea3460e3f"
when "darwin-10.12-amd64" then "40a3188ef4b498141786af2243403c92b9bed1d476c370faa42aa5b5fb95433d"
when "darwin-10.12-arm64" then "71fed124fde0da8443569398e57f96353302dbe08c1bfd68657a02c98235f624"
else
raise "gitea: Unsupported system #{os}-#{arch}"
end
"gitea-#{version}-#{os}-#{arch}"
end
def self.bin_url(version)
"https://dl.gitea.io/gitea/#{version}/#{bin_filename(version)}"
end
stable do
version "1.14.3"
url Gitea.bin_url(version)
sha256 `curl -sL #{url}.sha256`.split(" ").first
end
head do
version "main"
url Gitea.bin_url(version)
sha256 `curl -sL #{url}.sha256`.split(" ").first
end
head do
url "https://github.com/go-gitea/gitea.git", :branch => "main"
depends_on "go" => :build
end
url @@url
sha256 @@sha256
conflicts_with "gitea-head", because: "both install gitea binaries"
bottle :unneeded
def install
if build.head?
mkdir_p buildpath/File.join("src", "code.gitea.io")
ln_s buildpath, buildpath/File.join("src", "code.gitea.io", "gitea")
ENV.append_path "PATH", File.join(buildpath, "bin")
ENV["GOPATH"] = buildpath
ENV["GOHOME"] = buildpath
ENV["TAGS"] = "bindata sqlite sqlite_unlock_notify"
system "cd src/code.gitea.io/gitea && make build"
bin.install "#{buildpath}/gitea" => "gitea"
else
bin.install "#{buildpath}/#{Gitea.bin_filename(version)}" => "gitea"
end
filename = Gitea.class_variable_get("@@filename")
bin.install filename => "gitea"
end
test do

31
tea-head.rb Normal file
View File

@ -0,0 +1,31 @@
class TeaHead < Formula
desc "A command line tool to interact with Gitea servers"
homepage "https://gitea.com/gitea/tea"
version "0.7.0"
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
@@filename = "tea-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/tea/#{version}/#{@@filename}.xz"
@@sha256 = %x[ curl -sL #{@@url}.sha256 ].split.first
url @@url
sha256 @@sha256
conflicts_with "tea", because: "both install tea binaries"
bottle :unneeded
def install
filename = TeaHead.class_variable_get("@@filename")
bin.install filename => "tea"
end
test do
system "#{bin}/tea", "--version"
end
end

76
tea.rb
View File

@ -1,63 +1,37 @@
require "formula"
class Tea < Formula
desc "A command line tool to interact with Gitea servers"
homepage "https://gitea.com/gitea/tea"
head "https://gitea.com/gitea/tea.git"
version "0.7.0"
def self.bin_filename(version)
os = OS.mac? ? "darwin" : "linux"
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
arch = case Hardware::CPU.arch
when :x86_64 then "amd64"
when :arm64 then "arm64"
else
raise "tea: Unsupported system architecture #{Hardware::CPU.arch}"
end
@@filename = "tea-#{version}-#{os}-#{arch}"
@@url = "https://dl.gitea.io/tea/#{version}/#{@@filename}.xz"
@@sha256 = case "#{os}-#{arch}"
when "linux-amd64" then "c49ef093f649a9ea74fb16954a51626ebd1b494c9143b000dad5fc935cb62527"
when "linux-arm64" then "6497398cefed6536cb2f524a93b38edbf8e7635d01bed12e18334430a4fcb9c0"
when "darwin-amd64" then "245cf071858c25ee594bbfec0cc0bcc19ae9219de09d8221daa660cb82592e4b"
else
raise "tea: Unsupported system #{os}-#{arch}"
end
"tea-#{version}-#{os}-#{arch}"
end
url @@url
sha256 @@sha256
def self.bin_url(version)
"https://dl.gitea.io/tea/#{version}/#{bin_filename(version)}"
end
stable do
version "0.7.0"
url Tea.bin_url(version)
sha256 `curl -sL ${url}.sha256`.split(" ").first
end
head do
version "master"
url Tea.bin_url(version)
sha256 `curl -sL ${url}.sha256`.split(" ").first
end
head do
url "https://gitea.com/gitea/tea.git", :branch => "master"
depends_on "go" => :build
conflicts_with "tea-head", because: "both install tea binaries"
bottle :unneeded
def install
filename = Tea.class_variable_get("@@filename")
bin.install filename => "tea"
end
test do
system "#{bin}/tea", "--version"
end
def install
case
when build.head?
mkdir_p buildpath/File.join("src", "code.gitea.io")
ln_s buildpath, buildpath/File.join("src", "code.gitea.io", "tea")
ENV.append_path "PATH", File.join(buildpath, "bin")
ENV["GOPATH"] = buildpath
ENV["GOHOME"] = buildpath
system "cd src/code.gitea.io/tea && make build"
bin.install "#{buildpath}/tea" => "tea"
else
bin.install "#{buildpath}/#{Tea.bin_filename(version)}" => "tea"
end
end
end