|
|
64e627 |
#!/bin/bash
|
|
|
64e627 |
#
|
|
|
64e627 |
# cli_checkPathComponent.sh -- This function checks parts/components
|
|
|
64e627 |
# from repository paths. Generally, the path information is passed to
|
|
|
64e627 |
# the function's first positional argument and the part/component we
|
|
|
64e627 |
# want to check is passed to the function's second positional
|
|
|
64e627 |
# argument. If the second argument is not passed, then the first
|
|
|
64e627 |
# argument is assumed to be the part/component we want to check, and
|
|
|
64e627 |
# the action value (ACTIONVAL) variable is used instead as source path
|
|
|
64e627 |
# information.
|
|
|
64e627 |
#
|
|
|
2d3646 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
64e627 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
64e627 |
# General Public License for more details.
|
|
|
64e627 |
#
|
|
|
64e627 |
# You should have received a copy of the GNU General Public License
|
|
|
64e627 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
64e627 |
# ----------------------------------------------------------------------
|
|
|
7b46a4 |
# $Id$
|
|
|
64e627 |
# ----------------------------------------------------------------------
|
|
|
64e627 |
|
|
|
64e627 |
function cli_checkPathComponent {
|
|
|
64e627 |
|
|
|
64e627 |
local -a PATTERNS
|
|
|
64e627 |
local LOCATION=''
|
|
|
64e627 |
local OPTION=''
|
|
|
64e627 |
local MESSAGE=''
|
|
|
64e627 |
|
|
|
64e627 |
# Define location which we retrive information from.
|
|
|
64e627 |
if [[ "$#" -eq 1 ]];then
|
|
|
64e627 |
LOCATION="$ACTIONVAL"
|
|
|
64e627 |
OPTION="$1"
|
|
|
64e627 |
elif [[ "$#" -eq 2 ]];then
|
|
|
64e627 |
LOCATION="$1"
|
|
|
64e627 |
OPTION="$2"
|
|
|
64e627 |
else
|
|
|
040e8e |
cli_printMessage "${FUNCNAME}: `gettext "Invalid arguments."`" 'AsErrorLine'
|
|
|
eee226 |
cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
|
|
|
64e627 |
fi
|
|
|
64e627 |
|
|
|
64e627 |
# Define patterns.
|
|
|
64e627 |
PATTERNS[0]="^.+/$(cli_getPathComponent "${LOCATION}" '--release-pattern')/.*$"
|
|
|
64e627 |
PATTERNS[1]=$(cli_getPathComponent "${LOCATION}" '--release-architecture')
|
|
|
64e627 |
PATTERNS[2]=$(cli_getPathComponent "${LOCATION}" '--release-theme')
|
|
|
64e627 |
|
|
|
64e627 |
# Identify which part of the release we want to output.
|
|
|
64e627 |
case "$OPTION" in
|
|
|
64e627 |
|
|
|
64e627 |
'--release' )
|
|
|
64e627 |
if [[ $LOCATION =~ ${PATTERN[0]} ]];then
|
|
|
0b4ba3 |
MESSAGE="`eval_gettext "The release \\\`\\\$LOCATION' is not valid."`"
|
|
|
64e627 |
fi
|
|
|
64e627 |
;;
|
|
|
64e627 |
|
|
|
64e627 |
'--architecture' )
|
|
|
64e627 |
if [[ $LOCATION =~ ${PATTERN[1]} ]];then
|
|
|
0b4ba3 |
MESSAGE="`eval_gettext "The architecture \\\`\\\$LOCATION' is not valid."`"
|
|
|
64e627 |
fi
|
|
|
64e627 |
;;
|
|
|
64e627 |
|
|
|
64e627 |
'--theme' )
|
|
|
64e627 |
if [[ $LOCATION =~ ${PATTERN[2]} ]];then
|
|
|
0b4ba3 |
MESSAGE="`eval_gettext "The theme \\\`\\\$LOCATION' is not valid."`"
|
|
|
64e627 |
fi
|
|
|
64e627 |
;;
|
|
|
64e627 |
|
|
|
8f5395 |
'--default' | * )
|
|
|
8f5395 |
if [[ $LOCATION == '' ]] \
|
|
|
8f5395 |
|| [[ $LOCATION =~ '(\.\.(/)?)' ]] \
|
|
|
8f5395 |
|| [[ ! $LOCATION =~ '^[A-Za-z0-9\.:/_-]+$' ]]; then
|
|
|
b790be |
MESSAGE="`eval_gettext "The value \\\`\\\$LOCATION' is not valid."`"
|
|
|
64e627 |
fi
|
|
|
64e627 |
;;
|
|
|
64e627 |
esac
|
|
|
64e627 |
|
|
|
64e627 |
# Output message.
|
|
|
64e627 |
if [[ $MESSAGE != '' ]];then
|
|
|
64e627 |
cli_printMessage "$MESSAGE" 'AsErrorLine'
|
|
|
eee226 |
cli_printMessage "${FUNCDIRNAM}" "AsToKnowMoreLine"
|
|
|
64e627 |
fi
|
|
|
64e627 |
|
|
|
64e627 |
}
|