Enable simple modification of git repo location

Add the DIB_GITREPOBASE variable to the source-repositories element
to enable global changing of git repository location.

Change-Id: Icfac5e103fce6e5a3f1a2db094144a0ed89fcc33
This commit is contained in:
Jon-Paul Sullivan 2014-02-19 17:38:34 +00:00
parent 61d474f2cd
commit 0edfcf6587
2 changed files with 18 additions and 0 deletions

View File

@ -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.

View File

@ -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