chore: quote all bash variables when used (#8066)

This way bash won't expand and post-process variable values in any way.
The changes are driven with
[`shellcheck`](https://github.com/koalaman/shellcheck)
This commit is contained in:
Andrey Lushnikov 2021-08-07 15:32:18 +03:00 committed by GitHub
parent 513a16266a
commit b1b4d7b819
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 115 additions and 115 deletions

View file

@ -4,7 +4,7 @@ set +x
set -o pipefail set -o pipefail
if [[ ($1 == '--help') || ($1 == '-h') ]]; then if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo "usage: $(basename $0) [firefox-linux|firefox-win32|firefox-win64|webkit-gtk|webkit-wpe|webkit-gtk-wpe|webkit-win64|webkit-mac-10.14|webkit-mac-10.15] [-f|--force]" echo "usage: $(basename "$0") [firefox-linux|firefox-win32|firefox-win64|webkit-gtk|webkit-wpe|webkit-gtk-wpe|webkit-win64|webkit-mac-10.14|webkit-mac-10.15] [-f|--force]"
echo echo
echo "Prepares checkout under browser folder, applies patches, builds, archives, and uploads if build is missing." echo "Prepares checkout under browser folder, applies patches, builds, archives, and uploads if build is missing."
echo "Script will bail out early if the build for the browser version is already present." echo "Script will bail out early if the build for the browser version is already present."
@ -17,7 +17,7 @@ fi
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
echo "missing build flavor!" echo "missing build flavor!"
echo "try './$(basename $0) --help' for more information" echo "try './$(basename "$0") --help' for more information"
exit 1 exit 1
fi fi
@ -354,7 +354,7 @@ else
LOG_PATH="/tmp/log-$BROWSER_NAME.zip" LOG_PATH="/tmp/log-$BROWSER_NAME.zip"
fi fi
if [[ -f $ZIP_PATH ]]; then if [[ -f "$ZIP_PATH" ]]; then
echo "Archive $ZIP_PATH already exists - remove and re-run the script." echo "Archive $ZIP_PATH already exists - remove and re-run the script."
exit 1 exit 1
fi fi
@ -392,12 +392,12 @@ function generate_and_upload_browser_build {
fi fi
echo "-- archiving to $ZIP_PATH" echo "-- archiving to $ZIP_PATH"
if ! ./$BROWSER_NAME/archive.sh $ZIP_PATH "$EXTRA_ARCHIVE_ARGS"; then if ! ./$BROWSER_NAME/archive.sh "$ZIP_PATH" "$EXTRA_ARCHIVE_ARGS"; then
return 23 return 23
fi fi
echo "-- uploading" echo "-- uploading"
if ! ./upload.sh $BUILD_BLOB_PATH $ZIP_PATH; then if ! ./upload.sh "$BUILD_BLOB_PATH" "$ZIP_PATH"; then
return 24 return 24
fi fi
return 0 return 0
@ -419,7 +419,7 @@ if generate_and_upload_browser_build 2>&1 | ./sanitize_and_compress_log.js $LOG_
( (
for i in $(cat "${BROWSER_NAME}/${BUILDS_LIST}"); do for i in $(cat "${BROWSER_NAME}/${BUILDS_LIST}"); do
URL="https://playwright2.blob.core.windows.net/builds/${BROWSER_NAME}/${BUILD_NUMBER}/$i" URL="https://playwright2.blob.core.windows.net/builds/${BROWSER_NAME}/${BUILD_NUMBER}/$i"
if ! [[ $(curl -s -L -I $URL | head -1 | cut -f2 -d' ') == 200 ]]; then if ! [[ $(curl -s -L -I "$URL" | head -1 | cut -f2 -d' ') == 200 ]]; then
# Exit subshell # Exit subshell
echo "Missing build at ${URL}" echo "Missing build at ${URL}"
exit exit
@ -448,7 +448,7 @@ else
FAILED_STEP="<unknown step>" FAILED_STEP="<unknown step>"
fi fi
# Upload logs only in case of failure and report failure. # Upload logs only in case of failure and report failure.
./upload.sh ${LOG_BLOB_PATH} ${LOG_PATH} || true ./upload.sh "${LOG_BLOB_PATH}" ${LOG_PATH} || true
send_telegram_message "$BUILD_ALIAS -- ${FAILED_STEP} failed! ❌ <a href='https://playwright.azureedge.net/builds/${LOG_BLOB_PATH}'>${LOG_BLOB_NAME}</a>" send_telegram_message "$BUILD_ALIAS -- ${FAILED_STEP} failed! ❌ <a href='https://playwright.azureedge.net/builds/${LOG_BLOB_PATH}'>${LOG_BLOB_NAME}</a>"
exit 1 exit 1
fi fi

View file

@ -3,12 +3,12 @@ set -e
set +x set +x
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
SCRIPT_PATH=$(pwd -P) SCRIPT_PATH=$(pwd -P)
main() { main() {
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
echo "usage: $(basename $0) [output-absolute-path]" echo "usage: $(basename "$0") [output-absolute-path]"
echo echo
echo "Generate distributable .zip archive from ./output folder that was previously downloaded." echo "Generate distributable .zip archive from ./output folder that was previously downloaded."
echo echo
@ -29,7 +29,7 @@ main() {
echo "ERROR: path $ZIP_PATH exists; can't do anything." echo "ERROR: path $ZIP_PATH exists; can't do anything."
exit 1 exit 1
fi fi
if ! [[ -d $(dirname $ZIP_PATH) ]]; then if ! [[ -d $(dirname "$ZIP_PATH") ]]; then
echo "ERROR: folder for path $($ZIP_PATH) does not exist." echo "ERROR: folder for path $($ZIP_PATH) does not exist."
exit 1 exit 1
fi fi
@ -45,7 +45,7 @@ main() {
fi fi
cd "${SCRIPT_PATH}" cd "${SCRIPT_PATH}"
cp output/build.zip $ZIP_PATH cp output/build.zip "$ZIP_PATH"
} }
function archive_compiled_chromium() { function archive_compiled_chromium() {

View file

@ -3,10 +3,10 @@ set -e
set +x set +x
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
USAGE=$(cat<<EOF USAGE=$(cat<<EOF
usage: $(basename $0) [--mirror|--mirror-linux|--mirror-win32|--mirror-win64|--mirror-mac|--compile-mac-arm64|--compile-linux|--compile-win32|--compile-win64|--compile-mac] usage: $(basename "$0") [--mirror|--mirror-linux|--mirror-win32|--mirror-win64|--mirror-mac|--compile-mac-arm64|--compile-linux|--compile-win32|--compile-win64|--compile-mac]
Either compiles chromium or mirrors it from Chromium Continuous Builds CDN. Either compiles chromium or mirrors it from Chromium Continuous Builds CDN.
EOF EOF
@ -20,9 +20,9 @@ main() {
echo "$USAGE" echo "$USAGE"
exit 0 exit 0
elif [[ $1 == "--mirror"* ]]; then elif [[ $1 == "--mirror"* ]]; then
mirror_chromium $1 mirror_chromium "$1"
elif [[ $1 == "--compile"* ]]; then elif [[ $1 == "--compile"* ]]; then
compile_chromium $1 compile_chromium "$1"
else else
echo "ERROR: unknown first argument. Use --help for details." echo "ERROR: unknown first argument. Use --help for details."
exit 1 exit 1
@ -82,9 +82,9 @@ compile_chromium() {
if [[ $1 == "--compile-win"* ]]; then if [[ $1 == "--compile-win"* ]]; then
if [[ -z "$USE_GOMA" ]]; then if [[ -z "$USE_GOMA" ]]; then
/c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_FOLDER}/buildwin.bat)" /c/Windows/System32/cmd.exe "/c $(cygpath -w "${SCRIPT_FOLDER}"/buildwin.bat)"
else else
/c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_FOLDER}/buildwingoma.bat)" /c/Windows/System32/cmd.exe "/c $(cygpath -w "${SCRIPT_FOLDER}"/buildwingoma.bat)"
fi fi
else else
gn gen out/Default gn gen out/Default
@ -144,4 +144,4 @@ mirror_chromium() {
unzip chromium-upstream.zip unzip chromium-upstream.zip
} }
main $1 main "$1"

View file

@ -3,7 +3,7 @@ set -e
set +x set +x
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
rm -rf output rm -rf output
if [[ ! -z "${CR_CHECKOUT_PATH}" ]]; then if [[ ! -z "${CR_CHECKOUT_PATH}" ]]; then

View file

@ -3,7 +3,7 @@ set -e
set -x set -x
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
if [[ ! -d ./electron-build-tools ]]; then if [[ ! -d ./electron-build-tools ]]; then
git clone --single-branch --branch master https://github.com/electron/build-tools/ electron-build-tools git clone --single-branch --branch master https://github.com/electron/build-tools/ electron-build-tools
@ -19,7 +19,7 @@ cd electron-build-tools/third_party/goma
export GOMA_START_COMPILER_PROXY=true export GOMA_START_COMPILER_PROXY=true
if [[ $1 == "--help" ]]; then if [[ $1 == "--help" ]]; then
echo "$(basename $0) [login|start|stop|--help]" echo "$(basename "$0") [login|start|stop|--help]"
exit 0 exit 0
elif [[ $1 == "login" ]]; then elif [[ $1 == "login" ]]; then
if [[ $(uname) == "MINGW"* ]]; then if [[ $(uname) == "MINGW"* ]]; then
@ -35,7 +35,7 @@ elif [[ $1 == "start" ]]; then
fi fi
if [[ ! -f "$HOME/.goma_oauth2_config" ]]; then if [[ ! -f "$HOME/.goma_oauth2_config" ]]; then
echo "ERROR: goma is not logged in!" echo "ERROR: goma is not logged in!"
echo "run '$(basename $0) login'" echo "run '$(basename "$0") login'"
exit 1 exit 1
fi fi
if [[ $(uname) == "MINGW"* ]]; then if [[ $(uname) == "MINGW"* ]]; then

View file

@ -110,16 +110,16 @@ else
fi fi
# Switch to git repository. # Switch to git repository.
cd $CHECKOUT_PATH cd "$CHECKOUT_PATH"
# Setting up |$REMOTE_BROWSER_UPSTREAM| remote and fetch the $BASE_BRANCH # Setting up |$REMOTE_BROWSER_UPSTREAM| remote and fetch the $BASE_BRANCH
if git remote get-url $REMOTE_BROWSER_UPSTREAM >/dev/null; then if git remote get-url $REMOTE_BROWSER_UPSTREAM >/dev/null; then
if ! [[ $(git config --get remote.$REMOTE_BROWSER_UPSTREAM.url || echo "") == "$REMOTE_URL" ]]; then if ! [[ $(git config --get remote.$REMOTE_BROWSER_UPSTREAM.url || echo "") == "$REMOTE_URL" ]]; then
echo "ERROR: remote $REMOTE_BROWSER_UPSTREAM is not pointing to '$REMOTE_URL'! run `prepare_checkout.sh` first" echo "ERROR: remote $REMOTE_BROWSER_UPSTREAM is not pointing to '$REMOTE_URL'! run 'prepare_checkout.sh' first"
exit 1 exit 1
fi fi
else else
echo "ERROR: checkout does not have $REMOTE_BROWSER_UPSTREAM; run `prepare_checkout.sh` first" echo "ERROR: checkout does not have $REMOTE_BROWSER_UPSTREAM; run 'prepare_checkout.sh' first"
exit 1 exit 1
fi fi
@ -131,17 +131,17 @@ else
echo "-- checking $FRIENDLY_CHECKOUT_PATH is clean - OK" echo "-- checking $FRIENDLY_CHECKOUT_PATH is clean - OK"
fi fi
PATCH_NAME=$(ls -1 $EXPORT_PATH/patches) PATCH_NAME=$(ls -1 "$EXPORT_PATH"/patches)
if [[ -z "$PATCH_NAME" ]]; then if [[ -z "$PATCH_NAME" ]]; then
PATCH_NAME="bootstrap.diff" PATCH_NAME="bootstrap.diff"
OLD_DIFF="" OLD_DIFF=""
else else
OLD_DIFF=$(cat $EXPORT_PATH/patches/$PATCH_NAME) OLD_DIFF=$(cat "$EXPORT_PATH"/patches/$PATCH_NAME)
fi fi
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
NEW_BASE_REVISION=$(git merge-base $REMOTE_BROWSER_UPSTREAM/$BASE_BRANCH $CURRENT_BRANCH) NEW_BASE_REVISION=$(git merge-base $REMOTE_BROWSER_UPSTREAM/"$BASE_BRANCH" "$CURRENT_BRANCH")
NEW_DIFF=$(git diff --diff-algorithm=myers --full-index $NEW_BASE_REVISION $CURRENT_BRANCH -- . ":!${EXTRA_FOLDER_CHECKOUT_RELPATH}") NEW_DIFF=$(git diff --diff-algorithm=myers --full-index "$NEW_BASE_REVISION" "$CURRENT_BRANCH" -- . ":!${EXTRA_FOLDER_CHECKOUT_RELPATH}")
# Increment BUILD_NUMBER # Increment BUILD_NUMBER
BUILD_NUMBER=$(curl ${BUILD_NUMBER_UPSTREAM_URL} | head -1) BUILD_NUMBER=$(curl ${BUILD_NUMBER_UPSTREAM_URL} | head -1)
@ -149,10 +149,10 @@ BUILD_NUMBER=$((BUILD_NUMBER+1))
echo "REMOTE_URL=\"$REMOTE_URL\" echo "REMOTE_URL=\"$REMOTE_URL\"
BASE_BRANCH=\"$BASE_BRANCH\" BASE_BRANCH=\"$BASE_BRANCH\"
BASE_REVISION=\"$NEW_BASE_REVISION\"" > $EXPORT_PATH/UPSTREAM_CONFIG.sh BASE_REVISION=\"$NEW_BASE_REVISION\"" > "$EXPORT_PATH"/UPSTREAM_CONFIG.sh
echo "$NEW_DIFF" > $EXPORT_PATH/patches/$PATCH_NAME echo "$NEW_DIFF" > "$EXPORT_PATH"/patches/$PATCH_NAME
echo $BUILD_NUMBER > $EXPORT_PATH/BUILD_NUMBER echo $BUILD_NUMBER > "$EXPORT_PATH"/BUILD_NUMBER
echo "Changed: $(git config user.email) $(date)" >> $EXPORT_PATH/BUILD_NUMBER echo "Changed: $(git config user.email) $(date)" >> "$EXPORT_PATH"/BUILD_NUMBER
echo "-- exporting standalone folder" echo "-- exporting standalone folder"
rm -rf "${EXTRA_FOLDER_PW_PATH}" rm -rf "${EXTRA_FOLDER_PW_PATH}"

View file

@ -3,7 +3,7 @@ set -e
set +x set +x
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
echo "usage: $(basename $0) [output-absolute-path]" echo "usage: $(basename "$0") [output-absolute-path]"
echo echo
echo "Generate distributable .zip archive from ./checkout folder that was previously built." echo "Generate distributable .zip archive from ./checkout folder that was previously built."
echo echo
@ -23,13 +23,13 @@ if [[ -f $ZIP_PATH ]]; then
echo "ERROR: path $ZIP_PATH exists; can't do anything." echo "ERROR: path $ZIP_PATH exists; can't do anything."
exit 1 exit 1
fi fi
if ! [[ -d $(dirname $ZIP_PATH) ]]; then if ! [[ -d $(dirname "$ZIP_PATH") ]]; then
echo "ERROR: folder for path $($ZIP_PATH) does not exist." echo "ERROR: folder for path $($ZIP_PATH) does not exist."
exit 1 exit 1
fi fi
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
SCRIPT_FOLDER="$(pwd -P)" SCRIPT_FOLDER="$(pwd -P)"
if [[ ! -z "${FF_CHECKOUT_PATH}" ]]; then if [[ ! -z "${FF_CHECKOUT_PATH}" ]]; then
@ -42,7 +42,7 @@ fi
OBJ_FOLDER="obj-build-playwright" OBJ_FOLDER="obj-build-playwright"
./mach package ./mach package
node "${SCRIPT_FOLDER}"/install-preferences.js $PWD/$OBJ_FOLDER/dist/firefox node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/$OBJ_FOLDER/dist/firefox
if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then
echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?" echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?"
@ -57,4 +57,4 @@ fi
# tar resulting directory and cleanup TMP. # tar resulting directory and cleanup TMP.
cd $OBJ_FOLDER/dist cd $OBJ_FOLDER/dist
zip -r $ZIP_PATH firefox zip -r "$ZIP_PATH" firefox

View file

@ -11,7 +11,7 @@ XCODE_VERSION_WITH_REQUIRED_SDK_VERSION="8.3.3"
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
SCRIPT_FOLDER="$(pwd -P)" SCRIPT_FOLDER="$(pwd -P)"
source "${SCRIPT_FOLDER}/../utils.sh" source "${SCRIPT_FOLDER}/../utils.sh"
@ -118,8 +118,8 @@ if [[ $1 == "--juggler" ]]; then
fi fi
if [[ "$(uname)" == "Darwin" ]]; then if [[ "$(uname)" == "Darwin" ]]; then
node "${SCRIPT_FOLDER}"/install-preferences.js $PWD/${OBJ_FOLDER}/dist node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist
else else
node "${SCRIPT_FOLDER}"/install-preferences.js $PWD/${OBJ_FOLDER}/dist/bin node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist/bin
fi fi

View file

@ -7,7 +7,7 @@ if [[ ! -z "${FF_CHECKOUT_PATH}" ]]; then
cd "${FF_CHECKOUT_PATH}" cd "${FF_CHECKOUT_PATH}"
echo "WARNING: checkout path from FF_CHECKOUT_PATH env: ${FF_CHECKOUT_PATH}" echo "WARNING: checkout path from FF_CHECKOUT_PATH env: ${FF_CHECKOUT_PATH}"
else else
cd "$(dirname $0)" cd "$(dirname "$0")"
cd "../firefox/checkout" cd "../firefox/checkout"
fi fi

View file

@ -3,7 +3,7 @@ set -e
set +x set +x
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
echo "usage: $(basename $0) [output-absolute-path]" echo "usage: $(basename "$0") [output-absolute-path]"
echo echo
echo "Generate distributable .zip archive from ./checkout folder that was previously built." echo "Generate distributable .zip archive from ./checkout folder that was previously built."
echo echo
@ -23,13 +23,13 @@ if [[ -f $ZIP_PATH ]]; then
echo "ERROR: path $ZIP_PATH exists; can't do anything." echo "ERROR: path $ZIP_PATH exists; can't do anything."
exit 1 exit 1
fi fi
if ! [[ -d $(dirname $ZIP_PATH) ]]; then if ! [[ -d $(dirname "$ZIP_PATH") ]]; then
echo "ERROR: folder for path $($ZIP_PATH) does not exist." echo "ERROR: folder for path $($ZIP_PATH) does not exist."
exit 1 exit 1
fi fi
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
SCRIPT_FOLDER="$(pwd -P)" SCRIPT_FOLDER="$(pwd -P)"
if [[ ! -z "${FF_CHECKOUT_PATH}" ]]; then if [[ ! -z "${FF_CHECKOUT_PATH}" ]]; then
@ -42,7 +42,7 @@ fi
OBJ_FOLDER="obj-build-playwright" OBJ_FOLDER="obj-build-playwright"
./mach package ./mach package
node "${SCRIPT_FOLDER}"/install-preferences.js $PWD/$OBJ_FOLDER/dist/firefox node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/$OBJ_FOLDER/dist/firefox
if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then
echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?" echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?"
@ -57,4 +57,4 @@ fi
# tar resulting directory and cleanup TMP. # tar resulting directory and cleanup TMP.
cd $OBJ_FOLDER/dist cd $OBJ_FOLDER/dist
zip -r $ZIP_PATH firefox zip -r "$ZIP_PATH" firefox

View file

@ -11,7 +11,7 @@ XCODE_VERSION_WITH_REQUIRED_SDK_VERSION="8.3.3"
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
SCRIPT_FOLDER="$(pwd -P)" SCRIPT_FOLDER="$(pwd -P)"
source "${SCRIPT_FOLDER}/../utils.sh" source "${SCRIPT_FOLDER}/../utils.sh"
@ -118,8 +118,8 @@ if [[ $1 == "--juggler" ]]; then
fi fi
if [[ "$(uname)" == "Darwin" ]]; then if [[ "$(uname)" == "Darwin" ]]; then
node "${SCRIPT_FOLDER}"/install-preferences.js $PWD/${OBJ_FOLDER}/dist node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist
else else
node "${SCRIPT_FOLDER}"/install-preferences.js $PWD/${OBJ_FOLDER}/dist/bin node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist/bin
fi fi

View file

@ -7,7 +7,7 @@ if [[ ! -z "${FF_CHECKOUT_PATH}" ]]; then
cd "${FF_CHECKOUT_PATH}" cd "${FF_CHECKOUT_PATH}"
echo "WARNING: checkout path from FF_CHECKOUT_PATH env: ${FF_CHECKOUT_PATH}" echo "WARNING: checkout path from FF_CHECKOUT_PATH env: ${FF_CHECKOUT_PATH}"
else else
cd "$(dirname $0)" cd "$(dirname "$0")"
cd "checkout" cd "checkout"
fi fi

View file

@ -10,7 +10,7 @@ REMOTE_BROWSER_UPSTREAM="browser_upstream"
BUILD_BRANCH="playwright-build" BUILD_BRANCH="playwright-build"
if [[ ($1 == '--help') || ($1 == '-h') ]]; then if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo "usage: $(basename $0) [firefox|firefox-beta|webkit] [custom_checkout_path]" echo "usage: $(basename "$0") [firefox|firefox-beta|webkit] [custom_checkout_path]"
echo echo
echo "Prepares browser checkout. The checkout is a GIT repository that:" echo "Prepares browser checkout. The checkout is a GIT repository that:"
echo "- has a '$REMOTE_BROWSER_UPSTREAM' remote pointing to a REMOTE_URL from UPSTREAM_CONFIG.sh" echo "- has a '$REMOTE_BROWSER_UPSTREAM' remote pointing to a REMOTE_URL from UPSTREAM_CONFIG.sh"
@ -23,7 +23,7 @@ fi
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
echo "missing browser: 'firefox' or 'webkit'" echo "missing browser: 'firefox' or 'webkit'"
echo "try './$(basename $0) --help' for more information" echo "try './$(basename "$0") --help' for more information"
exit 1 exit 1
fi fi
@ -139,11 +139,11 @@ if ! [[ -d $CHECKOUT_PATH ]]; then
echo "-- $FRIENDLY_CHECKOUT_PATH is missing - checking out.." echo "-- $FRIENDLY_CHECKOUT_PATH is missing - checking out.."
if [[ -n "$CI" ]]; then if [[ -n "$CI" ]]; then
# In CI environment, we re-checkout constantly, so we do a shallow checkout to save time. # In CI environment, we re-checkout constantly, so we do a shallow checkout to save time.
git clone --single-branch --depth 1 --branch $BASE_BRANCH $REMOTE_URL $CHECKOUT_PATH git clone --single-branch --depth 1 --branch "$BASE_BRANCH" "$REMOTE_URL" "$CHECKOUT_PATH"
else else
# In non-CI environment, do a full checkout. This takes time, # In non-CI environment, do a full checkout. This takes time,
# but liberates from the `git fetch --unshallow`. # but liberates from the `git fetch --unshallow`.
git clone --single-branch --branch $BASE_BRANCH $REMOTE_URL $CHECKOUT_PATH git clone --single-branch --branch "$BASE_BRANCH" "$REMOTE_URL" "$CHECKOUT_PATH"
fi fi
else else
echo "-- checking $FRIENDLY_CHECKOUT_PATH folder - OK" echo "-- checking $FRIENDLY_CHECKOUT_PATH folder - OK"
@ -158,7 +158,7 @@ else
fi fi
# ============== SETTING UP GIT REPOSITORY ============== # ============== SETTING UP GIT REPOSITORY ==============
cd $CHECKOUT_PATH cd "$CHECKOUT_PATH"
# Bail out if git repo is dirty. # Bail out if git repo is dirty.
if [[ -n $(git status -s --untracked-files=no) ]]; then if [[ -n $(git status -s --untracked-files=no) ]]; then
@ -169,7 +169,7 @@ fi
# Setting up |$REMOTE_BROWSER_UPSTREAM| remote and fetch the $BASE_BRANCH # Setting up |$REMOTE_BROWSER_UPSTREAM| remote and fetch the $BASE_BRANCH
if git remote get-url $REMOTE_BROWSER_UPSTREAM >/dev/null; then if git remote get-url $REMOTE_BROWSER_UPSTREAM >/dev/null; then
echo "-- setting |$REMOTE_BROWSER_UPSTREAM| remote url to $REMOTE_URL" echo "-- setting |$REMOTE_BROWSER_UPSTREAM| remote url to $REMOTE_URL"
git remote set-url $REMOTE_BROWSER_UPSTREAM $REMOTE_URL git remote set-url $REMOTE_BROWSER_UPSTREAM "$REMOTE_URL"
else else
echo "-- adding |$REMOTE_BROWSER_UPSTREAM| remote to $REMOTE_URL" echo "-- adding |$REMOTE_BROWSER_UPSTREAM| remote to $REMOTE_URL"
git remote rename origin $REMOTE_BROWSER_UPSTREAM git remote rename origin $REMOTE_BROWSER_UPSTREAM
@ -179,7 +179,7 @@ fi
# If not, fetch from REMOTE_BROWSER_UPSTREAM and slowly fetch more and more commits # If not, fetch from REMOTE_BROWSER_UPSTREAM and slowly fetch more and more commits
# until we find $BASE_REVISION. # until we find $BASE_REVISION.
# This technique allows us start with a shallow clone. # This technique allows us start with a shallow clone.
if ! git cat-file -e $BASE_REVISION^{commit} 2>/dev/null; then if ! git cat-file -e "$BASE_REVISION"^{commit} 2>/dev/null; then
# Detach git head so that we can fetch into branch. # Detach git head so that we can fetch into branch.
git checkout --detach >/dev/null 2>/dev/null git checkout --detach >/dev/null 2>/dev/null
@ -188,9 +188,9 @@ if ! git cat-file -e $BASE_REVISION^{commit} 2>/dev/null; then
SUCCESS="no" SUCCESS="no"
while (( FETCH_DEPTH <= 8192 )); do while (( FETCH_DEPTH <= 8192 )); do
echo "Fetching ${FETCH_DEPTH} commits to find base revision..." echo "Fetching ${FETCH_DEPTH} commits to find base revision..."
git fetch --depth "${FETCH_DEPTH}" $REMOTE_BROWSER_UPSTREAM $BASE_BRANCH git fetch --depth "${FETCH_DEPTH}" $REMOTE_BROWSER_UPSTREAM "$BASE_BRANCH"
FETCH_DEPTH=$(( FETCH_DEPTH * 2 )); FETCH_DEPTH=$(( FETCH_DEPTH * 2 ));
if git cat-file -e $BASE_REVISION^{commit} >/dev/null; then if git cat-file -e "$BASE_REVISION"^{commit} >/dev/null; then
SUCCESS="yes" SUCCESS="yes"
break; break;
fi fi
@ -204,7 +204,7 @@ fi
echo "-- checking $FRIENDLY_CHECKOUT_PATH repo has BASE_REVISION (@$BASE_REVISION) commit - OK" echo "-- checking $FRIENDLY_CHECKOUT_PATH repo has BASE_REVISION (@$BASE_REVISION) commit - OK"
# Check out the $BASE_REVISION # Check out the $BASE_REVISION
git checkout $BASE_REVISION git checkout "$BASE_REVISION"
# Create a playwright-build branch and apply all the patches to it. # Create a playwright-build branch and apply all the patches to it.
if git show-ref --verify --quiet refs/heads/playwright-build; then if git show-ref --verify --quiet refs/heads/playwright-build; then
@ -212,7 +212,7 @@ if git show-ref --verify --quiet refs/heads/playwright-build; then
fi fi
git checkout -b playwright-build git checkout -b playwright-build
echo "-- applying patches" echo "-- applying patches"
git apply --index --whitespace=nowarn $PATCHES_PATH/* git apply --index --whitespace=nowarn "$PATCHES_PATH"/*
if [[ ! -z "${WEBKIT_EXTRA_FOLDER_PATH}" ]]; then if [[ ! -z "${WEBKIT_EXTRA_FOLDER_PATH}" ]]; then
echo "-- adding WebKit embedders" echo "-- adding WebKit embedders"
@ -222,8 +222,8 @@ if [[ ! -z "${WEBKIT_EXTRA_FOLDER_PATH}" ]]; then
echo "ERROR: $EMBEDDER_DIR already exists! Remove it and re-run the script." echo "ERROR: $EMBEDDER_DIR already exists! Remove it and re-run the script."
exit 1 exit 1
fi fi
cp -r "${WEBKIT_EXTRA_FOLDER_PATH}" $EMBEDDER_DIR cp -r "${WEBKIT_EXTRA_FOLDER_PATH}" "$EMBEDDER_DIR"
git add $EMBEDDER_DIR git add "$EMBEDDER_DIR"
elif [[ ! -z "${FIREFOX_EXTRA_FOLDER_PATH}" ]]; then elif [[ ! -z "${FIREFOX_EXTRA_FOLDER_PATH}" ]]; then
echo "-- adding juggler" echo "-- adding juggler"
EMBEDDER_DIR="$PWD/juggler" EMBEDDER_DIR="$PWD/juggler"
@ -232,8 +232,8 @@ elif [[ ! -z "${FIREFOX_EXTRA_FOLDER_PATH}" ]]; then
echo "ERROR: $EMBEDDER_DIR already exists! Remove it and re-run the script." echo "ERROR: $EMBEDDER_DIR already exists! Remove it and re-run the script."
exit 1 exit 1
fi fi
cp -r "${FIREFOX_EXTRA_FOLDER_PATH}" $EMBEDDER_DIR cp -r "${FIREFOX_EXTRA_FOLDER_PATH}" "$EMBEDDER_DIR"
git add $EMBEDDER_DIR git add "$EMBEDDER_DIR"
fi fi
git commit -a --author="playwright-devops <devops@playwright.dev>" -m "chore($1): bootstrap build #$BUILD_NUMBER" git commit -a --author="playwright-devops <devops@playwright.dev>" -m "chore($1): bootstrap build #$BUILD_NUMBER"

View file

@ -10,5 +10,5 @@ send_telegram_message() {
-X POST \ -X POST \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{"disable_web_page_preview": true, "chat_id": "-1001225613794", "parse_mode": "html", "text": "'"$TEXT"'", "disable_notification": false}' \ -d '{"disable_web_page_preview": true, "chat_id": "-1001225613794", "parse_mode": "html", "text": "'"$TEXT"'", "disable_notification": false}' \
https://api.telegram.org/bot$TELEGRAM_BOT_KEY/sendMessage >/dev/null https://api.telegram.org/bot"$TELEGRAM_BOT_KEY"/sendMessage >/dev/null
} }

View file

@ -6,9 +6,9 @@ trap "cd $(pwd -P)" EXIT
cd "$(dirname "$0")" cd "$(dirname "$0")"
if [[ ($1 == '--help') || ($1 == '-h') ]]; then if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo "usage: $(basename $0) [BLOB-PATH] [--check|ZIP-PATH]" echo "usage: $(basename "$0") [BLOB-PATH] [--check|ZIP-PATH]"
echo echo
echo "Upload ZIP-PATH to BLOB-PATH in `builds` container." echo "Upload ZIP-PATH to BLOB-PATH in 'builds' container."
echo echo
echo "--check pass |--check| as a second parameter instead of a zip-path to check for" echo "--check pass |--check| as a second parameter instead of a zip-path to check for"
echo " existance of BLOB-PATH" echo " existance of BLOB-PATH"
@ -27,7 +27,7 @@ fi
if [[ $# < 2 ]]; then if [[ $# < 2 ]]; then
echo "not enought arguments!" echo "not enought arguments!"
echo "try '$(basename $0) --help' for more information" echo "try '$(basename "$0") --help' for more information"
exit 1 exit 1
fi fi
@ -35,7 +35,7 @@ BLOB_PATH="$1"
ZIP_PATH="$2" ZIP_PATH="$2"
if [[ ("$2" == '--check') ]]; then if [[ ("$2" == '--check') ]]; then
EXISTS=$(az storage blob exists -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -n "$BLOB_PATH" --query "exists") EXISTS=$(az storage blob exists -c builds --account-key "$AZ_ACCOUNT_KEY" --account-name "$AZ_ACCOUNT_NAME" -n "$BLOB_PATH" --query "exists")
if [[ $EXISTS == "true" ]]; then if [[ $EXISTS == "true" ]]; then
exit 0 exit 0
else else
@ -53,11 +53,11 @@ if [[ "${ZIP_PATH}" != *.zip && "${ZIP_PATH}" != *.gz ]]; then
fi fi
if [[ $(uname) == MINGW* ]]; then if [[ $(uname) == MINGW* ]]; then
# Convert POSIX path to MSYS # Convert POSIX path to MSYS
WIN_PATH=$({ cd $(dirname $ZIP_PATH) && pwd -W; } | sed 's|/|\\|g') WIN_PATH=$({ cd $(dirname "$ZIP_PATH") && pwd -W; } | sed 's|/|\\|g')
WIN_PATH="${WIN_PATH}\\$(basename $ZIP_PATH)" WIN_PATH="${WIN_PATH}\\$(basename "$ZIP_PATH")"
az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $WIN_PATH -n $BLOB_PATH az storage blob upload -c builds --account-key "$AZ_ACCOUNT_KEY" --account-name "$AZ_ACCOUNT_NAME" -f "$WIN_PATH" -n "$BLOB_PATH"
else else
az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $ZIP_PATH -n "$BLOB_PATH" az storage blob upload -c builds --account-key "$AZ_ACCOUNT_KEY" --account-name "$AZ_ACCOUNT_NAME" -f "$ZIP_PATH" -n "$BLOB_PATH"
fi fi
echo "UPLOAD SUCCESSFUL!" echo "UPLOAD SUCCESSFUL!"

View file

@ -3,7 +3,7 @@ set -e
set +x set +x
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
echo "usage: $(basename $0) [output-absolute-path]" echo "usage: $(basename "$0") [output-absolute-path]"
echo echo
echo "Generate distributable .zip archive from ./checkout folder that was previously built." echo "Generate distributable .zip archive from ./checkout folder that was previously built."
echo echo
@ -23,7 +23,7 @@ if [[ -f $ZIP_PATH ]]; then
echo "ERROR: path $ZIP_PATH exists; can't do anything." echo "ERROR: path $ZIP_PATH exists; can't do anything."
exit 1 exit 1
fi fi
if ! [[ -d $(dirname $ZIP_PATH) ]]; then if ! [[ -d $(dirname "$ZIP_PATH") ]]; then
echo "ERROR: folder for path $($ZIP_PATH) does not exist." echo "ERROR: folder for path $($ZIP_PATH) does not exist."
exit 1 exit 1
fi fi
@ -53,27 +53,27 @@ main() {
createZipForLinux() { createZipForLinux() {
# create a TMP directory to copy all necessary files # create a TMP directory to copy all necessary files
local tmpdir=$(mktemp -d -t webkit-deploy-XXXXXXXXXX) local tmpdir=$(mktemp -d -t webkit-deploy-XXXXXXXXXX)
mkdir -p $tmpdir mkdir -p "$tmpdir"
# copy runner # copy runner
cp -t $tmpdir $SCRIPTS_DIR/pw_run.sh cp -t "$tmpdir" "$SCRIPTS_DIR"/pw_run.sh
# copy protocol # copy protocol
node $SCRIPTS_DIR/concat_protocol.js > $tmpdir/protocol.json node "$SCRIPTS_DIR"/concat_protocol.js > "$tmpdir"/protocol.json
# Generate and unpack MiniBrowser bundles for each port # Generate and unpack MiniBrowser bundles for each port
for port in gtk wpe; do for port in gtk wpe; do
WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/${port^^} Tools/Scripts/generate-bundle \ WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/${port^^} Tools/Scripts/generate-bundle \
--bundle=MiniBrowser --release \ --bundle=MiniBrowser --release \
--platform=${port} --destination=${tmpdir} --platform=${port} --destination="${tmpdir}"
unzip ${tmpdir}/MiniBrowser_${port}_release.zip -d ${tmpdir}/minibrowser-${port} unzip "${tmpdir}"/MiniBrowser_${port}_release.zip -d "${tmpdir}"/minibrowser-${port}
rm -f ${tmpdir}/MiniBrowser_${port}_release.zip rm -f "${tmpdir}"/MiniBrowser_${port}_release.zip
done done
# tar resulting directory and cleanup TMP. # tar resulting directory and cleanup TMP.
cd $tmpdir cd "$tmpdir"
zip --symlinks -r $ZIP_PATH ./ zip --symlinks -r "$ZIP_PATH" ./
cd - cd -
rm -rf $tmpdir rm -rf "$tmpdir"
} }
# see https://docs.microsoft.com/en-us/visualstudio/install/tools-for-managing-visual-studio-instances?view=vs-2019 # see https://docs.microsoft.com/en-us/visualstudio/install/tools-for-managing-visual-studio-instances?view=vs-2019
@ -90,25 +90,25 @@ printMSVCRedistDir() {
createZipForWindows() { createZipForWindows() {
# create a TMP directory to copy all necessary files # create a TMP directory to copy all necessary files
local tmpdir="/tmp/webkit-deploy-$(date +%s)" local tmpdir="/tmp/webkit-deploy-$(date +%s)"
mkdir -p $tmpdir mkdir -p "$tmpdir"
cp -t $tmpdir ./WebKitLibraries/win/bin64/*.dll cp -t "$tmpdir" ./WebKitLibraries/win/bin64/*.dll
cd WebKitBuild/Release/bin64 cd WebKitBuild/Release/bin64
cp -r -t $tmpdir WebKit.resources cp -r -t "$tmpdir" WebKit.resources
cp -t $tmpdir JavaScriptCore.dll PlaywrightLib.dll WTF.dll WebKit2.dll libEGL.dll libGLESv2.dll cp -t "$tmpdir" JavaScriptCore.dll PlaywrightLib.dll WTF.dll WebKit2.dll libEGL.dll libGLESv2.dll
cp -t $tmpdir Playwright.exe WebKitNetworkProcess.exe WebKitWebProcess.exe cp -t "$tmpdir" Playwright.exe WebKitNetworkProcess.exe WebKitWebProcess.exe
cd - cd -
cd "$(printMSVCRedistDir)" cd "$(printMSVCRedistDir)"
cp -t $tmpdir msvcp140.dll vcruntime140.dll vcruntime140_1.dll msvcp140_2.dll cp -t "$tmpdir" msvcp140.dll vcruntime140.dll vcruntime140_1.dll msvcp140_2.dll
cd - cd -
# copy protocol # copy protocol
node $SCRIPTS_DIR/concat_protocol.js > $tmpdir/protocol.json node "$SCRIPTS_DIR"/concat_protocol.js > "$tmpdir"/protocol.json
# tar resulting directory and cleanup TMP. # tar resulting directory and cleanup TMP.
cd $tmpdir cd "$tmpdir"
zip -r $ZIP_PATH ./ zip -r "$ZIP_PATH" ./
cd - cd -
rm -rf $tmpdir rm -rf "$tmpdir"
} }
createZipForMac() { createZipForMac() {
@ -116,28 +116,28 @@ createZipForMac() {
local tmpdir=$(mktemp -d) local tmpdir=$(mktemp -d)
# copy all relevant files # copy all relevant files
ditto {./WebKitBuild/Release,$tmpdir}/com.apple.WebKit.Networking.xpc ditto {./WebKitBuild/Release,"$tmpdir"}/com.apple.WebKit.Networking.xpc
ditto {./WebKitBuild/Release,$tmpdir}/com.apple.WebKit.Plugin.64.xpc ditto {./WebKitBuild/Release,"$tmpdir"}/com.apple.WebKit.Plugin.64.xpc
ditto {./WebKitBuild/Release,$tmpdir}/com.apple.WebKit.WebContent.xpc ditto {./WebKitBuild/Release,"$tmpdir"}/com.apple.WebKit.WebContent.xpc
ditto {./WebKitBuild/Release,$tmpdir}/JavaScriptCore.framework ditto {./WebKitBuild/Release,"$tmpdir"}/JavaScriptCore.framework
ditto {./WebKitBuild/Release,$tmpdir}/libANGLE-shared.dylib ditto {./WebKitBuild/Release,"$tmpdir"}/libANGLE-shared.dylib
ditto {./WebKitBuild/Release,$tmpdir}/libwebrtc.dylib ditto {./WebKitBuild/Release,"$tmpdir"}/libwebrtc.dylib
ditto {./WebKitBuild/Release,$tmpdir}/Playwright.app ditto {./WebKitBuild/Release,"$tmpdir"}/Playwright.app
ditto {./WebKitBuild/Release,$tmpdir}/PluginProcessShim.dylib ditto {./WebKitBuild/Release,"$tmpdir"}/PluginProcessShim.dylib
ditto {./WebKitBuild/Release,$tmpdir}/WebCore.framework ditto {./WebKitBuild/Release,"$tmpdir"}/WebCore.framework
ditto {./WebKitBuild/Release,$tmpdir}/WebInspectorUI.framework ditto {./WebKitBuild/Release,"$tmpdir"}/WebInspectorUI.framework
ditto {./WebKitBuild/Release,$tmpdir}/WebKit.framework ditto {./WebKitBuild/Release,"$tmpdir"}/WebKit.framework
ditto {./WebKitBuild/Release,$tmpdir}/WebKitLegacy.framework ditto {./WebKitBuild/Release,"$tmpdir"}/WebKitLegacy.framework
ditto {$SCRIPTS_DIR,$tmpdir}/pw_run.sh ditto {"$SCRIPTS_DIR","$tmpdir"}/pw_run.sh
# copy protocol # copy protocol
node $SCRIPTS_DIR/concat_protocol.js > $tmpdir/protocol.json node "$SCRIPTS_DIR"/concat_protocol.js > "$tmpdir"/protocol.json
# Remove all broken symlinks. @see https://github.com/microsoft/playwright/issues/5472 # Remove all broken symlinks. @see https://github.com/microsoft/playwright/issues/5472
find "${tmpdir}" -type l ! -exec test -e {} \; -print | xargs rm find "${tmpdir}" -type l ! -exec test -e {} \; -print | xargs rm
# zip resulting directory and cleanup TMP. # zip resulting directory and cleanup TMP.
ditto -c -k $tmpdir $ZIP_PATH ditto -c -k "$tmpdir" "$ZIP_PATH"
rm -rf $tmpdir rm -rf "$tmpdir"
} }
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT

View file

@ -3,7 +3,7 @@ set -e
set +x set +x
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
SCRIPT_FOLDER="$(pwd -P)" SCRIPT_FOLDER="$(pwd -P)"
source "${SCRIPT_FOLDER}/../utils.sh" source "${SCRIPT_FOLDER}/../utils.sh"
@ -80,7 +80,7 @@ elif [[ "$(uname)" == "Linux" ]]; then
build_wpe build_wpe
fi fi
elif [[ "$(uname)" == MINGW* ]]; then elif [[ "$(uname)" == MINGW* ]]; then
/c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_FOLDER}/buildwin.bat)" /c/Windows/System32/cmd.exe "/c $(cygpath -w "${SCRIPT_FOLDER}"/buildwin.bat)"
else else
echo "ERROR: cannot upload on this platform!" 1>&2 echo "ERROR: cannot upload on this platform!" 1>&2
exit 1; exit 1;

View file

@ -3,7 +3,7 @@ set -e
set +x set +x
trap "cd $(pwd -P)" EXIT trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)" cd "$(dirname "$0")"
if [[ ! -z "${WK_CHECKOUT_PATH}" ]]; then if [[ ! -z "${WK_CHECKOUT_PATH}" ]]; then
cd "${WK_CHECKOUT_PATH}" cd "${WK_CHECKOUT_PATH}"