@@ -47,7 +47,7 @@ clean_templates() {
47
47
48
48
# Commit to template-library-core the removal of obsolete configuration modules
49
49
remove_obsolete_components () {
50
- cd " ${LIBRARY_CORE_DIR} " || echo_error " Failed to change directory to ' $LIBRARY_CORE_DIR ' "
50
+ cd_or_die " ${LIBRARY_CORE_DIR} "
51
51
# FIXME: ideally should check that there is only deleted files left
52
52
git add -A .
53
53
git commit -m ' Remove obsolete components'
@@ -60,12 +60,12 @@ publish_templates() {
60
60
echo_info " Publishing Component Templates"
61
61
type=$1
62
62
tag=$2
63
- cd " configuration-modules-$1 " || echo_error " Failed to change directory to 'configuration-modules- $1 ' "
63
+ cd_or_die " configuration-modules-$1 "
64
64
git checkout " $tag "
65
65
mvn-c clean compile
66
66
# ugly hack
67
67
if [ -d ncm-metaconfig ]; then
68
- cd ncm-metaconfig || echo_error " Failed to change directory to 'ncm-metaconfig' "
68
+ cd_or_die ncm-metaconfig
69
69
mvn-c clean test
70
70
cd ..
71
71
fi
@@ -76,7 +76,7 @@ publish_templates() {
76
76
cp -r ncm-* /target/pan/components/* " ${components_root} "
77
77
cp -r ncm-metaconfig/target/pan/metaconfig/* " ${metaconfig_root} "
78
78
git checkout master
79
- cd " ${LIBRARY_CORE_DIR} "
79
+ cd_or_die " ${LIBRARY_CORE_DIR} "
80
80
git add .
81
81
git commit -m " Component templates (${type} ) for tag ${tag} "
82
82
cd ..
@@ -138,7 +138,7 @@ update_version_file() {
138
138
release_minor=" _1"
139
139
fi
140
140
version_template=quattor/client/version.pan
141
- cd " $LIBRARY_CORE_DIR " || echo_error " Failed to change directory to ' $LIBRARY_CORE_DIR ' "
141
+ cd_or_die " $LIBRARY_CORE_DIR "
142
142
143
143
cat > ${version_template} << EOF
144
144
template quattor/client/version;
156
156
tag_repository () {
157
157
repo=$1
158
158
tag=$2
159
- cd " $repo " || echo_error " Failed to change directory to ' $repo ' "
159
+ cd_or_die " $repo "
160
160
# FIXME: we may want to check that the tag doesn't exist already
161
161
git tag -s -m " Release ${tag} " " ${tag} "
162
162
git push origin --tags HEAD
@@ -166,7 +166,7 @@ tag_repository() {
166
166
tag_branches () {
167
167
repo=$1
168
168
version=$2
169
- cd " $repo " || echo_error " Failed to change directory to ' $repo ' "
169
+ cd_or_die " $repo "
170
170
# Ignore remote HEAD symlink and branches marked as obsolete
171
171
branches=$( git branch -r | grep -v ' -> ' | egrep -v ' obsolete$' )
172
172
for branch in ${branches}
@@ -202,6 +202,12 @@ function exit_usage {
202
202
exit 3
203
203
}
204
204
205
+ function cd_or_die {
206
+ # Change directory or die trying
207
+ cd " $@ " || error 2 " Failed to change directory to $* "
208
+ return 0
209
+ }
210
+
205
211
# Check that dependencies required to perform a release are available
206
212
missing_deps=0
207
213
for cmd in {gpg,gpg-agent,git,mvn,createrepo,tar,sed}; do
@@ -251,7 +257,7 @@ if gpg-agent; then
251
257
if [[ ! -d " $r " ]]; then
252
258
git clone -q
" [email protected] :quattor/$r .git"
253
259
fi
254
- cd " $r " || echo_error " Failed to change directory to ' $r ' "
260
+ cd_or_die " $r "
255
261
git branch -r | grep " $RELEASE " > /dev/null && git checkout -q " quattor-$RELEASE " || git checkout -q master
256
262
details=" $details \n$r \t$( git branch | grep ' ^\*' ) "
257
263
cd ..
@@ -266,7 +272,7 @@ if gpg-agent; then
266
272
if [[ $prompt == " yes" ]]; then
267
273
for r in $REPOS_MVN ; do
268
274
echo_info " ---------------- Releasing $r ----------------"
269
- cd " $r " || echo_error " Failed to change directory to ' $r ' "
275
+ cd_or_die " $r "
270
276
mvn-c -q -DautoVersionSubmodules=true -Dgpg.useagent=true -Darguments=-Dgpg.useagent=true -B -D" releaseVersion=$VERSION " clean release:prepare
271
277
if [[ $? -gt 0 ]]; then
272
278
echo_error " RELEASE FAILURE"
@@ -302,7 +308,7 @@ if gpg-agent; then
302
308
303
309
echo_success " ---------------- YUM repositories complete, tagging git repositories ----------------"
304
310
305
- cd " $RELEASE_ROOT /src" || echo_error " Failed to change directory to ' $RELEASE_ROOT /src' "
311
+ cd_or_die " $RELEASE_ROOT /src"
306
312
307
313
echo_info " ---------------- Updating template-library-core ----------------"
308
314
clean_templates
0 commit comments