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
1=== modified file 'build_doc.sh'
2--- build_doc.sh 2012-06-27 09:00:36 +0000
3+++ build_doc.sh 2013-03-18 13:41:21 +0000
4@@ -4,6 +4,7 @@
5 DOCSCRIPT=${DOCDIR}/doc-build-scripts
6 LOGFILE=${DOCDIR}/build_doc.log
7 ERRORFILE=${DOCDIR}/build_doc.err
8+BZRLOG=${DOCDIR}/bzr-log-l10.txt
9 EMAIL_REPORT=openerp-doc@lists.launchpad.net
10
11 function email_error {
12@@ -12,7 +13,7 @@
13 "doc.openerp.com: error when building $version doc." \
14 "$DOCSCRIPT/email_error_body.txt" \
15 -s "localhost" \
16- -a "$DOCDIR/build_doc.err, $DOCDIR/build_doc.log, $DOCDIR/bzr-log-l10.txt" \
17+ -a "$ERRORFILE, $LOGFILE, $BZRLOG" \
18 | msmtp -t --read-envelope-from
19 echo "Sending email with error and log files."
20 }
21@@ -23,7 +24,7 @@
22 "doc.openerp.com: success when building $version doc." \
23 "$DOCSCRIPT/email_success_body.txt" \
24 -s "localhost" \
25- -a "$DOCDIR/bzr-log-l10.txt" \
26+ -a "$BZRLOG" \
27 | msmtp -t --read-envelope-from
28 echo "Sending email with success message and last bzr logs."
29 }
30@@ -38,49 +39,45 @@
31 export PYTHONPATH=${DOCDIR}/bzr-repository/server-${version}
32 fi
33 nice -n 12 make html 2>>${ERRORFILE} 1>>${LOGFILE}
34- for i in `ls -1 i18n/`; do
35- pushd .
36- cd "i18n/$i"
37+ for i in i18n/*; do
38+ pushd "$i"
39 make clean
40- echo "Building i18n/$i"
41- echo "Building i18n/$i" 1>>${LOGFILE}
42+ echo "Building $i"
43+ echo "Building $i" >> ${LOGFILE}
44 nice -n 12 make html 2>>${ERRORFILE} 1>>${LOGFILE}
45- mv "build/html" "../../build/html/$i"
46+ mv "build/html" "../../build/html/$(basename $i)"
47 popd
48 done
49- cat ${ERRORFILE} | grep ERROR
50- errno=$?
51- if [ "$errno" == "0" ];then
52- echo "Error: make html exitcode: $errno" >> ${ERRORFILE}
53+
54+ if grep -q ERROR ${ERRORFILE}; then
55+ echo "Error: make html generated errors" >> ${ERRORFILE}
56+ return 1
57+ else
58+ return 0
59 fi
60- return $errno
61 }
62
63 # Assume to be in a doc-openerp-vX.X directory.
64 function bzrpull {
65- bzr pull
66- errno=$?
67- if [ "$errno" != "0" ];then
68- echo "Error: bzr pull exitcode: $errno" >> ${ERRORFILE}
69+ if ! bzr pull; then
70+ echo "Error: bzr pull error" >> ${ERRORFILE}
71 fi
72 }
73
74 # Assume to be in a doc-openerp-vX.X directory.
75 function build_and_move {
76 version=$1
77- revno=`bzr revno`
78- bzr log -l10 > $DOCDIR/bzr-log-l10.txt
79+ revno=$(bzr revno)
80+ bzr log -l10 > $BZRLOG
81 filename="${DOCDIR}/www-$version-rev$revno"
82 if [ "$version" != "trunk" -a -e $filename ]; then
83 echo "$filename already exists, do nothing."
84 else
85 echo "building doc to create $filename"
86- makehtml $version
87- ok=$?
88- if [ "${ok}" != "0" ]; then
89- echo "$filename OK" 1>>${LOGFILE}
90+ if makehtml $version; then
91+ echo "$filename OK" >> ${LOGFILE}
92 else
93- echo "An error has occured when generating $filename" 1>> ${ERRORFILE}
94+ echo "An error has occured when generating $filename" >> ${ERRORFILE}
95 fi
96
97 mv build/html $filename
98@@ -97,7 +94,7 @@
99 # create new link and delete old directories.
100 echo "Relinking" >> $LOGFILE
101 rm -rf "${DOCDIR}/www/$version" && ln -s $filename "${DOCDIR}/www/$version"
102- for i in `ls -1d ${DOCDIR}/www-$version-rev*`; do
103+ for i in ${DOCDIR}/www-$version-rev*; do
104 if [ "$i" != "$filename" ]; then
105 rm -rf $i
106 fi
107@@ -112,8 +109,8 @@
108 }
109
110 for version in v5.0 v6.0 v6.1 trunk; do
111- echo `date` > $LOGFILE
112- echo `date` > $ERRORFILE
113+ date > $LOGFILE
114+ date > $ERRORFILE
115
116 BASE_DIR=openobject-doc
117 if [ "$version" == "trunk" ]; then
118@@ -123,8 +120,8 @@
119 bzrpull
120 build_and_move $version
121
122- echo `date` >> $ERRORFILE
123- echo `date` >> $LOGFILE
124+ date >> $ERRORFILE
125+ date >> $LOGFILE
126 mv $ERRORFILE ${ERRORFILE}.$version
127 mv $LOGFILE ${LOGFILE}.$version
128 done

Subscribers

People subscribed via source and target branches