support m1 devices #149
|
@ -1,3 +1,5 @@
|
|||
require './utils/macos_codesign.rb'
|
||||
|
||||
class Changelog < Formula
|
||||
desc "Generate changelog of gitea repository"
|
||||
homepage "https://gitea.com/gitea/changelog"
|
||||
|
@ -28,13 +30,13 @@ class Changelog < Formula
|
|||
url @@url,
|
||||
using: @@using
|
||||
|
||||
bottle :unneeded
|
||||
def install
|
||||
if stable.using.blank?
|
||||
filename = Changelog.class_variable_get("@@filename")
|
||||
else
|
||||
filename = downloader.cached_location
|
||||
end
|
||||
apply_ad_hoc_signature(filename)
|
||||
bin.install filename => "changelog"
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require './utils/macos_codesign.rb'
|
||||
|
||||
class GiteaHead < Formula
|
||||
desc "Git with a cup of tea, painless self-hosted git service"
|
||||
homepage "https://gitea.io"
|
||||
|
@ -29,13 +31,13 @@ class GiteaHead < Formula
|
|||
using: @@using
|
||||
|
||||
conflicts_with "gitea", because: "both install gitea binaries"
|
||||
bottle :unneeded
|
||||
def install
|
||||
if stable.using.blank?
|
||||
filename = GiteaHead.class_variable_get("@@filename")
|
||||
else
|
||||
filename = downloader.cached_location
|
||||
end
|
||||
apply_ad_hoc_signature(filename)
|
||||
bin.install filename => "gitea"
|
||||
end
|
||||
|
||||
|
|
3
gitea.rb
3
gitea.rb
|
@ -1,3 +1,5 @@
|
|||
require './utils/macos_codesign.rb'
|
||||
|
||||
class Gitea < Formula
|
||||
desc "Git with a cup of tea, painless self-hosted git service"
|
||||
homepage "https://gitea.io"
|
||||
|
@ -43,6 +45,7 @@ class Gitea < Formula
|
|||
else
|
||||
filename = downloader.cached_location
|
||||
end
|
||||
apply_ad_hoc_signature(filename)
|
||||
bin.install filename => "gitea"
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require './utils/macos_codesign.rb'
|
||||
|
||||
class TeaHead < Formula
|
||||
desc "A command line tool to interact with Gitea servers"
|
||||
homepage "https://gitea.com/gitea/tea"
|
||||
|
@ -29,13 +31,13 @@ class TeaHead < Formula
|
|||
using: @@using
|
||||
|
||||
conflicts_with "tea", because: "both install tea binaries"
|
||||
bottle :unneeded
|
||||
def install
|
||||
if stable.using.blank?
|
||||
filename = TeaHead.class_variable_get("@@filename")
|
||||
else
|
||||
filename = downloader.cached_location
|
||||
end
|
||||
end
|
||||
apply_ad_hoc_signature(filename)
|
||||
bin.install filename => "tea"
|
||||
end
|
||||
|
||||
|
|
4
tea.rb
4
tea.rb
|
@ -1,3 +1,5 @@
|
|||
require './utils/macos_codesign.rb'
|
||||
|
||||
class Tea < Formula
|
||||
desc "A command line tool to interact with Gitea servers"
|
||||
homepage "https://gitea.com/gitea/tea"
|
||||
|
@ -37,13 +39,13 @@ class Tea < Formula
|
|||
using: @@using
|
||||
|
||||
conflicts_with "tea-head", because: "both install tea binaries"
|
||||
bottle :unneeded
|
||||
def install
|
||||
if stable.using.blank?
|
||||
filename = Tea.class_variable_get("@@filename")
|
||||
else
|
||||
filename = downloader.cached_location
|
||||
end
|
||||
apply_ad_hoc_signature(filename)
|
||||
bin.install filename => "tea"
|
||||
end
|
||||
|
||||
|
|
35
utils/macos_codesign.rb
Normal file
35
utils/macos_codesign.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
## this file is licensed under BSD-2-Clause License (https://github.com/Homebrew/brew/blob/4665bb8e663c6d0ef452f4c124742732c96f8fd6/LICENSE.txt)
|
||||
## source: https://github.com/homebrew/brew/blob/4665bb8e663c6d0ef452f4c124742732c96f8fd6/Library/Homebrew/os/mac/keg.rb
|
||||
|
||||
def apply_ad_hoc_signature(file)
|
||||
return if MacOS.version < :big_sur
|
||||
return unless Hardware::CPU.arm?
|
||||
|
||||
odebug "Codesigning #{file}"
|
||||
# Use quiet_system to squash notifications about resigning binaries
|
||||
# which already have valid signatures.
|
||||
return if quiet_system("codesign", "--sign", "-", "--force",
|
||||
"--preserve-metadata=entitlements,requirements,flags,runtime",
|
||||
file)
|
||||
|
||||
# If the codesigning fails, it may be a bug in Apple's codesign utility
|
||||
# A known workaround is to copy the file to another inode, then move it back
|
||||
# erasing the previous file. Then sign again.
|
||||
#
|
||||
# TODO: remove this once the bug in Apple's codesign utility is fixed
|
||||
Dir::Tmpname.create("workaround") do |tmppath|
|
||||
FileUtils.cp file, tmppath
|
||||
FileUtils.mv tmppath, file, force: true
|
||||
end
|
||||
|
||||
# Try signing again
|
||||
odebug "Codesigning (2nd try) #{file}"
|
||||
return if quiet_system("codesign", "--sign", "-", "--force",
|
||||
"--preserve-metadata=entitlements,requirements,flags,runtime",
|
||||
file)
|
||||
|
||||
# If it fails again, error out
|
||||
onoe <<~EOS
|
||||
Failed applying an ad-hoc signature to #{file}
|
||||
EOS
|
||||
end
|
Loading…
Reference in New Issue
Block a user