|
Alain Reguera Delgado |
66223d |
#!/bin/bash
|
|
Alain Reguera Delgado |
66223d |
######################################################################
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# tcar_getPathComponent.sh -- This function standardizes the way
|
|
Alain Reguera Delgado |
66223d |
# directory structures are organized inside the working copy of
|
|
Alain Reguera Delgado |
66223d |
# CentOS Artwork Repository. You can use this function to retrieve
|
|
Alain Reguera Delgado |
66223d |
# information from paths (e.g., releases, architectures and theme
|
|
Alain Reguera Delgado |
66223d |
# artistic motifs) or the patterns used to build the paths.
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# Written by:
|
|
Alain Reguera Delgado |
66223d |
# * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# Copyright (C) 2009-2013 The CentOS Artwork SIG
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
66223d |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
66223d |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
66223d |
# your option) any later version.
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
66223d |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
66223d |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
66223d |
# General Public License for more details.
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
66223d |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
66223d |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
66223d |
#
|
|
Alain Reguera Delgado |
66223d |
######################################################################
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
function tcar_getPathComponent {
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Define short options.
|
|
Alain Reguera Delgado |
66223d |
local ARGSS=''
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Define long options.
|
|
Alain Reguera Delgado |
66223d |
local ARGSL='release,release-major,release-minor,release-pattern,architecture,architecture-pattern,motif,motif-name,motif-version,motif-pattern,repo-dir'
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Define release pattern.
|
|
Alain Reguera Delgado |
66223d |
local VERSION="(([[:digit:]]+)(\.([[:digit:]]+))?)"
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Define architecture pattern. Make it match the architectures the
|
|
Alain Reguera Delgado |
66223d |
# CentOS distribution is able to be installed on.
|
|
Alain Reguera Delgado |
66223d |
local ARCHITECTURE="(i386|x86_64)"
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Define regular expression pattern that match the theme artistic
|
|
Alain Reguera Delgado |
66223d |
# motif component inside the path strings.
|
|
Alain Reguera Delgado |
66223d |
local THEME_MOTIF="Themes/Motifs/(([[:alnum:]]+)/(${VERSION}))"
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Initialize arguments with an empty value and set it as local
|
|
Alain Reguera Delgado |
66223d |
# variable to this function scope. Doing this is very important to
|
|
Alain Reguera Delgado |
66223d |
# avoid any clash with higher execution environments.
|
|
Alain Reguera Delgado |
66223d |
local TCAR_MODULE_ARGUMENT=''
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Process all arguments currently available in this function
|
|
Alain Reguera Delgado |
66223d |
# environment. If either ARGSS or ARGSL local variables have been
|
|
Alain Reguera Delgado |
66223d |
# defined, argument processing goes through getopt for validation.
|
|
Alain Reguera Delgado |
66223d |
tcar_setModuleArguments "${@}"
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Redefine positional parameters using TCAR_MODULE_ARGUMENT variable.
|
|
Alain Reguera Delgado |
66223d |
eval set -- "${TCAR_MODULE_ARGUMENT}"
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Define location we want to apply verifications to.
|
|
Alain Reguera Delgado |
66223d |
local LOCATION=$(echo ${@} | sed -r 's!^.*--[[:space:]](.+)$!\1!')
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
# Look for options passed through positional parameters.
|
|
Alain Reguera Delgado |
66223d |
while true;do
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
case "${1}" in
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--release )
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | egrep "${VERSION}" | sed -r "s!.*/${VERSION}/.*!\1!"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--release-major )
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | egrep "${VERSION}" | sed -r "s!.*/${VERSION}/.*!\2!"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--release-minor )
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | egrep "${VERSION}" | sed -r "s!.*/${VERSION}/.*!\4!"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--release-pattern )
|
|
Alain Reguera Delgado |
66223d |
echo "${VERSION}"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--architecture )
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | egrep "${ARCHITECTURE}" | sed -r "s!${ARCHITECTURE}!\1!"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--architecture-pattern )
|
|
Alain Reguera Delgado |
66223d |
echo "${ARCHITECTURE}"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--motif )
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\1!"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--motif-name )
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\2!"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--motif-version )
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\3!"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--motif-pattern )
|
|
Alain Reguera Delgado |
66223d |
echo "${THEME_MOTIF}"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
--repo-dir )
|
|
Alain Reguera Delgado |
66223d |
echo "${LOCATION}" | sed "s,${TCAR_USER_WRKDIR}/,,"
|
|
Alain Reguera Delgado |
66223d |
shift 1
|
|
Alain Reguera Delgado |
66223d |
break
|
|
Alain Reguera Delgado |
66223d |
;;
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
esac
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
done
|
|
Alain Reguera Delgado |
66223d |
|
|
Alain Reguera Delgado |
66223d |
}
|