You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
smartgears-distribution/distro/contents/scripts/download

63 lines
2.0 KiB
Plaintext

group=org.gcube.core
artifact=common-smartgears
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
version=`curl -silent -L "maven.research-infrastructures.eu/nexus/service/local/artifact/maven/resolve?r=$repo&g=$group&a=$artifact&v=LATEST&e=tar.gz&c=distro" \
| 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
echo -e "\ndownloading common-smartgears-$version.tar.gz...\c"
http_code=`curl -s -o "common-smartgears-$version.tar.gz" -w "%{http_code}" -L "maven.research-infrastructures.eu/nexus/service/local/artifact/maven/redirect?r=$repo&g=$group&a=$artifact&v=$version&e=tar.gz&c=distro"`
if [ ! "$http_code" = "200" ]; then
echo -e "\n\nERROR: cannot download version $version from $repo." >&2
echo -e "\naborting.\n"
rm "common-smartgears-$version.tar.gz"
exit 1
fi
echo -e "done.\n"