|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# cli_getPathComponent.sh -- This function standardizes the way
|
|
|
878a2b |
# directory structures are organized inside the working copy of CentOS
|
|
|
878a2b |
# Artwork Repository. You can use this function to retrive information
|
|
|
878a2b |
# from paths (e.g., releases, architectures and theme artistic motifs)
|
|
|
878a2b |
# or the patterns used to build the paths.
|
|
|
878a2b |
#
|
|
|
03486a |
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
# it under the terms of the GNU General Public License as published by
|
|
|
878a2b |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
878a2b |
# your option) any later version.
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is distributed in the hope that it will be useful, but
|
|
|
878a2b |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
878a2b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
# You should have received a copy of the GNU General Public License
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function cli_getPathComponent {
|
|
|
878a2b |
|
|
|
878a2b |
# Define short options.
|
|
|
878a2b |
local ARGSS=''
|
|
|
878a2b |
|
|
|
878a2b |
# Define long options.
|
|
|
878a2b |
local ARGSL='release,release-major,release-minor,release-pattern,architecture,architecture-pattern,motif,motif-name,motif-release,motif-pattern'
|
|
|
878a2b |
|
|
|
878a2b |
# Define release pattern.
|
|
|
878a2b |
local RELEASE="(([[:digit:]]+)(\.([[:digit:]]+)){0,1})"
|
|
|
878a2b |
|
|
|
878a2b |
# Define architecture pattern. Make it match the architectures the
|
|
|
878a2b |
# CentOS distribution is able to be installed on.
|
|
|
878a2b |
local ARCHITECTURE="(i386|x86_64)"
|
|
|
878a2b |
|
|
|
878a2b |
# Define pattern for themes' artistic motifs.
|
|
|
878a2b |
local THEME_MOTIF="Identity/Images/Themes/(([[:alnum:]]+)/(${RELEASE}))"
|
|
|
878a2b |
|
|
|
1c94ca |
# Initialize arguments with an empty value and set it as local
|
|
|
1c94ca |
# variable to this function scope. Doing this is very important to
|
|
|
1c94ca |
# avoid any clash with higher execution environments.
|
|
|
1c94ca |
local ARGUMENTS=''
|
|
|
1c94ca |
|
|
|
1c94ca |
# Prepare ARGUMENTS variable for getopt.
|
|
|
878a2b |
cli_parseArgumentsReDef "$@"
|
|
|
878a2b |
|
|
|
1c94ca |
# Redefine ARGUMENTS using getopt(1) command parser.
|
|
|
878a2b |
cli_parseArguments
|
|
|
878a2b |
|
|
|
878a2b |
# Redefine positional parameters using ARGUMENTS variable.
|
|
|
878a2b |
eval set -- "$ARGUMENTS"
|
|
|
878a2b |
|
|
|
878a2b |
# Define location we want to apply verifications to.
|
|
|
878a2b |
local LOCATION=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!')
|
|
|
878a2b |
|
|
|
878a2b |
# Look for options passed through positional parameters.
|
|
|
878a2b |
while true;do
|
|
|
878a2b |
|
|
|
878a2b |
case "$1" in
|
|
|
878a2b |
|
|
|
878a2b |
--release )
|
|
|
878a2b |
echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\1!"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--release-major )
|
|
|
878a2b |
echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\2!"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--release-minor )
|
|
|
878a2b |
echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\4!"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--release-pattern )
|
|
|
878a2b |
echo "${RELEASE}"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--architecture )
|
|
|
878a2b |
echo "$LOCATION" | egrep "${ARCHITECTURE}" | sed -r "s!${ARCHITECTURE}!\1!"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--architecture-pattern )
|
|
|
878a2b |
echo "${ARCHITECTURE}"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--motif )
|
|
|
878a2b |
echo "$LOCATION" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\1!"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--motif-name )
|
|
|
878a2b |
echo "$LOCATION" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\2!"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--motif-release )
|
|
|
878a2b |
echo "$LOCATION" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\3!"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--motif-pattern )
|
|
|
878a2b |
echo "${THEME_MOTIF}"
|
|
|
878a2b |
shift 1
|
|
|
878a2b |
break
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
esac
|
|
|
878a2b |
|
|
|
878a2b |
done
|
|
|
1c94ca |
|
|
|
878a2b |
}
|