dongsheng@634: #!/bin/sh
dongsheng@634: 
dongsheng@874: #
dongsheng@874: # Package build results & Upload to i18n-zh
dongsheng@874: #
dongsheng@874: 
dongsheng@634: build_dir=`dirname "$0"`/../build
dongsheng@634: rev_id=`hg parents --template '{date|shortdate}' | sed 's/-//g'`
dongsheng@634: 
dongsheng@874: for l in en zh it; do
dongsheng@637:   (
dongsheng@637:   if [ ! -d "${build_dir}/${l}" ] ; then
dongsheng@637:     continue
dongsheng@637:   fi
dongsheng@637: 
dongsheng@637:   cd ${build_dir}/${l};
dongsheng@634: 
dongsheng@634:   f='html'
dongsheng@634:   if [ -f "${f}/index.html" ] ; then
dongsheng@634:      d=hgbook-${l}-${f}
dongsheng@634:      rm -fr ${d} && cp -r ${f} ${d} && tar czf ../${d}-${rev_id}.tar.gz ${d}
dongsheng@634:   fi
dongsheng@634: 
dongsheng@634:   f='html-single'
dongsheng@634:   if [ -f "${f}/hgbook.html" ] ; then
dongsheng@634:      d=hgbook-${l}-${f}
dongsheng@634:      rm -fr ${d} && cp -r ${f} ${d} && tar czf ../${d}-${rev_id}.tar.gz ${d}
dongsheng@634:   fi
dongsheng@634: 
dongsheng@634:   if [ -f "pdf/hgbook.pdf" ] ; then
dongsheng@634:      cp pdf/hgbook.pdf ../hgbook-${l}-${rev_id}.pdf
dongsheng@634:      gzip -f9 ../hgbook-${l}-${rev_id}.pdf
dongsheng@634:   fi
songdongsheng@663: 
songdongsheng@663:   if [ -f "epub/hgbook.epub" ] ; then
songdongsheng@663:      cp epub/hgbook.epub ../hgbook-${l}-${rev_id}.epub
songdongsheng@663:   fi
dongsheng@634:   )
dongsheng@634: done
dongsheng@634: 
dongsheng@634: upload_pass=$1
dongsheng@634: upload_user=$2
dongsheng@634: 
songdongsheng@663: # echo "upload_pass: ${upload_pass}"
songdongsheng@663: # echo "upload_user: ${upload_user}"
songdongsheng@663: 
dongsheng@634: if [ "${upload_user}x" == "x" ]; then
dongsheng@634:   upload_user="dongsheng.song"
dongsheng@634: fi
dongsheng@634: 
dongsheng@634: if [ "${upload_pass}x" != "x" ]; then
dongsheng@634:   (
dongsheng@634:   cd ${build_dir}
dongsheng@637:   curl -s -O http://support.googlecode.com/svn/trunk/scripts/googlecode_upload.py
dongsheng@637:   if [[ "0" != $? ]]; then
dongsheng@637:     exit 1
dongsheng@637:   fi
dongsheng@634: 
dongsheng@634:   for l in en zh; do
songdongsheng@663:     if [ -f "hgbook-${l}-${rev_id}.epub" ] ; then
songdongsheng@663:       python googlecode_upload.py --user="${upload_user}" --password="${upload_pass}" \
songdongsheng@663:           -p "i18n-zh" -l "Type-Docs,book,hgbook,hg,mercurial,ebook" \
songdongsheng@663:           -s "Distributed revision control with Mercurial - ${l} - ePub" \
songdongsheng@663:           hgbook-${l}-${rev_id}.epub
songdongsheng@663:     fi
songdongsheng@663: 
dongsheng@637:     if [ -f "hgbook-${l}-${rev_id}.pdf.gz" ] ; then
songdongsheng@663:       python googlecode_upload.py --user="${upload_user}" --password="${upload_pass}" \
songdongsheng@663:           -p "i18n-zh" -l "Type-Docs,book,hgbook,hg,mercurial" \
dongsheng@637:           -s "Distributed revision control with Mercurial - ${l} - pdf" \
dongsheng@637:           hgbook-${l}-${rev_id}.pdf.gz
dongsheng@637:     fi
dongsheng@634: 
dongsheng@634:     for f in html html-single; do
songdongsheng@663:       if [ -f "hgbook-${l}-${f}-${rev_id}.tar.gz" ] ; then
songdongsheng@663:         python googlecode_upload.py --user="${upload_user}" --password="${upload_pass}" \
songdongsheng@663:             -p "i18n-zh" -l "Type-Docs,book,hgbook,hg,mercurial" \
dongsheng@637:             -s "Distributed revision control with Mercurial - ${l} - ${f}" \
dongsheng@637:             hgbook-${l}-${f}-${rev_id}.tar.gz
dongsheng@637:       fi
dongsheng@634:     done
dongsheng@634:   done
dongsheng@634:   )
dongsheng@634: fi