60 lines
2.0 KiB
Bash
60 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# Copyright 2010-2012, Asio Software Technologies
|
|
# Distributed under the terms of the GNU General Public License v3
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Downloads or updates specified GIT repository
|
|
# Parameters: %dest_directory% %address% [%branch%]
|
|
#-------------------------------------------------------------------------------
|
|
function checkoutGit() {
|
|
local DIRECTORY="${1}"
|
|
local ADDRESS="${2}"
|
|
local BRANCH="${3:-master}"
|
|
if [ -d ${DIRECTORY} ]; then
|
|
cd ${DIRECTORY}
|
|
run "git reset --hard origin/${BRANCH}" || return 1
|
|
run "git clean --force" || return 1
|
|
run "git pull --no-stat" || return 1
|
|
else
|
|
run "git clone ${ADDRESS} ${DIRECTORY}" || return 1
|
|
if [ ${BRANCH} != "master" ]; then
|
|
cd ${DIRECTORY}
|
|
run "git checkout ${BRANCH}" || return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Downloads or updates specified RSYNC repository
|
|
# Parameters: %dest_directory% %address%
|
|
#-------------------------------------------------------------------------------
|
|
function checkoutRsync() {
|
|
DIRECTORY="${1}"
|
|
ADDRESS="${2}"
|
|
run "rsync --compress --delete --delete-after --devices --force --links \
|
|
--partial --perms --recursive --safe-links --stats --times \
|
|
--timeout=${FETCHTIMEOUT} --whole-file --exclude=/.git --exclude=CVS \
|
|
--exclude=/distfiles --exclude=/local --exclude=/metadata/cache \
|
|
--exclude=/packages ${ADDRESS} ${DIRECTORY}" || return 1
|
|
return 0
|
|
}
|
|
|
|
#-------------------------------------------------------------------------------
|
|
# Downloads or updates specified SVN repository
|
|
# Parameters: %dest_directory% %address%
|
|
#-------------------------------------------------------------------------------
|
|
function checkoutSubversion() {
|
|
local DIRECTORY="${1}"
|
|
local ADDRESS="${2}"
|
|
if [ -d ${DIRECTORY} ]; then
|
|
cd ${DIRECTORY}
|
|
run "svn cleanup" || return 1
|
|
run "svn update" || return 1
|
|
else
|
|
run "svn checkout ${ADDRESS} ${DIRECTORY}" || return 1
|
|
fi
|
|
return 0
|
|
}
|