Merge lp:~openerp-doc/openerp-doc-utils/doc-build-scripts-improvements-xmo into lp:~openerp-doc/openerp-doc-utils/doc-build-scripts

Proposed by Xavier (Open ERP)
Status: Merged
Merged at revision: 23
Proposed branch: lp:~openerp-doc/openerp-doc-utils/doc-build-scripts-improvements-xmo
Merge into: lp:~openerp-doc/openerp-doc-utils/doc-build-scripts
Diff against target: 128 lines (+26/-29)
1 file modified
build_doc.sh (+26/-29)
To merge this branch: bzr merge lp:~openerp-doc/openerp-doc-utils/doc-build-scripts-improvements-xmo
Reviewer Review Type Date Requested Status
OpenERP Documentation Experts Pending
Review via email: mp+143679@code.launchpad.net

Description of the change

A few improvements to the main shell script:

* Improve/simplify useless uses of test and cat
* Use pushd correctly
* Use file constants for mail attachments

To post a comment you must log in.
22. By Xavier (Open ERP)

[FIX] useless use of backticks (and echo)

23. By Xavier (Open ERP)

[FIX] useless uses of ls

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'build_doc.sh'
--- build_doc.sh 2012-06-27 09:00:36 +0000
+++ build_doc.sh 2013-03-18 13:41:21 +0000
@@ -4,6 +4,7 @@
4DOCSCRIPT=${DOCDIR}/doc-build-scripts4DOCSCRIPT=${DOCDIR}/doc-build-scripts
5LOGFILE=${DOCDIR}/build_doc.log5LOGFILE=${DOCDIR}/build_doc.log
6ERRORFILE=${DOCDIR}/build_doc.err6ERRORFILE=${DOCDIR}/build_doc.err
7BZRLOG=${DOCDIR}/bzr-log-l10.txt
7EMAIL_REPORT=openerp-doc@lists.launchpad.net8EMAIL_REPORT=openerp-doc@lists.launchpad.net
89
9function email_error {10function email_error {
@@ -12,7 +13,7 @@
12 "doc.openerp.com: error when building $version doc." \13 "doc.openerp.com: error when building $version doc." \
13 "$DOCSCRIPT/email_error_body.txt" \14 "$DOCSCRIPT/email_error_body.txt" \
14 -s "localhost" \15 -s "localhost" \
15 -a "$DOCDIR/build_doc.err, $DOCDIR/build_doc.log, $DOCDIR/bzr-log-l10.txt" \16 -a "$ERRORFILE, $LOGFILE, $BZRLOG" \
16 | msmtp -t --read-envelope-from17 | msmtp -t --read-envelope-from
17 echo "Sending email with error and log files."18 echo "Sending email with error and log files."
18}19}
@@ -23,7 +24,7 @@
23 "doc.openerp.com: success when building $version doc." \24 "doc.openerp.com: success when building $version doc." \
24 "$DOCSCRIPT/email_success_body.txt" \25 "$DOCSCRIPT/email_success_body.txt" \
25 -s "localhost" \26 -s "localhost" \
26 -a "$DOCDIR/bzr-log-l10.txt" \27 -a "$BZRLOG" \
27 | msmtp -t --read-envelope-from28 | msmtp -t --read-envelope-from
28 echo "Sending email with success message and last bzr logs."29 echo "Sending email with success message and last bzr logs."
29}30}
@@ -38,49 +39,45 @@
38 export PYTHONPATH=${DOCDIR}/bzr-repository/server-${version}39 export PYTHONPATH=${DOCDIR}/bzr-repository/server-${version}
39 fi40 fi
40 nice -n 12 make html 2>>${ERRORFILE} 1>>${LOGFILE}41 nice -n 12 make html 2>>${ERRORFILE} 1>>${LOGFILE}
41 for i in `ls -1 i18n/`; do42 for i in i18n/*; do
42 pushd .43 pushd "$i"
43 cd "i18n/$i"
44 make clean44 make clean
45 echo "Building i18n/$i"45 echo "Building $i"
46 echo "Building i18n/$i" 1>>${LOGFILE}46 echo "Building $i" >> ${LOGFILE}
47 nice -n 12 make html 2>>${ERRORFILE} 1>>${LOGFILE}47 nice -n 12 make html 2>>${ERRORFILE} 1>>${LOGFILE}
48 mv "build/html" "../../build/html/$i"48 mv "build/html" "../../build/html/$(basename $i)"
49 popd49 popd
50 done50 done
51 cat ${ERRORFILE} | grep ERROR51
52 errno=$?52 if grep -q ERROR ${ERRORFILE}; then
53 if [ "$errno" == "0" ];then53 echo "Error: make html generated errors" >> ${ERRORFILE}
54 echo "Error: make html exitcode: $errno" >> ${ERRORFILE}54 return 1
55 else
56 return 0
55 fi57 fi
56 return $errno
57}58}
5859
59# Assume to be in a doc-openerp-vX.X directory.60# Assume to be in a doc-openerp-vX.X directory.
60function bzrpull {61function bzrpull {
61 bzr pull62 if ! bzr pull; then
62 errno=$?63 echo "Error: bzr pull error" >> ${ERRORFILE}
63 if [ "$errno" != "0" ];then
64 echo "Error: bzr pull exitcode: $errno" >> ${ERRORFILE}
65 fi64 fi
66}65}
6766
68# Assume to be in a doc-openerp-vX.X directory.67# Assume to be in a doc-openerp-vX.X directory.
69function build_and_move {68function build_and_move {
70 version=$169 version=$1
71 revno=`bzr revno`70 revno=$(bzr revno)
72 bzr log -l10 > $DOCDIR/bzr-log-l10.txt71 bzr log -l10 > $BZRLOG
73 filename="${DOCDIR}/www-$version-rev$revno"72 filename="${DOCDIR}/www-$version-rev$revno"
74 if [ "$version" != "trunk" -a -e $filename ]; then73 if [ "$version" != "trunk" -a -e $filename ]; then
75 echo "$filename already exists, do nothing."74 echo "$filename already exists, do nothing."
76 else75 else
77 echo "building doc to create $filename"76 echo "building doc to create $filename"
78 makehtml $version77 if makehtml $version; then
79 ok=$?78 echo "$filename OK" >> ${LOGFILE}
80 if [ "${ok}" != "0" ]; then
81 echo "$filename OK" 1>>${LOGFILE}
82 else79 else
83 echo "An error has occured when generating $filename" 1>> ${ERRORFILE}80 echo "An error has occured when generating $filename" >> ${ERRORFILE}
84 fi81 fi
8582
86 mv build/html $filename83 mv build/html $filename
@@ -97,7 +94,7 @@
97 # create new link and delete old directories.94 # create new link and delete old directories.
98 echo "Relinking" >> $LOGFILE95 echo "Relinking" >> $LOGFILE
99 rm -rf "${DOCDIR}/www/$version" && ln -s $filename "${DOCDIR}/www/$version"96 rm -rf "${DOCDIR}/www/$version" && ln -s $filename "${DOCDIR}/www/$version"
100 for i in `ls -1d ${DOCDIR}/www-$version-rev*`; do97 for i in ${DOCDIR}/www-$version-rev*; do
101 if [ "$i" != "$filename" ]; then98 if [ "$i" != "$filename" ]; then
102 rm -rf $i99 rm -rf $i
103 fi100 fi
@@ -112,8 +109,8 @@
112}109}
113110
114for version in v5.0 v6.0 v6.1 trunk; do111for version in v5.0 v6.0 v6.1 trunk; do
115 echo `date` > $LOGFILE112 date > $LOGFILE
116 echo `date` > $ERRORFILE113 date > $ERRORFILE
117114
118 BASE_DIR=openobject-doc115 BASE_DIR=openobject-doc
119 if [ "$version" == "trunk" ]; then116 if [ "$version" == "trunk" ]; then
@@ -123,8 +120,8 @@
123 bzrpull120 bzrpull
124 build_and_move $version121 build_and_move $version
125122
126 echo `date` >> $ERRORFILE123 date >> $ERRORFILE
127 echo `date` >> $LOGFILE124 date >> $LOGFILE
128 mv $ERRORFILE ${ERRORFILE}.$version125 mv $ERRORFILE ${ERRORFILE}.$version
129 mv $LOGFILE ${LOGFILE}.$version126 mv $LOGFILE ${LOGFILE}.$version
130done127done

Subscribers

People subscribed via source and target branches