devops: revamp archive.sh scripts to accept a target .zip name

This is required so that we can setup a locking directory for cron
jobs later on.
This commit is contained in:
Andrey Lushnikov 2019-11-20 18:01:07 -08:00
Родитель af0ba0e713
Коммит 4f3834dd69
3 изменённых файлов: 116 добавлений и 62 удалений

Просмотреть файл

@ -1,48 +1,59 @@
#!/bin/bash
set -e
set +x
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
echo "usage: $(basename $0)"
echo "usage: $(basename $0) [output-absolute-path]"
echo
echo "Generate distributable .zip archive from ./checkout folder that was previously built."
echo
exit 0
fi
set -e
set -x
if [[ $# != 1 ]]; then
echo "error: missing zip output path"
echo "try '$(basename $0) --help' for details"
exit 1
fi
createZIPForLinuxOrMac() {
local zipname=$1
local OBJ_FOLDER=$(ls -1 | grep obj-)
if [[ $OBJ_FOLDER == "" ]]; then
echo "ERROR: cannot find obj-* folder in the checkout/. Did you build?"
exit 1;
fi
if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then
echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?"
exit 1;
fi
# Copy the libstdc++ version we linked against.
# TODO(aslushnikov): this won't be needed with official builds.
if [[ "$(uname)" == "Linux" ]]; then
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $OBJ_FOLDER/dist/firefox/libstdc++.so.6
fi
# tar resulting directory and cleanup TMP.
cd $OBJ_FOLDER/dist
zip -r ../../../$zipname firefox
cd -
}
ZIP_PATH=$1
if [[ $ZIP_PATH != /* ]]; then
echo "ERROR: path $ZIP_PATH is not absolute"
exit 1
fi
if [[ $ZIP_PATH != *.zip ]]; then
echo "ERROR: path $ZIP_PATH must have .zip extension"
exit 1
fi
if [[ -f $ZIP_PATH ]]; then
echo "ERROR: path $ZIP_PATH exists; can't do anything."
exit 1
fi
if ! [[ -d $(dirname $ZIP_PATH) ]]; then
echo "ERROR: folder for path $($ZIP_PATH) does not exist."
exit 1
fi
trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)"
cd checkout
if [[ "$(uname)" == "Darwin" ]]; then
createZIPForLinuxOrMac "firefox-mac.zip"
elif [[ "$(uname)" == "Linux" ]]; then
createZIPForLinuxOrMac "firefox-linux.zip"
else
echo "ERROR: cannot upload on this platform!" 1>&2
OBJ_FOLDER=$(ls -1 | grep obj-)
if [[ $OBJ_FOLDER == "" ]]; then
echo "ERROR: cannot find obj-* folder in the checkout/. Did you build?"
exit 1;
fi
if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then
echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?"
exit 1;
fi
# Copy the libstdc++ version we linked against.
# TODO(aslushnikov): this won't be needed with official builds.
if [[ "$(uname)" == "Linux" ]]; then
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $OBJ_FOLDER/dist/firefox/libstdc++.so.6
fi
# tar resulting directory and cleanup TMP.
cd $OBJ_FOLDER/dist
zip -r $ZIP_PATH firefox

Просмотреть файл

@ -6,21 +6,15 @@ trap "cd $(pwd -P)" EXIT
cd "$(dirname "$0")"
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo "usage: $(basename $0) [firefox|webkit]"
echo "usage: $(basename $0) [firefox|webkit] [zip-path]"
echo
echo "Archive and upload a browser"
echo "Upload .zip as a browser build."
echo
echo "NOTE: \$AZ_ACCOUNT_KEY (azure account name) and \$AZ_ACCOUNT_NAME (azure account name)"
echo "env variables are required to upload builds to CDN."
exit 0
fi
if [[ $# == 0 ]]; then
echo "missing browser: 'firefox' or 'webkit'"
echo "try '$(basename $0) --help' for more information"
exit 1
fi
if [[ (-z $AZ_ACCOUNT_KEY) || (-z $AZ_ACCOUNT_NAME) ]]; then
echo "ERROR: Either \$AZ_ACCOUNT_KEY or \$AZ_ACCOUNT_NAME environment variable is missing."
echo " 'Azure Account Name' and 'Azure Account Key' secrets that are required"
@ -28,36 +22,64 @@ if [[ (-z $AZ_ACCOUNT_KEY) || (-z $AZ_ACCOUNT_NAME) ]]; then
exit 1
fi
ARCHIVE_SCRIPT=""
if [[ $# < 1 ]]; then
echo "missing browser: 'firefox' or 'webkit'"
echo "try '$(basename $0) --help' for more information"
exit 1
fi
BROWSER_NAME=""
BUILD_NUMBER=""
BLOB_NAME=""
if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then
# we always apply our patches atop of beta since it seems to get better
# reliability guarantees.
ARCHIVE_FOLDER="$PWD/firefox"
BUILD_NUMBER=$(cat "$PWD/firefox/BUILD_NUMBER")
ARCHIVE_SCRIPT="$PWD/firefox/archive.sh"
BROWSER_NAME="firefox"
if [[ "$(uname)" == "Darwin" ]]; then
BLOB_NAME="firefox-mac.zip"
elif [[ "$(uname)" == "Linux" ]]; then
BLOB_NAME="firefox-linux.zip"
else
echo "ERROR: unzupported platform - $(uname)"
exit 1
fi
elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then
ARCHIVE_FOLDER="$PWD/webkit"
BUILD_NUMBER=$(cat "$PWD/webkit/BUILD_NUMBER")
ARCHIVE_SCRIPT="$PWD/webkit/archive.sh"
BROWSER_NAME="webkit"
if [[ "$(uname)" == "Darwin" ]]; then
MAC_MAJOR_MINOR_VERSION=$(sw_vers -productVersion | grep -o '^\d\+.\d\+')
BLOB_NAME="minibrowser-mac-$MAC_MAJOR_MINOR_VERSION.zip"
elif [[ "$(uname)" == "Linux" ]]; then
BLOB_NAME="minibrowser-linux.zip"
else
echo "ERROR: unzupported platform - $(uname)"
exit 1
fi
else
echo ERROR: unknown browser to export - "$1"
exit 1
fi
if ! [[ -z $(ls $ARCHIVE_FOLDER | grep '.zip') ]]; then
echo ERROR: .zip file already exists in $ARCHIVE_FOLDER!
echo Remove manually all zip files and re-run the script.
if [[ $# < 2 ]]; then
echo "missing path to zip archive to upload"
echo "try '$(basename $0) --help' for more information"
exit 1
fi
ZIP_PATH=$2
if ! [[ -f $ZIP_PATH ]]; then
echo "ERROR: $ZIP_PATH does not exist"
exit 1
fi
if ! [[ $ZIP_PATH == *.zip ]]; then
echo "ERROR: $ZIP_PATH is not a zip archive (must have a .zip extension)"
exit 1
fi
$ARCHIVE_SCRIPT
ZIP_NAME=$(ls $ARCHIVE_FOLDER | grep '.zip')
ZIP_PATH=$ARCHIVE_FOLDER/$ZIP_NAME
BLOB_NAME="$BROWSER_NAME/$BUILD_NUMBER/$ZIP_NAME"
az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $ZIP_PATH -n "$BLOB_NAME"
echo "Uploaded $(du -h "$ZIP_PATH" | awk '{print $1}') as $BLOB_NAME"
rm $ZIP_PATH
BLOB_PATH="$BROWSER_NAME/$BUILD_NUMBER/$BLOB_NAME"
az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $ZIP_PATH -n "$BLOB_PATH"
echo "UPLOAD SUCCESSFUL!"
echo "-- SRC: $ZIP_PATH"
echo "-- SIZE: $(du -h "$ZIP_PATH" | awk '{print $1}')"
echo "-- DST: $BLOB_PATH"

Просмотреть файл

@ -1,19 +1,43 @@
#!/bin/bash
set -e
set +x
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
echo "usage: $(basename $0)"
echo "usage: $(basename $0) [output-absolute-path]"
echo
echo "Generate distributable .zip archive from ./checkout folder that was previously built."
echo
exit 0
fi
set -e
set -x
if [[ $# != 1 ]]; then
echo "error: missing zip output path"
echo "try '$(basename $0) --help' for details"
exit 1
fi
ZIP_PATH=$1
if [[ $ZIP_PATH != /* ]]; then
echo "ERROR: path $ZIP_PATH is not absolute"
exit 1
fi
if [[ $ZIP_PATH != *.zip ]]; then
echo "ERROR: path $ZIP_PATH must have .zip extension"
exit 1
fi
if [[ -f $ZIP_PATH ]]; then
echo "ERROR: path $ZIP_PATH exists; can't do anything."
exit 1
fi
if ! [[ -d $(dirname $ZIP_PATH) ]]; then
echo "ERROR: folder for path $($ZIP_PATH) does not exist."
exit 1
fi
main() {
cd checkout
set -x
if [[ "$(uname)" == "Darwin" ]]; then
createZipForMac
elif [[ "$(uname)" == "Linux" ]]; then
@ -42,8 +66,7 @@ createZipForLinux() {
rm $tmpdir/libgdk_pixbuf*
# tar resulting directory and cleanup TMP.
local zipname="minibrowser-linux.zip"
zip -jr ../$zipname $tmpdir
zip -jr $ZIP_PATH $tmpdir
rm -rf $tmpdir
}
@ -69,9 +92,7 @@ createZipForMac() {
node ../concat_protocol.js > $tmpdir/protocol.json
# zip resulting directory and cleanup TMP.
local MAC_MAJOR_MINOR_VERSION=$(sw_vers -productVersion | grep -o '^\d\+.\d\+')
local zipname="minibrowser-mac-$MAC_MAJOR_MINOR_VERSION.zip"
ditto -c -k $tmpdir ../$zipname
ditto -c -k $tmpdir $ZIP_PATH
rm -rf $tmpdir
}