|
|
3b9515 |
#!/bin/bash
|
|
|
3b9515 |
#
|
|
|
3b9515 |
# vcs.sh -- This function standardizes version control tasks inside
|
|
|
3b9515 |
# the repository.
|
|
|
3b9515 |
#
|
|
|
3b9515 |
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
|
|
|
3b9515 |
#
|
|
|
3b9515 |
# This program is free software; you can redistribute it and/or modify
|
|
|
3b9515 |
# it under the terms of the GNU General Public License as published by
|
|
|
3b9515 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
3b9515 |
# (at your option) any later version.
|
|
|
3b9515 |
#
|
|
|
3b9515 |
# This program is distributed in the hope that it will be useful, but
|
|
|
3b9515 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
3b9515 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
3b9515 |
# General Public License for more details.
|
|
|
3b9515 |
#
|
|
|
3b9515 |
# You should have received a copy of the GNU General Public License
|
|
|
3b9515 |
# along with this program; if not, write to the Free Software
|
|
|
3b9515 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
3b9515 |
#
|
|
|
3b9515 |
# ----------------------------------------------------------------------
|
|
|
3b9515 |
# $Id$
|
|
|
3b9515 |
# ----------------------------------------------------------------------
|
|
|
3b9515 |
|
|
|
3b9515 |
function vcs {
|
|
|
3b9515 |
|
|
|
3b9515 |
local ACTIONNAM=''
|
|
|
3b9515 |
local ACTIONNAMS=''
|
|
|
3b9515 |
local ACTIONVAL=''
|
|
|
3b9515 |
|
|
|
3b9515 |
# Verify whether version control actions should be performed or
|
|
|
3b9515 |
# not inside the repository directory structure.
|
|
|
3b9515 |
local ENABLED=$(cli_getConfigValue "${CLI_BASEDIR}/${CLI_NAME}.conf" "version_control" "enabled")
|
|
|
3b9515 |
if [[ ! ${ENABLED} =~ '^(yes|ye|y|0)$' ]];then
|
|
|
3b9515 |
return
|
|
|
3b9515 |
fi
|
|
|
3b9515 |
|
|
|
3b9515 |
# Initialize version control system to use inside the repository.
|
|
|
3b9515 |
local PACKAGE=$(cli_getConfigValue "${CLI_BASEDIR}/${CLI_NAME}.conf" "version_control" "package")
|
|
|
3b9515 |
|
|
|
3b9515 |
# Set possible values to packages used as version control system.
|
|
|
3b9515 |
if [[ ${PACKAGE} =~ '^(git|subversion)$' ]];then
|
|
|
3b9515 |
|
|
|
3b9515 |
# Initialize the absolute path to commands we'll use as
|
|
|
3b9515 |
# version control system in the working copy.
|
|
|
3b9515 |
case ${PACKAGE} in
|
|
|
3b9515 |
|
|
|
3b9515 |
'git' )
|
|
|
3b9515 |
COMMAND=/usr/bin/git
|
|
|
3b9515 |
;;
|
|
|
3b9515 |
|
|
|
3b9515 |
'subversion' )
|
|
|
3b9515 |
COMMAND=/usr/bin/svn
|
|
|
3b9515 |
;;
|
|
|
3b9515 |
esac
|
|
|
3b9515 |
|
|
|
3b9515 |
else
|
|
|
3b9515 |
cli_printMessage "${PACKAGE} `gettext "isn't supported as version control system."`" --as-error-line
|
|
|
3b9515 |
fi
|
|
|
3b9515 |
|
|
|
3b9515 |
# Verify whether the related package is installed or not.
|
|
|
3b9515 |
cli_checkFiles ${PACKAGE} --is-installed
|
|
|
3b9515 |
|
|
|
3b9515 |
# Interpret arguments and options passed through command-line.
|
|
|
3b9515 |
vcs_getOptions
|
|
|
3b9515 |
|
|
|
3b9515 |
# Initialize function specific export id.
|
|
|
3b9515 |
local EXPORTID="${CLI_FUNCDIRNAM}/$(cli_getRepoName ${PACKAGE} -d)/$(cli_getRepoName ${PACKAGE} -f)"
|
|
|
3b9515 |
|
|
|
3b9515 |
# Export specific functionalities to the script environment.
|
|
|
3b9515 |
cli_exportFunctions "${EXPORTID}"
|
|
|
3b9515 |
|
|
|
3b9515 |
# Execute version control.
|
|
|
3b9515 |
${PACKAGE}
|
|
|
3b9515 |
|
|
|
3b9515 |
# Unset specific functionalities from the script environment.
|
|
|
3b9515 |
cli_unsetFunctions "${EXPORTID}"
|
|
|
3b9515 |
|
|
|
3b9515 |
}
|