Created
March 26, 2015 09:02
-
-
Save ThierryGoubier/039c401680f3d92815ea to your computer and use it in GitHub Desktop.
shell script for downloading the pharo 4 minimal image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# stop the script if a single command fails | |
set -e | |
# define an echo that only outputs to stderr | |
echoerr() { echo "$@" 1>&2; } | |
# try to use curl if possible | |
if [[ `which curl 2> /dev/null` ]]; then | |
DOWNLOAD="curl --silent --location --compressed "; | |
DOWNLOAD_TO="$DOWNLOAD --output "; | |
elif [[ `which wget 2> /dev/null` ]]; then | |
DOWNLOAD_TO="wget --quiet --output-document="; | |
DOWNLOAD="$DOWNLOAD_TO-"; | |
else | |
echo "Please install curl or wget on your machine"; | |
exit 1 | |
fi | |
# ARGUMENT HANDLING ============================================================= | |
if { [ "$1" = "-h" ] || [ "$1" = "--help" ]; }; then | |
echo "This script downloads the latest Pharo 40 Image. | |
The following artifacts are created: | |
Pharo.changes A changes file for the Pharo Image | |
Pharo.image A Pharo image, to be opened with the Pharo VM | |
" | |
exit 0; | |
elif [ $# -gt 0 ]; then | |
echo "--help is the only argument allowed" | |
exit 1; | |
fi | |
# DOWNLOADING THE LATEST PHARO 40 MINIMAL IMAGE ========================================= | |
IMAGE_URL="http://files.pharo.org/image/40/latest-minimal.zip" | |
echoerr "Downloading the latest 40 minimal Image:" | |
echoerr " $IMAGE_URL" | |
TMP_DIR=`mktemp -d image.XXXXXX` | |
$DOWNLOAD_TO$TMP_DIR/image.zip $IMAGE_URL | |
unzip -q $TMP_DIR/image.zip -d $TMP_DIR | |
rm -rf image image.zip | |
PHARO_IMAGE=`find $TMP_DIR -name \*.image` | |
mv "$PHARO_IMAGE" Pharo.image | |
PHARO_CHANGES=`find $TMP_DIR -name \*.changes` | |
mv "$PHARO_CHANGES" Pharo.changes; | |
rm -r $TMP_DIR >> /dev/null | |
echo Pharo.image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment