[tbb-commits] [tor-browser-build/master] Bug 24632: Adapt firefox and tor-browser to new macOS toolchain

gk at torproject.org gk at torproject.org
Wed Jun 6 18:23:58 UTC 2018


commit e76952c389487d657c3f52fede5e9ca56ec02397
Author: Georg Koppen <gk at torproject.org>
Date:   Wed Jun 6 18:22:41 2018 +0000

    Bug 24632: Adapt firefox and tor-browser to new macOS toolchain
    
    After building Firefox we now get a 'Tor Browser.app' instead of a
    'TorBrowser.app'. This patch makes sure the additional whitespace in the
    app name is correctly handled by the build script and the one that deals
    with packaging the final bundle.
    
    We need to ship a fix for the Firefox packaging step as well as
    |./mach package| wants to build the final .dmg in that step, too, which
    breaks: there is no .dmg creation tool available. Setting
    `INNER_MAKE_PACKAGE` to `true` does not seem to work anymore. That part
    of this patch is currently only a workaround to get the nightly builds
    going. We should come up with a better solution that allows us to skip
    that part of the Firefox packaging step on all supported platforms.
---
 projects/firefox/build        | 25 ++++++++++------
 projects/firefox/config       |  4 ++-
 projects/firefox/no-dmg.patch | 29 ++++++++++++++++++
 projects/tor-browser/build    | 70 +++++++++++++++++++++----------------------
 4 files changed, 83 insertions(+), 45 deletions(-)

diff --git a/projects/firefox/build b/projects/firefox/build
index 62186d1..8278c14 100644
--- a/projects/firefox/build
+++ b/projects/firefox/build
@@ -48,10 +48,13 @@ EOF
 #  export SELFRANDO_skip_shuffle=
 #[% END -%]
 
-[% IF c("var/linux") %]
+[% IF ! c("var/windows") %]
   mkdir -p /var/tmp/dist
   tar -C /var/tmp/dist -xf [% c('input_files_by_name/rust') %]
   export PATH="/var/tmp/dist/rust/bin:$PATH"
+[% END -%]
+
+[% IF c("var/linux") %]
   # Add llvm so stylo can build
   tar -C /var/tmp/dist -xf [% c('input_files_by_name/llvm') %]
   export LLVM_CONFIG="/var/tmp/dist/llvm/bin/llvm-config"
@@ -60,7 +63,7 @@ EOF
 tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
 
 [% IF c("var/osx") %]
-  mkdir -p $distdir/TorBrowser.app/Contents/MacOS
+  mkdir -p "$distdir/Tor Browser.app/Contents/MacOS"
 [% ELSE %]
   mkdir -p $distdir/Browser
 [% END %]
@@ -118,6 +121,10 @@ fi
   patch -p1 < $rootdir/STL_win64.patch
 [% END -%]
 
+[% IF c("var/osx") %]
+  patch -p1 < $rootdir/no-dmg.patch
+[% END -%]
+
 rm -f configure
 rm -f js/src/configure
 
