From 571f67ee6474de6816e2b056afc867c0e12d019f Mon Sep 17 00:00:00 2001 From: BeatLink Date: Sun, 16 Jun 2019 01:57:29 -0500 Subject: [PATCH] Overhaul of build script add several printf messages to describe the build process move icon generation to this script update all paths to use new layout and folder names update script to use variables for common paths add commands in preparation for appimage build --- browser/build.sh | 91 +++++++++++++++++++++++++------ browser/scripts/generate_icons.sh | 23 -------- 2 files changed, 73 insertions(+), 41 deletions(-) delete mode 100755 browser/scripts/generate_icons.sh diff --git a/browser/build.sh b/browser/build.sh index dbd7daf..dbb3dc7 100755 --- a/browser/build.sh +++ b/browser/build.sh @@ -1,52 +1,107 @@ #!/bin/bash - -# PREBUILD ######################################################################################## +printf "\n------------------------------------- SCRIPT SETUP ------------------------------------------\n"; # Prevents build from breaking in CI/CD environments export SHELL=/bin/bash; -# Downloads and immediately runs bootstrapper to install dependencies. +# Sets up internal script variables +printf "\nSetting up script variables\n"; +SCRIPT_FOLDER=$(realpath $(dirname $0)); +REPOSITORY_FOLDER=$(realpath $SCRIPT_FOLDER/../); +printf "SCRIPT_FOLDER: $SCRIPT_FOLDER\n"; +printf "REPOSITORY_FOLDER: $REPOSITORY_FOLDER\n"; + +# Installs some needed dependencies +printf "\nInstalling script dependencies\n"; +sudo apt update; +sudo apt install python python3 inkscape wget -y; + +printf "\n\n------------------------------------ ICON GENERATION ----------------------------------------\n"; + +ICON_FILE=$REPOSITORY_FOLDER/branding/icon/icon.svg; +BRANDING_FOLDER=$SCRIPT_FOLDER/resources/source_files/browser/branding/librewolf; +printf "\nGenerating icons from $ICON_FILE and moving to $BRANDING_FOLDER\n"; + +# Linux Icons +inkscape -z -f $ICON_FILE -e $BRANDING_FOLDER/default16.png -w 16 -h16; +inkscape -z -f $ICON_FILE -e $BRANDING_FOLDER/default32.png -w 32 -h32; +inkscape -z -f $ICON_FILE -e $BRANDING_FOLDER/default48.png -w 48 -h48; +inkscape -z -f $ICON_FILE -e $BRANDING_FOLDER/default64.png -w 64 -h64; +inkscape -z -f $ICON_FILE -e $BRANDING_FOLDER/default128.png -w 128 -h128; + +# Windows Icons +inkscape -z -f $ICON_FILE -e $BRANDING_FOLDER/VisualElements_70.png -w 70 -h70; +inkscape -z -f $ICON_FILE -e $BRANDING_FOLDER/VisualElements_150.png -w 150 -h150; + +# TODO: Add Apple Icons + +printf "\n\n--------------------------------------- PREBUILD --------------------------------------------\n"; + +# Downloads and runs bootstrapper to install dependencies. +printf "\nRunning bootstrapper to install build dependencies\n"; wget -nv -O - \ https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py \ | python - --application-choice=browser --no-interactive; # adds the new rust install to PATH +printf "\nAdding new rust install to PATH\n"; . $HOME/.cargo/env; -# Downloads further dependencies -sudo apt install inkscape -y; +printf "\n\n---------------------------------------- BUILD ----------------------------------------------\n"; -# BUILD ########################################################################################### # Creates and enters the folder where compiling will take place -mkdir work_dir; -cd work_dir; +printf "\nCreating compile folder\n"; +mkdir compile_folder; +cd compile_folder; # Clones the firefox source code for compiling +printf "\nCloning Firefox Source Code\n"; hg clone https://hg.mozilla.org/releases/mozilla-release; -# Generates and extracts our branding to the source code, changing it from firefox to librewolf -../scripts/generate_icons.sh; -cp -r ../source_files/* mozilla-release; +# Copies our branding to the source code, changing it from firefox to librewolf +printf "\nCopying branding to firefox source code\n"; +cp -r $SCRIPT_FOLDER/resources/source_files/* mozilla-release; # Bootstraps, builds and packages librewolf cd mozilla-release; +printf "\nRunning bootstrapper to install build dependencies\n"; ./mach bootstrap --application-choice=browser --no-interactive; +printf "\nBuilding LibreWolf\n"; ./mach build; +printf "\nPackaging LibreWolf\n"; ./mach package; +cd $SCRIPT_FOLDER; -# POSTBUILD ####################################################################################### +printf "\n\n-------------------------------------- POSTBUILD --------------------------------------------\n"; # moves the packaged tarball to the main folder -cd ../../; -cp ./work_dir/mozilla-release/obj*/dist/librewolf*.tar.bz2 ./; +printf "\nRelocating binary tarball to script folder\n" +cp ./compile_folder/mozilla-release/obj*/dist/librewolf*.tar.bz2 ./; + +# Remove the compile folder +printf "\nDeleting the compile_folder\n"; +rm -rf ./compile_folder; + +printf "\n\n--------------------------------- SETTINGS INTEGRATION --------------------------------------\n"; # Adds the librefox config files to the packaged tarball -PACKAGE_FILE_NAME="librewolf*.tar.bz2"; +PACKAGE_FILE_NAME="librewolf*.tar.bz2\n"; +printf "\nExtracting librewolf binary tarball\n"; tar -xvf ./$PACKAGE_FILE_NAME; -cp -r ../settings/* ./librewolf; +printf "\nCopying librewolf settings to extracted binary tarball\n"; +cp -r $REPOSITORY_FOLDER/settings/* ./librewolf; +printf "\nRecompressing binary tarball\n"; tar -jcvf ./$PACKAGE_FILE_NAME librewolf; +printf "\nDeleting extracted binary tarball folder\n"; rm -rvf ./librewolf; -# Cleanup ######################################################################################### -# todo: remove work dir +# BUILD APP IMAGE ################################################################################# +# cp -r $BINARY_FOLDER ./app_image_build_folder +# Adds the librefox config files to the packaged tarball +# PACKAGE_FILE_NAME="librewolf*.tar.bz2"; +# tar -xvf ./$PACKAGE_FILE_NAME; +# cp -r ../settings/* ./librewolf; +# tar -jcvf ./$PACKAGE_FILE_NAME librewolf; +# rm -rvf ./librewolf; + diff --git a/browser/scripts/generate_icons.sh b/browser/scripts/generate_icons.sh deleted file mode 100755 index 2587296..0000000 --- a/browser/scripts/generate_icons.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -SRC_DIR=`dirname $0`; - -# update these if the location/name of this script, the main icon file or the branding folder changes -ICON_FILE_PATH=$SRC_DIR/../../branding/icon/icon.svg; -BRANDING_FOLDER_PATH=$SRC_DIR/../source_files/browser/branding/librewolf; - -# generate icons and moves them to the branding folder -echo Generating icons from $ICON_FILE_PATH and moving to $BRANDING_FOLDER_PATH; - -# Linux Icons -inkscape --without-gui --file=$ICON_FILE_PATH --export-png=$BRANDING_FOLDER_PATH/default16.png --export-width=16 --export-height=16; -inkscape --without-gui --file=$ICON_FILE_PATH --export-png=$BRANDING_FOLDER_PATH/default32.png --export-width=32 --export-height=32; -inkscape --without-gui --file=$ICON_FILE_PATH --export-png=$BRANDING_FOLDER_PATH/default48.png --export-width=48 --export-height=48; -inkscape --without-gui --file=$ICON_FILE_PATH --export-png=$BRANDING_FOLDER_PATH/default64.png --export-width=64 --export-height=64; -inkscape --without-gui --file=$ICON_FILE_PATH --export-png=$BRANDING_FOLDER_PATH/default128.png --export-width=128 --export-height=128; - -# Windows Icons -inkscape --without-gui --file=$ICON_FILE_PATH --export-png=$BRANDING_FOLDER_PATH/VisualElements_70.png --export-width=70 --export-height=70; -inkscape --without-gui --file=$ICON_FILE_PATH --export-png=$BRANDING_FOLDER_PATH/VisualElements_150.png --export-width=150 --export-height=150; - -# Apple Icons