|
|
5b6935 |
#!/bin/bash
|
|
|
5b6935 |
#
|
|
|
a0d7a2 |
# cli_getPathComponent.sh -- This function standardizes the way
|
|
|
a0d7a2 |
# directory structures are organized inside the working copy of CentOS
|
|
|
a0d7a2 |
# Artwork Repository. You can use this function to retrive information
|
|
|
a0d7a2 |
# from path (e.g., releases, architectures and themes) or the patterns
|
|
|
a0d7a2 |
# used to build the paths.
|
|
|
5b6935 |
#
|
|
|
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
|
|
|
5b6935 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
5b6935 |
# General Public License for more details.
|
|
|
5b6935 |
#
|
|
|
5b6935 |
# You should have received a copy of the GNU General Public License
|
|
|
5b6935 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
5b6935 |
# ----------------------------------------------------------------------
|
|
|
5b6935 |
# $Id$
|
|
|
5b6935 |
# ----------------------------------------------------------------------
|
|
|
5b6935 |
|
|
|
78667f |
function cli_getPathComponent {
|
|
|
5b6935 |
|
|
|
a0d7a2 |
# Define short options.
|
|
|
a0d7a2 |
local ARGSS=''
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
# Define long options.
|
|
|
a0d7a2 |
local ARGSL='release,release-major,release-minor,release-pattern,architecture,architecture-pattern,theme,theme-name,theme-release,theme-pattern'
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
# Initialize arguments with an empty value and set it as local
|
|
|
a0d7a2 |
# variable to this function scope.
|
|
|
a0d7a2 |
local ARGUMENTS=''
|
|
|
5b6935 |
|
|
|
5b6935 |
# Define release pattern.
|
|
|
a0d7a2 |
local RELEASE="(([[:digit:]]+)(\.([[:digit:]]+)){,1})"
|
|
|
5b6935 |
|
|
|
7649f3 |
# Define architecture pattern. Make it match the architectures the
|
|
|
7649f3 |
# CentOS distribution is able to be installed on.
|
|
|
a0d7a2 |
local ARCHITECTURE="(i386|x86_64)"
|
|
|
9e4cfb |
|
|
|
9e4cfb |
# Define theme pattern for trunk, branches, and tags directory
|
|
|
9e4cfb |
# structures.
|
|
|
a0d7a2 |
local THEME="Identity/Images/Themes/(([A-Za-z0-9]+)/(${RELEASE}))/"
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
# Redefine ARGUMENTS variable using current positional parameters.
|
|
|
a0d7a2 |
cli_doParseArgumentsReDef "$@"
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
# Redefine ARGUMENTS variable using getopt output.
|
|
|
a0d7a2 |
cli_doParseArguments
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
# Redefine positional parameters using ARGUMENTS variable.
|
|
|
a0d7a2 |
eval set -- "$ARGUMENTS"
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
# Define location we want to apply verifications to.
|
|
|
a0d7a2 |
local LOCATION=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!')
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
# Look for options passed through positional parameters.
|
|
|
a0d7a2 |
while true;do
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
case "$1" in
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--release )
|
|
|
a0d7a2 |
echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\1!"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--release-major )
|
|
|
a0d7a2 |
echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\2!"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--release-minor )
|
|
|
a0d7a2 |
echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\4!"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--release-pattern )
|
|
|
a0d7a2 |
echo "${RELEASE}"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--architecture )
|
|
|
a0d7a2 |
echo "$LOCATION" | egrep "${ARCHITECTURE}" | sed -r "s!${ARCHITECTURE}!\1!"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--architecture-pattern )
|
|
|
a0d7a2 |
echo "${ARCHITECTURE}"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--theme )
|
|
|
a0d7a2 |
echo "$LOCATION" | egrep "${THEME}" | sed -r "s!.*${THEME}.*!\1!"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--theme-name )
|
|
|
a0d7a2 |
echo "$LOCATION" | egrep "${THEME}" | sed -r "s!.*${THEME}.*!\2!"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--theme-release )
|
|
|
a0d7a2 |
echo "$LOCATION" | egrep "${THEME}" | sed -r "s!.*${THEME}.*!\3!"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
--theme-pattern )
|
|
|
a0d7a2 |
echo "${THEME}"
|
|
|
a0d7a2 |
shift 2
|
|
|
a0d7a2 |
break
|
|
|
a0d7a2 |
;;
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
esac
|
|
|
a0d7a2 |
|
|
|
a0d7a2 |
done
|
|
|
5b6935 |
}
|