From 4f15447e044a234871684d59696ac965a4ec25da Mon Sep 17 00:00:00 2001 From: daijro Date: Thu, 21 Nov 2024 18:38:29 -0600 Subject: [PATCH] Deprecate old launcher & locales --- Makefile | 7 +-- legacy/README.md | 6 +++ {launcher => legacy/launcher}/build.sh | 0 {launcher => legacy/launcher}/constants.go | 0 {launcher => legacy/launcher}/exec.go | 0 {launcher => legacy/launcher}/go.mod | 0 {launcher => legacy/launcher}/go.sum | 0 {launcher => legacy/launcher}/load-addons.go | 0 {launcher => legacy/launcher}/main.go | 0 .../launcher}/procgroup-unix.go | 0 .../launcher}/procgroup-win.go | 0 {launcher => legacy/launcher}/validate.go | 0 {launcher => legacy/launcher}/xpi-dl.go | 0 legacy/scripts/generate-locales.sh | 49 +++++++++++++++++++ scripts/package.py | 13 +---- scripts/run-pw.py | 2 +- 16 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 legacy/README.md rename {launcher => legacy/launcher}/build.sh (100%) rename {launcher => legacy/launcher}/constants.go (100%) rename {launcher => legacy/launcher}/exec.go (100%) rename {launcher => legacy/launcher}/go.mod (100%) rename {launcher => legacy/launcher}/go.sum (100%) rename {launcher => legacy/launcher}/load-addons.go (100%) rename {launcher => legacy/launcher}/main.go (100%) rename {launcher => legacy/launcher}/procgroup-unix.go (100%) rename {launcher => legacy/launcher}/procgroup-win.go (100%) rename {launcher => legacy/launcher}/validate.go (100%) rename {launcher => legacy/launcher}/xpi-dl.go (100%) create mode 100644 legacy/scripts/generate-locales.sh diff --git a/Makefile b/Makefile index 426ba2f..c37ed5a 100644 --- a/Makefile +++ b/Makefile @@ -124,10 +124,9 @@ check-arch: fi build-launcher: check-arch - cd launcher && bash build.sh $(arch) $(os) + cd legacy/launcher && bash build.sh $(arch) $(os) package-linux: - make build-launcher arch=$(arch) os=linux; python3 scripts/package.py linux \ --includes \ settings/chrome.css \ @@ -139,7 +138,6 @@ package-linux: --fonts windows macos linux package-macos: - make build-launcher arch=$(arch) os=macos; python3 scripts/package.py macos \ --includes \ settings/chrome.css \ @@ -150,7 +148,6 @@ package-macos: --fonts windows linux package-windows: - make build-launcher arch=$(arch) os=windows; python3 scripts/package.py windows \ --includes \ settings/chrome.css \ @@ -164,7 +161,7 @@ package-windows: run-launcher: rm -rf $(cf_source_dir)/obj-x86_64-pc-linux-gnu/dist/bin/launch; make build-launcher arch=x86_64 os=linux; - cp launcher/dist/launch $(cf_source_dir)/obj-x86_64-pc-linux-gnu/dist/bin/launch; + cp legacy/launcher/dist/launch $(cf_source_dir)/obj-x86_64-pc-linux-gnu/dist/bin/launch; $(cf_source_dir)/obj-x86_64-pc-linux-gnu/dist/bin/launch run-pw: diff --git a/legacy/README.md b/legacy/README.md new file mode 100644 index 0000000..96e1e2e --- /dev/null +++ b/legacy/README.md @@ -0,0 +1,6 @@ +## Deprecated Assets + +##### 2024-11-21 + +- Old launcher has been deprecated due to it not supporting non-Linux platforms, and for using FF's debugging protocol to load addons [#90](https://github.com/daijro/camoufox/issues/90). +- `generate-locales.sh` (based on [LibreWolf's locale build system](https://gitlab.com/librewolf-community/browser/source/-/blob/3dc56de7b0665724bf3842198cebe961c42a81e0/scripts/generate-locales.sh)) was deprecated due to "Camoufox" leaking to the page [#90](https://github.com/daijro/camoufox/issues/90). \ No newline at end of file diff --git a/launcher/build.sh b/legacy/launcher/build.sh similarity index 100% rename from launcher/build.sh rename to legacy/launcher/build.sh diff --git a/launcher/constants.go b/legacy/launcher/constants.go similarity index 100% rename from launcher/constants.go rename to legacy/launcher/constants.go diff --git a/launcher/exec.go b/legacy/launcher/exec.go similarity index 100% rename from launcher/exec.go rename to legacy/launcher/exec.go diff --git a/launcher/go.mod b/legacy/launcher/go.mod similarity index 100% rename from launcher/go.mod rename to legacy/launcher/go.mod diff --git a/launcher/go.sum b/legacy/launcher/go.sum similarity index 100% rename from launcher/go.sum rename to legacy/launcher/go.sum diff --git a/launcher/load-addons.go b/legacy/launcher/load-addons.go similarity index 100% rename from launcher/load-addons.go rename to legacy/launcher/load-addons.go diff --git a/launcher/main.go b/legacy/launcher/main.go similarity index 100% rename from launcher/main.go rename to legacy/launcher/main.go diff --git a/launcher/procgroup-unix.go b/legacy/launcher/procgroup-unix.go similarity index 100% rename from launcher/procgroup-unix.go rename to legacy/launcher/procgroup-unix.go diff --git a/launcher/procgroup-win.go b/legacy/launcher/procgroup-win.go similarity index 100% rename from launcher/procgroup-win.go rename to legacy/launcher/procgroup-win.go diff --git a/launcher/validate.go b/legacy/launcher/validate.go similarity index 100% rename from launcher/validate.go rename to legacy/launcher/validate.go diff --git a/launcher/xpi-dl.go b/legacy/launcher/xpi-dl.go similarity index 100% rename from launcher/xpi-dl.go rename to legacy/launcher/xpi-dl.go diff --git a/legacy/scripts/generate-locales.sh b/legacy/scripts/generate-locales.sh new file mode 100644 index 0000000..e5fa3bb --- /dev/null +++ b/legacy/scripts/generate-locales.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash + +if [ ! -f browser/locales/shipped-locales ]; then + echo "ERROR: Run this script from the root of the Camoufox source code" + exit 1 +fi + +rm -rf browser/locales/l10n +mkdir browser/locales/l10n + +N=8 +for i in $(seq $N); do echo; done +total=$(wc -l < browser/locales/shipped-locales) + +echo_status() { + printf "\033[$((($N - $n) + 1))A$@ %40s\r\033[$((($N - $n) + 1))B" +} + +generate_locale() { + if echo " en-US ca ja " | grep -q " $1 "; then + echo_status "Skipping locale \"$1\"" + sleep 1 + echo_status + return + fi + echo_status "Downloading locale \"$1\"" + wget -q -O browser/locales/l10n/$1.zip https://hg.mozilla.org/l10n-central/$1/archive/tip.zip + echo_status "Extracting locale \"$1\"" + 7z x -y -obrowser/locales/l10n browser/locales/l10n/$1.zip > /dev/null + mv browser/locales/l10n/$1-*/ browser/locales/l10n/$1/ + rm -f browser/locales/l10n/$1.zip + echo_status "Generating locale \"$1\"" + mv browser/locales/l10n/$1/browser/branding/official browser/locales/l10n/$1/browser/branding/camoufox + find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Mozilla Firefox/Camoufox/g' {} \; + find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Mozilla/Camoufox/g' {} \; + find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Firefox/Camoufox/g' {} \; + echo_status "Done" + sleep 0.3 + echo_status +} + +while read in; do + ((n=n%N)); ((n++==0)) && wait + generate_locale $in & +done < browser/locales/shipped-locales + +wait + +printf "\033[$(($N))A\rGenerated $total locales %-40s\n" \ No newline at end of file diff --git a/scripts/package.py b/scripts/package.py index ce39ee7..523481b 100644 --- a/scripts/package.py +++ b/scripts/package.py @@ -84,13 +84,6 @@ def add_includes_to_package(package_file, includes, fonts, new_file, target): for file in list_files(root_dir=os.path.join('bundle', 'fonts', font), suffix='*'): 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 '') - shutil.copy2( - os.path.join('launcher', 'dist', launch_file), - os.path.join(temp_dir, launch_file), - ) - # Remove unneeded paths for path in UNNEEDED_PATHS: if os.path.isdir(os.path.join(target_dir, path)): @@ -116,7 +109,6 @@ def get_args(): parser.add_argument( '--arch', choices=['x86_64', 'i686', 'arm64'], help='Architecture for Windows build' ) - parser.add_argument('--no-locales', action='store_true', help='Do not package locales') parser.add_argument('--fonts', nargs='+', help='Font directories to include under fonts/') return parser.parse_args() @@ -134,10 +126,7 @@ def main(): moz_target = get_moz_target(target=args.os, arch=args.arch) with temp_cd(src_dir): # Create package files - if args.no_locales: - run('./mach package') - else: - run('cat browser/locales/shipped-locales | xargs ./mach package-multi-locale --locales') + run('./mach package') # Find package files search_path = os.path.abspath( f'obj-{moz_target}/dist/camoufox-{args.version}-{args.release}.*.{file_ext}' diff --git a/scripts/run-pw.py b/scripts/run-pw.py index 927df55..29a5e7f 100644 --- a/scripts/run-pw.py +++ b/scripts/run-pw.py @@ -58,7 +58,7 @@ def main(): src_dir = find_src_dir('.', args.version, args.release) moz_target = get_moz_target(target='linux', arch='x86_64') - launcher_path = os.path.abspath(os.path.join('.', 'launcher', 'dist', 'launch')) + launcher_path = os.path.abspath(os.path.join('.', 'legacy', 'launcher', 'dist', 'launch')) with temp_cd(src_dir): print(f'Looking for file: obj-{moz_target}/dist/bin/camoufox-bin')