### Linux build prerequisites and setup commands Source: https://github.com/betterbird/thunderbird-patches/blob/main/README.md Commands to install dependencies and set up the build environment on Linux. Includes updating apt, installing packages, installing Mercurial (with an alternative method), installing Rust, and preparing the build directory. ```bash sudo apt update ``` ```bash sudo apt-get install git python3 python3-dev python3-pip curl ``` ```bash sudo apt-get install libdbusmenu-gtk3-dev ``` ```bash sudo apt-get install mercurial ``` ```bash echo "export PATH=\"$(python3 -m site --user-base)/bin:$PATH\"" >> ~/.bashrc ``` ```bash python3 -m pip install --user mercurial ``` ```bash hg version ``` ```bash curl https://sh.rustup.rs -sSf | sh ``` ```bash $HOME/.cargo/bin/rustup override set 1.XX.0 ``` ```bash mkdir build && cd build ``` ```bash git clone https://github.com/Betterbird/thunderbird-patches.git ``` ```bash cp thunderbird-patches/build/build.sh . ``` ```bash ./build.sh NN ``` -------------------------------- ### macOS build prerequisites and setup commands Source: https://github.com/betterbird/thunderbird-patches/blob/main/README.md Commands to install dependencies and set up the build environment on macOS. Includes installing Homebrew, Xcode modifications, adding Xcode to PATH, installing Mercurial, Rust, wget, and preparing the build directory. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` ```bash sudo xcode-select --switch /Applications/Xcode.app ``` ```bash sudo xcodebuild -license ``` ```bash export PATH=/opt/homebrew/bin:$PATH ``` ```bash brew install hg ``` ```bash hg version ``` ```bash curl https://sh.rustup.rs -sSf | sh ``` ```bash $HOME/.cargo/bin/rustup override set 1.XX.0 ``` ```bash brew install wget ``` ```bash mkdir build && cd build ``` ```bash git clone https://github.com/Betterbird/thunderbird-patches.git ``` ```bash cp thunderbird-patches/build/build.sh . ``` ```bash ./build.sh NN ``` -------------------------------- ### Install nvm Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Downloads and runs the nvm install script from GitHub. After installation, it sources .bashrc to load nvm into the current shell. ```bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash . ~/.bashrc ``` -------------------------------- ### Example usage of repack.cmd, langpack.cmd, repack-linux.cmd Source: https://github.com/betterbird/thunderbird-patches Example commands run from a MozillaBuild shell after ./build.sh 153 produced the en-US installer. They produce the specified installer, tarball, and langpack files. ```batch rem From a MozillaBuild shell, after ./build.sh 153 produced the en-US installer: repack.cmd de 153.6.0esr-bb12 langpack.cmd de 153.6.0esr-bb12 repack-linux.cmd de 153.6.0esr-bb12 rem Produces: betterbird-153.6.0esr-bb12.de.win64.installer.exe, rem betterbird-153.6.0esr-bb12.de.linux-x86_64.tar.xz, rem langpacks\de-153.6.0esr-bb12.xpi ``` -------------------------------- ### Install APT packages Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Installs all required system packages for building, including compilers, libraries, and utilities. ```bash sudo apt install mlocate git mercurial nano micro watchman python3-pywatchman python3 \ python3-pip python3-setuptools python3-wheel default-jre default-jdk wget curl gcc g++ \ binutils build-essential cmake ninja-build fonts-powerline powerline nasm shc \ libc6 libc6-dev libgcc-10-dev libstdc++-10-dev libstdc++6 linux-libc-dev libstdc++6-6 libstdc++-10-dev \ libx11-dev libxext-dev libxt-dev libxcb1-dev libxcb-shm0-dev libx11-xcb-dev \ libbsd-dev libgtk-3-dev libdbus-glib-1-dev ``` -------------------------------- ### Install Rustup, Rustc, and Cargo Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Downloads and runs the rustup installer with a specific toolchain for aarch64. The command sets the default toolchain to 1.60.0-aarch64-unknown-linux-gnu and includes the rustfmt component. After installation, it sources .bashrc to update the environment. ```bash wget https://sh.rustup.rs mv index.html rustup-init.sh chmod +x rustup-init.sh ./rustup-init.sh -y --default-toolchain 1.60.0-aarch64-unknown-linux-gnu --default-host aarch64-unknown-linux-gnu --component rustfmt . ~/.bashrc ``` -------------------------------- ### Install cbindgen and bindgen Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Installs cbindgen version 0.23.0 and the latest bindgen using Cargo. Requires Rust toolchain to be installed. ```bash cargo install cbindgen --version 0.23.0 cargo install bindgen ``` -------------------------------- ### Setup GitHub configuration Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Configures global git user name, email, and pull rebase behavior. ```bash git config --global user.name "XXXXXX" git config --global user.email "XXXXXXXXXXX" git config --global pull.rebase false ``` -------------------------------- ### Install Node.js 16.17.0 with nvm Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Installs Node.js version 16.17.0 via nvm, sets it as the active version, and sets it as the default alias for future shells. ```bash nvm install 16.17.0 nvm use 16.17.0 nvm alias default 16.17.0 ``` -------------------------------- ### switch-mozconfig.sh example usage Source: https://github.com/betterbird/thunderbird-patches Example invocations of switch-mozconfig.sh showing the expected output messages for toggling between arm64 and x86. ```bash # After a build with mozconfig-x86 staged by the build script: ./switch-mozconfig.sh # "Switched to arm64 in mozconfig" ./switch-mozconfig.sh # "Switched to x86 in mozconfig" ``` -------------------------------- ### Install LLVM 14.0.6 using LLVM apt repo Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Downloads and adds the LLVM GPG key, adds the Bullseye LLVM 14 repo to /etc/apt/sources.list, then updates package lists. ```bash wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - ``` ```bash deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-14 main ``` ```bash sudo apt update ``` -------------------------------- ### Basic install or update with defaults Source: https://github.com/betterbird/thunderbird-patches Runs the installer with default options, performing an install or update. Requires sudo. ```bash sudo ./install-betterbird.sh ``` -------------------------------- ### Install LLVM-14 packages with apt Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Installs all LLVM-14 packages with pinned versions on Debian/Ubuntu. Requires sudo privileges. The exact version string is required for each package. ```bash sudo apt install \ clang-14-doc=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ clang-14-examples=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ clang-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ clang-format-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ clang-tidy-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ clang-tools-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ clangd-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libc++-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libc++1-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libc++abi-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libc++abi1-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libclang-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libclang-common-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libclang-cpp14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libclang-cpp14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libclang1-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libclc-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libclc-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libfuzzer-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ liblld-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ liblld-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ liblldb-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ liblldb-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libllvm-14-ocaml-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libllvm14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libmlir-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libmlir-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libomp-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libomp-14-doc=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libomp5-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libunwind-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ libunwind-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ lld-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ lldb-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ llvm-14-dev=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ llvm-14-doc=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ llvm-14-examples=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ llvm-14-linker-tools=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ llvm-14-runtime=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ llvm-14-tools=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ llvm-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ mlir-14-tools=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ python3-clang-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 \ python3-lldb-14=1:14.0.6~++20220622053050+f28c006a5895-1~exp1~20220622173135.152 ``` -------------------------------- ### Setup Mercurial configuration Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Edits the Mercurial config file to set up username, extensions, and fsmonitor. ```bash hg config --edit ``` -------------------------------- ### Install latest npm globally Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Updates npm to the latest version globally using npm itself. ```bash npm install --location=global npm@latest ``` -------------------------------- ### Error handling for missing clone and wrong version Source: https://github.com/betterbird/thunderbird-patches Shows error messages and exit codes for missing clone and unknown version. Missing clone prints 'No clone of https://github.com/Betterbird/thunderbird-patches.git' and 'How did you get this build script in the first place?' then exits 1. Unknown version prints 'No such version' and exits 1. ```bash ./build.sh 153 # "No clone of https://github.com/Betterbird/thunderbird-patches.git" # "How did you get this build script in the first place?" → exit 1 ./build.sh 999 # "No such version" → exit 1 ``` -------------------------------- ### Update system and reconfigure locales and timezone Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Initial system setup: update package lists, reconfigure locales to en_US.UTF-8, and set timezone to Berlin or Madrid for consistency with other Betterbird builds. ```bash sudo apt update ``` ```bash sudo dpkg-reconfigure locales ``` ```bash sudo dpkg-reconfigure tzdata ``` ```bash sudo apt upgrade ``` -------------------------------- ### repack.cmd usage Source: https://github.com/betterbird/thunderbird-patches Command-line usage for the localized Windows installer repack script. Takes a locale code and version string. ```text Usage: repack.cmd ``` -------------------------------- ### Manual toggle between x86 and arm64 mozconfig variants Source: https://github.com/betterbird/thunderbird-patches Example commands to manually switch between Mac x86 and arm64 mozconfig variants. Copies the templates to mozconfig and mozconfig-arm64, then runs switch-mozconfig.sh which outputs 'Switched to arm64 in mozconfig'. ```bash # Manual toggle between x86 and arm64 mozconfig variants: cp thunderbird-patches/153/mozconfig-Mac mozconfig cp thunderbird-patches/153/mozconfig-Mac-arm64 mozconfig-arm64 ./switch-mozconfig.sh # → "Switched to arm64 in mozconfig" ``` -------------------------------- ### Main execution sequence (lines 222–225) Source: https://github.com/betterbird/thunderbird-patches The main execution sequence of the install script, showing the order of operations from checking if Betterbird is running to registering MIME types and logging success. ```bash checkIfBetterbirdIsRunning downloadUpdate checkHash backup extract addCustomIcons createDesktopFile registerMIME echoLog "Install successful: Betterbird installed in $installDir/betterbird." echoLog "Desktop file in $desktopFile." ``` -------------------------------- ### Example series file excerpt Source: https://github.com/betterbird/thunderbird-patches A real excerpt from 153/series showing the format of patch entries with optional comments after '##'. Includes branding, features, and misc patches. ```text ### Betterbird patches ## Branding branding/01-branding.patch branding/02-branding.patch branding/02a-branding-fix-export-to-mobile-string.patch branding/02a-branding.patch branding/03-branding.patch ## Binary images branding/03-branding-mac.patch ## Binary images for Mac branding/03-branding-svg.patch ## SVG images branding/04-branding.patch ## Binary patch for Windows only, modifying 7zSD.sfx branding/05-branding.patch branding/05a-branding.patch branding/05b-branding.patch branding/05b-branding-localised-installer.patch branding/05c-branding-localised-installer.patch branding/05b-branding-UA-string.patch ### Popping this patch will cause a total recompile branding/05d-branding-MACBUNDLE_ID.patch ### Popping this patch will cause a total recompile features/feature-1802145-reestablish-movemail.patch ### Popping this patch will cause a total recompile branding/05c-branding-appstrings-properties.patch branding/06-branding.patch branding/07-branding.patch branding/10-branding-notifications.patch ## Misc misc/39-misc-linting-console.patch misc/99-misc-release-set-version.patch misc/02-misc-user-agent-string.patch ... ``` -------------------------------- ### checkInfo function signature Source: https://github.com/betterbird/thunderbird-patches Checks whether a running betterbird.exe process is located at a different path than the launcher. Returns true if the module path does not start with appPath, false for non-Betterbird processes. ```cpp bool checkInfo(PROCESSENTRY32& processInfo, TCHAR *appPath) ``` -------------------------------- ### Basic first build Source: https://github.com/betterbird/thunderbird-patches Initial build after cloning the repos per the README. Creates a build directory, clones the thunderbird-patches repository, copies the build script, and runs it with version 153. ```bash mkdir build && cd build git clone https://github.com/Betterbird/thunderbird-patches.git cp thunderbird-patches/build/build.sh . ./build.sh 153 ``` -------------------------------- ### Prompt to continue build after applying patches Source: https://github.com/betterbird/thunderbird-patches After generating and running the external.sh wget fetcher, running hg qpush -all and hg qseries, both scripts prompt the user to continue. If the answer is not 'Y', they print instructions to build manually and exit 0. On 'Y', they run ./mach build and ./mach package (comm variant does this from the Mozilla repo root via cd .. first). ```bash Patches applied. Continue to build? read -p "Proceed? (Y/N) " ANSWER if [ "$ANSWER" != "Y" ]; then echo "When ready, please: cd $MOZILLA_DIR && ./mach build && ./mach package" exit 0 fi ``` -------------------------------- ### Incremental build with noclobber and apply options Source: https://github.com/betterbird/thunderbird-patches Incremental build without clobbering, or with patches only. The noclobber option touches CLOBBER instead of running ./mach clobber; apply stops after hg qpush -all or hg qseries. ```bash ./build.sh 153 noclobber # touch CLOBBER instead of ./mach clobber ./build.sh 153 apply # stop after hg qpush -all / hg qseries ``` -------------------------------- ### CLI usage for install-betterbird.sh Source: https://github.com/betterbird/thunderbird-patches Shows the command-line interface for the Betterbird Linux installer/updater. Options include -f/--force, -l/--lang, and -c/--channel. Only the release channel is guaranteed to work. ```bash Usage: $0 [-f|--force] [-l|--lang LANG] [-c|--channel CH] -f, --force Force re-install even if the same version is already installed. -l, --lang LANG Set language (default: en-US). Options: en-US, de, fr, es-ES, ja, it, nl, pt-BR, ru. -c, --channel CH Set update channel (default: release). Options: previous, release, latest, future. Only release is guaranteed to work. ``` -------------------------------- ### Stage patches into plain patches/ directories Source: https://github.com/betterbird/thunderbird-patches Copies series files and patch files from the thunderbird-patches directory into the repo's patches/ directories. Unlike build.sh, patches go into plain patches/ directories (not .hg/patches) and there is no cherrypicks copy step. ```bash cp ../thunderbird-patches/$VERSION/series$MOZU patches/series cp ../thunderbird-patches/$VERSION/series comm/patches/series cp ../thunderbird-patches/$VERSION/branding/*.patch comm/patches/ cp ../thunderbird-patches/$VERSION/bugs/*.patch comm/patches/ cp ../thunderbird-patches/$VERSION/features/*.patch comm/patches/ cp ../thunderbird-patches/$VERSION/misc/*.patch comm/patches/ mv comm/patches/*$MOZ.patch patches/ ``` -------------------------------- ### Apply patches from series file Source: https://github.com/betterbird/thunderbird-patches For each non-comment, non-blank line of the series file, applies the patch with git apply --apply --whitespace=nowarn. A missing patch file is a fatal error (exit 1). The series is applied in order for the main repo first, then for comm. ```bash patch=$(echo $line | cut -f1 -d'#' | sed 's/ *$//') if [[ -f patches/$patch ]]; then echo Applying patch $patch ... git apply --apply --whitespace=nowarn patches/$patch else echo Patch $patch not found. Exiting. exit 1 fi ``` -------------------------------- ### switch-mozconfig.sh CLI usage Source: https://github.com/betterbird/thunderbird-patches Usage line for switch-mozconfig.sh: takes no arguments. ```text Usage: (no arguments) ``` -------------------------------- ### wWinMain entry point signature Source: https://github.com/betterbird/thunderbird-patches Entry point of the launcher. Receives the command line and hands it on to Betterbird for mailto: URLs. The hInstance, hPrevInstance, and nCmdShow parameters are unused; SW_NORMAL is hard-coded. ```cpp int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow) ``` -------------------------------- ### Refresh comm patch queue and build Source: https://github.com/betterbird/thunderbird-patches Runs ./refresh-comm-patches.sh with a patch number and filename. Prompts 'Proceed? (Y/N)'; answer Y to build, N to just apply. ```bash ./refresh-comm-patches.sh 153 42-feature-something.patch # ... prompts "Proceed? (Y/N)"; answer Y to build, N to just apply ``` -------------------------------- ### One-off build from published tarball Source: https://github.com/betterbird/thunderbird-patches Creates a build directory, clones the thunderbird-patches repository, copies the build script, and runs it with version 153. ```bash mkdir build && cd build git clone https://github.com/Betterbird/thunderbird-patches.git cp thunderbird-patches/build/build-one-off.sh . ./build-one-off.sh 153 ``` -------------------------------- ### Apply-only and non-clobbering variants Source: https://github.com/betterbird/thunderbird-patches Runs the script with 'apply' to stop after git apply of both series, or 'noclobber' to skip ./mach clobber. ```bash ./build-one-off.sh 153 apply # stop after git apply of both series ./build-one-off.sh 153 noclobber # skip ./mach clobber ``` -------------------------------- ### Force re-install of the German release channel Source: https://github.com/betterbird/thunderbird-patches Forces a re-install using the German language and the release channel. Requires sudo. ```bash sudo ./install-betterbird.sh --force --lang de --channel release ``` -------------------------------- ### Windows resource cleanup and Mozilla-repo skip Source: https://github.com/betterbird/thunderbird-patches Windows resource cleanup deletes *.rc/*.res in obj-x86_64-pc-windows-msvc and exits 0. The nomoz option skips Mozilla repo update and Mozilla patch queue. ```bash ./build.sh 153 delres # delete *.rc/*.res in obj-x86_64-pc-windows-msvc, exit 0 ./build.sh 153 nomoz # skip Mozilla repo update and Mozilla patch queue ``` -------------------------------- ### Build Betterbird-102 Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Runs the build script to build Betterbird version 102. This command is executed from the directory containing the build.sh script. ```bash ./build.sh 102 ``` -------------------------------- ### Error handling (hash mismatch) Source: https://github.com/betterbird/thunderbird-patches Shows the expected output when a hash mismatch occurs: the script prints an error message and removes the downloaded archive, then exits with code 1. ```bash sudo ./install-betterbird.sh # "Hash not found in sha256-153.txt." # "Removing downloaded archive..." → exit 1 ``` -------------------------------- ### Usage: $0 VERSION [apply|noclobber] Source: https://github.com/betterbird/thunderbird-patches CLI interface for the one-off build script. VERSION must match a directory thunderbird-patches/ and an appdata file metadata/eu.betterbird.Betterbird..appdata.xml. The optional apply argument stops after patches are applied; noclobber skips ./mach clobber. ```bash Usage: $0 VERSION [apply|noclobber] ``` -------------------------------- ### Patch staging (comm variant) Source: https://github.com/betterbird/thunderbird-patches Copies the plain 'series' file and patch files from the comm variant's thunderbird-patches directory, excluding *$MOZ.patch files. Uses rsync -u -i because 'cp -u doesn't work on Mac :-('. Also supports ../../private-patches/*.patch → .hg/patches/features/. ```bash rsync -u -i ../../thunderbird-patches/$VERSION/series .hg/patches/series rsync -u -i ../../thunderbird-patches/$VERSION/branding/*.patch --exclude=*$MOZ.patch .hg/patches/branding/ rsync -u -i ../../thunderbird-patches/$VERSION/bugs/*.patch --exclude=*$MOZ.patch .hg/patches/bugs/ rsync -u -i ../../thunderbird-patches/$VERSION/features/*.patch --exclude=*$MOZ.patch .hg/patches/features/ rsync -u -i ../../thunderbird-patches/$VERSION/misc/*.patch --exclude=*$MOZ.patch .hg/patches/misc/ rsync -u -i ../../thunderbird-patches/$VERSION/cherrypicks/*.patch --exclude=*$MOZ.patch .hg/patches/cherrypicks/ ``` -------------------------------- ### Queue positioning with hg qgo and hg qpop Source: https://github.com/betterbird/thunderbird-patches If PATCH_NAME is not 'none', pops the queue down to just before the named patch so a single refreshed patch can be re-applied on top. ```bash hg qgo $PATCH_NAME hg qpop ``` -------------------------------- ### Patch staging (moz variant) Source: https://github.com/betterbird/thunderbird-patches Copies the series$MOZU file and only *$MOZ.patch files from the moz variant's thunderbird-patches directory. Path prefix is '../' because it runs from the Mozilla repo root, not from comm. ```bash rsync -u -i ../thunderbird-patches/$VERSION/series$MOZU .hg/patches/series rsync -u -i ../thunderbird-patches/$VERSION/branding/*$MOZ.patch .hg/patches/branding/ rsync -u -i ../thunderbird-patches/$VERSION/bugs/*$MOZ.patch .hg/patches/bugs/ rsync -u -i ../thunderbird-patches/$VERSION/features/*$MOZ.patch .hg/patches/features/ rsync -u -i ../thunderbird-patches/$VERSION/misc/*$MOZ.patch .hg/patches/misc/ rsync -u -i ../thunderbird-patches/$VERSION/cherrypicks/*$MOZ.patch .hg/patches/cherrypicks/ ``` -------------------------------- ### Verify qparent matches expected revision Source: https://github.com/betterbird/thunderbird-patches Both scripts verify that the Mercurial MQ tag 'qparent' matches the first 12 characters of the expected revision from NN/NN.sh, and exit 1 otherwise. refresh-comm-patches.sh checks both Mozilla and comm repos; refresh-moz-patches.sh checks only Mozilla. ```bash QPARENT=`hg tags | grep qparent | sed s/.*://` if [ $QPARENT != ${MOZILLA_REV:0:12} ]; then echo "Parent of Mozilla repo is $QPARENT, expected ${MOZILLA_REV:0:12}" exit 1 fi ``` -------------------------------- ### Build and repack portable launcher Source: https://github.com/betterbird/thunderbird-patches Commands to build the Betterbird launcher solution and repack the portable version. Requires a MozillaBuild shell and the repack-portable.cmd script. ```cmd msbuild BetterbirdLauncher.sln /p:Configuration=Release /p:Platform=x64 copy /Y BetterbirdLauncher\x64\Release\BetterbirdLauncher.exe . repack-portable.cmd en-US 153.6.0esr-bb12 ``` -------------------------------- ### Error handling (missing patch in series) Source: https://github.com/betterbird/thunderbird-patches Shows the error message and exit code when a patch is missing in the series. ```bash ./build-one-off.sh 153 # "Patch not found. Exiting." → exit 1 ``` -------------------------------- ### changeAbsolutePaths declaration (lib.cpp:376) Source: https://github.com/betterbird/thunderbird-patches UTF-8 text variant: reads via fileToMemoryW, rewrites via changeContent, writes via replaceFileContentW. ```cpp void changeAbsolutePaths(const TCHAR* profilePath, const TCHAR* lastProfilePath, const TCHAR* filename, short substitution) ``` -------------------------------- ### Linux mozconfig-Linux (153) Source: https://github.com/betterbird/thunderbird-patches Linux-specific build configuration for version 153. Enables system/application addon scopes and sideloading, enables EGL for fuzzy fonts, sets MOZ_NO_PIE_COMPAT for a small launcher executable, and sets MOZ_APP_REMOTINGNAME to match the desktop file's StartupWMClass. ```bash # System/application addons ac_add_options --with-unsigned-addon-scopes=app,system ac_add_options --allow-addon-sideload # Fix fuzzy fonts by enabling EGL. ac_add_options --enable-default-toolkit=cairo-gtk3-wayland # Used for Linux to create small launcher executable for file browsers. export MOZ_NO_PIE_COMPAT=1 # Set the WM_CLASS referenced in the .desktop file. export MOZ_APP_REMOTINGNAME=eu.betterbird.Betterbird ``` -------------------------------- ### Clone thunderbird-patches repository Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Clones the Betterbird thunderbird-patches repository recursively and copies the build script to the current directory. The commands create a build-102 directory in the home folder and navigate into it. ```bash cd ~ mkdir build-102 cd ~/build-102 git clone --recursive https://github.com/Betterbird/thunderbird-patches.git cp -p thunderbird-patches/build/build.sh . ``` -------------------------------- ### Refresh without repositioning Source: https://github.com/betterbird/thunderbird-patches Runs ./refresh-moz-patches.sh with 'none' to refresh without repositioning. ```bash ./refresh-moz-patches.sh 153 none ``` -------------------------------- ### fileToMemoryW declaration (lib.cpp:57) Source: https://github.com/betterbird/thunderbird-patches Reads a UTF-8 file as UTF-16 and returns a NUL-terminated TCHAR* buffer. Returns NULL on failure. ```cpp TCHAR* fileToMemoryW(TCHAR* filename) ``` -------------------------------- ### fileToMemory declaration (lib.cpp:23) Source: https://github.com/betterbird/thunderbird-patches Reads a file in binary mode and returns a malloc'ed buffer. Returns NULL on failure. ```cpp char* fileToMemory(TCHAR* filename, size_t* size) ``` -------------------------------- ### sed commands to rewrite external patch URLs Source: https://github.com/betterbird/thunderbird-patches Used by build.sh and build-one-off.sh to transform annotations into wget commands. The first sed replaces '/rev/' with '/raw-rev/', the second converts a line with '##' into a wget command with '-O' and '|| true' to make failed fetches non-fatal. ```bash sed -i -e 's/\/rev\//\/raw-rev\//' external.sh sed -i -e 's/\(.*\) # \(.*\)/wget -nc \2 -O .hg\/patches\/\1 || true/' external.sh ``` -------------------------------- ### Sourcing the version script in build scripts Source: https://github.com/betterbird/thunderbird-patches Used inside build.sh, build-one-off.sh, and refresh-*.sh to load per-version variables. The script is sourced and sets MOZILLA_REPO, MOZILLA_REV, COMM_REPO, COMM_REV, RUST_VER, MOZ, and MOZU. It has no exit code of its own; consumers fail with exit 1 if the file does not exist. ```bash # Inside build.sh / build-one-off.sh / refresh-*.sh: . ./thunderbird-patches/$VERSION/$VERSION.sh # Now: $MOZILLA_REPO, $MOZILLA_REV, $COMM_REPO, $COMM_REV, $RUST_VER, $MOZ, $MOZU are set. ``` -------------------------------- ### replaceFileContentW declaration (lib.cpp:127) Source: https://github.com/betterbird/thunderbird-patches Same as replaceFileContent but writes UTF-8 text mode. Applies fseek to remove the BOM. ```cpp void replaceFileContentW(const TCHAR* filename, const TCHAR* content) ``` -------------------------------- ### Add LLVM-14 to PATH in .bashrc Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Adds the LLVM-14 bin directory to the PATH. Add this line to your .bashrc file to make it persistent. ```bash export PATH="/usr/lib/llvm-14/bin:$PATH" ``` -------------------------------- ### changeContent declaration (lib.cpp:175) Source: https://github.com/betterbird/thunderbird-patches Core string rewriter. Replaces occurrences of newLastProfilePath with newProfilePath, counting replacements in *hits. Returns a malloc'ed new string or NULL on allocation failure. ```cpp TCHAR* changeContent(const TCHAR* profilePath, const TCHAR* lastProfilePath, const TCHAR* content, short substitution, size_t* hits) ``` -------------------------------- ### Extract source tarball URL from AppStream metadata Source: https://github.com/betterbird/thunderbird-patches Uses sed with -rz to extract the source artifact location from the AppStream file. The URL is then fetched with wget -q -nc, unpacked with tar -xf, and the directory renamed to $MOZILLA_DIR by stripping the esr.source.tar.xz suffix. ```bash APPDATA_FILE="thunderbird-patches/metadata/eu.betterbird.Betterbird.$VERSION.appdata.xml" SOURCE=$(cat $APPDATA_FILE | sed -rz 's@.+\s*([^<]+)<\/location>.+@\1@') ``` -------------------------------- ### repack-portable.cmd header comments Source: https://github.com/betterbird/thunderbird-patches Header comments for the repack-portable.cmd script, indicating the locale and version parameters passed as %~1 and %~2. ```batch :: %~1 - locale :: %~2 - version ``` -------------------------------- ### Windows mozconfig (153) Source: https://github.com/betterbird/thunderbird-patches Windows-specific build configuration for version 153. Sets target to x86_64-pc-windows-msvc, enables warnings-as-errors and clang plugin, disables maintenance service, and points WIN32_REDIST_DIR to the MSVC redistributable downloaded by the build system. ```bash ac_add_options --target=x86_64-pc-windows-msvc ac_add_options --enable-warnings-as-errors ac_add_options --enable-clang-plugin ac_add_options --disable-maintenance-service export WIN32_REDIST_DIR=/C/mozilla-source-esr153/.mozbuild/vs/VC/Redist/MSVC/14.50.35710/x64/Microsoft.VC145.CRT ``` -------------------------------- ### replaceAbsolutePathsInProfileData declaration (lib.cpp:398) Source: https://github.com/betterbird/thunderbird-patches Top-level entry called from wWinMain. Builds profilePath and rewrites profile files if the recorded location differs from the current one. ```cpp void replaceAbsolutePathsInProfileData(TCHAR* appPath) ``` -------------------------------- ### replaceFileContent declaration (lib.cpp:91) Source: https://github.com/betterbird/thunderbird-patches Deletes the target file and writes len bytes in binary mode. Silent no-op on delete/write failures. ```cpp void replaceFileContent(const TCHAR* filename, const char* content, size_t len) ``` -------------------------------- ### switch-mozconfig.sh exported behavior Source: https://github.com/betterbird/thunderbird-patches Shell script logic that toggles between arm64 and x86 mozconfig files. If mozconfig-arm64 exists, switches to arm64; if mozconfig-x86 exists, switches to x86; otherwise prints an error and exits 1. ```bash if [[ -f mozconfig-arm64 ]]; then mv mozconfig mozconfig-x86 mv mozconfig-arm64 mozconfig echo "Switched to arm64 in mozconfig" elif [[ -f mozconfig-x86 ]]; then mv mozconfig mozconfig-arm64 mv mozconfig-x86 mozconfig echo "Switched to x86 in mozconfig" else echo "Error: neither mozconfig-arm64 nor mozconfig-x86 found" exit 1 fi ``` -------------------------------- ### changeAbsolutePathsLZ4 declaration (lib.cpp:283) Source: https://github.com/betterbird/thunderbird-patches Rewrites paths inside a Mozilla LZ4-compressed JSON file (mozLz40 format). Silent no-op if the file is missing, not a mozLz40 file, or decompression size mismatches. ```cpp void changeAbsolutePathsLZ4(const TCHAR* profilePath, const TCHAR* lastProfilePath, const TCHAR* filename, short substitution) ``` -------------------------------- ### BetterBirdRunningOnOtherPath function signature Source: https://github.com/betterbird/thunderbird-patches Iterates all processes to detect if a betterbird.exe instance is running from a different path. Returns true on the first match, false if none found or if the snapshot handle is invalid. ```cpp bool BetterBirdRunningOnOtherPath(TCHAR *appPath) ``` -------------------------------- ### Resolve source tarball URL with sed Source: https://github.com/betterbird/thunderbird-patches Extracts the source tarball URL from the appdata XML file using a sed command with extended regex and null separator. The output is the URL to the source archive. ```bash sed -rz 's@.+\s*([^<]+)<\/location>.+@\1@' \ thunderbird-patches/metadata/eu.betterbird.Betterbird.153.appdata.xml # https://archive.mozilla.org/pub/thunderbird/candidates/153.6.0esr-candidates/build1/source/thunderbird-153.6.0esr.source.tar.xz ``` -------------------------------- ### Adding a new bug-fix patch to the 153 queue Source: https://github.com/betterbird/thunderbird-patches Use this workflow to add a new bug-fix patch to the 153 queue. Generate the patch from a Mercurial changeset with `hg qnew`, append it to the comm series (and to series-moz if it targets the Mozilla tree), then commit the patch and series change to the thunderbird-patches repo. ```bash # 1. Generate the patch from a Mercurial changeset: hg qnew bugs/NNN39-some-fix.patch # 2. Append to the comm series (and to series-moz if it targets the Mozilla tree): echo "bugs/NNN39-some-fix.patch" >> thunderbird-patches/153/series # 3. Commit the patch + series change to the thunderbird-patches repo. ``` -------------------------------- ### Series file line format Source: https://github.com/betterbird/thunderbird-patches Each line in a series file specifies a patch path relative to the MQ patch directory, optionally followed by an annotation after '##'. Lines are applied strictly top to bottom. ```plaintext [## ] ``` -------------------------------- ### fillPercentEncoding declaration (lib.cpp:165) Source: https://github.com/betterbird/thunderbird-patches Converts one UTF-16 code unit to its UTF-8 percent-encoding. Sets *percentLen to the number of characters written. ```cpp void fillPercentEncoding(TCHAR c, char percent[13], int* percentLen) ``` -------------------------------- ### Usage: $0 VERSION PATCH_NAME Source: https://github.com/betterbird/thunderbird-patches CLI interface for both refresh scripts. Requires a VERSION directory in thunderbird-patches and a PATCH_NAME to position the queue before, or 'none' to skip positioning. ```bash Usage: $0 VERSION PATCH_NAME ``` -------------------------------- ### Add a patch to the series file (Mercurial workflow) Source: https://github.com/betterbird/thunderbird-patches Shows the steps to add a new patch to the series file: copy the patch file into the appropriate directory, append its path to the series file, then re-run the build driver to apply it. ```bash # 1. Place the patch file: cp fix.patch thunderbird-patches/153/bugs/NNN39-some-fix.patch # 2. Append it to the series: echo "bugs/NNN39-some-fix.patch" >> thunderbird-patches/153/series # 3. Re-run the build driver; build.sh copies series + patches and qpush -all applies them. ``` -------------------------------- ### Mercurial config content Source: https://github.com/betterbird/thunderbird-patches/blob/main/build/build-env-aarch64.MD Content to be added to the Mercurial config file after running hg config --edit. ```ini [ui] username = XXXXXXXXX [extensions] mq = [fsmonitor] mode = on ``` -------------------------------- ### Error handling for wrong parent revision Source: https://github.com/betterbird/thunderbird-patches Runs ./refresh-comm-patches.sh with 'none' to trigger a parent revision mismatch. Outputs 'Parent of comm repo is 92ef4dd866c7, expected 8070f5d975d6' and exits with code 1. ```bash ./refresh-comm-patches.sh 153 none # "Parent of comm repo is 92ef4dd866c7, expected 8070f5d975d6" → exit 1 ``` -------------------------------- ### Substitution flag constants (lib.cpp:12-15) Source: https://github.com/betterbird/thunderbird-patches Bitmask constants for the `substitution` parameter. Values are combined with bitwise OR to control path rewriting behavior. ```cpp const short DOUBLE_BACKSLASH = 1; const short BACKSLASH_TO_SLASH = 2; const short ENCODE_PERCENT = 4; const short ENCODE_JSON_STYLE = 8; ``` -------------------------------- ### Mac mozconfig-Mac (153) - x86_64 target Source: https://github.com/betterbird/thunderbird-patches Mac-specific build configuration for version 153 targeting x86_64. Sets the target to x86_64-apple-darwin. ```bash ac_add_options --target=x86_64-apple-darwin ``` -------------------------------- ### Mac mozconfig-Mac-arm64 (153) - arm64 target Source: https://github.com/betterbird/thunderbird-patches Mac-specific build configuration for version 153 targeting arm64. Sets the target to aarch64-apple-darwin and adds -mcpu=apple-m1 flags for cross-compiling for ARM64 (M1/M2). ```bash ac_add_options --target=aarch64-apple-darwin export CFLAGS="$CFLAGS -mcpu=apple-m1" export CXXFLAGS="$CXXFLAGS -mcpu=apple-m1" ```