#!/bin/bash # build.sh - build librewolf on windows # derived from https://gitlab.com/librewolf-community/browser/linux/-/blob/master/PKGBUILD # # This script is set up like a Makefile, it's a list of functions that perform a # certain sub-task, that function can be called as a commandline argument to the script. # set -e . ./version.sh srcdir=firefox-$pkgver # # Basic functionality # fetch() { echo "fetch: begin." # fetch the firefox source. rm -f firefox-$pkgver.source.tar.xz echo "Downloading firefox-$pkgver.source.tar.xz ..." wget -q https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz if [ $? -ne 0 ]; then exit 1; fi if [ ! -f firefox-$pkgver.source.tar.xz ]; then exit 1; fi echo "fetch: done." } extract() { echo "extract: begin." echo "Deleting previous firefox-$pkgver ..." rm -rf firefox-$pkgver echo "Extracting firefox-$pkgver.source.tar.xz ..." tar xf firefox-$pkgver.source.tar.xz if [ $? -ne 0 ]; then exit 1; fi if [ ! -d firefox-$pkgver ]; then exit 1; fi echo "extract: done." } # LibreWolf specific mozconfig and patches create_mozconfig() { cat >../mozconfig < /dev/null cp "/c/Program Files/LibreWolf/librewolf.cfg" librewolf.cfg if [ $? -ne 0 ]; then exit 1; fi git diff librewolf.cfg > ../patches/permissive/librewolf-config.patch git diff librewolf.cfg git checkout librewolf.cfg > /dev/null 2>&1 popd > /dev/null } policies_diff() { pushd settings/distribution > /dev/null cp "/c/Program Files/LibreWolf/distribution/policies.json" policies.json if [ $? -ne 0 ]; then exit 1; fi git diff policies.json > ../../patches/permissive/librewolf-policies.patch git diff policies.json git checkout policies.json > /dev/null 2>&1 popd > /dev/null } init_mozilla_unified() { wget https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py python3 bootstrap.py --vcs=git } set_mozilla_unified() { srcdir=mozilla-unified } # # process commandline arguments and do something # done_something=0 # cross-compile actions... # # linux_patches - the 'do_patches' for linux->win crosscompile. # linux_artifacts - standard artifact zip file. perhaps a -setup.exe. # setup_deb_root - setup compile environment (root stuff) # setup_deb_user - setup compile environmnet (build user) # setup_rpm_root - setup compile environment (root stuff) # setup_rpm_user - setup compile environmnet (build user) . ./linux_xcompile.sh if [[ "$*" == *linux_patches* ]]; then linux_patches done_something=1 fi if [[ "$*" == *linux_artifacts* ]]; then linux_artifacts done_something=1 fi if [[ "$*" == *setup_deb_root* ]]; then setup_deb_root done_something=1 fi if [[ "$*" == *setup_deb_user* ]]; then setup_deb_user done_something=1 fi if [[ "$*" == *setup_rpm_root* ]]; then setup_rpm_root done_something=1 fi if [[ "$*" == *setup_rpm_user* ]]; then setup_rpm_user done_something=1 fi # various administrative actions... if [[ "$*" == *init_mozilla_unified* ]]; then init_mozilla_unified done_something=1 fi if [[ "$*" == *set_mozilla_unified* ]]; then set_mozilla_unified done_something=1 fi if [[ "$*" == *clean* ]]; then clean done_something=1 fi if [[ "$*" == *all* ]]; then fetch extract do_patches build permissive=permissive artifacts_win done_something=1 fi if [[ "$*" == *git_subs* ]]; then git_subs done_something=1 fi if [[ "$*" == *rustup* ]]; then rustup done_something=1 fi if [[ "$*" == *mach_env* ]]; then mach_env done_something=1 fi # dependencies on various platforms... if [[ "$*" == *deps_deb* ]]; then deps_deb done_something=1 fi if [[ "$*" == *deps_rpm* ]]; then deps_rpm done_something=1 fi if [[ "$*" == *deps_pkg* ]]; then deps_pkg done_something=1 fi if [[ "$*" == *deps_mac* ]]; then deps_mac done_something=1 fi # main building actions... if [[ "$*" == *fetch* ]]; then fetch done_something=1 fi if [[ "$*" == *extract* ]]; then extract done_something=1 fi if [[ "$*" == *do_patches* ]]; then do_patches done_something=1 fi if [[ "$*" == *git_init* ]]; then git_init done_something=1 fi if [[ "$*" == *build* ]]; then build done_something=1 fi # creating the artifacts... if [[ "$*" == *artifacts_perm* ]]; then permissive=permissive artifacts_win done_something=1 else if [[ "$*" == *artifacts_win* ]]; then artifacts_win done_something=1 fi fi if [[ "$*" == *artifacts_deb_perm* ]]; then permissive=permissive artifacts_deb done_something=1 else if [[ "$*" == *artifacts_deb* ]]; then artifacts_deb done_something=1 fi fi if [[ "$*" == *artifacts_rpm_perm* ]]; then permissive=permissive artifacts_rpm done_something=1 else if [[ "$*" == *artifacts_rpm* ]]; then artifacts_rpm done_something=1 fi fi # librewolf.cfg and policies.json differences if [[ "$*" == *config_diff* ]]; then config_diff done_something=1 fi if [[ "$*" == *policies_diff* ]]; then policies_diff done_something=1 fi if [[ "$*" == *mach_run_config* ]]; then cp -r settings/* $(echo $srcdir/obj-*)/dist/bin done_something=1 fi # by default, give help.. if (( done_something == 0 )); then cat << EOF Use: ./build.sh clean | all | [other stuff...] fetch - fetch the tarball. extract - extract the tarball. do_patches - create a mozconfig, and patch the source. build - the actual build. artifacts_win - apply .cfg, build the zip file and NSIS setup.exe installer. artifacts_perm - package as above, but use the permissive config/policies. # Linux related functions: deps_deb - install dependencies with apt. deps_rpm - install dependencies with dnf. deps_pkg - install dependencies with pkg. (freebsd) deps_mac - install dependencies with brew. (macOS) artifacts_deb - apply .cfg, create a dist zip file (for debian10). artifacts_deb_perm - include permissive build. artifacts_rpm - apply .cfg, create a dist zip file (for fedora33). artifacts_rpm_perm - include permissive build. # Generic utility functionality: all - build all, produce all artifacts including -permissive. clean - remove generated cruft. mach_env - create mach build environment. rustup - perform a rustup for this user. git_subs - update git submodules. config_diff - diff between my .cfg and dist .cfg file. (win10) policies_diff - diff between my policies and the dist policies. (win10) git_init - create .git folder in $srcdir for creating patches. mach_run_config - copy librewolf config/policies to enable 'mach run'. # Cross-compile from linux: linux_patches - the 'do_patches' for linux->win crosscompile. linux_artifacts - standard artifact zip file. perhaps a -setup.exe. setup_deb_root - setup compile environment (root stuff) setup_deb_user - setup compile environmnet (build user) setup_rpm_root - setup compile environment (root stuff) setup_rpm_user - setup compile environmnet (build user) # Nightly: init_mozilla_central - use bootstrap.py to grab the latest mozilla-source set_mozilla_central - use mozilla-source instead of $srcdir source Documentation is in the build-howto.md. In a docker situation, we'd like to run something like: ./build.sh fetch extract linux_patches build linux_artifacts # Installation from linux zip file: Copy the zip file in your \$HOME folder, then: `` unzip librewolf-*.zip cd librewolf ./register-librewolf `` That should give an app icon. You can have it elsewhere and it will work. # Examples: For windows, use: ./build.sh fetch extract do_patches build artifacts_win ./build.sh all For debian, use: sudo ./build.sh deps_deb ./build.sh rustup mach_env ./build.sh fetch extract do_patches build artifacts_deb EOF exit 1 fi