diff --git a/elements/source-repositories/README.md b/elements/source-repositories/README.md index f72168f0..5243c441 100644 --- a/elements/source-repositories/README.md +++ b/elements/source-repositories/README.md @@ -81,3 +81,11 @@ of the repositories (by users or by other elements). The repository names and types are written to an environment.d hook script at 01-source-repositories-environment. This allows later hook scripts during the install.d phase to know which install type to use for the element. + +The base url for all git repositories can be set by use of: + + DIB_GITREPOBASE + +So setting DIB\_GITREPOBASE=https://github.com/ when the repo location is set +to http://git.openstack.org/openstack/nova.git will result in use of the +https://github.com/openstack/nova.git repository. diff --git a/elements/source-repositories/extra-data.d/98-source-repositories b/elements/source-repositories/extra-data.d/98-source-repositories index 61bc9618..7239a473 100755 --- a/elements/source-repositories/extra-data.d/98-source-repositories +++ b/elements/source-repositories/extra-data.d/98-source-repositories @@ -46,6 +46,16 @@ function get_repos_for_element(){ case $REPOTYPE in git) + if [ -z "${!REPOLOCATION_OVERRIDE:-""}" -a -n "${DIB_GITREPOBASE:-""}" ] ; then + # Transform the current repo base to the new one + local NEW_REPOLOCATION=$(echo $REPOLOCATION |\ + sed "s,^[^:]\+://[^/]\+/\(~[^/]\+\)\?\(.*\)$,${DIB_GITREPOBASE}\2,g") + echo "Transformed ${REPOLOCATION} to ${NEW_REPOLOCATION}" + REPOLOCATION=$NEW_REPOLOCATION + # Also update the cache location + CACHE_NAME=$(echo "${REPOTYPE}_${REPOLOCATION}" | sha1sum | awk '{ print $1 }' ) + CACHE_PATH=~/.cache/image-create/repository-sources/$CACHE_NAME + fi sudo mkdir -p $REPO_SUB_DIRECTORY if [ ! -e "$CACHE_PATH" ] ; then