@@ -128,12 +135,12 @@ rm -f js/src/configure
 [% IF c("var/osx") %]
   cp -a obj-macos/dist/firefox/* $distdir
   # Remove firefox-bin (we don't use it, see ticket #10126)
-  rm -f $distdir/TorBrowser.app/Contents/MacOS/firefox-bin
+  rm -f "$distdir/Tor Browser.app/Contents/MacOS/firefox-bin"
 
   # Adjust the Info.plist file
-  INFO_PLIST=$distdir/TorBrowser.app/Contents/Info.plist
-  mv $INFO_PLIST tmp.plist
-  python $rootdir/fix-info-plist.py '[% c("var/torbrowser_version") %]' '[% c("var/copyright_year") %]' < tmp.plist > $INFO_PLIST
+  INFO_PLIST="$distdir/Tor Browser.app/Contents/Info.plist"
+  mv "$INFO_PLIST" tmp.plist
+  python $rootdir/fix-info-plist.py '[% c("var/torbrowser_version") %]' '[% c("var/copyright_year") %]' < tmp.plist > "$INFO_PLIST"
   rm -f tmp.plist
 [% END %]
 
@@ -198,8 +205,8 @@ cd $distdir
   [% c("var/rezip", { rezip_file => 'Browser/omni.ja' }) %]
   [% c("var/rezip", { rezip_file => 'Browser/browser/omni.ja' }) %]
 [% ELSIF c("var/osx") %]
-  [% c("var/rezip", { rezip_file => 'TorBrowser.app/Contents/Resources/omni.ja' }) %]
-  [% c("var/rezip", { rezip_file => 'TorBrowser.app/Contents/Resources/browser/omni.ja' }) %]
+  [% c("var/rezip", { rezip_file => '"Tor Browser.app/Contents/Resources/omni.ja"' }) %]
+  [% c("var/rezip", { rezip_file => '"Tor Browser.app/Contents/Resources/browser/omni.ja"' }) %]
 [% END %]
 
 [% IF c("var/windows") %]
@@ -211,7 +218,7 @@ mkdir -p [% dest_dir _ '/' _ c('filename') %]
 
 [%
 IF c("var/osx");
-  SET browserdir='TorBrowser.app/Contents';
+  SET browserdir='"Tor Browser.app/Contents"';
 ELSE;
   SET browserdir='Browser';
 END;
diff --git a/projects/firefox/config b/projects/firefox/config
index d6b8313..927fb0b 100644
--- a/projects/firefox/config
+++ b/projects/firefox/config
@@ -86,6 +86,8 @@ input_files:
 #    enable: '[% c("var/linux") && ! c("var/release") %]'
   - filename: fix-info-plist.py
     enable: '[% c("var/osx") %]'
+  - filename: no-dmg.patch
+    enable: '[% c("var/osx") %]'
   - URL: https://people.torproject.org/~gk/mirrors/sources/msvcr100.dll
     sha256sum: 8793353461826fbd48f25ea8b835be204b758ce7510db2af631b28850355bd18
     enable: '[% c("var/windows-i686") %]'
@@ -99,7 +101,7 @@ input_files:
     enable: '[% c("var/windows-x86_64") %]'
   - project: rust
     name: rust
-    enable: '[% c("var/linux") %]'
+    enable: '[% ! c("var/windows") %]'
   - project: llvm
     name: llvm
     enable: '[% c("var/linux") %]'
diff --git a/projects/firefox/no-dmg.patch b/projects/firefox/no-dmg.patch
new file mode 100644
index 0000000..1e722af
--- /dev/null
+++ b/projects/firefox/no-dmg.patch
@@ -0,0 +1,29 @@
+From 7204fc9191a55dbbd3b94ee2d64ece8d9910cf23 Mon Sep 17 00:00:00 2001
+From: Georg Koppen <gk at torproject.org>
+Date: Thu, 31 May 2018 19:15:18 +0000
+Subject: [PATCH] Don't create a .dmg yet
+
+
+diff --git a/toolkit/mozapps/installer/upload-files.mk b/toolkit/mozapps/installer/upload-files.mk
+index 8ace9703a160..82df89d1f431 100644
+--- a/toolkit/mozapps/installer/upload-files.mk
++++ b/toolkit/mozapps/installer/upload-files.mk
+@@ -216,14 +216,7 @@ ifeq ($(MOZ_PKG_FORMAT),DMG)
+ 
+   _ABS_MOZSRCDIR = $(shell cd $(MOZILLA_DIR) && pwd)
+   PKG_DMG_SOURCE = $(MOZ_PKG_DIR)
+-  INNER_MAKE_PACKAGE = \
+-    $(call py_action,make_dmg, \
+-        $(if $(MOZ_PKG_MAC_DSSTORE),--dsstore '$(MOZ_PKG_MAC_DSSTORE)') \
+-        $(if $(MOZ_PKG_MAC_BACKGROUND),--background '$(MOZ_PKG_MAC_BACKGROUND)') \
+-        $(if $(MOZ_PKG_MAC_ICON),--icon '$(MOZ_PKG_MAC_ICON)') \
+-        --volume-name '$(MOZ_APP_DISPLAYNAME)' \
+-        '$(PKG_DMG_SOURCE)' '$(PACKAGE)' \
+-        )
++  INNER_MAKE_PACKAGE = true
+   INNER_UNMAKE_PACKAGE = \
+     $(call py_action,unpack_dmg, \
+         $(if $(MOZ_PKG_MAC_DSSTORE),--dsstore '$(MOZ_PKG_MAC_DSSTORE)') \
+-- 
+2.17.0
+
diff --git a/projects/tor-browser/build b/projects/tor-browser/build
index 4d1be00..d807633 100644
--- a/projects/tor-browser/build
+++ b/projects/tor-browser/build
@@ -14,7 +14,7 @@ mkdir -p $OUTDIR
 TB_STAGE_DIR=$distdir/tor-browser-stage
 
 [% IF c("var/osx") %]
-  TBDIR=$TB_STAGE_DIR/TorBrowser.app
+  TBDIR="$TB_STAGE_DIR/Tor Browser.app"
 
   DOCSPATH=Contents/Resources/TorBrowser/Docs
   EXTSPATH=Contents/Resources/distribution/extensions
@@ -34,11 +34,11 @@ TB_STAGE_DIR=$distdir/tor-browser-stage
   EXTOVERRIDESPATH=TorBrowser/Data/Browser/profile.default/preferences/extension-overrides.js
   MEEKPROFILEPATH=TorBrowser/Data/Browser/profile.meek-http-helper
 
-  mkdir -p $TBDIR/TorBrowser/Data/Browser/Caches
+  mkdir -p "$TBDIR/TorBrowser/Data/Browser/Caches"
 [% END %]
 
-mkdir -p $TBDIR/$EXTSPATH
-mkdir -p $TBDIR/$MEEKPROFILEPATH/extensions
+mkdir -p "$TBDIR/$EXTSPATH"
+mkdir -p "$TBDIR/$MEEKPROFILEPATH/extensions"
 
 # Extract the MAR tools.
 unzip -d $rootdir $rootdir/[% c('input_files_by_name/firefox') %]/mar-tools-*.zip
@@ -49,23 +49,23 @@ MARTOOLS=$rootdir/mar-tools
   unzip -d $rootdir $rootdir/mar-tools-linux32.zip
 [% END -%]
 
-mv [% c('input_files_by_name/tor-launcher') %] $TBDIR/$EXTSPATH/tor-launcher at torproject.org.xpi
-mv [% c('input_files_by_name/torbutton') %] $TBDIR/$EXTSPATH/torbutton at torproject.org.xpi
-mv [% c('input_files_by_name/https-everywhere') %] $TBDIR/$EXTSPATH/https-everywhere-eff at eff.org.xpi
-mv [% c('input_files_by_name/noscript') %] $TBDIR/$EXTSPATH/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi
+mv [% c('input_files_by_name/tor-launcher') %] "$TBDIR/$EXTSPATH/tor-launcher at torproject.org.xpi"
+mv [% c('input_files_by_name/torbutton') %] "$TBDIR/$EXTSPATH/torbutton at torproject.org.xpi"
+mv [% c('input_files_by_name/https-everywhere') %] "$TBDIR/$EXTSPATH/https-everywhere-eff at eff.org.xpi"
+mv [% c('input_files_by_name/noscript') %] "$TBDIR/$EXTSPATH/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
 
-tar -C $TBDIR -xf [% c('input_files_by_name/obfs4') %]
-tar -C $TBDIR -xf [% c('input_files_by_name/meek') %]
-mv $TBDIR/meek-http-helper at bamsoftware.com.xpi $TBDIR/$MEEKPROFILEPATH/extensions/
+tar -C "$TBDIR" -xf [% c('input_files_by_name/obfs4') %]
+tar -C "$TBDIR" -xf [% c('input_files_by_name/meek') %]
+mv "$TBDIR/meek-http-helper at bamsoftware.com.xpi" "$TBDIR/$MEEKPROFILEPATH/extensions/"
 [% IF c("var/snowflake") %]
-  tar -C $TBDIR -xf [% c('input_files_by_name/snowflake') -%]
+  tar -C "$TBDIR" -xf [% c('input_files_by_name/snowflake') -%]
 [% END -%]
 
 [% IF c("var/fteproxy") -%]
-  tar -C $TBDIR -xf [% c('input_files_by_name/fteproxy') %]
+  tar -C "$TBDIR" -xf [% c('input_files_by_name/fteproxy') %]
 [% END -%]
 
-tar -C $TBDIR[% IF c("var/osx") %]/Contents/Resources[% END %] -xf [% c('input_files_by_name/fonts') %]
+tar -C "$TBDIR[% IF c("var/osx") %]/Contents/Resources[% END %]" -xf [% c('input_files_by_name/fonts') %]
 
 [% IF c("var/linux") %]
   cp RelativeLink/* ${TB_STAGE_DIR}/Browser/
@@ -77,7 +77,7 @@ RBM_TB_EOF
 [% END %]
 
 tar -C ${TB_STAGE_DIR} -xf [% c('input_files_by_name/firefox') %]/tor-browser.tar.gz
-tar -C $TBDIR[% IF ! c("var/osx") %]/TorBrowser[% END %] -xf [% c('input_files_by_name/tor') %]/tor.tar.gz
+tar -C "$TBDIR[% IF ! c("var/osx") %]/TorBrowser[% END %]" -xf [% c('input_files_by_name/tor') %]/tor.tar.gz
 
 [% IF c("var/linux");
      SET bundledata_osname = 'linux';
@@ -107,8 +107,8 @@ tar -C $TBDIR[% IF ! c("var/osx") %]/TorBrowser[% END %] -xf [% c('input_files_b
   mv $SKELETON_TMP Bundle-Data/mac
 
   # Install a "tor" shim that sets the working directory. See #10030.
-  mv $TBDIR/$TORBINPATH/tor $TBDIR/$TORBINPATH/tor.real
-  cp Bundle-Data/mac-tor.sh $TBDIR/$TORCONFIGPATH/tor
+  mv "$TBDIR/$TORBINPATH/tor" "$TBDIR/$TORBINPATH/tor.real"
+  cp Bundle-Data/mac-tor.sh "$TBDIR/$TORCONFIGPATH/tor"
 
   [% IF ! c("var/release") -%]
     SANDBOX_FOLDER="$TB_STAGE_DIR/Sandboxed Tor Browser"
@@ -118,17 +118,17 @@ tar -C $TBDIR[% IF ! c("var/osx") %]/TorBrowser[% END %] -xf [% c('input_files_b
   tar -C Bundle-Data/mac-applications.dmg -c . | tar -C $TB_STAGE_DIR -x
 [% END %]
 
-mkdir -p $TBDIR/$DOCSPATH
-cp -a Bundle-Data/Docs/* $TBDIR/$DOCSPATH
-tar -C Bundle-Data/[% bundledata_osname %] -c . | tar -C $TBDIR[% IF ! c("var/osx") %]/TorBrowser[% END %] -x
+mkdir -p "$TBDIR/$DOCSPATH"
+cp -a Bundle-Data/Docs/* "$TBDIR/$DOCSPATH"
+tar -C Bundle-Data/[% bundledata_osname %] -c . | tar -C "$TBDIR[% IF ! c("var/osx") %]/TorBrowser[% END %]" -x
 
-cat Bundle-Data/PTConfigs/[% bundledata_osname %]/torrc-defaults-appendix >> $TBDIR/$TORCONFIGPATH/torrc-defaults
+cat Bundle-Data/PTConfigs/[% bundledata_osname %]/torrc-defaults-appendix >> "$TBDIR/$TORCONFIGPATH/torrc-defaults"
 [% IF c("var/linux") -%]
   [% IF ! c("var/snowflake") %]
     grep -v 'default_bridge\.snowflake' Bundle-Data/PTConfigs/bridge_prefs.js \
-       >> $TBDIR/$EXTOVERRIDESPATH
+       >> "$TBDIR/$EXTOVERRIDESPATH"
   [% ELSE %]
-    cat Bundle-Data/PTConfigs/bridge_prefs.js >> $TBDIR/$EXTOVERRIDESPATH
+    cat Bundle-Data/PTConfigs/bridge_prefs.js >> "$TBDIR/$EXTOVERRIDESPATH"
   [% END %]
 [% END -%]
 [% IF c("var/windows") -%]
@@ -136,18 +136,18 @@ cat Bundle-Data/PTConfigs/[% bundledata_osname %]/torrc-defaults-appendix >> $TB
   # We don't have fte available on Windows x86_64 yet
   grep -v 'default_bridge\.snowflake' Bundle-Data/PTConfigs/bridge_prefs.js \
   [% IF c("var/windows-x86_64") %]| grep -v 'default_bridge\.fte' [% END %] \
-      >> $TBDIR/$EXTOVERRIDESPATH
+      >> "$TBDIR/$EXTOVERRIDESPATH"
 [% END -%]
 [% IF c("var/osx") -%]
   # FTE is temporarily removed due to bug 18495.
   grep -Ev 'default_bridge\.fte' Bundle-Data/PTConfigs/bridge_prefs.js \
   [% IF ! c("var/snowflake") %]| grep -v 'default_bridge\.snowflake' [% END %] \
-      >> $TBDIR/$EXTOVERRIDESPATH
+      >> "$TBDIR/$EXTOVERRIDESPATH"
 [% END -%]
-cat Bundle-Data/PTConfigs/meek-http-helper-user.js >> $TBDIR/$MEEKPROFILEPATH/user.js
+cat Bundle-Data/PTConfigs/meek-http-helper-user.js >> "$TBDIR/$MEEKPROFILEPATH/user.js"
 
 [% IF c("var/osx") %]
-  pushd $TBDIR
+  pushd "$TBDIR"
   # Create the meek-template-sha256sum.txt file by generating a list
   # of hashes (one for each file within the meek-http-helper profile) and
   # and then generating one final hash from the contents of the list.
@@ -156,8 +156,8 @@ cat Bundle-Data/PTConfigs/meek-http-helper-user.js >> $TBDIR/$MEEKPROFILEPATH/us
 [% END %]
 
 [% IF ! c("var/multi_lingual") %]
-  echo 'pref("extensions.torlauncher.prompt_for_locale", false);' >> $TBDIR/$EXTOVERRIDESPATH
-  echo 'pref("intl.locale.matchOS", false);' >> $TBDIR/$EXTOVERRIDESPATH
+  echo 'pref("extensions.torlauncher.prompt_for_locale", false);' >> "$TBDIR/$EXTOVERRIDESPATH"
+  echo 'pref("intl.locale.matchOS", false);' >> "$TBDIR/$EXTOVERRIDESPATH"
 [% END %]
 
 [% IF c("var/linux") %]
@@ -178,7 +178,7 @@ cat Bundle-Data/PTConfigs/meek-http-helper-user.js >> $TBDIR/$MEEKPROFILEPATH/us
 [% END %]
 
 
-pushd $TBDIR[% IF c("var/osx") %]/Contents/Resources[% END %]/browser/
+pushd "$TBDIR[% IF c("var/osx") %]/Contents/Resources[% END %]/browser/"
 # For the proper search engines in our language packs
 unzip omni.ja chrome/en-US/locale/browser/searchplugins* || [ $? -lt 3 ]
 mv chrome/en-US/locale/browser/searchplugins $rootdir
@@ -223,7 +223,7 @@ popd
       }) %]
   # If we are building a multi-lingual package, add all of the language packs.
   [% IF c("var/multi_lingual") %]
-    cp [% xpi %] $TBDIR/$EXTSPATH/langpack-[% lang %]@firefox.mozilla.org.xpi
+    cp [% xpi %] "$TBDIR/$EXTSPATH/langpack-[% lang %]@firefox.mozilla.org.xpi"
   [% END %]
   cd ..
   rm -rf prep_[% lang %]
@@ -232,7 +232,7 @@ popd
 [% IF c("var/multi_lingual") %]
   # Set the update.locale (it is used to replace %LOCALE% within
   # app.update.url).
-  pushd $TBDIR[% IF c("var/osx") %]/Contents/Resources/[% END %]
+  pushd "$TBDIR[% IF c("var/osx") %]/Contents/Resources/[% END %]"
   echo ${PKG_LOCALE} > update.locale
   [% c("var/touch") %] update.locale
   zip -Xm omni.ja update.locale
@@ -253,11 +253,11 @@ popd
 cp -a ${TB_STAGE_DIR} $distdir/$PKG_DIR
 
 [% IF c("var/windows") %]
-  TBDIR=$distdir/$PKG_DIR/"Tor Browser"/Browser
+  TBDIR="$distdir/$PKG_DIR/Tor Browser/Browser"
 [% ELSIF c("var/osx") %]
-  TBDIR=$distdir/$PKG_DIR/TorBrowser.app
+  TBDIR="$distdir/$PKG_DIR/Tor Browser.app"
 [% ELSE %]
-  TBDIR=$distdir/$PKG_DIR/Browser
+  TBDIR="$distdir/$PKG_DIR/Browser"
 [% END %]
 
 pushd "$TBDIR[% IF c("var/osx") %]/Contents/Resources/[% END %]"



More information about the tbb-commits mailing list