mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
228ae0939c
|
|||
|
ac943c430c
|
|||
|
bc3923c9ca
|
|||
|
e6b1e5a554
|
|||
|
94625fce38
|
|||
|
b03343f506
|
|||
|
b1896d4a4f
|
|||
|
9d32509c61
|
|||
|
1c2745cd36
|
|||
|
80a0d55b24
|
|||
|
fd0ec4d772
|
|||
|
c0c809a86a
|
|||
|
cb63806262
|
|||
|
6d7ab95ca2
|
|||
|
f4d6e3a56d
|
|||
|
3f1059940d
|
|||
|
5c722e36c5
|
|||
|
f52dd8dc6d
|
|||
|
4cdbaf1ec0
|
|||
|
f3a289b11c
|
|||
|
9019e73d60
|
|||
|
28930381a8
|
|||
|
df25e54ef7
|
|||
|
6d21d1bef4
|
|||
|
99aa76b398
|
72
CHANGELOG.md
72
CHANGELOG.md
@@ -2,6 +2,78 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [0.6.13](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.12...v0.6.13) (2021-08-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **native_comp:** add option to enable/disable relinking *.eln files ([ac943c4](https://github.com/jimeh/build-emacs-for-macos/commit/ac943c430c58e0761ac44e8d25d4d55a461d01a2))
|
||||||
|
|
||||||
|
### [0.6.12](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.11...v0.6.12) (2021-08-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **sign:** resolve signing issue caused by re-linking shared lib in *.eln files ([e6b1e5a](https://github.com/jimeh/build-emacs-for-macos/commit/e6b1e5a554fd0f776bd01c17cfb1ebbbdf7a7831))
|
||||||
|
|
||||||
|
### [0.6.11](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.10...v0.6.11) (2021-07-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **native-comp:** fix re-linking and signing issue with *.eln files ([b03343f](https://github.com/jimeh/build-emacs-for-macos/commit/b03343f506aa3ceabdfa03f8a2916b2db4873f3f))
|
||||||
|
|
||||||
|
### [0.6.10](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.9...v0.6.10) (2021-07-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **native-comp:** *.eln files were not being found during shared lib embedding ([9d32509](https://github.com/jimeh/build-emacs-for-macos/commit/9d32509c615076618957cc47c82f6e9d8f972fe7))
|
||||||
|
|
||||||
|
### [0.6.9](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.8...v0.6.9) (2021-07-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **release:** add bulk edit command to quickly change multiple GitHub releases ([cb63806](https://github.com/jimeh/build-emacs-for-macos/commit/cb638062625d9bc3eee12515067fb09e05a08414))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **plan:** correctly parse --test-release-type flag ([fd0ec4d](https://github.com/jimeh/build-emacs-for-macos/commit/fd0ec4d772dd3da93afc234fb3024220b2099c88))
|
||||||
|
|
||||||
|
### [0.6.8](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.7...v0.6.8) (2021-07-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **builds:** add support for stable builds ([f4d6e3a](https://github.com/jimeh/build-emacs-for-macos/commit/f4d6e3a56d2c15b0c86af18e8d16bebbeb92a8ab))
|
||||||
|
|
||||||
|
### [0.6.7](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.6...v0.6.7) (2021-07-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **bundle:** move bundled shared libraries to Contents/Frameworks ([5c722e3](https://github.com/jimeh/build-emacs-for-macos/commit/5c722e36c571aa7bf558b7f210c011f12d8d8a1c))
|
||||||
|
|
||||||
|
### [0.6.6](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.5...v0.6.6) (2021-07-01)
|
||||||
|
|
||||||
|
### [0.6.5](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.4...v0.6.5) (2021-07-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **native_comp:** improve handling of *.eln files in .app bundle ([9019e73](https://github.com/jimeh/build-emacs-for-macos/commit/9019e73d606f0379f988f46d6008770f8f3f7a51))
|
||||||
|
|
||||||
|
### [0.6.4](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.3...v0.6.4) (2021-06-30)
|
||||||
|
|
||||||
|
### [0.6.3](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.2...v0.6.3) (2021-06-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **patches:** correctly set ref when loading a build plan YAML ([99aa76b](https://github.com/jimeh/build-emacs-for-macos/commit/99aa76b3985195c310a20bafa19a8c7a4c8558fd))
|
||||||
|
|
||||||
### [0.6.2](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.1...v0.6.2) (2021-06-29)
|
### [0.6.2](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.1...v0.6.2) (2021-06-29)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ The build produced does have some limitations:
|
|||||||
that built the application will yield warnings. If you want to make a signed
|
that built the application will yield warnings. If you want to make a signed
|
||||||
Emacs.app, google is you friend for finding signing instructions.
|
Emacs.app, google is you friend for finding signing instructions.
|
||||||
|
|
||||||
|
## Binary Builds
|
||||||
|
|
||||||
|
Nightly and stable binary builds produced with this build script are available
|
||||||
|
from [jimeh/emacs-builds](https://github.com/jimeh/emacs-builds).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- [Xcode](https://apps.apple.com/gb/app/xcode/id497799835?mt=12)
|
- [Xcode](https://apps.apple.com/gb/app/xcode/id497799835?mt=12)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ require 'net/http'
|
|||||||
require 'optparse'
|
require 'optparse'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
require 'time'
|
require 'time'
|
||||||
|
require 'tmpdir'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ class Build
|
|||||||
handle_native_lisp(app)
|
handle_native_lisp(app)
|
||||||
add_cli_helper(app)
|
add_cli_helper(app)
|
||||||
|
|
||||||
LibEmbedder.new(app, brew_dir, extra_libs).embed
|
LibEmbedder.new(app, brew_dir, extra_libs, optsion[:relink_eln]).embed
|
||||||
GccLibEmbedder.new(app, gcc_info).embed if options[:native_comp]
|
GccLibEmbedder.new(app, gcc_info).embed if options[:native_comp]
|
||||||
|
|
||||||
archive_build(build_dir) if options[:archive]
|
archive_build(build_dir) if options[:archive]
|
||||||
@@ -117,9 +118,10 @@ class Build
|
|||||||
def load_plan(filename)
|
def load_plan(filename)
|
||||||
plan = YAML.safe_load(File.read(filename), [:Time])
|
plan = YAML.safe_load(File.read(filename), [:Time])
|
||||||
|
|
||||||
|
@ref = plan.dig('source', 'ref')
|
||||||
@meta = {
|
@meta = {
|
||||||
sha: plan.dig('source', 'commit', 'sha'),
|
sha: plan.dig('source', 'commit', 'sha'),
|
||||||
ref: plan.dig('source', 'ref'),
|
ref: @ref,
|
||||||
date: plan.dig('source', 'commit', 'date')
|
date: plan.dig('source', 'commit', 'date')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,11 +157,22 @@ class Build
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extra_libs
|
def extra_libs
|
||||||
@extra_libs ||= [
|
return @extra_libs if @extra_libs
|
||||||
|
|
||||||
|
libs = [
|
||||||
File.join(brew_dir, 'opt/expat/lib/libexpat.1.dylib'),
|
File.join(brew_dir, 'opt/expat/lib/libexpat.1.dylib'),
|
||||||
File.join(brew_dir, 'opt/libiconv/lib/libiconv.2.dylib'),
|
File.join(brew_dir, 'opt/libiconv/lib/libiconv.2.dylib'),
|
||||||
File.join(brew_dir, 'opt/zlib/lib/libz.1.dylib')
|
File.join(brew_dir, 'opt/zlib/lib/libz.1.dylib')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if options[:native_comp]
|
||||||
|
libgcc_s = File.join(
|
||||||
|
brew_dir, 'lib', 'gcc', gcc_info.major_version, 'libgcc_s.1.dylib'
|
||||||
|
)
|
||||||
|
libs << libgcc_s if File.exist?(libgcc_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
@extra_libs = libs
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_tarball(sha)
|
def download_tarball(sha)
|
||||||
@@ -292,6 +305,8 @@ class Build
|
|||||||
"-L#{gcc_info.libgccjit_lib_dir}",
|
"-L#{gcc_info.libgccjit_lib_dir}",
|
||||||
"-I#{File.join(gcc_info.root_dir, 'include')}",
|
"-I#{File.join(gcc_info.root_dir, 'include')}",
|
||||||
"-I#{File.join(gcc_info.libgccjit_root_dir, 'include')}",
|
"-I#{File.join(gcc_info.libgccjit_root_dir, 'include')}",
|
||||||
|
# Ensure library re-linking and code signing will work after building.
|
||||||
|
'-Wl,-headerpad_max_install_names',
|
||||||
ENV['LDFLAGS']
|
ENV['LDFLAGS']
|
||||||
].compact.join(' ')
|
].compact.join(' ')
|
||||||
|
|
||||||
@@ -411,20 +426,17 @@ class Build
|
|||||||
contents_dir = File.join(app, 'Contents')
|
contents_dir = File.join(app, 'Contents')
|
||||||
|
|
||||||
FileUtils.cd(contents_dir) do
|
FileUtils.cd(contents_dir) do
|
||||||
# Skip creation of symlinks if *.eln files are located under
|
|
||||||
# Resources/native-lisp. Emacs is capable of finding lisp sources and
|
|
||||||
# *.eln cache files without symlinks.
|
|
||||||
return if Dir['Resources/native-lisp/**/*.eln'].any?
|
|
||||||
|
|
||||||
info 'Creating symlinks within Emacs.app needed for native-comp'
|
|
||||||
|
|
||||||
FileUtils.ln_s('Resources/lisp', 'lisp') unless File.exist?('lisp')
|
|
||||||
|
|
||||||
source = Dir['MacOS/libexec/emacs/**/eln-cache',
|
source = Dir['MacOS/libexec/emacs/**/eln-cache',
|
||||||
'MacOS/lib/emacs/**/native-lisp'].first
|
'MacOS/lib/emacs/**/native-lisp'].first
|
||||||
|
|
||||||
if source.nil?
|
# Skip creation of symlinks if *.eln files are not located in a location
|
||||||
err 'Failed to find native-lisp cache directory for symlink creation.'
|
# known to be used by builds which need symlinks and other tweaks.
|
||||||
|
return if source.nil?
|
||||||
|
|
||||||
|
info 'Creating symlinks within Emacs.app needed for native-comp'
|
||||||
|
|
||||||
|
if !File.exist?('lisp') && File.exist?('Resources/lisp')
|
||||||
|
FileUtils.ln_s('Resources/lisp', 'lisp')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check for folder name containing two dots (.), as this causes Apple's
|
# Check for folder name containing two dots (.), as this causes Apple's
|
||||||
@@ -434,10 +446,9 @@ class Build
|
|||||||
# The workaround for now is to rename the folder replacing the dots with
|
# The workaround for now is to rename the folder replacing the dots with
|
||||||
# hyphens (-), and create the native-lisp symlink pointing to the new
|
# hyphens (-), and create the native-lisp symlink pointing to the new
|
||||||
# location.
|
# location.
|
||||||
if source.match(%r{/.+\..+\..+/})
|
eln_dir = File.dirname(Dir[File.join(source, '**', '*.eln')].first)
|
||||||
# Dig deeper into native-lisp directory
|
|
||||||
eln_dir = File.dirname(Dir[File.join(source, '**', '*.eln')].first)
|
|
||||||
|
|
||||||
|
if eln_dir.match(%r{/.+\..+\..+/})
|
||||||
base = File.basename(eln_dir)
|
base = File.basename(eln_dir)
|
||||||
parent = File.dirname(eln_dir)
|
parent = File.dirname(eln_dir)
|
||||||
|
|
||||||
@@ -738,8 +749,6 @@ class AbstractEmbedder
|
|||||||
@app = app
|
@app = app
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def invocation_dir
|
def invocation_dir
|
||||||
File.join(app, 'Contents', 'MacOS')
|
File.join(app, 'Contents', 'MacOS')
|
||||||
end
|
end
|
||||||
@@ -757,7 +766,7 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
attr_reader :lib_source
|
attr_reader :lib_source
|
||||||
attr_reader :extra_libs
|
attr_reader :extra_libs
|
||||||
|
|
||||||
def initialize(app, lib_source, extra_libs = [])
|
def initialize(app, lib_source, extra_libs = [], embed_eln_files = true)
|
||||||
super(app)
|
super(app)
|
||||||
|
|
||||||
@lib_source = lib_source
|
@lib_source = lib_source
|
||||||
@@ -779,7 +788,7 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
rel_path = Pathname.new(lib_dir).relative_path_from(
|
rel_path = Pathname.new(lib_dir).relative_path_from(
|
||||||
Pathname.new(File.dirname(binary))
|
Pathname.new(File.dirname(binary))
|
||||||
).to_s
|
).to_s
|
||||||
eln_files.each { |f| copy_libs(f, rel_path) }
|
eln_files.each { |f| copy_libs(f, rel_path) } if embed_eln_files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -787,19 +796,7 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
private
|
private
|
||||||
|
|
||||||
def eln_files
|
def eln_files
|
||||||
@eln_files ||= Dir[
|
@eln_files ||= Dir[File.join(app, 'Contents', '**', '*.eln')]
|
||||||
File.join(
|
|
||||||
app, 'Contents', 'Resources', 'native-lisp', '**', '*.eln'
|
|
||||||
),
|
|
||||||
File.join(
|
|
||||||
app, 'Contents', 'MacOS', 'lib', 'emacs', '**',
|
|
||||||
'native-lisp', '**', '*.eln'
|
|
||||||
),
|
|
||||||
File.join(
|
|
||||||
app, 'Contents', 'MacOS', 'libexec', 'emacs', '**',
|
|
||||||
'eln-cache', '**', '*.eln'
|
|
||||||
)
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_libs(exe, rel_path = nil)
|
def copy_libs(exe, rel_path = nil)
|
||||||
@@ -905,15 +902,15 @@ class GccLibEmbedder < AbstractEmbedder
|
|||||||
end
|
end
|
||||||
|
|
||||||
def target_dir
|
def target_dir
|
||||||
File.join(invocation_dir, gcc_info.relative_lib_dir)
|
File.join(lib_dir, gcc_info.relative_lib_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_darwin_dir
|
def source_darwin_dir
|
||||||
File.join(invocation_dir, gcc_info.relative_darwin_lib_dir)
|
File.join(lib_dir, gcc_info.relative_darwin_lib_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_darwin_dir
|
def target_darwin_dir
|
||||||
File.join(invocation_dir, gcc_info.sanitized_relative_darwin_lib_dir)
|
File.join(lib_dir, gcc_info.sanitized_relative_darwin_lib_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_dir
|
def source_dir
|
||||||
@@ -969,7 +966,21 @@ class GccInfo
|
|||||||
def sanitized_relative_darwin_lib_dir
|
def sanitized_relative_darwin_lib_dir
|
||||||
@sanitized_relative_darwin_lib_dir ||= File.join(
|
@sanitized_relative_darwin_lib_dir ||= File.join(
|
||||||
File.dirname(relative_darwin_lib_dir),
|
File.dirname(relative_darwin_lib_dir),
|
||||||
File.basename(relative_darwin_lib_dir).split('.').first
|
File.basename(relative_darwin_lib_dir).gsub('.', '_')
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def app_bundle_relative_lib_dir
|
||||||
|
@app_bundle_relative_lib_dir ||= relative_dir(
|
||||||
|
File.join(embedder.lib_dir, relative_lib_dir),
|
||||||
|
embedder.invocation_dir
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def app_bundle_relative_darwin_lib_dir
|
||||||
|
@app_bundle_relative_darwin_lib_dir ||= relative_dir(
|
||||||
|
File.join(embedder.lib_dir, sanitized_relative_darwin_lib_dir),
|
||||||
|
embedder.invocation_dir
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1016,6 +1027,10 @@ class GccInfo
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def embedder
|
||||||
|
@embedder ||= AbstractEmbedder.new(Dir.mktmpdir(['Emacs', '.app']))
|
||||||
|
end
|
||||||
|
|
||||||
def relative_dir(path, root)
|
def relative_dir(path, root)
|
||||||
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
|
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
|
||||||
end
|
end
|
||||||
@@ -1082,6 +1097,12 @@ if __FILE__ == $PROGRAM_NAME
|
|||||||
cli_options[:native_full_aot] = v
|
cli_options[:native_full_aot] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('--[no-]relink-eln-files',
|
||||||
|
'Enable/disable re-linking shared libraries in bundled *.eln ' \
|
||||||
|
'files (default: enabled)') do |v|
|
||||||
|
cli_options[:relink_eln] = v
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('--[no-]rsvg',
|
opts.on('--[no-]rsvg',
|
||||||
'Enable/disable SVG image support via librsvg ' \
|
'Enable/disable SVG image support via librsvg ' \
|
||||||
'(default: enabled)') do |v|
|
'(default: enabled)') do |v|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
|
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
|
||||||
index 8c638312b0..87af889ef4 100644
|
index 638d4b274c..2599211936 100644
|
||||||
--- a/lisp/emacs-lisp/comp.el
|
--- a/lisp/emacs-lisp/comp.el
|
||||||
+++ b/lisp/emacs-lisp/comp.el
|
+++ b/lisp/emacs-lisp/comp.el
|
||||||
@@ -4215,6 +4215,52 @@ native-compile-async
|
@@ -4224,6 +4224,52 @@ native-compile-async
|
||||||
(let ((load (not (not load))))
|
(let ((load (not (not load))))
|
||||||
(native--compile-async files recursively load selector)))
|
(native--compile-async files recursively load selector)))
|
||||||
|
|
||||||
@@ -16,10 +16,10 @@ index 8c638312b0..87af889ef4 100644
|
|||||||
+ (devtools-dir
|
+ (devtools-dir
|
||||||
+ "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")
|
+ "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")
|
||||||
+ (gcc-dir (expand-file-name
|
+ (gcc-dir (expand-file-name
|
||||||
+ "<%= relative_lib_dir %>"
|
+ "<%= app_bundle_relative_lib_dir %>"
|
||||||
+ invocation-directory))
|
+ invocation-directory))
|
||||||
+ (darwin-dir (expand-file-name
|
+ (darwin-dir (expand-file-name
|
||||||
+ "<%= sanitized_relative_darwin_lib_dir %>"
|
+ "<%= app_bundle_relative_darwin_lib_dir %>"
|
||||||
+ invocation-directory))
|
+ invocation-directory))
|
||||||
+ (lib-paths (list)))
|
+ (lib-paths (list)))
|
||||||
+
|
+
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/hexops/gotextdiff/myers"
|
"github.com/hexops/gotextdiff/myers"
|
||||||
"github.com/hexops/gotextdiff/span"
|
"github.com/hexops/gotextdiff/span"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,11 +43,11 @@ type UpdateOptions struct {
|
|||||||
// BuildsRepo is the GitHub repository containing binary releases.
|
// BuildsRepo is the GitHub repository containing binary releases.
|
||||||
BuildsRepo *repository.Repository
|
BuildsRepo *repository.Repository
|
||||||
|
|
||||||
// TapRepo is the GitHub repository to update the cask formula in.
|
// TapRepo is the GitHub repository to update the casks in.
|
||||||
TapRepo *repository.Repository
|
TapRepo *repository.Repository
|
||||||
|
|
||||||
// Ref is the git ref to apply cask formula updates on top of. Default
|
// Ref is the git ref to apply cask updates on top of. Default branch will
|
||||||
// branch will be used if empty.
|
// be used if empty.
|
||||||
Ref string
|
Ref string
|
||||||
|
|
||||||
// OutputDir specifies a directory to write cask files to. When set, tap
|
// OutputDir specifies a directory to write cask files to. When set, tap
|
||||||
@@ -56,10 +57,10 @@ type UpdateOptions struct {
|
|||||||
|
|
||||||
// Force update will ignore the outdated live check flag, and process all
|
// Force update will ignore the outdated live check flag, and process all
|
||||||
// casks regardless. But it will only update the cask in question if the
|
// casks regardless. But it will only update the cask in question if the
|
||||||
// resulting output cask formula is different.
|
// resulting output cask is different.
|
||||||
Force bool
|
Force bool
|
||||||
|
|
||||||
// TemplatesDir is the directory where cask formula templates are located.
|
// TemplatesDir is the directory where cask templates are located.
|
||||||
TemplatesDir string
|
TemplatesDir string
|
||||||
|
|
||||||
LiveChecks []*LiveCheck
|
LiveChecks []*LiveCheck
|
||||||
@@ -150,7 +151,7 @@ func (s *Updater) putFile(
|
|||||||
content []byte,
|
content []byte,
|
||||||
) (bool, error) {
|
) (bool, error) {
|
||||||
parent := filepath.Dir(filename)
|
parent := filepath.Dir(filename)
|
||||||
s.logger.Info("processing formula update",
|
s.logger.Info("processing cask update",
|
||||||
"output-directory", parent, "cask", chk.Cask, "file", filename,
|
"output-directory", parent, "cask", chk.Cask, "file", filename,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -164,18 +165,18 @@ func (s *Updater) putFile(
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
infoMsg := "creating formula"
|
infoMsg := "creating cask"
|
||||||
|
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
infoMsg = "updating formula"
|
infoMsg = "updating cask"
|
||||||
if bytes.Equal(existingContent, content) {
|
if bytes.Equal(existingContent, content) {
|
||||||
s.logger.Info(
|
s.logger.Info(
|
||||||
"skip update: no change to cask formula content",
|
"skip update: no change to cask content",
|
||||||
"cask", chk.Cask, "file", filename,
|
"cask", chk.Cask, "file", filename,
|
||||||
)
|
)
|
||||||
|
|
||||||
s.logger.Debug(
|
s.logger.Debug(
|
||||||
"formula content",
|
"cask content",
|
||||||
"file", filename, "content", string(content),
|
"file", filename, "content", string(content),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -198,7 +199,7 @@ func (s *Updater) putFile(
|
|||||||
)
|
)
|
||||||
|
|
||||||
s.logger.Debug(
|
s.logger.Debug(
|
||||||
"formula content",
|
"cask content",
|
||||||
"file", filename, "content", string(content),
|
"file", filename, "content", string(content),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -218,7 +219,7 @@ func (s *Updater) putRepoFile(
|
|||||||
filename string,
|
filename string,
|
||||||
content []byte,
|
content []byte,
|
||||||
) (bool, error) {
|
) (bool, error) {
|
||||||
s.logger.Info("processing formula update",
|
s.logger.Info("processing cask update",
|
||||||
"tap-repo", repo.Source, "cask", chk.Cask, "file", filename,
|
"tap-repo", repo.Source, "cask", chk.Cask, "file", filename,
|
||||||
)
|
)
|
||||||
repoContent, _, resp, err := s.gh.Repositories.GetContents(
|
repoContent, _, resp, err := s.gh.Repositories.GetContents(
|
||||||
@@ -264,12 +265,12 @@ func (s *Updater) createRepoFile(
|
|||||||
diff := fmt.Sprint(gotextdiff.ToUnified(filename, filename, "", edits))
|
diff := fmt.Sprint(gotextdiff.ToUnified(filename, filename, "", edits))
|
||||||
|
|
||||||
s.logger.Info(
|
s.logger.Info(
|
||||||
"creating formula",
|
"creating cask",
|
||||||
"cask", chk.Cask, "version", chk.Version.Latest, "file", filename,
|
"cask", chk.Cask, "version", chk.Version.Latest, "file", filename,
|
||||||
"diff", diff,
|
"diff", diff,
|
||||||
)
|
)
|
||||||
s.logger.Debug(
|
s.logger.Debug(
|
||||||
"formula content",
|
"cask content",
|
||||||
"file", filename, "content", string(content),
|
"file", filename, "content", string(content),
|
||||||
)
|
)
|
||||||
contResp, _, err := s.gh.Repositories.CreateFile(
|
contResp, _, err := s.gh.Repositories.CreateFile(
|
||||||
@@ -307,7 +308,7 @@ func (s *Updater) updateRepoFile(
|
|||||||
|
|
||||||
if existingContent == string(content) {
|
if existingContent == string(content) {
|
||||||
s.logger.Info(
|
s.logger.Info(
|
||||||
"skip update: no change to formula content",
|
"skip update: no change to cask content",
|
||||||
"cask", chk.Cask, "file", filename,
|
"cask", chk.Cask, "file", filename,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -329,12 +330,12 @@ func (s *Updater) updateRepoFile(
|
|||||||
))
|
))
|
||||||
|
|
||||||
s.logger.Info(
|
s.logger.Info(
|
||||||
"updating formula",
|
"updating cask",
|
||||||
"cask", chk.Cask, "version", chk.Version.Latest, "file", filename,
|
"cask", chk.Cask, "version", chk.Version.Latest, "file", filename,
|
||||||
"diff", diff,
|
"diff", diff,
|
||||||
)
|
)
|
||||||
s.logger.Debug(
|
s.logger.Debug(
|
||||||
"formula content",
|
"cask content",
|
||||||
"file", filename, "content", string(content),
|
"file", filename, "content", string(content),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -363,9 +364,14 @@ func (s *Updater) renderCask(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
chk *LiveCheck,
|
chk *LiveCheck,
|
||||||
) ([]byte, error) {
|
) ([]byte, error) {
|
||||||
releaseName := "Emacs." + chk.Version.Latest
|
releaseName, err := release.VersionToName(chk.Version.Latest)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
s.logger.Info("fetching release details", "release", releaseName)
|
s.logger.Info("fetching release details",
|
||||||
|
"release", releaseName, "repo", s.BuildsRepo.URL(),
|
||||||
|
)
|
||||||
release, resp, err := s.gh.Repositories.GetReleaseByTag(
|
release, resp, err := s.gh.Repositories.GetReleaseByTag(
|
||||||
ctx, s.BuildsRepo.Owner(), s.BuildsRepo.Name(), releaseName,
|
ctx, s.BuildsRepo.Owner(), s.BuildsRepo.Name(), releaseName,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func caskCmd() *cli2.Command {
|
|||||||
|
|
||||||
return &cli2.Command{
|
return &cli2.Command{
|
||||||
Name: "cask",
|
Name: "cask",
|
||||||
Usage: "manage Homebrew Cask formula",
|
Usage: "manage Homebrew Casks",
|
||||||
Flags: []cli2.Flag{
|
Flags: []cli2.Flag{
|
||||||
&cli2.StringFlag{
|
&cli2.StringFlag{
|
||||||
Name: "builds-repository",
|
Name: "builds-repository",
|
||||||
@@ -101,7 +101,7 @@ func caskUpdateCmd() *cli2.Command {
|
|||||||
Name: "force",
|
Name: "force",
|
||||||
Aliases: []string{"f"},
|
Aliases: []string{"f"},
|
||||||
Usage: "force update file even if livecheck has it marked " +
|
Usage: "force update file even if livecheck has it marked " +
|
||||||
"as not outdated (does not force update if formula " +
|
"as not outdated (does not force update if cask " +
|
||||||
"content is unchanged)",
|
"content is unchanged)",
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func planAction(c *cli2.Context, opts *Options) error {
|
|||||||
GithubToken: c.String("github-token"),
|
GithubToken: c.String("github-token"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.String("test-build-type") == "draft" {
|
if c.String("test-release-type") == "draft" {
|
||||||
planOpts.TestBuildType = plan.Draft
|
planOpts.TestBuildType = plan.Draft
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -60,6 +61,7 @@ func releaseCmd() *cli2.Command {
|
|||||||
Subcommands: []*cli2.Command{
|
Subcommands: []*cli2.Command{
|
||||||
releaseCheckCmd(),
|
releaseCheckCmd(),
|
||||||
releasePublishCmd(),
|
releasePublishCmd(),
|
||||||
|
releaseBulkCmd(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,3 +208,56 @@ func releasePublishAction(
|
|||||||
|
|
||||||
return release.Publish(c.Context, rlsOpts)
|
return release.Publish(c.Context, rlsOpts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func releaseBulkCmd() *cli2.Command {
|
||||||
|
return &cli2.Command{
|
||||||
|
Name: "bulk",
|
||||||
|
Usage: "bulk modify GitHub releases",
|
||||||
|
ArgsUsage: "",
|
||||||
|
Flags: []cli2.Flag{
|
||||||
|
&cli2.StringFlag{
|
||||||
|
Name: "name",
|
||||||
|
Usage: "regexp pattern matching release names to modify",
|
||||||
|
},
|
||||||
|
&cli2.StringFlag{
|
||||||
|
Name: "prerelease",
|
||||||
|
Usage: "change prerelease flag, must be \"true\" or " +
|
||||||
|
"\"false\", otherwise prerelease value is not changed",
|
||||||
|
},
|
||||||
|
&cli2.BoolFlag{
|
||||||
|
Name: "dry-run",
|
||||||
|
Usage: "do not perform any changes",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: releaseActionWrapper(releaseBulkAction),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func releaseBulkAction(
|
||||||
|
c *cli2.Context,
|
||||||
|
opts *Options,
|
||||||
|
rOpts *releaseOptions,
|
||||||
|
) error {
|
||||||
|
bulkOpts := &release.BulkOptions{
|
||||||
|
Repository: rOpts.Repository,
|
||||||
|
NamePattern: c.String("name"),
|
||||||
|
DryRun: c.Bool("dry-run"),
|
||||||
|
GithubToken: rOpts.GithubToken,
|
||||||
|
}
|
||||||
|
|
||||||
|
switch c.String("prerelease") {
|
||||||
|
case "true":
|
||||||
|
v := true
|
||||||
|
bulkOpts.Prerelease = &v
|
||||||
|
case "false":
|
||||||
|
v := false
|
||||||
|
bulkOpts.Prerelease = &v
|
||||||
|
case "":
|
||||||
|
default:
|
||||||
|
return errors.New(
|
||||||
|
"--prerelease by me \"true\" or \"false\" when specified",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return release.Bulk(c.Context, bulkOpts)
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/jimeh/build-emacs-for-macos/pkg/commit"
|
"github.com/jimeh/build-emacs-for-macos/pkg/commit"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/osinfo"
|
"github.com/jimeh/build-emacs-for-macos/pkg/osinfo"
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -64,15 +65,17 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseName := fmt.Sprintf(
|
version := fmt.Sprintf(
|
||||||
"Emacs.%s.%s.%s",
|
"%s.%s.%s",
|
||||||
commitInfo.DateString(),
|
commitInfo.DateString(),
|
||||||
commitInfo.ShortSHA(),
|
commitInfo.ShortSHA(),
|
||||||
sanitizeString(opts.Ref),
|
sanitizeString(opts.Ref),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
releaseName := fmt.Sprintf("Emacs.%s", version)
|
||||||
buildName := fmt.Sprintf(
|
buildName := fmt.Sprintf(
|
||||||
"%s.%s.%s",
|
"Emacs.%s.%s.%s",
|
||||||
releaseName,
|
version,
|
||||||
sanitizeString(osInfo.Name+"-"+osInfo.MajorMinor()),
|
sanitizeString(osInfo.Name+"-"+osInfo.MajorMinor()),
|
||||||
sanitizeString(osInfo.Arch),
|
sanitizeString(osInfo.Arch),
|
||||||
)
|
)
|
||||||
@@ -92,7 +95,8 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
|||||||
},
|
},
|
||||||
OS: osInfo,
|
OS: osInfo,
|
||||||
Release: &Release{
|
Release: &Release{
|
||||||
Name: releaseName,
|
Name: releaseName,
|
||||||
|
Prerelease: true,
|
||||||
},
|
},
|
||||||
Output: &Output{
|
Output: &Output{
|
||||||
Directory: opts.OutputDir,
|
Directory: opts.OutputDir,
|
||||||
@@ -100,16 +104,28 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If given git ref is a stable release tag (emacs-23.2b, emacs-27.2, etc.)
|
||||||
|
// we modify release properties accordingly.
|
||||||
|
if v, err := release.GitRefToStableVersion(opts.Ref); err == nil {
|
||||||
|
plan.Release.Prerelease = false
|
||||||
|
plan.Release.Name, err = release.VersionToName(v)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if opts.TestBuild != "" {
|
if opts.TestBuild != "" {
|
||||||
testName := sanitizeString(opts.TestBuild)
|
testName := sanitizeString(opts.TestBuild)
|
||||||
|
|
||||||
plan.Build.Name += ".test." + testName
|
plan.Build.Name += ".test." + testName
|
||||||
plan.Release.Title = "Test Builds"
|
plan.Release.Title = "Test Builds"
|
||||||
plan.Release.Name = "test-builds"
|
plan.Release.Name = "test-builds"
|
||||||
|
|
||||||
|
plan.Release.Prerelease = true
|
||||||
|
plan.Release.Draft = false
|
||||||
if opts.TestBuildType == Draft {
|
if opts.TestBuildType == Draft {
|
||||||
|
plan.Release.Prerelease = false
|
||||||
plan.Release.Draft = true
|
plan.Release.Draft = true
|
||||||
} else {
|
|
||||||
plan.Release.Prerelease = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
index := strings.LastIndex(diskImage, ".")
|
index := strings.LastIndex(diskImage, ".")
|
||||||
|
|||||||
84
pkg/release/bulk.go
Normal file
84
pkg/release/bulk.go
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
package release
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/google/go-github/v35/github"
|
||||||
|
"github.com/hashicorp/go-hclog"
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/gh"
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BulkOptions struct {
|
||||||
|
Repository *repository.Repository
|
||||||
|
NamePattern string
|
||||||
|
Prerelease *bool
|
||||||
|
DryRun bool
|
||||||
|
GithubToken string
|
||||||
|
}
|
||||||
|
|
||||||
|
func Bulk(ctx context.Context, opts *BulkOptions) error {
|
||||||
|
logger := hclog.FromContext(ctx).Named("release")
|
||||||
|
gh := gh.New(ctx, opts.GithubToken)
|
||||||
|
|
||||||
|
nameMatcher, err := regexp.Compile(opts.NamePattern)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nextPage := 1
|
||||||
|
lastPage := 1
|
||||||
|
|
||||||
|
for nextPage <= lastPage {
|
||||||
|
releases, resp, err := gh.Repositories.ListReleases(
|
||||||
|
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||||
|
&github.ListOptions{
|
||||||
|
Page: nextPage,
|
||||||
|
PerPage: 100,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
nextPage = resp.NextPage
|
||||||
|
lastPage = resp.LastPage
|
||||||
|
|
||||||
|
for _, r := range releases {
|
||||||
|
if !nameMatcher.MatchString(r.GetName()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Info("match found", "release", r.GetName())
|
||||||
|
|
||||||
|
var changes []interface{}
|
||||||
|
if opts.Prerelease != nil && r.GetPrerelease() != *opts.Prerelease {
|
||||||
|
changes = append(changes, "prerelease", *opts.Prerelease)
|
||||||
|
r.Prerelease = opts.Prerelease
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(changes) > 0 {
|
||||||
|
changes = append(
|
||||||
|
[]interface{}{"release", r.GetName()}, changes...,
|
||||||
|
)
|
||||||
|
logger.Info("modifying", changes...)
|
||||||
|
if !opts.DryRun {
|
||||||
|
_, _, err = gh.Repositories.EditRelease(
|
||||||
|
ctx, opts.Repository.Owner(), opts.Repository.Name(),
|
||||||
|
r.GetID(), r,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if nextPage == 0 || lastPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
42
pkg/release/version.go
Normal file
42
pkg/release/version.go
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package release
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Errors
|
||||||
|
var (
|
||||||
|
Err = errors.New("release")
|
||||||
|
ErrInvalidName = fmt.Errorf("%w: invalid name", Err)
|
||||||
|
ErrEmptyVersion = fmt.Errorf("%w: empty version", Err)
|
||||||
|
ErrNotStableRef = fmt.Errorf(
|
||||||
|
"%w: git ref is not stable tagged release", Err,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
stableVersion = regexp.MustCompile(`^\d+\.\d+(?:[a-z]+)?$`)
|
||||||
|
stableGetRef = regexp.MustCompile(`^emacs-(\d+\.\d+(?:[a-z]+)?)$`)
|
||||||
|
)
|
||||||
|
|
||||||
|
func VersionToName(version string) (string, error) {
|
||||||
|
if version == "" {
|
||||||
|
return "", ErrEmptyVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
if stableVersion.MatchString(version) {
|
||||||
|
return "Emacs-" + version, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Emacs." + version, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GitRefToStableVersion(ref string) (string, error) {
|
||||||
|
if m := stableGetRef.FindStringSubmatch(ref); len(m) > 1 {
|
||||||
|
return m[1], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", fmt.Errorf("%w: \"%s\"", ErrNotStableRef, ref)
|
||||||
|
}
|
||||||
138
pkg/release/version_test.go
Normal file
138
pkg/release/version_test.go
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
package release
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestVersionToName(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
version string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want string
|
||||||
|
wantErr string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty",
|
||||||
|
args: args{
|
||||||
|
version: "",
|
||||||
|
},
|
||||||
|
wantErr: "release: empty version",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "nightly",
|
||||||
|
args: args{
|
||||||
|
version: "2021-07-01.1b88404.master",
|
||||||
|
},
|
||||||
|
want: "Emacs.2021-07-01.1b88404.master",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "stable",
|
||||||
|
args: args{
|
||||||
|
version: "27.2",
|
||||||
|
},
|
||||||
|
want: "Emacs-27.2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "stable with letter",
|
||||||
|
args: args{
|
||||||
|
version: "23.3b",
|
||||||
|
},
|
||||||
|
want: "Emacs-23.3b",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got, err := VersionToName(tt.args.version)
|
||||||
|
|
||||||
|
assert.Equal(t, tt.want, got)
|
||||||
|
|
||||||
|
if tt.wantErr != "" {
|
||||||
|
assert.EqualError(t, err, tt.wantErr)
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGitRefToStableVersion(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
version string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want string
|
||||||
|
wantErr string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty",
|
||||||
|
args: args{
|
||||||
|
version: "",
|
||||||
|
},
|
||||||
|
wantErr: "release: git ref is not stable tagged release: \"\"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "master",
|
||||||
|
args: args{
|
||||||
|
version: "master",
|
||||||
|
},
|
||||||
|
wantErr: "release: git ref is not stable tagged release: " +
|
||||||
|
"\"master\"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "feature",
|
||||||
|
args: args{
|
||||||
|
version: "feature/native-comp",
|
||||||
|
},
|
||||||
|
wantErr: "release: git ref is not stable tagged release: " +
|
||||||
|
"\"feature/native-comp\"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "stable",
|
||||||
|
args: args{
|
||||||
|
version: "emacs-27.2",
|
||||||
|
},
|
||||||
|
want: "27.2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "stable with letter",
|
||||||
|
args: args{
|
||||||
|
version: "emacs-23.3b",
|
||||||
|
},
|
||||||
|
want: "23.3b",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "future stable",
|
||||||
|
args: args{
|
||||||
|
version: "emacs-239.33",
|
||||||
|
},
|
||||||
|
want: "239.33",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "future stable with letter",
|
||||||
|
args: args{
|
||||||
|
version: "emacs-239.33c",
|
||||||
|
},
|
||||||
|
want: "239.33c",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got, err := GitRefToStableVersion(tt.args.version)
|
||||||
|
|
||||||
|
assert.Equal(t, tt.want, got)
|
||||||
|
|
||||||
|
if tt.wantErr != "" {
|
||||||
|
assert.EqualError(t, err, tt.wantErr)
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -117,42 +117,24 @@ func signCLIHelper(ctx context.Context, appBundle string, opts *Options) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// elnFiles finds all native-compilation *.eln files within a Emacs.app bundle,
|
// elnFiles finds all native-compilation *.eln files within a Emacs.app bundle,
|
||||||
// based on expected paths they might be stored in.
|
// excluding any *.eln which should be automatically located by codesign when
|
||||||
|
// signing the Emacs.app bundle itself with the --deep flag. Essentially this
|
||||||
|
// only returns *.eln files which must be individually signed before signing the
|
||||||
|
// app bundle itself.
|
||||||
func elnFiles(emacsApp string) ([]string, error) {
|
func elnFiles(emacsApp string) ([]string, error) {
|
||||||
dirs := []string{
|
|
||||||
// Current *.eln location.
|
|
||||||
filepath.Join(emacsApp, "Contents", "Resources", "native-lisp"),
|
|
||||||
// Legacy *.eln location.
|
|
||||||
filepath.Join(emacsApp, "Contents", "MacOS", "lib", "emacs"),
|
|
||||||
}
|
|
||||||
|
|
||||||
var files []string
|
var files []string
|
||||||
walkDirFunc := func(path string, _d fs.DirEntry, _err error) error {
|
walkDirFunc := func(path string, d fs.DirEntry, _err error) error {
|
||||||
if strings.HasSuffix(path, ".eln") {
|
if d.Type().IsRegular() && strings.HasSuffix(path, ".eln") &&
|
||||||
|
!strings.Contains(path, ".app/Contents/Frameworks/") {
|
||||||
files = append(files, path)
|
files = append(files, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dir := range dirs {
|
err := filepath.WalkDir(filepath.Join(emacsApp, "Contents"), walkDirFunc)
|
||||||
fi, err := os.Stat(dir)
|
if err != nil {
|
||||||
if err != nil {
|
return nil, err
|
||||||
if os.IsNotExist(err) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !fi.IsDir() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
err = filepath.WalkDir(dir, walkDirFunc)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return files, nil
|
return files, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user