From bc2a74c233dd63b800697cefe9cf4a118c11d01c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 23 Sep 2026 14:41:14 -0400 Subject: [PATCH] Restore separate macOS component staging and custom XUL support We still might want a custom XUL at some point in the future. --- app/build.sh | 5 +++++ app/mac/build-and-unify | 21 ++++++++++++------- app/scripts/fetch_xulrunner | 42 +++++++++++++++++-------------------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/app/build.sh b/app/build.sh index 8dcdefd9f3..8b9dde7609 100755 --- a/app/build.sh +++ b/app/build.sh @@ -709,6 +709,11 @@ if [ $BUILD_MAC == 1 ]; then xz -d --stdout "$CALLDIR/mac/zotero.xz" > "$CONTENTSDIR/MacOS/zotero" chmod 755 "$CONTENTSDIR/MacOS/zotero" + # Overlay custom Firefox components (e.g., XUL or libmozglue.dylib) + if [ -n "$custom_components_hash_mac" ]; then + cp -R "$MAC_RUNTIME_PATH/../MacOS/." "$CONTENTSDIR/MacOS/" + fi + # Use our own updater, because Mozilla's requires updates signed by Mozilla cd "$CONTENTSDIR/MacOS" check_lfs_file "$CALLDIR/mac/updater.tar.xz" diff --git a/app/mac/build-and-unify b/app/mac/build-and-unify index 19579864fd..6cff315439 100755 --- a/app/mac/build-and-unify +++ b/app/mac/build-and-unify @@ -56,14 +56,19 @@ cp x64/$fx_app_name/Contents/MacOS/firefox zotero xz zotero mv zotero.xz "$APP_ROOT_DIR/mac/zotero.xz" -# Package custom libmozglue.dylib for fetch_xulrunner. -# Upload the file to ${custom_components_url}mac/ and set custom_components_hash_mac in -# config.sh. -xz --stdout x64/$fx_app_name/Contents/MacOS/libmozglue.dylib > libmozglue.dylib.xz -components_hash=$(shasum -a 256 libmozglue.dylib.xz | cut -d ' ' -f 1) -mozglue_file="${GECKO_VERSION_MAC//esr}-libmozglue-$components_hash.dylib.xz" -mv libmozglue.dylib.xz "$APP_ROOT_DIR/mac/$mozglue_file" -echo "Custom libmozglue.dylib: $APP_ROOT_DIR/mac/$mozglue_file" +# Package custom Firefox components for fetch_xulrunner. Add XUL to this list if needed. +# Upload the archive to ${custom_components_url}mac/ and set custom_components_hash_mac +# in config.sh to the hash printed below. +custom_components=(libmozglue.dylib) +mkdir MacOS +for component in "${custom_components[@]}"; do + cp "x64/$fx_app_name/Contents/MacOS/$component" MacOS/ +done +tar cfJ MacOS.tar.xz MacOS +components_hash=$(shasum -a 256 MacOS.tar.xz | cut -d ' ' -f 1) +components_file="$APP_ROOT_DIR/mac/$components_hash.tar.xz" +mv MacOS.tar.xz "$components_file" +echo "Custom Firefox components: $components_file" echo "custom_components_hash_mac=\"$components_hash\"" # Save a copy of ChannelPrefs.framework diff --git a/app/scripts/fetch_xulrunner b/app/scripts/fetch_xulrunner index f68f30d425..f49db0c0c4 100755 --- a/app/scripts/fetch_xulrunner +++ b/app/scripts/fetch_xulrunner @@ -612,50 +612,46 @@ if [ $BUILD_MAC == 1 ]; then hdiutil detach -quiet /Volumes/Firefox fi - # Download and extract custom libmozglue.dylib + # Download custom components (e.g., XUL), as an xz-compressed tarball of the MacOS folder with + # custom files in it echo - hash="$custom_components_hash_mac" - if [ -n "$hash" ]; then - xzfile="Firefox $GECKO_VERSION libmozglue.dylib.xz" - # Filename doesn't include "esr" - url="${custom_components_url}mac/${GECKO_VERSION//esr}-libmozglue-$hash.dylib.xz" - + rm -rf MacOS + if [ -n "$custom_components_hash_mac" ]; then + tarfile="Firefox $GECKO_VERSION MacOS.tar.xz" if [[ "$(uname)" = "Darwin" ]]; then shasum="shasum -a 256" else shasum=sha256sum fi - download_xz() { - echo "Downloading custom libmozglue.dylib" + download_components() { + echo "Downloading custom Firefox components" echo - echo $url - curl -fo "$xzfile" "$url" + curl -fo "$tarfile" "${custom_components_url}mac/$custom_components_hash_mac.tar.xz" } - verify_hash() { - echo "$hash $xzfile" | $shasum -c - + verify_components_hash() { + echo "$custom_components_hash_mac $tarfile" | $shasum -c - } - # Download if file doesn't exist - if [ ! -e "$xzfile" ]; then - download_xz + if [ ! -e "$tarfile" ]; then + download_components fi + # Verify hash echo - if ! verify_hash; then - echo "SHA hash mismatch. Redownloading libmozglue.dylib…" - rm -f "$xzfile" - download_xz + if ! verify_components_hash; then + echo "SHA hash mismatch. Redownloading custom Firefox components…" + rm -f "$tarfile" + download_components echo - if ! verify_hash; then + if ! verify_components_hash; then echo "Hash still doesn't match. Aborting." exit 1 fi fi echo - - xz -d --stdout "$xzfile" > Firefox.app/Contents/MacOS/libmozglue.dylib + tar xvf "$tarfile" echo fi