From 6083c08140774ff834083bcee7a2587a5532496e Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 20 Nov 2023 02:22:33 +0000 Subject: [PATCH] feat(arm64): support arm64 builds --- templates/_helpers.tpl | 27 ++++++++++++ templates/emacs-app-good.rb.tpl | 9 ++-- templates/emacs-app-monthly.rb.tpl | 62 +++++++++++++++++++++++++++ templates/emacs-app-nightly-28.rb.tpl | 9 ++-- templates/emacs-app-nightly-29.rb.tpl | 9 ++-- templates/emacs-app-nightly.rb.tpl | 11 ++--- templates/emacs-app-pretest.rb.tpl | 9 ++-- templates/emacs-app.rb.tpl | 9 ++-- 8 files changed, 113 insertions(+), 32 deletions(-) create mode 100644 templates/_helpers.tpl create mode 100644 templates/emacs-app-monthly.rb.tpl diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl new file mode 100644 index 00000000..065d4dfe --- /dev/null +++ b/templates/_helpers.tpl @@ -0,0 +1,27 @@ +{{ define "sources" -}} +{{ $arm64SHA := (.SHA256 "macOS-13" "arm64") -}} +{{ $arm64URL := (.DownloadURL "macOS-13" "arm64") -}} +{{ $x86_64SHA := (.SHA256 "macOS-11" "x86_64") -}} +{{ $x86_64URL := (.DownloadURL "macOS-11" "x86_64") -}} +{{ if (and (ne $arm64URL "") (ne $x86_64URL "")) }} + on_arm do + sha256 '{{ $arm64SHA }}' + url '{{ $arm64URL }}' + depends_on macos: '>= :ventura' + end + + on_intel do + sha256 '{{ $x86_64SHA }}' + url '{{ $x86_64URL }}' + depends_on macos: '>= :big_sur' # macOS 11 + end +{{- else if ne $arm64URL "" }} + sha256 '{{ $arm64SHA }}' + url '{{ $arm64URL }}' + depends_on macos: '>= :ventura', arch: :arm64 +{{- else }} + sha256 '{{ $x86_64SHA }}' + url '{{ $x86_64URL }}' + depends_on macos: '>= :big_sur' +{{- end }} +{{- end }} diff --git a/templates/emacs-app-good.rb.tpl b/templates/emacs-app-good.rb.tpl index c664dd9d..af0f106a 100644 --- a/templates/emacs-app-good.rb.tpl +++ b/templates/emacs-app-good.rb.tpl @@ -1,15 +1,13 @@ # frozen_string_literal: true cask 'emacs-app-good' do - version '{{ .Version }}' - - sha256 '{{ .SHA256 "macOS-11" "x86_64" }}' - url '{{ .DownloadURL "macOS-11" "x86_64" }}' - name 'Emacs' desc 'GNU Emacs text editor (known good nightly build)' homepage 'https://github.com/jimeh/emacs-builds' + version '{{ .Version }}' +{{ template "sources" . }} + livecheck do url 'https://github.com/jimeh/emacs-builds/issues/7' strategy :page_match do |page| @@ -21,6 +19,7 @@ cask 'emacs-app-good' do conflicts_with( cask: %w[ emacs-app + emacs-app-monthly emacs-app-nightly emacs-app-nightly-28 emacs-app-nightly-29 diff --git a/templates/emacs-app-monthly.rb.tpl b/templates/emacs-app-monthly.rb.tpl new file mode 100644 index 00000000..6dddfe8f --- /dev/null +++ b/templates/emacs-app-monthly.rb.tpl @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +cask 'emacs-app-monthly' do + name 'Emacs' + desc 'GNU Emacs text editor (monthly build)' + homepage 'https://github.com/jimeh/emacs-builds' + + version '{{ .Version }}' +{{ template "sources" . }} + + livecheck do + url 'https://github.com/jimeh/emacs-builds.git' + strategy :git do |tags| + tags.map do |tag| + m = /^Emacs\.(\d{4}-\d{2}-01\.\w+\.master)$/.match(tag) + next unless m + + m[1] + end.compact + end + end + + conflicts_with( + cask: %w[ + emacs-app + emacs-app-good + emacs-app-nightly-28 + emacs-app-nightly-29 + emacs-app-pretest + emacs + emacs-nightly + emacs-pretest + emacs-mac + emacs-mac-spacemacs-icon + ], + formula: %w[ + emacs + emacs-mac + ] + ) + + app 'Emacs.app' + binary "#{appdir}/Emacs.app/Contents/MacOS/bin/ebrowse" + binary "#{appdir}/Emacs.app/Contents/MacOS/bin/emacs" + binary "#{appdir}/Emacs.app/Contents/MacOS/bin/emacsclient" + binary "#{appdir}/Emacs.app/Contents/MacOS/bin/etags" + binary "#{appdir}/Emacs.app/Contents/Resources/include/emacs-module.h", + target: "#{HOMEBREW_PREFIX}/include/emacs-module.h" + binary "#{appdir}/Emacs.app/Contents/Resources/site-lisp/subdirs.el", + target: "#{HOMEBREW_PREFIX}/share/emacs/site-lisp/subdirs.el" + + manpage "#{appdir}/Emacs.app/Contents/Resources/man/man1/ebrowse.1.gz" + manpage "#{appdir}/Emacs.app/Contents/Resources/man/man1/emacs.1.gz" + manpage "#{appdir}/Emacs.app/Contents/Resources/man/man1/emacsclient.1.gz" + manpage "#{appdir}/Emacs.app/Contents/Resources/man/man1/etags.1.gz" + + zap trash: [ + '~/Library/Caches/org.gnu.Emacs', + '~/Library/Preferences/org.gnu.Emacs.plist', + '~/Library/Saved Application State/org.gnu.Emacs.savedState' + ] +end diff --git a/templates/emacs-app-nightly-28.rb.tpl b/templates/emacs-app-nightly-28.rb.tpl index 1f21a5c1..7b05ee73 100644 --- a/templates/emacs-app-nightly-28.rb.tpl +++ b/templates/emacs-app-nightly-28.rb.tpl @@ -1,15 +1,13 @@ # frozen_string_literal: true cask 'emacs-app-nightly-28' do - version '{{ .Version }}' - - sha256 '{{ .SHA256 "macOS-11" "x86_64" }}' - url '{{ .DownloadURL "macOS-11" "x86_64" }}' - name 'Emacs' desc 'GNU Emacs text editor (nightly build of emacs-28 branch)' homepage 'https://github.com/jimeh/emacs-builds' + version '{{ .Version }}' +{{ template "sources" . }} + livecheck do url 'https://github.com/jimeh/emacs-builds.git' strategy :git do |tags| @@ -26,6 +24,7 @@ cask 'emacs-app-nightly-28' do cask: %w[ emacs-app emacs-app-good + emacs-app-monthly emacs-app-nightly emacs-app-nightly-29 emacs-app-pretest diff --git a/templates/emacs-app-nightly-29.rb.tpl b/templates/emacs-app-nightly-29.rb.tpl index f13cb133..0df214be 100644 --- a/templates/emacs-app-nightly-29.rb.tpl +++ b/templates/emacs-app-nightly-29.rb.tpl @@ -1,15 +1,13 @@ # frozen_string_literal: true cask 'emacs-app-nightly-29' do - version '{{ .Version }}' - - sha256 '{{ .SHA256 "macOS-11" "x86_64" }}' - url '{{ .DownloadURL "macOS-11" "x86_64" }}' - name 'Emacs' desc 'GNU Emacs text editor (nightly build of emacs-29 branch)' homepage 'https://github.com/jimeh/emacs-builds' + version '{{ .Version }}' +{{ template "sources" . }} + livecheck do url 'https://github.com/jimeh/emacs-builds.git' strategy :git do |tags| @@ -26,6 +24,7 @@ cask 'emacs-app-nightly-29' do cask: %w[ emacs-app emacs-app-good + emacs-app-monthly emacs-app-nightly emacs-app-nightly-28 emacs-app-pretest diff --git a/templates/emacs-app-nightly.rb.tpl b/templates/emacs-app-nightly.rb.tpl index 1bec9c09..18ed2c50 100644 --- a/templates/emacs-app-nightly.rb.tpl +++ b/templates/emacs-app-nightly.rb.tpl @@ -1,15 +1,13 @@ # frozen_string_literal: true cask 'emacs-app-nightly' do - version '{{ .Version }}' - - sha256 '{{ .SHA256 "macOS-11" "x86_64" }}' - url '{{ .DownloadURL "macOS-11" "x86_64" }}' - name 'Emacs' desc 'GNU Emacs text editor (nightly build)' homepage 'https://github.com/jimeh/emacs-builds' + version '{{ .Version }}' +{{ template sources . }} + livecheck do url 'https://github.com/jimeh/emacs-builds.git' strategy :git do |tags| @@ -26,6 +24,7 @@ cask 'emacs-app-nightly' do cask: %w[ emacs-app emacs-app-good + emacs-app-monthly emacs-app-nightly-28 emacs-app-nightly-29 emacs-app-pretest @@ -41,8 +40,6 @@ cask 'emacs-app-nightly' do ] ) - depends_on macos: '>= :big_sur' - app 'Emacs.app' binary "#{appdir}/Emacs.app/Contents/MacOS/bin/ebrowse" binary "#{appdir}/Emacs.app/Contents/MacOS/bin/emacs" diff --git a/templates/emacs-app-pretest.rb.tpl b/templates/emacs-app-pretest.rb.tpl index 100783db..7d5b2ae9 100644 --- a/templates/emacs-app-pretest.rb.tpl +++ b/templates/emacs-app-pretest.rb.tpl @@ -1,15 +1,13 @@ # frozen_string_literal: true cask 'emacs-app-pretest' do - version '{{ .Version }}' - - sha256 '{{ .SHA256 "macOS-11" "x86_64" }}' - url '{{ .DownloadURL "macOS-11" "x86_64" }}' - name 'Emacs' desc 'GNU Emacs text editor (latest pretest)' homepage 'https://github.com/jimeh/emacs-builds' + version '{{ .Version }}' +{{ template "sources" . }} + livecheck do url 'https://github.com/jimeh/emacs-builds.git' strategy :git do |tags| @@ -26,6 +24,7 @@ cask 'emacs-app-pretest' do cask: %w[ emacs-app emacs-app-good + emacs-app-monthly emacs-app-nightly emacs-app-nightly-28 emacs-app-nightly-29 diff --git a/templates/emacs-app.rb.tpl b/templates/emacs-app.rb.tpl index b7133bb0..98fa7a25 100644 --- a/templates/emacs-app.rb.tpl +++ b/templates/emacs-app.rb.tpl @@ -1,15 +1,13 @@ # frozen_string_literal: true cask 'emacs-app' do - version '{{ .Version }}' - - sha256 '{{ .SHA256 "macOS-10-15" "x86_64" }}' - url '{{ .DownloadURL "macOS-10-15" "x86_64" }}' - name 'Emacs' desc 'GNU Emacs text editor' homepage 'https://github.com/jimeh/emacs-builds' + version '{{ .Version }}' +{{ template "sources" . }} + livecheck do url 'https://github.com/jimeh/emacs-builds.git' strategy :git do |tags| @@ -25,6 +23,7 @@ cask 'emacs-app' do conflicts_with( cask: %w[ emacs-app-good + emacs-app-monthly emacs-app-nightly emacs-app-nightly-28 emacs-app-nightly-29