@@ -6,7 +6,7 @@ REPOS_BRANCH_TAG="template-library-os template-library-grid template-library-ope
66RELEASE=" "
77BUILD=" "
88MAXFILES=2048
9- RELEASE_ROOT=$( dirname $( readlink -f " $0 " ) )
9+ RELEASE_ROOT=$( dirname " $( readlink -f " $0 " ) " )
1010LIBRARY_CORE_DIR=$RELEASE_ROOT /src/template-library-core
1111
1212if [[ $( ulimit -n) -lt $MAXFILES ]]; then
@@ -31,26 +31,28 @@ shopt -s expand_aliases
3131# Update the Quattor version used by template-library-examples (SCDB-based) to the one being released
3232update_examples () {
3333 tag=$1
34- cd template-library-examples
35- sed -i -e " s%quattor/[0-Z\.\_\-]\+\s%quattor/$tag %" $( find clusters -name cluster.build.properties)
36- git commit -a -m " Update Quattor version used by examples to ${tag} "
37- cd ..
34+ (
35+ cd template-library-examples || return
36+ find clusters -name cluster.build.properties -print0 | xargs -0 sed -i -e " s%quattor/[0-Z\.\_\-]\+\s%quattor/$tag %"
37+ git commit -a -m " Update Quattor version used by examples to ${tag} "
38+ )
3839}
3940
4041# Remove all current configuration module related templates.
4142# To be used before starting the update: after the updated
4243# only the obsolete configuration modules will be missing.
4344clean_templates () {
44- rm -Rf ${LIBRARY_CORE_DIR} /components/*
45+ rm -Rf " ${LIBRARY_CORE_DIR} /components" /*
4546}
4647
4748# Commit to template-library-core the removal of obsolete configuration modules
4849remove_obsolete_components () {
49- cd ${LIBRARY_CORE_DIR}
50- # FIXME: ideally should check that there is only deleted files left
51- git add -A .
52- git commit -m ' Remove obsolete components'
53- cd ..
50+ (
51+ cd " ${LIBRARY_CORE_DIR} " || echo_error " Failed to change directory to '$LIBRARY_CORE_DIR '"
52+ # FIXME: ideally should check that there is only deleted files left
53+ git add -A .
54+ git commit -m ' Remove obsolete components'
55+ )
5456}
5557
5658# Update the templates related to configuration modules.
@@ -59,23 +61,23 @@ publish_templates() {
5961 echo_info " Publishing Component Templates"
6062 type=$1
6163 tag=$2
62- cd configuration-modules-$1
63- git checkout $tag
64- mvn -e clean compile
64+ cd " configuration-modules-$1 " || echo_error " Failed to change directory to 'configuration-modules- $1 ' "
65+ git checkout " $tag "
66+ mvn-c clean compile
6567 # ugly hack
6668 if [ -d ncm-metaconfig ]; then
67- cd ncm-metaconfig
69+ cd ncm-metaconfig || echo_error " Failed to change directory to 'ncm-metaconfig' "
6870 mvn -e clean test
6971 cd ..
7072 fi
71- components_root=${LIBRARY_CORE_DIR} /components
72- metaconfig_root=${LIBRARY_CORE_DIR} /metaconfig
73- mkdir -p ${components_root}
74- mkdir -p ${metaconfig_root}
75- cp -r ncm-* /target/pan/components/* ${components_root}
76- cp -r ncm-metaconfig/target/pan/metaconfig/* ${metaconfig_root}
73+ components_root=" ${LIBRARY_CORE_DIR} /components"
74+ metaconfig_root=" ${LIBRARY_CORE_DIR} /metaconfig"
75+ mkdir -p " ${components_root} "
76+ mkdir -p " ${metaconfig_root} "
77+ cp -r ncm-* /target/pan/components/* " ${components_root} "
78+ cp -r ncm-metaconfig/target/pan/metaconfig/* " ${metaconfig_root} "
7779 git checkout master
78- cd ${LIBRARY_CORE_DIR}
80+ cd " ${LIBRARY_CORE_DIR} " || return
7981 git add .
8082 git commit -m " Component templates (${type} ) for tag ${tag} "
8183 cd ..
@@ -91,7 +93,7 @@ publish_aii() {
9193
9294 # It's better to do a rm before copying, in case a template has been suppressed.
9395 # For aii-core, don't delete subdirectory as some are files not coming from somewhere else...
94- rm ${ dest_root} /* .pan
96+ rm " $ dest_root" /* .pan
9597
9698 (
9799 cd aii || return
@@ -130,52 +132,53 @@ publish_aii() {
130132# Build the template version.pan appropriate for the version
131133update_version_file () {
132134 release_major=$1
133- if [ -z " $( echo $release_major | egrep ' rc[0-9]*$' ) " ]
134- then
135- release_minor=" -1"
135+ if ! echo " $release_major " | grep -E ' rc[0-9]*$' ; then
136+ release_minor=" -1"
136137 else
137- release_minor=" _1"
138+ release_minor=" _1"
138139 fi
139140 version_template=quattor/client/version.pan
140- cd ${LIBRARY_CORE_DIR}
141+ (
142+ cd " $LIBRARY_CORE_DIR " || echo_error " Failed to change directory to '$LIBRARY_CORE_DIR '"
141143
142- cat > ${version_template} << EOF
144+ cat > ${version_template} << EOF
143145template quattor/client/version;
144146
145147variable QUATTOR_RELEASE ?= '${release_major} ';
146148variable QUATTOR_REPOSITORY_RELEASE ?= QUATTOR_RELEASE;
147149variable QUATTOR_PACKAGES_VERSION ?= QUATTOR_REPOSITORY_RELEASE + '${release_minor} ';
148150EOF
149-
150- git add .
151- git commit -m " Update Quattor version file for ${release_major} "
152- cd -
151+ git add .
152+ git commit -m " Update Quattor version file for ${release_major} "
153+ )
153154}
154155
155156tag_repository () {
156157 repo=$1
157158 tag=$2
158- cd ${repo}
159- # FIXME: we may want to check that the tag doesn't exist already
160- git tag -s -m " Release ${tag} " " ${tag} "
161- git push origin --tags HEAD
162- cd -
159+ (
160+ cd " $repo " || echo_error " Failed to change directory to '$repo '"
161+ # FIXME: we may want to check that the tag doesn't exist already
162+ git tag -s -m " Release ${tag} " " ${tag} "
163+ git push origin --tags HEAD
164+ )
163165}
164166
165167tag_branches () {
166168 repo=$1
167169 version=$2
168- cd ${repo}
169- # Ignore remote HEAD symlink and branches marked as obsolete
170- branches=$( git branch -r | grep -v ' -> ' | egrep -v ' obsolete$' )
171- for branch in ${branches}
172- do
173- branch_name=$( basename ${branch} )
174- tag=${branch_name} -${version}
175- git tag -s -m " Release ${version} of branch ${branch_name} " " ${tag} " " ${branch} "
176- done
177- git push origin --tags
178- cd -
170+ (
171+ cd " $repo " || echo_error " Failed to change directory to '$repo '"
172+ # Ignore remote HEAD symlink and branches marked as obsolete
173+ branches=$( git branch -r | grep -v ' -> ' | grep -Ev ' obsolete$' )
174+ for branch in ${branches}
175+ do
176+ branch_name=$( basename " ${branch} " )
177+ tag=${branch_name} -${version}
178+ git tag -s -m " Release ${version} of branch ${branch_name} " " ${tag} " " ${branch} "
179+ done
180+ git push origin --tags
181+ )
179182}
180183
181184function echo_warning {
@@ -204,9 +207,9 @@ function exit_usage {
204207# Check that dependencies required to perform a release are available
205208missing_deps=0
206209for cmd in {gpg,gpg-agent,git,mvn,createrepo,tar,sed}; do
207- hash $cmd 2> /dev/null || {
210+ hash " $cmd " 2> /dev/null || {
208211 echo_error " Command '$cmd ' is required but could not be found"
209- missing_deps=$(( $ missing_deps + 1 ))
212+ missing_deps=$(( missing_deps + 1 ))
210213 }
211214done
212215if [[ $missing_deps -gt 0 ]]; then
217220
218221if [[ -n $1 ]]; then
219222 RELEASE=$1
220- if echo $RELEASE | grep -qv ' ^[1-9][0-9]\?\.\([1-9]\|1[012]\)\.[0-9]\+$' ; then
223+ if echo " $RELEASE " | grep -qv ' ^[1-9][0-9]\?\.\([1-9]\|1[012]\)\.[0-9]\+$' ; then
221224 echo_error " Release version doesn't match expected format."
222225 exit_usage
223226 fi
241244details=" "
242245
243246if gpg-agent; then
244- if gpg --yes --sign $0 ; then
247+ if gpg --yes --sign " $0 " ; then
245248 echo -n " Preparing repositories for release... "
246- cd $RELEASE_ROOT
249+ cd " $RELEASE_ROOT " || exit 1
247250 mkdir -p src/
248- cd src/
251+ cd src/ || exit 1
249252 for r in $REPOS_MVN $REPOS_ONE_TAG $REPOS_BRANCH_TAG ; do
250- if [[ ! -d $r ]]; then
251- git clone -q
[email protected] :quattor/
$r .git
253+ if [[ ! -d " $r " ]]; then
254+ git clone -q
" [email protected] :quattor/$r .git" 255+ fi
256+ cd " $r " || echo_error " Failed to change directory to '$r '"
257+ if git branch -r | grep -q " $RELEASE " ; then
258+ git checkout -q " quattor-$RELEASE "
259+ else
260+ git checkout -q master
252261 fi
253- cd $r
254- git branch -r | grep $RELEASE > /dev/null && git checkout -q quattor-$RELEASE || git checkout -q master
255- details=" $details \n$r \t$( git branch | grep ' ^*' ) "
262+ details=" $details \n$r \t$( git branch | grep ' ^\*' ) "
256263 cd ..
257264 done
258265 echo " Done."
259266 echo
260- echo -e $details | column -t
267+ echo -e " $details " | column -t
261268 echo
262269 echo " We will build $VERSION from the branches shown above, continue with release? yes/NO"
263270 echo -n " > "
264- read prompt
271+ read -r prompt
265272 if [[ $prompt == " yes" ]]; then
266273 for r in $REPOS_MVN ; do
267274 echo_info " ---------------- Releasing $r ----------------"
268- cd $r
269- mvn -e -q -DautoVersionSubmodules=true -Dgpg.useagent=true -Darguments=-Dgpg.useagent=true -B -DreleaseVersion=" $VERSION " clean release:prepare
270- if [[ $? -gt 0 ]] ; then
275+ cd " $r " || echo_error " Failed to change directory to ' $r ' "
276+ mvn_prepare= " mvn -e -q -DautoVersionSubmodules=true -Dgpg.useagent=true -Darguments=-Dgpg.useagent=true -B -DreleaseVersion=$VERSION clean release:prepare"
277+ if ! $mvn_prepare ; then
271278 echo_error " RELEASE FAILURE"
272279 exit 1
273280 fi
@@ -277,31 +284,31 @@ if gpg-agent; then
277284
278285 echo_success " ---------------- Releases complete, building YUM repositories ----------------"
279286
280- cd $RELEASE_ROOT
287+ cd " $RELEASE_ROOT " || exit 1
281288 mkdir -p target/
282289
283290 echo_info " Collecting RPMs"
284- mkdir -p target/$VERSION
285- find src/ -type f -name \* .rpm | grep /target/rpm/ | xargs -I @ cp @ target/$VERSION /
291+ mkdir -p " target/$VERSION "
292+ find src/ -type f -name \* .rpm | grep /target/rpm/ | xargs -I @ cp @ " target/$VERSION /"
286293
287- cd target/
294+ cd target/ || exit 1
288295
289296 echo_info " Signing RPMs"
290- rpm --resign $VERSION /* .rpm
297+ rpm --resign " $VERSION " /* .rpm
291298
292299 echo_info " Creating repository"
293- createrepo -s sha $VERSION /
300+ createrepo -s sha " $VERSION /"
294301
295302 echo_info " Signing repository"
296- gpg --detach-sign --armor $VERSION /repodata/repomd.xml
303+ gpg --detach-sign --armor " $VERSION /repodata/repomd.xml"
297304
298305 echo_info " Creating repository tarball"
299- tar -cjf quattor-$VERSION .tar.bz2 $VERSION /
306+ tar -cjf " quattor-$VERSION .tar.bz2" " $VERSION /"
300307 echo_info " Repository tarball built: target/quattor-$VERSION .tar.bz2"
301308
302309 echo_success " ---------------- YUM repositories complete, tagging git repositories ----------------"
303310
304- cd $RELEASE_ROOT /src
311+ cd " $RELEASE_ROOT /src" || echo_error " Failed to change directory to ' $RELEASE_ROOT /src' "
305312
306313 echo_info " ---------------- Updating template-library-core ----------------"
307314 clean_templates
@@ -321,17 +328,17 @@ if gpg-agent; then
321328 update_version_file " $VERSION " && echo_info " Quattor version template sucessfully updated"
322329
323330 echo_info " Updating examples"
324- update_examples $VERSION
331+ update_examples " $VERSION "
325332
326333 echo_info " Tagging template library repositories..."
327334 # FIXME: ideally tag should be configurable but for now there is only template-library repos
328335 for repo in $REPOS_ONE_TAG
329336 do
330- tag_repository $repo " $VERSION " && echo_info " Tagged $repo "
337+ tag_repository " $repo " " $VERSION " && echo_info " Tagged $repo "
331338 done
332339 for repo in $REPOS_BRANCH_TAG
333340 do
334- tag_branches $repo " $VERSION " && echo_info " Tagged branches in $repo "
341+ tag_branches " $repo " " $VERSION " && echo_info " Tagged branches in $repo "
335342 done
336343
337344 echo_success " ---------------- Update of template-library-core successfully completed ----------------"
0 commit comments