From 9019e73d606f0379f988f46d6008770f8f3f7a51 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 1 Jul 2021 23:33:50 +0100 Subject: [PATCH] fix(native_comp): improve handling of *.eln files in .app bundle Specifically support latest changes in master which places *.eln files within the .app bundle in "Contents/Frameworks". --- build-emacs-for-macos | 24 ++++++++++-------------- pkg/sign/emacs.go | 8 ++++++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build-emacs-for-macos b/build-emacs-for-macos index dd747e2..b8c26ee 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -412,20 +412,17 @@ class Build contents_dir = File.join(app, 'Contents') 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', 'MacOS/lib/emacs/**/native-lisp'].first - if source.nil? - err 'Failed to find native-lisp cache directory for symlink creation.' + # Skip creation of symlinks if *.eln files are not located in a location + # 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 # Check for folder name containing two dots (.), as this causes Apple's @@ -435,10 +432,9 @@ class Build # The workaround for now is to rename the folder replacing the dots with # hyphens (-), and create the native-lisp symlink pointing to the new # location. - if source.match(%r{/.+\..+\..+/}) - # Dig deeper into native-lisp directory - eln_dir = File.dirname(Dir[File.join(source, '**', '*.eln')].first) + eln_dir = File.dirname(Dir[File.join(source, '**', '*.eln')].first) + if eln_dir.match(%r{/.+\..+\..+/}) base = File.basename(eln_dir) parent = File.dirname(eln_dir) diff --git a/pkg/sign/emacs.go b/pkg/sign/emacs.go index 05a3f25..c59e790 100644 --- a/pkg/sign/emacs.go +++ b/pkg/sign/emacs.go @@ -117,11 +117,15 @@ func signCLIHelper(ctx context.Context, appBundle string, opts *Options) error { } // 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) { var files []string walkDirFunc := func(path string, d fs.DirEntry, _err error) error { - if d.Type().IsRegular() && strings.HasSuffix(path, ".eln") { + if d.Type().IsRegular() && strings.HasSuffix(path, ".eln") && + !strings.Contains(path, ".app/Contents/Frameworks/") { files = append(files, path) }