Commit 183f0f58 authored by Richard Pospesel's avatar Richard Pospesel Committed by brizental
Browse files

TB 41089: Add tor-browser build scripts + Makefile to tor-browser

parent 8a8a742e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -419,3 +419,6 @@ CLAUDE.local.md
# Ignore .json.gz (typically profiles) in the root directory
# lint-ignore-next-line: git-only
/*.json.gz

# Ignore binary base of Tor Browser
.binaries
+72 −0
Original line number Diff line number Diff line
.DEFAULT_GOAL := all

# https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile
mkfile_path := "$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))"

DEV_ROOT = "$(mkfile_path)/../.."
BINARIES = "$(DEV_ROOT)/.binaries"
ARCHITECTURE = "$(shell uname -m)"

# Correct the architecture naming for ARM to match what mozilla has
ifeq ($(ARCHITECTURE), "arm64")
  ARCHITECTURE = "aarch64"
endif

ifeq ($(ARCHITECTURE), "aarch64")
  LINUX_VENDOR = "unknown"
else
  LINUX_VENDOR = "pc"
endif

# Define build output path based on the platform.
ifeq ("$(shell uname)", "Darwin")
  BUILD_OUTPUT = "$(DEV_ROOT)/obj-$(ARCHITECTURE)-apple-darwin$(shell uname -r)"
else
  BUILD_OUTPUT = "$(DEV_ROOT)/obj-$(ARCHITECTURE)-$(LINUX_VENDOR)-linux-gnu"
endif

# Define the run command based on the platform.
ifeq ("$(shell uname)", "Darwin")
  RUN_CMD := cd "$(BINARIES)/Tor Browser.app/Contents/MacOS/" && ./firefox --purgecaches
else
  RUN_CMD := "$(BINARIES)/dev/Browser/start-tor-browser" -v --purgecaches $(ARGS)
endif

config:
	./config.sh $(DEV_ROOT)

ide-vscode:
	./ide.sh vscode $(DEV_ROOT)

ide-eclipse:
	./ide.sh eclipse $(DEV_ROOT)

ide-visualstudio:
	./ide.sh visualstudio $(DEV_ROOT)

fetch:
	./fetch.sh $(BINARIES)

build:
	./build.sh $(DEV_ROOT)

deploy:
	./deploy.sh $(BINARIES) $(BUILD_OUTPUT)

prepare-tests:
	./prepare-tests.sh $(BINARIES) $(BUILD_OUTPUT)

all: build deploy

run:
	$(RUN_CMD)

jslint:
	./jslint.sh $(DEV_ROOT) $(JS)

clobber:
	./clobber.sh $(DEV_ROOT)

clean:
	rm -rf $(BUILD_OUTPUT)
+110 −0
Original line number Diff line number Diff line
#!/bin/bash

CERTNAME=my-codesign-cert-tor
BROWSERPATH=.

if [ $# -ge 1 ]
then
  BROWSERPATH=$1
fi


security find-certificate -c $CERTNAME > /dev/null

if [ $? -ne 0 ]
then
  echo ""
  echo "ERROR: Self Signing Certificate not found, please create:"
  echo "  1. In the Keychain Access app on your Mac, choose Keychain Access > Certificate Assistant > Create a Certificate."
  echo "  2. Enter the name '$CERTNAME' for the certificate"
  echo "  3. Choose an identity type:  Self Signed Root"
  echo "  4. Certificate Type > Code Signing"
  echo "  5. Check 'Let me override defaults' & click Continue."
  echo "  6. Enter a unique Serial Number. (123 is fine)"
  echo "  7. Enter a big Validity Period (days), like 3560 & click Continue."
  echo "  8. Fill in your personal information & click Continue."
  echo "  9. Accept defaults for the rest of the dialog boxes. (Continue several times)"
  echo "  10. Certificate Created! Click Done."
  echo ""
  echo "For additional help see:"
  echo "  https://support.apple.com/en-ca/guide/keychain-access/kyca8916/mac"
  echo "  https://stackoverflow.com/questions/58356844/what-are-the-ways-or-technologies-to-sign-an-executable-application-file-in-mac"
  
  echo ""
  read -n 1 -r -s -p $'Press enter to launch "Keychain Access"...\n'
  open /System/Applications/Utilities/Keychain\ Access.app

  exit -1
fi

echo "Found $CERTNAME, looking for browser to sign..."

if [ ! -f "$BROWSERPATH/XUL" ]
then
  TESTPATH="$BROWSERPATH/Contents/MacOS"
  if [ -f "$TESTPATH/XUL" ]
  then
      BROWSERPATH=$TESTPATH
  else
    echo "Error: browser files not detected in $BROWSERPATH!"
    echo "  This script needs to be run in the 'Contents/MacOS' directory of a SomeBrowser.app directory"
    exit -1
  fi
fi

echo "Mozilla based browser found, signing..."
echo '  Will be asked for password to certificate for all the things that need to be signed. Click "Always Allow" to automate'

cd "$BROWSERPATH"

codesign -s $CERTNAME *.dylib
codesign -s $CERTNAME plugin-container.app

if [ -d Tor ]
then
  codesign -s $CERTNAME Tor/PluggableTransports/*
  codesign -s $CERTNAME Tor/libevent-2.1.7.dylib
  if [ -f Tor/tor.real ]
  then
    codesign -s $CERTNAME Tor/tor.real
  fi
  if [ -f Tor/tor ]
  then
    codesign -s $CERTNAME Tor/tor
  fi
fi

codesign -s $CERTNAME XUL

if [ -d updater.app ]
then
  codesign -s $CERTNAME updater.app
fi

# mullvadbrowser
if [ -f mullvadbrowser ]
then
  codesign -s $CERTNAME mullvadbrowser
fi

# BB or TB
if [ -f firefox ]
then
  codesign -s $CERTNAME firefox
fi

echo ""
echo "Browser signing step done!"
echo ""

echo "App still needs one more override to be easily opened with double click in Finder"
echo "Alternatively you can right click it, select 'Open' and then select 'Open' from the override popup"
echo "Or to enable it to be double clicked to open perform the following"
echo ""
echo "Double click the app and select either 'Ok' or 'Cancel' from the warning popup depending on which you get (Do Not 'Move to Trash')"
echo 'Go to Preferences -> Security & Privacy and click on padlock to allow changes. '
echo '  Then in "Allow appications downloaded from" select either:'
echo '    - App Store and identified developers'
echo '    - Anywhere'
echo '  Below that may be a notice about your specific app saying it was blocked because it was not from an identified developer. Click "Open Anyways" and "Open"'
+15 −0
Original line number Diff line number Diff line
#!/bin/bash
set -e
DEV_ROOT=$1

cd $DEV_ROOT
./mach build

if [ -z "$LOCALES" ]; then
  ./mach build stage-package
else
  export MOZ_CHROME_MULTILOCALE=$LOCALES
  # No quotes on purpose
  ./mach package-multi-locale --locales en-US $MOZ_CHROME_MULTILOCALE
  AB_CD=multi ./mach build stage-package
fi
+6 −0
Original line number Diff line number Diff line
#!/bin/bash
set -e
DEV_ROOT=$1

cd $DEV_ROOT
./mach clobber
Loading