1.1 --- a/scripts/functions Sat May 10 12:33:37 2014 +0200
1.2 +++ b/scripts/functions Sun May 11 23:31:54 2014 +0200
1.3 @@ -830,34 +830,56 @@
1.4 # Prerequisites: either the server does not require password,
1.5 # or the user has already taken any action to authenticate to the server.
1.6 # The cloned tree will *not* be stored in the local tarballs dir!
1.7 -# Usage: CT_GetGit <basename> <url [url ...]>
1.8 +# Usage: CT_GetGit <basename> <cset> <url>
1.9 CT_GetGit() {
1.10 - local basename="$1"; shift
1.11 - local url
1.12 - local cloned=0
1.13 + local basename="${1}"
1.14 + local cset="${2}"
1.15 + local url="${3}"
1.16 + local file="${basename}-${cset}.tar.gz"
1.17 + local dir="${CT_TARBALLS_DIR}/${basename}-${cset}.git"
1.18 + local dest="${CT_TARBALLS_DIR}/${file}"
1.19 + local tmp="${CT_TARBALLS_DIR}/${file}.tmp-dl"
1.20 +
1.21 + # Do we alreadyhave it?
1.22 + if CT_GetLocal "${file}"; then
1.23 + return 0
1.24 + fi
1.25 + # Nope...
1.26
1.27 if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then
1.28 CT_DoLog WARN "Downloads forbidden, not trying git retrieval"
1.29 return 1
1.30 fi
1.31
1.32 - # Do we have it in our tarballs dir?
1.33 - if [ -d "${CT_TARBALLS_DIR}/${basename}/.git" ]; then
1.34 - CT_DoLog EXTRA "Updating git tree '${basename}'"
1.35 - CT_Pushd "${CT_TARBALLS_DIR}/${basename}"
1.36 - CT_DoExecLog ALL git pull
1.37 + # Add URLs on the LAN mirror
1.38 + # We subvert the normal download method, just to look for
1.39 + # looking at the local mirror
1.40 + if CT_GetFile "${basename}-${cset}" .tar.gz; then
1.41 + return 0
1.42 + fi
1.43 +
1.44 + CT_DoLog EXTRA "Retrieving '${basename}-${cset}' (git)"
1.45 +
1.46 + # Remove potential left-over from a previous run
1.47 + CT_DoExecLog ALL rm -rf "${tmp}.tar.gz" "${tmp}.tar" "${tmp}" "${dir}"
1.48 +
1.49 + if CT_DoExecLog ALL git clone "${url}" "${dir}"; then
1.50 + # Yep, cloned OK
1.51 + CT_Pushd "${dir}"
1.52 + CT_DoExecLog ALL git archive --format=tar \
1.53 + --prefix="${basename}-${cset}/" \
1.54 + -o "${tmp}.tar" \
1.55 + "${cset}"
1.56 + CT_DoExecLog ALL gzip -9 "${tmp}.tar"
1.57 + CT_DoExecLog ALL mv -f "${tmp}.tar.gz" "${dest}"
1.58 + CT_SaveLocal "${dest}"
1.59 + CT_DoExecLog ALL rm -rf "${tmp}.tar.gz" "${tmp}.tar" "${tmp}" "${dir}"
1.60 CT_Popd
1.61 else
1.62 - CT_DoLog EXTRA "Retrieving git tree '${basename}'"
1.63 - for url in "${@}"; do
1.64 - CT_DoLog ALL "Trying to clone from '${url}'"
1.65 - CT_DoForceRmdir "${CT_TARBALLS_DIR}/${basename}"
1.66 - if git clone "${url}" "${CT_TARBALLS_DIR}/${basename}" 2>&1 |CT_DoLog ALL; then
1.67 - cloned=1
1.68 - break
1.69 - fi
1.70 - done
1.71 - CT_TestOrAbort "Could not clone '${basename}'" ${cloned} -ne 0
1.72 + # Woops...
1.73 + CT_DoExecLog ALL rm -rf "${dir}"
1.74 + CT_DoLog Debug "Could not clone '${basename}'"
1.75 + return 1
1.76 fi
1.77 }
1.78