328582
Add cli_checkRepoDirTarget.sh and cli_getRepodirParallel.sh.
@@ -0,0 +1,96 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# cli_checkRepoDirTarget.sh -- This function provides input validation
|
4
|
+
# to repository entries considered as target location.
|
5
|
+
#
|
6
|
+
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or
|
9
|
+
# modify it under the terms of the GNU General Public License as
|
10
|
+
# published by the Free Software Foundation; either version 2 of the
|
11
|
+
# License, or (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful, but
|
14
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16
|
+
# General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
21
|
+
# USA.
|
22
|
+
#
|
23
|
+
# ----------------------------------------------------------------------
|
24
|
+
# $Id: cli_checkRepoDirTarget.sh 547 2010-11-26 16:58:06Z al $
|
25
|
+
# ----------------------------------------------------------------------
|
26
|
+
|
27
|
+
function cli_checkRepoDirTarget {
|
28
|
+
|
29
|
+
# Check target value before making an absolute path from it.
|
30
|
+
if [[ $TARGET =~ '(\.\.(/)?)' ]];then
|
31
|
+
cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine'
|
32
|
+
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
33
|
+
fi
|
34
|
+
if [[ ! $TARGET =~ '^[A-Za-z0-9\.:/-]+$' ]];then
|
35
|
+
cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine'
|
36
|
+
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
37
|
+
fi
|
38
|
+
|
39
|
+
# Redefine target value to build repository absolute path from
|
40
|
+
# repository top level on. As we are removing
|
41
|
+
# /home/centos/artwork/ from all centos-art.sh output (in order to
|
42
|
+
# save horizontal output space), we need to be sure that all
|
43
|
+
# strings begining with trunk/..., branches/..., and tags/... use
|
44
|
+
# the correct absolute path. That is, you can refer trunk's
|
45
|
+
# entries using both /home/centos/artwork/trunk/... or just
|
46
|
+
# trunk/..., the /home/centos/artwork/ part is automatically added
|
47
|
+
# here.
|
48
|
+
if [[ $TARGET =~ '^(trunk|branches|tags)/.+$' ]];then
|
49
|
+
TARGET=/home/centos/artwork/$TARGET
|
50
|
+
fi
|
51
|
+
|
52
|
+
# Check target value.
|
53
|
+
if [[ -a ${TARGET} ]];then
|
54
|
+
|
55
|
+
# At this point target value does existent as working copy
|
56
|
+
# entry. We don't use existent locations as target. So, print
|
57
|
+
# a message and stop script execution.
|
58
|
+
cli_printMessage "`eval_gettext "The location \\\`\\\$TARGET' already exists."`" 'AsErrorLine'
|
59
|
+
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
60
|
+
|
61
|
+
else
|
62
|
+
|
63
|
+
# At this point existent locations inside working copy and
|
64
|
+
# invalid urls have been discarded. Assume a new target
|
65
|
+
# location has being specified. So, build the absolute path
|
66
|
+
# for it.
|
67
|
+
|
68
|
+
# Add directory to the top of the directory stack.
|
69
|
+
pushd "$(dirname $TARGET)" > /dev/null
|
70
|
+
|
71
|
+
# Check directory existence inside the repository.
|
72
|
+
if [[ $(pwd) =~ '^/home/centos/artwork' ]];then
|
73
|
+
# Re-define target value using absolute path.
|
74
|
+
TARGET=$(pwd)/$(basename $TARGET)
|
75
|
+
fi
|
76
|
+
|
77
|
+
# Remove directory from the directory stack.
|
78
|
+
popd > /dev/null
|
79
|
+
|
80
|
+
# Verify target location. It is required that target location
|
81
|
+
# points to an entry under (trunk|branches|tags)/Identity/...
|
82
|
+
# directory structure *only*. Remember that Identity parent
|
83
|
+
# directory structure is the reference used to create parallel
|
84
|
+
# directories (i.e., documentation, configuration scripts,
|
85
|
+
# translations, etc.). We don't manipulate parallel
|
86
|
+
# directories with path ---or any other--- functionality
|
87
|
+
# directly. Consider manipulation of parallel directories as
|
88
|
+
# a consequence of a previous manipulation of Identity parent
|
89
|
+
# directory structure.
|
90
|
+
if [[ ! ${TARGET} =~ '^.+/(trunk|branches|tags)/Identity/.+$' ]];then
|
91
|
+
cli_printMessage "`eval_gettext "cannot create \\\`\\\$TARGET': It isn't an identity directory structure."`" 'AsErrorLine'
|
92
|
+
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
93
|
+
fi
|
94
|
+
fi
|
95
|
+
|
96
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# cli_getRepoDirParallel.sh -- This function returns the parallel
|
4
|
+
# directory of path passed through action value variable. This
|
5
|
+
# function implements the parallel directory conceptual idea.
|
6
|
+
#
|
7
|
+
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
8
|
+
#
|
9
|
+
# This program is free software; you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation; either version 2 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# This program is distributed in the hope that it will be useful, but
|
15
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
# General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with this program; if not, write to the Free Software
|
21
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
22
|
+
# USA.
|
23
|
+
#
|
24
|
+
# ----------------------------------------------------------------------
|
25
|
+
# $Id$
|
26
|
+
# ----------------------------------------------------------------------
|
27
|
+
|
28
|
+
function cli_getRepoDirParallel {
|
29
|
+
|
30
|
+
# Initialize bond string.
|
31
|
+
local BOND=$1
|
32
|
+
|
33
|
+
# Initialize parallel directory using first argument.
|
34
|
+
local DIR=$2
|
35
|
+
|
36
|
+
# Remove top level directory from action value to create the bond.
|
37
|
+
BOND=$(echo $BOND | sed -r "s!^.+/(trunk|branches|tags)/!!")
|
38
|
+
|
39
|
+
# Concatenate parallel-directory base location and bond
|
40
|
+
# information in order to produce the final parallel-directory
|
41
|
+
# path.
|
42
|
+
echo $DIR/$BOND
|
43
|
+
|
44
|
+
}
|