# HG changeset patch # User Xerxes R?nby # Date 1298282923 -3600 # Node ID 15bb449380ba1b8336cfda68cc5c16fc1241c13d # Parent c3adcbdf8b9d38423c50854d681835903d500c33 Initial checkin of buildslave wget cache wrapper. This is a wrapper for wget that caches files fetched using wget foo -O file This wget cache wrapper are currently being run on the buildslaves jaunty-ia32, natty-armv7l and squeeze-armv7l connected to the http://builder.classpath.org/icedtea/buildbot/ buildmaster To prevent the buildslaves to re-download all openjdk drops for each build diff -r c3adcbdf8b9d -r 15bb449380ba buildslave/tools/wget.cache.wrapper --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/buildslave/tools/wget.cache.wrapper Mon Feb 21 11:08:43 2011 +0100 @@ -0,0 +1,65 @@ +#!/bin/bash + +# Copyright (C) 2011, Xerxes Ranby +# This wget cache wrapper is free software; you can redistribute it +# and/or modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# http://www.gnu.org/copyleft/gpl.html + +# This is a wrapper for wget that caches files fetched using +# wget foo -O files + +# This wget cache wrapper are currently being run on the buildslaves +# jaunty-ia32, natty-armv7l and squeeze-armv7l connected to the +# http://builder.classpath.org/icedtea/buildbot/ buildmaster +# to prevent the buildslaves to re-download all openjdk drops for each build + +##### Please configure me to match your setup. + +WGET=/usr/bin/wget.real +CACHEDIR=/home/wgetcache/ + +##### Please do not change anything below this line + +TARGETDIR=$(pwd) + +#remeber all arguments to wget +ALLARG=$* + +#find out if the last argument are -O file +FILEINDEX=$# +shift $((${FILEINDEX}-2)) +ARG=$1 +FILE=$2 + +if [ ${ARG} == "-O" ] ; then + if [ ! -e ${CACHEDIR}${FILE} ]; then + # file do not exist in cache + # download the file to the cache using wget! + cd ${CACHEDIR} + + # make sure subdirs in the cache exist + CACHEDIRSUBPATH=$(dirname ${FILE}) + mkdir -p ${CACHEDIRSUBPATH} + + ${WGET} ${ALLARG} + fi + + if [ -e ${CACHEDIR}${FILE} ] ; then + # ok good, file exist now in cache + # copy the file from cache to destination + cd ${TARGETDIR} + cp ${CACHEDIR}${FILE} ${FILE} + exit 0 + else + #something got wrong + exit 1 + fi +else + # Last argument are something else than -O file + # We do not know how to cache this.... sorry. + # instead we simply run wget with all passed arguments + # and pretend we dont exist + ${WGET} ${ALLARG} +fi