From fa28228acb472cd03855e546863ab6bd3dd5e772 Mon Sep 17 00:00:00 2001 From: abaevbog Date: Tue, 9 May 2023 05:41:27 -0400 Subject: [PATCH] Automatically run fetch_xulrunner if xulrunner is missing or out of date (#3111) --- app/build.sh | 47 +++++++++++++++++++++++++++++++++++++ app/scripts/fetch_xulrunner | 4 +++- app/scripts/xulrunner_hash | 43 +++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100755 app/scripts/xulrunner_hash diff --git a/app/build.sh b/app/build.sh index d5f0c875c7..6f22a389a9 100755 --- a/app/build.sh +++ b/app/build.sh @@ -110,6 +110,53 @@ while getopts "d:f:p:c:tseq" opt; do shift $((OPTIND-1)); OPTIND=1 done +function check_xulrunner_hash { + platform=$1 + + if [ $platform == "m" ]; then + platform_hash_file="hash-mac" + elif [ $platform == "w" ]; then + platform_hash_file="hash-win" + elif [ $platform == "l" ]; then + platform_hash_file="hash-linux" + else + echo "Platform parameter incorrect. Acceptable values: m/w/l" + exit 1 + fi + + if [ ! -e "$CALLDIR/xulrunner/$platform_hash_file" ]; then + echo "xulrunner not found -- downloading" + echo + $CALLDIR/scripts/fetch_xulrunner -p $platform + else + recalculated_xulrunner_hash=$($CALLDIR/scripts/xulrunner_hash -p $platform) + current_xulrunner_hash=$(< "$CALLDIR/xulrunner/$platform_hash_file") + if [ "$current_xulrunner_hash" != "$recalculated_xulrunner_hash" ]; then + echo "xulrunner hashes don't match -- redownloading" + echo + $CALLDIR/scripts/fetch_xulrunner -p $platform + current_xulrunner_hash=$(< "$CALLDIR/xulrunner/$platform_hash_file") + if [ "$current_xulrunner_hash" != "$recalculated_xulrunner_hash" ]; then + echo "xulrunner hashes don't match after running fetch_xulrunner!" + exit 1 + fi + fi + fi +} + +#Check if xulrunner and GECKO_VERSION for each platform match +if [ $BUILD_MAC == 1 ]; then + check_xulrunner_hash m +fi +if [ $BUILD_WIN == 1 ]; then + check_xulrunner_hash w +fi +if [ $BUILD_LINUX == 1 ]; then + check_xulrunner_hash l +fi + + + # Require source dir or ZIP file if [[ -z "$SOURCE_DIR" ]] && [[ -z "$ZIP_FILE" ]]; then usage diff --git a/app/scripts/fetch_xulrunner b/app/scripts/fetch_xulrunner index f2dc38428a..32d629d711 100755 --- a/app/scripts/fetch_xulrunner +++ b/app/scripts/fetch_xulrunner @@ -347,6 +347,7 @@ if [ $BUILD_MAC == 1 ]; then #if [ ! -e "Firefox $GECKO_VERSION MacOS.zip" ]; then # rm "MacOS.zip" #fi + echo $($SCRIPT_DIR/xulrunner_hash -p m) > hash-mac fi if [ $BUILD_WIN == 1 ]; then @@ -374,6 +375,7 @@ if [ $BUILD_WIN == 1 ]; then echo echo done + echo $($SCRIPT_DIR/xulrunner_hash -p w) > hash-win fi if [ $BUILD_LINUX == 1 ]; then @@ -404,7 +406,7 @@ if [ $BUILD_LINUX == 1 ]; then pushd firefox-x86_64 modify_omni linux64 popd - + echo $($SCRIPT_DIR/xulrunner_hash -p l) > hash-linux rm "firefox-$GECKO_VERSION.tar.bz2" fi diff --git a/app/scripts/xulrunner_hash b/app/scripts/xulrunner_hash new file mode 100755 index 0000000000..dd9149beea --- /dev/null +++ b/app/scripts/xulrunner_hash @@ -0,0 +1,43 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +APP_ROOT_DIR="$(dirname "$SCRIPT_DIR")" +. "$APP_ROOT_DIR/config.sh" +cd "$APP_ROOT_DIR" + +platform="" +while getopts ":p:" opt; do + case $opt in + p) + platform="$OPTARG" + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + + +if [ $platform == "m" ]; then + GECKO_VERSION="$GECKO_VERSION_MAC" +elif [ $platform == "w" ]; then + GECKO_VERSION="$GECKO_VERSION_WIN" +elif [ $platform == "l" ]; then + GECKO_VERSION="$GECKO_VERSION_LINUX" +else + echo "Platform parameter incorrect. Usage: -p m(mac)/w(windows)/l(linux)" + exit 1 +fi + +xulrunner_content=$(< "$SCRIPT_DIR/fetch_xulrunner") +xulrunner_gecko_hash=$(echo -n "$GECKO_VERSION - $xulrunner_content" | openssl dgst -sha256) + +echo "$xulrunner_gecko_hash" + +