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