#!/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 pkgver=87.0 deps_deb() { echo "deps_deb: begin." deps="python3 python3-distutils clang pkg-config libpulse-dev gcc curl wget nodejs libpango1.0-dev nasm yasm zip m4 libgtk-3-dev libgtk2.0-dev libdbus-glib-1-dev libxt-dev" apt -y install $deps echo "deps_deb: done." } deps_rpm() { echo "deps_rpm: begin." deps="python3 python3-distutils-extra clang pkg-config gcc curl wget nodejs nasm yasm zip m4 python3-zstandard python-zstandard python-devel python3-devel gtk3-devel llvm gtk2-devel dbus-glib-devel libXt-devel pulseaudio-libs-devel" dnf -y install $deps echo "deps_rpm: done." } deps_pkg() { echo "deps_pkg: begin." deps="wget gsed gmake m4 python3 py37-sqlite3 pkgconf llvm node nasm zip unzip yasm" pkg install $deps echo "deps_pkg: done." } clean() { echo "clean: begin." echo "Deleting firefox-${pkgver} ..." rm -rf firefox-$pkgver echo "Deleting other cruft ..." rm -rf librewolf rm -f firefox-$pkgver.source.tar.xz rm -f mozconfig rm -f *.patch # windows rm -f librewolf-$pkgver.en-US.win64.zip rm -f librewolf-$pkgver.en-US.win64-setup.exe rm -f librewolf-$pkgver.en-US.win64-experimental.zip rm -f librewolf-$pkgver.en-US.win64-experimental-setup.exe rm -f tmp.nsi tmp-experimental.nsi # linux rm -f librewolf-$pkgver.en-US.deb.zip rm -f librewolf-$pkgver.en-US.deb-experimental.zip rm -f librewolf-$pkgver.en-US.rpm.zip echo "clean: done." } fetch() { echo "fetch: begin." # fetch the firefox source. rm -f firefox-$pkgver.source.tar.xz wget 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." } do_patches() { echo "do_patches: begin." # get the patches echo 'Getting patches..' rm -f context-menu.patch megabar.patch mozilla-vpn-ad.patch remove_addons.patch unity-menubar.patch wget -q https://gitlab.com/librewolf-community/browser/linux/-/raw/master/context-menu.patch if [ $? -ne 0 ]; then exit 1; fi if [ ! -f context-menu.patch ]; then exit 1; fi wget -q https://gitlab.com/librewolf-community/browser/linux/-/raw/master/megabar.patch if [ $? -ne 0 ]; then exit 1; fi if [ ! -f megabar.patch ]; then exit 1; fi wget -q https://gitlab.com/librewolf-community/browser/linux/-/raw/master/mozilla-vpn-ad.patch if [ $? -ne 0 ]; then exit 1; fi if [ ! -f mozilla-vpn-ad.patch ]; then exit 1; fi wget -q https://gitlab.com/librewolf-community/browser/linux/-/raw/master/remove_addons.patch if [ $? -ne 0 ]; then exit 1; fi if [ ! -f remove_addons.patch ]; then exit 1; fi # create mozconfig.. if [ ! -d firefox-$pkgver ]; then exit 1; fi cd firefox-$pkgver cat >../mozconfig < /dev/null if [ $? -eq 0 ]; then sed=gsed; # disable webrtc, build errors cat>>../mozconfig < /dev/null cp "/c/Program Files/LibreWolf/librewolf.cfg" librewolf.cfg git diff librewolf.cfg > ../patches/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 git diff policies.json > ../../patches/librewolf-policies.patch git diff policies.json git checkout policies.json > /dev/null 2>&1 popd > /dev/null } # windows: change $PATH to find all the build tools in .mozbuild # this might do the trick on macos aswell? if [ -f '/c/mozilla-build/start-shell.bat' ]; then export TPATH=$HOME/.mozbuild/clang/bin:$HOME/.mozbuild/cbindgen:$HOME/.mozbuild/node:$HOME/.mozbuild/nasm export PATH=$TPATH:$PATH fi if [ -f $HOME/.cargo/env ]; then . $HOME/.cargo/env fi # process commandline arguments and do something done_something=0 if [[ "$*" == *config_diff* ]]; then config_diff done_something=1 fi if [[ "$*" == *policies_diff* ]]; then policies_diff done_something=1 fi # if [[ "$*" == *clean* ]]; then clean done_something=1 fi if [[ "$*" == *git_subs* ]]; then git_subs done_something=1 fi if [[ "$*" == *rustup* ]]; then rustup done_something=1 fi # 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 [[ "$*" == *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 [[ "$*" == *mach_env* ]]; then mach_env done_something=1 fi if [[ "$*" == *build* ]]; then build done_something=1 fi # if [[ "$*" == *artifacts_exp* ]]; then experimental=experimental artifacts_exp done_something=1 else if [[ "$*" == *artifacts_win* ]]; then artifacts_win done_something=1 fi fi if [[ "$*" == *artifacts_deb_exp* ]]; then experimental=experimental artifacts_deb done_something=1 else if [[ "$*" == *artifacts_deb* ]]; then artifacts_deb done_something=1 fi fi if [[ "$*" == *artifacts_rpm* ]]; then artifacts_rpm done_something=1 fi # by default, give help.. if (( done_something == 0 )); then cat <