From 80a657268eb0b4185b649258dc2b279f20bf415f Mon Sep 17 00:00:00 2001 From: daijro Date: Wed, 14 Aug 2024 05:22:01 -0500 Subject: [PATCH] Packaging & macos exec fixes - Use "open -a" to launch Camoufox.app - Fix fonts not copying correctly - Find & move asset files to dist/ correctly --- launcher/exec.go | 6 ++++++ multibuild.py | 3 ++- scripts/package.py | 9 +++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/launcher/exec.go b/launcher/exec.go index b07c337..95fa6c1 100644 --- a/launcher/exec.go +++ b/launcher/exec.go @@ -74,6 +74,12 @@ func runCamoufox(execName string, args []string, addonsList []string) { debugPortInt = getDebugPort(&args) } + // For macOS, use "open" command to launch the app + if normalizeOS(runtime.GOOS) == "macos" { + args = append([]string{"-a", execName}, args...) + execName = "open" + } + // Print args cmd := exec.Command(execName, args...) diff --git a/multibuild.py b/multibuild.py index add5240..27eb92e 100644 --- a/multibuild.py +++ b/multibuild.py @@ -64,7 +64,7 @@ class BSYS: @property def assets(self) -> List[str]: """Get the list of assets""" - package_pattern = 'camoufox-*.en-US.*.zip' + package_pattern = f'camoufox-*-{self.target[:3]}.{self.arch}.zip' return glob.glob(package_pattern) @staticmethod @@ -84,6 +84,7 @@ def run_build(target, arch): # Run package builder.package() # Move assets to dist + print('Assets:', ', '.join(builder.assets)) for asset in builder.assets: os.rename(asset, f'dist/{asset}') diff --git a/scripts/package.py b/scripts/package.py index c64a85c..630f7f3 100644 --- a/scripts/package.py +++ b/scripts/package.py @@ -37,10 +37,10 @@ def add_includes_to_package(package_file, includes, fonts, new_file, target): ) if target == 'macos': - # Move Nightly/Nightly.app -> Camoufox.app - nightly_dir = os.path.join(temp_dir, 'Nightly') + # Move Camoufox/Camoufox.app -> Camoufox.app + nightly_dir = os.path.join(temp_dir, 'Camoufox') shutil.move( - os.path.join(nightly_dir, 'Nightly.app'), os.path.join(temp_dir, 'Camoufox.app') + os.path.join(nightly_dir, 'Camoufox.app'), os.path.join(temp_dir, 'Camoufox.app') ) # Remove old app dir and all content in it shutil.rmtree(nightly_dir) @@ -85,9 +85,10 @@ def add_includes_to_package(package_file, includes, fonts, new_file, target): # Non-linux systems cannot read fonts within subfolders. # Instead, we walk the fonts/ directory and copy all files. else: + os.makedirs(fonts_dir, exist_ok=True) for font in fonts or []: for file in list_files(root_dir=os.path.join('bundle', 'fonts', font), suffix='*'): - shutil.copy2(file, fonts_dir) + shutil.copy2(file, os.path.join(fonts_dir, os.path.basename(file))) # Add launcher from launcher/dist/launch to temp_dir launch_file = 'launch' + ('.exe' if target == 'windows' else '')