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:
parent
af0ba0e713
commit
4f3834dd69
|
|
@ -1,48 +1,59 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set +x
|
||||||
|
|
||||||
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
|
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
|
||||||
echo "usage: $(basename $0)"
|
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
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -e
|
if [[ $# != 1 ]]; then
|
||||||
set -x
|
echo "error: missing zip output path"
|
||||||
|
echo "try '$(basename $0) --help' for details"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
createZIPForLinuxOrMac() {
|
ZIP_PATH=$1
|
||||||
local zipname=$1
|
if [[ $ZIP_PATH != /* ]]; then
|
||||||
local OBJ_FOLDER=$(ls -1 | grep obj-)
|
echo "ERROR: path $ZIP_PATH is not absolute"
|
||||||
if [[ $OBJ_FOLDER == "" ]]; then
|
exit 1
|
||||||
echo "ERROR: cannot find obj-* folder in the checkout/. Did you build?"
|
fi
|
||||||
exit 1;
|
if [[ $ZIP_PATH != *.zip ]]; then
|
||||||
fi
|
echo "ERROR: path $ZIP_PATH must have .zip extension"
|
||||||
if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then
|
exit 1
|
||||||
echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?"
|
fi
|
||||||
exit 1;
|
if [[ -f $ZIP_PATH ]]; then
|
||||||
fi
|
echo "ERROR: path $ZIP_PATH exists; can't do anything."
|
||||||
# Copy the libstdc++ version we linked against.
|
exit 1
|
||||||
# TODO(aslushnikov): this won't be needed with official builds.
|
fi
|
||||||
if [[ "$(uname)" == "Linux" ]]; then
|
if ! [[ -d $(dirname $ZIP_PATH) ]]; then
|
||||||
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $OBJ_FOLDER/dist/firefox/libstdc++.so.6
|
echo "ERROR: folder for path $($ZIP_PATH) does not exist."
|
||||||
fi
|
exit 1
|
||||||
|
fi
|
||||||
# tar resulting directory and cleanup TMP.
|
|
||||||
cd $OBJ_FOLDER/dist
|
|
||||||
zip -r ../../../$zipname firefox
|
|
||||||
cd -
|
|
||||||
}
|
|
||||||
|
|
||||||
trap "cd $(pwd -P)" EXIT
|
trap "cd $(pwd -P)" EXIT
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
cd checkout
|
cd checkout
|
||||||
|
|
||||||
if [[ "$(uname)" == "Darwin" ]]; then
|
OBJ_FOLDER=$(ls -1 | grep obj-)
|
||||||
createZIPForLinuxOrMac "firefox-mac.zip"
|
if [[ $OBJ_FOLDER == "" ]]; then
|
||||||
elif [[ "$(uname)" == "Linux" ]]; then
|
echo "ERROR: cannot find obj-* folder in the checkout/. Did you build?"
|
||||||
createZIPForLinuxOrMac "firefox-linux.zip"
|
|
||||||
else
|
|
||||||
echo "ERROR: cannot upload on this platform!" 1>&2
|
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
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")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
|
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
|
||||||
echo "usage: $(basename $0) [firefox|webkit]"
|
echo "usage: $(basename $0) [firefox|webkit] [zip-path]"
|
||||||
echo
|
echo
|
||||||
echo "Archive and upload a browser"
|
echo "Upload .zip as a browser build."
|
||||||
echo
|
echo
|
||||||
echo "NOTE: \$AZ_ACCOUNT_KEY (azure account name) and \$AZ_ACCOUNT_NAME (azure account name)"
|
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."
|
echo "env variables are required to upload builds to CDN."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
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 "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"
|
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
|
exit 1
|
||||||
fi
|
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=""
|
BROWSER_NAME=""
|
||||||
BUILD_NUMBER=""
|
BUILD_NUMBER=""
|
||||||
|
BLOB_NAME=""
|
||||||
if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then
|
if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then
|
||||||
# we always apply our patches atop of beta since it seems to get better
|
# we always apply our patches atop of beta since it seems to get better
|
||||||
# reliability guarantees.
|
# reliability guarantees.
|
||||||
ARCHIVE_FOLDER="$PWD/firefox"
|
|
||||||
BUILD_NUMBER=$(cat "$PWD/firefox/BUILD_NUMBER")
|
BUILD_NUMBER=$(cat "$PWD/firefox/BUILD_NUMBER")
|
||||||
ARCHIVE_SCRIPT="$PWD/firefox/archive.sh"
|
|
||||||
BROWSER_NAME="firefox"
|
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
|
elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then
|
||||||
ARCHIVE_FOLDER="$PWD/webkit"
|
|
||||||
BUILD_NUMBER=$(cat "$PWD/webkit/BUILD_NUMBER")
|
BUILD_NUMBER=$(cat "$PWD/webkit/BUILD_NUMBER")
|
||||||
ARCHIVE_SCRIPT="$PWD/webkit/archive.sh"
|
|
||||||
BROWSER_NAME="webkit"
|
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
|
else
|
||||||
echo ERROR: unknown browser to export - "$1"
|
echo ERROR: unknown browser to export - "$1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [[ -z $(ls $ARCHIVE_FOLDER | grep '.zip') ]]; then
|
if [[ $# < 2 ]]; then
|
||||||
echo ERROR: .zip file already exists in $ARCHIVE_FOLDER!
|
echo "missing path to zip archive to upload"
|
||||||
echo Remove manually all zip files and re-run the script.
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$ARCHIVE_SCRIPT
|
BLOB_PATH="$BROWSER_NAME/$BUILD_NUMBER/$BLOB_NAME"
|
||||||
ZIP_NAME=$(ls $ARCHIVE_FOLDER | grep '.zip')
|
az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $ZIP_PATH -n "$BLOB_PATH"
|
||||||
ZIP_PATH=$ARCHIVE_FOLDER/$ZIP_NAME
|
|
||||||
BLOB_NAME="$BROWSER_NAME/$BUILD_NUMBER/$ZIP_NAME"
|
echo "UPLOAD SUCCESSFUL!"
|
||||||
az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $ZIP_PATH -n "$BLOB_NAME"
|
echo "-- SRC: $ZIP_PATH"
|
||||||
echo "Uploaded $(du -h "$ZIP_PATH" | awk '{print $1}') as $BLOB_NAME"
|
echo "-- SIZE: $(du -h "$ZIP_PATH" | awk '{print $1}')"
|
||||||
rm $ZIP_PATH
|
echo "-- DST: $BLOB_PATH"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,43 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set +x
|
||||||
|
|
||||||
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
|
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
|
||||||
echo "usage: $(basename $0)"
|
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
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -e
|
if [[ $# != 1 ]]; then
|
||||||
set -x
|
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() {
|
main() {
|
||||||
cd checkout
|
cd checkout
|
||||||
|
|
||||||
|
set -x
|
||||||
if [[ "$(uname)" == "Darwin" ]]; then
|
if [[ "$(uname)" == "Darwin" ]]; then
|
||||||
createZipForMac
|
createZipForMac
|
||||||
elif [[ "$(uname)" == "Linux" ]]; then
|
elif [[ "$(uname)" == "Linux" ]]; then
|
||||||
|
|
@ -42,8 +66,7 @@ createZipForLinux() {
|
||||||
rm $tmpdir/libgdk_pixbuf*
|
rm $tmpdir/libgdk_pixbuf*
|
||||||
|
|
||||||
# tar resulting directory and cleanup TMP.
|
# tar resulting directory and cleanup TMP.
|
||||||
local zipname="minibrowser-linux.zip"
|
zip -jr $ZIP_PATH $tmpdir
|
||||||
zip -jr ../$zipname $tmpdir
|
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,9 +92,7 @@ createZipForMac() {
|
||||||
node ../concat_protocol.js > $tmpdir/protocol.json
|
node ../concat_protocol.js > $tmpdir/protocol.json
|
||||||
|
|
||||||
# zip resulting directory and cleanup TMP.
|
# zip resulting directory and cleanup TMP.
|
||||||
local MAC_MAJOR_MINOR_VERSION=$(sw_vers -productVersion | grep -o '^\d\+.\d\+')
|
ditto -c -k $tmpdir $ZIP_PATH
|
||||||
local zipname="minibrowser-mac-$MAC_MAJOR_MINOR_VERSION.zip"
|
|
||||||
ditto -c -k $tmpdir ../$zipname
|
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue