2013-10-07 15:40:29 +02:00
|
|
|
nexusurl=maven.research-infrastructures.eu/nexus
|
2013-10-07 12:30:08 +02:00
|
|
|
group=org.gcube.distribution
|
|
|
|
artifact=smartgears-distribution
|
2013-09-25 12:30:43 +02:00
|
|
|
repo=gcube-releases
|
|
|
|
|
|
|
|
function showhelp {
|
|
|
|
echo -e "\nusage: download [-v <version>] [-s|-h] \n"
|
|
|
|
echo " <version> = the version to download."
|
|
|
|
echo " = By default, this is the latest known version."
|
|
|
|
echo " s = download a snapshot version."
|
|
|
|
echo " x = dry run."
|
|
|
|
echo -e " h = shows this help.\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
while getopts ":v:sh" opt; do
|
|
|
|
case $opt in
|
|
|
|
v) version=$OPTARG;;
|
|
|
|
s) repo=gcube-snapshots;;
|
|
|
|
h) showhelp
|
|
|
|
exit 0 ;;
|
|
|
|
:) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ;
|
|
|
|
showhelp;
|
|
|
|
echo -e "\naborting.\n"
|
|
|
|
exit 1;;
|
|
|
|
\?) echo -e "\nERROR:invalid option: -$OPTARG";
|
|
|
|
showhelp;
|
|
|
|
echo -e "\naborting.\n"
|
|
|
|
exit 1 >&2 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
#######find latest version in target repo. could use LATEST but would not know how to reflect version in file name
|
|
|
|
|
|
|
|
|
|
|
|
version_regexp=".*<baseVersion>\(.*\)</baseVersion>.*"
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$version" ]; then
|
2013-10-07 15:40:29 +02:00
|
|
|
version=`curl -silent -L $nexusurl/service/local/artifact/maven/resolve?r=$repo&g=$group&a=$artifact&v=LATEST&e=tar.gz" \
|
2013-09-25 12:30:43 +02:00
|
|
|
| grep "$version_regexp" | sed "s|$version_regexp|\1|"` #(first extract matching line, then extract matching group)
|
|
|
|
|
|
|
|
if [ -z "$version" ]; then
|
|
|
|
echo -e "\nERROR: cannot find a version to download in $repo." >&2
|
|
|
|
echo -e "\naborting.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-07 12:30:08 +02:00
|
|
|
echo -e "\ndownloading smartgears-distribution-$version.tar.gz...\c"
|
2013-09-25 12:30:43 +02:00
|
|
|
|
|
|
|
|
2013-10-07 15:40:29 +02:00
|
|
|
http_code=`curl -s -o "smartgears-distribution-$version.tar.gz" -w "%{http_code}" -L "$nexusurl/service/local/artifact/maven/redirect?r=$repo&g=$group&a=$artifact&v=$version&e=tar.gz"`
|
2013-09-25 12:30:43 +02:00
|
|
|
|
|
|
|
if [ ! "$http_code" = "200" ]; then
|
|
|
|
echo -e "\n\nERROR: cannot download version $version from $repo." >&2
|
|
|
|
echo -e "\naborting.\n"
|
2013-10-07 12:30:08 +02:00
|
|
|
rm "smartgears-distribution-$version.tar.gz"
|
2013-09-25 12:30:43 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "done.\n"
|