|
|
5b6935 |
#!/bin/bash
|
|
|
5b6935 |
#
|
|
|
78667f |
# cli_getPathComponent.sh -- This function evaluates one repository
|
|
|
78667f |
# path and output parts/components from it. Generally, the path
|
|
|
78667f |
# information is passed to the function's first positional argument
|
|
|
78667f |
# and the part/component we want to retrive is passed to the
|
|
|
78667f |
# function's second positional argument. If second argument is not
|
|
|
78667f |
# passed, then first argument is assumed to be the part/component we
|
|
|
78667f |
# want to retrive, and action value (ACTIONVAL) variable is used
|
|
|
78667f |
# instead as source path information.
|
|
|
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 |
|
|
|
5b6935 |
local -a PATTERN
|
|
|
92af02 |
local LOCATION=''
|
|
|
92af02 |
local OPTION=''
|
|
|
92af02 |
|
|
|
78667f |
# Define location which we retrive information from.
|
|
|
92af02 |
if [[ "$#" -eq 1 ]];then
|
|
|
92af02 |
LOCATION="$ACTIONVAL"
|
|
|
92af02 |
OPTION="$1"
|
|
|
92af02 |
elif [[ "$#" -eq 2 ]];then
|
|
|
92af02 |
LOCATION="$1"
|
|
|
92af02 |
OPTION="$2"
|
|
|
92af02 |
else
|
|
|
42f172 |
cli_printMessage "`gettext "Invalid arguments."`" --as-error-line
|
|
|
92af02 |
fi
|
|
|
5b6935 |
|
|
|
5b6935 |
# Define release pattern.
|
|
|
5b6935 |
PATTERN[0]="(([[:digit:]]+)(\.([[:digit:]]+)){,1})"
|
|
|
5b6935 |
|
|
|
7649f3 |
# Define architecture pattern. Make it match the architectures the
|
|
|
7649f3 |
# CentOS distribution is able to be installed on.
|
|
|
7649f3 |
PATTERN[1]="(i386|x86_64)"
|
|
|
9e4cfb |
|
|
|
9e4cfb |
# Define theme pattern for trunk, branches, and tags directory
|
|
|
9e4cfb |
# structures.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# trunk:
|
|
|
9e4cfb |
# ------
|
|
|
9e4cfb |
# Themes are made of `Models' and `Motifs'. `Models' controls the
|
|
|
9e4cfb |
# `Motifs' characteristcs and it is not rendereable. On the other
|
|
|
9e4cfb |
# hand, `Motifs' controls the theme visual style and do is
|
|
|
9e4cfb |
# renderable. Since we only need to know the theme name when we
|
|
|
9e4cfb |
# render something, we take the `Motifs' directory structure as
|
|
|
9e4cfb |
# reference to find out the theme name we are producing images
|
|
|
9e4cfb |
# for.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# `Motifs' are organized by names, so when we say `a theme name'
|
|
|
9e4cfb |
# we are really saying `the artistic motif name of a theme', but
|
|
|
9e4cfb |
# for short `theme name' is used instead. `Models' are also
|
|
|
9e4cfb |
# organized by names, but we do never use model names to name a
|
|
|
9e4cfb |
# thame. We always say the `theme models' or `the models of the
|
|
|
9e4cfb |
# theme` to refere the theme component that controls the
|
|
|
9e4cfb |
# characteristics of artistic motifs. We never name a thame as its
|
|
|
9e4cfb |
# model. We use artistic motifs name for such purpose.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Inside artistic motif names, we organize different versions of
|
|
|
9e4cfb |
# the same artistic motif by means of numerical worklines.
|
|
|
9e4cfb |
# Worklines, inside trunk, have an integer numerical form and
|
|
|
9e4cfb |
# begin at `1'. They increment one unit each time a new/fresh
|
|
|
9e4cfb |
# visual style ---for the same artistic motif--- is conceived.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# For example, the Flame theme uses the flame filter of Gimp to
|
|
|
9e4cfb |
# produce different fractal patterns randomly. We use the flame
|
|
|
9e4cfb |
# filter to produce different visual styles under the same theme
|
|
|
9e4cfb |
# since all patterns we produce are based on the same pattern
|
|
|
9e4cfb |
# (i.e., the random fractal pattern of Gimp's flame filter). This
|
|
|
9e4cfb |
# way, if you no longer want to produce visual styles from flame
|
|
|
9e4cfb |
# filter, it is time to create a new artistic motif name for it.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# This schema is very convenient for designers and packagers,
|
|
|
9e4cfb |
# since different designers can create their own worklines and go
|
|
|
9e4cfb |
# on with them until CentOS distribution release date is close. At
|
|
|
9e4cfb |
# that time, a workline is selected and tagged for packaging.
|
|
|
9e4cfb |
# Translators and programmers can continue working indepently, and
|
|
|
9e4cfb |
# without affection, in their own directory structures.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Example:
|
|
|
b39a40 |
# +------> theme name
|
|
|
b39a40 |
# |-->|
|
|
|
f259c7 |
# trunk/Identity/Images/Themes/Flame/1
|
|
|
f259c7 |
# trunk/Identity/Images/Themes/Flame/2
|
|
|
f259c7 |
# trunk/Identity/Images/Themes/Flame/3
|
|
|
b39a40 |
# |
|
|
|
b39a40 |
# +----> theme version
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Sometimes we only need to retrive the theme name, but othertimes
|
|
|
9e4cfb |
# both the theme name and its work-line is required as well.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# branches:
|
|
|
9e4cfb |
# ---------
|
|
|
9e4cfb |
# The branch development line is treated just as trunk development
|
|
|
9e4cfb |
# line does, but we rarely use it since it could be confusing to
|
|
|
9e4cfb |
# know whether a tag was created from trunk or branches.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Conceive an enumeration schema in order to differentiate
|
|
|
9e4cfb |
# branches from trunk is not convenient either, it would introduce
|
|
|
9e4cfb |
# an intermediate point to the final production of tags we would
|
|
|
9e4cfb |
# need to be aware of. Instead of such configuration, we prefer
|
|
|
9e4cfb |
# to go straightforward from trunk to tags.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Intermediate branches for quality assurance might be good in
|
|
|
9e4cfb |
# some situations, but not when we produce themes. We need a
|
|
|
9e4cfb |
# simple structure, where we could design, render content (using
|
|
|
9e4cfb |
# centos-art.sh), and release for testing (through tags). If
|
|
|
9e4cfb |
# something goes wrong in the released tag, it would be fixed in
|
|
|
9e4cfb |
# trunk and later released in another tagged relase.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Of course, care should be taken to avoid making of trunk
|
|
|
9e4cfb |
# development line a chaotic place. Everbody should know exactly
|
|
|
9e4cfb |
# what they are doing therein. We need to design protections to
|
|
|
9e4cfb |
# isolate possible damages and that way, we could know exactly
|
|
|
9e4cfb |
# what and where we need to concentrate in and put our time on.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# In resume, do not use branches if you don't need to. Use trunk
|
|
|
9e4cfb |
# development line instead.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# tags:
|
|
|
9e4cfb |
# -----
|
|
|
9e4cfb |
# The tag frozen line is mainly used to perform theme releases.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Example:
|
|
|
b39a40 |
# +------> theme name
|
|
|
b39a40 |
# |-->|
|
|
|
f259c7 |
# tags/Identity/Images/Themes/Flame/1.0
|
|
|
f259c7 |
# trunk/Identity/Images/Themes/Flame/1 |--> minor update
|
|
|
b39a40 |
# |----> major udpate
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Tags have the format X.Z, where X is the first number in the
|
|
|
9e4cfb |
# name (e.g., `1') and represents the trunk/branches artistic
|
|
|
9e4cfb |
# motif version. The Z represents the second number in the name
|
|
|
9e4cfb |
# (e.g., `0') which is the tag version itself.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Tag versions start at `0' and increment one unit each time a new
|
|
|
9e4cfb |
# tag is created from the same artistic motif version. When a new
|
|
|
9e4cfb |
# tag is created for the same artistic motif version, the first
|
|
|
9e4cfb |
# number in the tag name remains intact. The first number in the
|
|
|
9e4cfb |
# tag name only changes when we create a new tag for a new
|
|
|
9e4cfb |
# artistic motif version.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Consider the following relations:
|
|
|
9e4cfb |
#
|
|
|
f259c7 |
# trunk/Identity/Images/Themes/Flame/1
|
|
|
f259c7 |
# tags/Identity/Images/Themes/Flame/1.0
|
|
|
f259c7 |
# tags/Identity/Images/Themes/Flame/1.1
|
|
|
f259c7 |
# tags/Identity/Images/Themes/Flame/1.2
|
|
|
9e4cfb |
#
|
|
|
f259c7 |
# trunk/Identity/Images/Themes/Flame/2
|
|
|
f259c7 |
# tags/Identity/Images/Themes/Flame/2.0
|
|
|
f259c7 |
# tags/Identity/Images/Themes/Flame/2.1
|
|
|
f259c7 |
# tags/Identity/Images/Themes/Flame/2.2
|
|
|
9e4cfb |
#
|
|
|
f259c7 |
# trunk/Identity/Images/Themes/TreeFlower/1
|
|
|
9e4cfb |
# ...
|
|
|
9e4cfb |
# and so on.
|
|
|
9e4cfb |
#
|
|
|
9e4cfb |
# Tag versions are created to release fixes and improvements, Tags
|
|
|
9e4cfb |
# are immutable (i.e., once tags are created, they shouldn't be
|
|
|
9e4cfb |
# modified.).
|
|
|
f259c7 |
PATTERN[2]="Identity/Images/Themes/(([A-Za-z0-9]+)/(${PATTERN[0]}))/"
|
|
|
5b6935 |
|
|
|
5b6935 |
# Identify which part of the release we want to output.
|
|
|
9e4cfb |
case "$OPTION" in
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--release' )
|
|
|
b39a40 |
echo "$LOCATION" | egrep "${PATTERN[0]}" | sed -r "s!.*/${PATTERN[0]}/.*!\1!"
|
|
|
5b6935 |
;;
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--release-major' )
|
|
|
b39a40 |
echo "$LOCATION" | egrep "${PATTERN[0]}" | sed -r "s!.*/${PATTERN[0]}/.*!\2!"
|
|
|
5b6935 |
;;
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--release-minor' )
|
|
|
b39a40 |
echo "$LOCATION" | egrep "${PATTERN[0]}" | sed -r "s!.*/${PATTERN[0]}/.*!\4!"
|
|
|
5b6935 |
;;
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--release-pattern' )
|
|
|
9e4cfb |
echo "${PATTERN[0]}"
|
|
|
5b6935 |
;;
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--architecture' )
|
|
|
b39a40 |
echo "$LOCATION" | egrep "${PATTERN[1]}" | sed -r "s!${PATTERN[1]}!\1!"
|
|
|
5b6935 |
;;
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--architecture-pattern' )
|
|
|
9e4cfb |
echo "${PATTERN[1]}"
|
|
|
5b6935 |
;;
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--theme' )
|
|
|
47aa17 |
echo "$LOCATION" | egrep "${PATTERN[2]}" | sed -r "s!.*${PATTERN[2]}.*!\1!"
|
|
|
9e4cfb |
;;
|
|
|
9e4cfb |
|
|
|
9e4cfb |
'--theme-name' )
|
|
|
47aa17 |
echo "$LOCATION" | egrep "${PATTERN[2]}" | sed -r "s!.*${PATTERN[2]}.*!\2!"
|
|
|
5b6935 |
;;
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--theme-release' )
|
|
|
47aa17 |
echo "$LOCATION" | egrep "${PATTERN[2]}" | sed -r "s!.*${PATTERN[2]}.*!\3!"
|
|
|
9e4cfb |
;;
|
|
|
5b6935 |
|
|
|
9e4cfb |
'--theme-pattern' )
|
|
|
9e4cfb |
echo "${PATTERN[2]}"
|
|
|
9e4cfb |
;;
|
|
|
9e4cfb |
|
|
|
9e4cfb |
esac
|
|
|
5b6935 |
|
|
|
5b6935 |
}
|