Skip to content

Instantly share code, notes, and snippets.

@ThierryGoubier
Created March 25, 2015 18:21
Show Gist options
  • Save ThierryGoubier/cb167b6b350a7c27e722 to your computer and use it in GitHub Desktop.
Save ThierryGoubier/cb167b6b350a7c27e722 to your computer and use it in GitHub Desktop.
get the latest pharo 4 image
#!/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 IMAGE =========================================
IMAGE_URL="http://files.pharo.org/image/40/latest.zip"
echoerr "Downloading the latest 40 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