Store cefode versions in /tmp/atom-cached-cefodes

This will make rake cleaning go faster
This commit is contained in:
probablycorey 2013-04-24 15:15:44 -07:00
parent cd7162b3bc
commit 915d2e42b7
2 changed files with 37 additions and 30 deletions

14
script/lib/polite-curl Executable file
View File

@ -0,0 +1,14 @@
if [ -t 0 ] ; then # If stdout is a terminal
INTERACTIVE=1
fi
polite_curl()
{
if [ $INTERACTIVE ] ; then
CURL_ARGS="--progress-bar"
else
CURL_ARGS="-fsS"
fi
curl $CURL_ARGS $*
}

View File

@ -1,50 +1,43 @@
#!/bin/bash
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
. $(dirname $0)/lib/polite-curl
cd "$(dirname "${BASH_SOURCE[0]}" )/.."
if [[ $1 == '-s' ]]; then
SYMBOLS=1
SYMBOLS="true"
shift
fi
if [ -z $1 ]; then
TARGET='cef'
else
TARGET=$1
fi
TARGET=${1:-cef}
DISTURL="https://gh-contractor-zcbenz.s3.amazonaws.com/cefode3/prebuilt-cef"
CURRENT_VERSION=$(cat cef/version 2>&1)
LATEST_VERSION=$(curl -fsSkL $DISTURL/version)
TEMP_DIR=$(mktemp -d -t prebuilt-cef-download.XXXXXX)
trap "rm -rf \"${TEMP_DIR}\"" EXIT
# Latest version
if ! LATEST_VERSION=$(curl -fsSkL $DISTURL/version); then
exit 1;
if [ -z "$LATEST_VERSION" ] ; then
echo "Could determine lastest version of cefode" >&2
exit 1
fi
# Current version
CURRENT_VERSION=`cat cef/version 2>&1`
TEMP_DIR=/tmp/atom-cached-cefodes/$LATEST_VERSION
if [[ $LATEST_VERSION != $CURRENT_VERSION ]]; then
echo "Downloading/extracting cefode3 u${LATEST_VERSION}..."
if [ -t 1 ] ; then # If run from the terminal
CURL_ARGS="--progress-bar"
if [ -d $TEMP_DIR ]; then
echo "Using cached version of cefode3 v${LATEST_VERSION} from ${TEMP_DIR}"
else
CURL_ARGS="-fsS"
fi
curl $CURL_ARGS "${DISTURL}/cef_binary_latest.zip" > "${TEMP_DIR}/cef.zip"
echo "Downloading/extracting cefode3 v${LATEST_VERSION}..."
mkdir -p $TEMP_DIR
polite_curl "${DISTURL}/cef_binary_latest.zip" > "${TEMP_DIR}/cef.zip"
unzip -q "${TEMP_DIR}/cef.zip" -d "${TEMP_DIR}"
fi
[ -e "${TARGET}" ] && rm -rf "${TARGET}"
mv "${TEMP_DIR}"/*_macosx "${TARGET}"
cp -r "${TEMP_DIR}"/*_macosx "${TARGET}"
echo ${LATEST_VERSION} > 'cef/version'
fi
if [[ "${SYMBOLS}" != "1" ]]; then
exit 0
if [ -n "$SYMBOLS" ]; then
echo "Downloading/extracting symbols for cefode3 u${LATEST_VERSION}..."
polite_curl "${DISTURL}/cef_binary_latest_symbols.zip" > "${TEMP_DIR}/symbols.zip"
unzip -q "${TEMP_DIR}/symbols.zip" -d "${TEMP_DIR}"
mv "${TEMP_DIR}"/*_macosx_symbols/* "${TARGET}/Release"
fi
echo "Downloading/extracting symbols for cefode3 u${LATEST_VERSION}..."
curl --progress-bar "${DISTURL}/cef_binary_latest_symbols.zip" > "${TEMP_DIR}/symbols.zip"
unzip -q "${TEMP_DIR}/symbols.zip" -d "${TEMP_DIR}"
mv "${TEMP_DIR}"/*_macosx_symbols/* "${TARGET}/Release"