/dist/make-package.sh

http://txt2tags.googlecode.com/ · Shell · 285 lines · 170 code · 67 blank · 48 comment · 33 complexity · dff9b31b91925a80f118d20ada7f86e0 MD5 · raw file

  1. #!/bin/bash
  2. # make-package.sh - Create the txt2tags .tgz for the new release
  3. # by Aurelio Jargas
  4. cd $(dirname "$0")/.. # enter into SVN root dir
  5. ROOT="$PWD"
  6. DIST="$PWD/dist"
  7. t2t="$ROOT/txt2tags"
  8. YEAR=$(date +%Y)
  9. VERSION=$(LANG= $t2t -V | sed '/txt2tags/!d; s/.*sion //; s/ <.*//')
  10. NAME=txt2tags-$VERSION
  11. OUTDIR="/tmp/$NAME"
  12. TGZ="$OUTDIR.tgz"
  13. FILES=$DIST/files/$NAME.txt
  14. # Flags to turn ON (1) or OFF (0) steps. Default is 1 to all.
  15. f_doc_update=1
  16. f_doc_check=1
  17. f_code_check=1
  18. f_cleanup=1
  19. f_copy=1
  20. f_tgz=1
  21. f_tgz_check=1
  22. ##############################################################################
  23. diffc(){ # Diff output with green/red lines instead +/-
  24. local esc=$(printf "\033")
  25. sed "
  26. s/^-\(.*\)/$esc[31;1m\1$esc[m/;
  27. s/^+\(.*\)/$esc[32;1m\1$esc[m/
  28. "
  29. }
  30. hecho(){ echo -e "\033[36;1m$*\033[m"; }
  31. ##############################################################################
  32. echo "SVN ROOT: $ROOT"
  33. echo "FILES : $FILES"
  34. echo "PACKAGE : $OUTDIR"
  35. echo "TGZ : $TGZ"
  36. echo
  37. echo "--------- Continue? --------- [^C to cancel]"
  38. read
  39. hecho ------------------------------------------------------------------------
  40. hecho ---- UPDATE DOCS
  41. if test $f_doc_update != 1
  42. then
  43. echo "Skipping conversion."
  44. else
  45. hecho "Converting Changelog"
  46. $t2t -t txt ChangeLog.t2t
  47. # OK
  48. hecho "Converting Man Pages" # -f !
  49. extras/html-update.sh -f -c -p $t2t -t man -E .man doc |
  50. grep -v 'man needs update:'
  51. ### removed from package
  52. # hecho "Converting HTML docs"
  53. # extras/html-update.sh -c -p $t2t doc
  54. ### removed from package
  55. # hecho "Converting Markup Demo"
  56. # [ "doc/markup/" -nt "doc/markup.html" ] &&
  57. # $t2t doc/markup/markup.t2t
  58. # for dir in doc/[A-Z][a-z]*/markup-*/; do
  59. # [ "$dir" -nt "${dir%/}.html" ] &&
  60. # $t2t ${dir}markup-*.t2t
  61. # done
  62. ### removed from package
  63. # hecho "Converting Markup Rules"
  64. # cd doc/rules && ./gensource && cd -
  65. # cd doc/rules && ../../txt2tags rules.t2t && cd -
  66. ### removed from package
  67. # hecho "Converting User Guides"
  68. # for dir in doc/[A-Z][a-z]*/userguide-*/; do
  69. # [ "$dir"/userguide*.t2t -nt "${dir%/}.pdf" ] && {
  70. # cd "$dir" && ./pdfgen && cd - ; }
  71. # done
  72. hecho "Converting User Guide"
  73. cd doc/English/userguide/ && ./pdfgen && cd -
  74. hecho "Converting samples"
  75. rm -fv samples/sample.{out,aux,log,toc,tex.bak,pdf}
  76. for t in $($t2t --targets | cut -f 1); do
  77. $t2t -t $t samples/sample.t2t
  78. done
  79. $t2t -t art --slides -i samples/sample.t2t -o samples/sample-slides-80x25.art
  80. hecho "Converting CSS samples"
  81. samples/css/gen
  82. fi
  83. hecho ------------------------------------------------------------------------
  84. hecho ---- CHECK UP
  85. if test $f_doc_check != 1
  86. then
  87. echo "Skipping docs checking."
  88. else
  89. # ChangeLog
  90. hecho "ChangeLog: searching for lines >80 columns"
  91. sed "s/$(echo -ne '\t')/ /g" ChangeLog | egrep '.{81}'
  92. # Man page
  93. hecho "Man Page: checking year in header"
  94. sed -n 3p doc/English/manpage.t2t | grep -qs "$YEAR$" || echo FAIL
  95. hecho "Man Page: checking year of Copyright"
  96. grep -qs "Copyright.*$YEAR" doc/English/manpage.man || echo FAIL
  97. # Man page - Portuguese
  98. hecho "Man Page (pt): checking year in header"
  99. sed -n 3p doc/Portuguese/manpage-pt.t2t | grep -qs "$YEAR$" || echo FAIL
  100. hecho "Man Page (pt): checking year of Copyright"
  101. grep -qs "Copyright.*$YEAR" doc/Portuguese/manpage-pt.man || echo FAIL
  102. fi
  103. if test $f_code_check != 1
  104. then
  105. echo "Skipping code checking."
  106. else
  107. hecho "Web interface: checking if is_standalone is turned ON"
  108. grep -qs '^\$is_standalone = 1;$' extras/txt2tags.php || echo FAIL
  109. # test-suite
  110. hecho "Test-suite: searching for error files"
  111. ls -1 test/*/error/* 2>/dev/null
  112. # Source code
  113. $DIST/check-code.sh
  114. fi
  115. hecho ------------------------------------------------------------------------
  116. hecho ---- CLEAN UP
  117. if test $f_cleanup != 1
  118. then
  119. echo "Skipping clean up."
  120. else
  121. hecho "Removing .DS_Store files (Mac)"
  122. find . -type f -name .DS_Store -exec rm -v {} \;
  123. hecho "Removing .pyc files"
  124. find . -type f -name *.pyc -exec rm -v {} \;
  125. hecho "Removing temporary PO files"
  126. rm -fv po/*.{new,old,mo}
  127. rm -fv po/messages
  128. hecho "Removing empty error folders in test-suite"
  129. rmdir test/*/error/ 2>&1 | grep -v 'No such file or directory'
  130. fi
  131. hecho ------------------------------------------------------------------------
  132. hecho ---- COPY FILES
  133. if test $f_copy != 1
  134. then
  135. echo "Skipping copy."
  136. else
  137. hecho "Create the empty package folder"
  138. test -d $OUTDIR && rm -r ${OUTDIR:-XXXNOTFOUNDXXX}
  139. mkdir $OUTDIR || { echo FAIL; exit 1; }
  140. # XXX use rsync instead cp (attention to -X)
  141. hecho "Copy files and folders, except /doc"
  142. cp -Rp -X \
  143. extras samples po test \
  144. COPYING README ChangeLog \
  145. txt2tags \
  146. $OUTDIR
  147. hecho "Create /doc in package"
  148. mkdir $OUTDIR/doc/ || { echo FAIL; exit 1; }
  149. hecho "Copy files to package /doc"
  150. cp -Xp doc/English/*.pdf $OUTDIR/doc/ # PDF: User Guide and quickref
  151. cp -Xp doc/English/manpage.man $OUTDIR/doc/ # manpage
  152. cp -Xp doc/English/manpage.t2t $OUTDIR/doc/ # manpage sources
  153. cp -Xp doc/*/manpage*.man $OUTDIR/doc/ # manpage translations
  154. # remove private files
  155. # rm -r $OUTDIR/po/tools
  156. rm $OUTDIR/samples/css/gen
  157. rm $OUTDIR/test/escaping.t2t
  158. rm $OUTDIR/po/tools/pygettext.py
  159. cp -Xp po/tools/pygettext.py $OUTDIR/po/tools/
  160. # remove SVN folders
  161. find $OUTDIR -type d -name .svn -exec rm -rf {} \; 2>/dev/null
  162. fi
  163. hecho ------------------------------------------------------------------------
  164. hecho ---- MAKE PACKAGE
  165. if test $f_tgz != 1
  166. then
  167. echo "Skipping package creation."
  168. else
  169. hecho "Making tgz"
  170. (cd $OUTDIR/.. && tar czf $NAME.tgz $NAME)
  171. fi
  172. hecho ------------------------------------------------------------------------
  173. hecho ---- CHECK PACKAGE
  174. if test $f_tgz_check != 1
  175. then
  176. echo "Skipping package check."
  177. exit
  178. fi
  179. #-----------------------------------------------------------------------------
  180. hecho "Extract information from the package"
  181. cd $OUTDIR
  182. tgz_size=$( du -hs "$TGZ" | cut -f1)
  183. folder_size=$(du -hs . | cut -f1)
  184. nr_files=$( find . -type f | wc -l | tr -d ' ')
  185. nr_folders=$( find . -type d -mindepth 1 | wc -l | tr -d ' ')
  186. echo -n "$tgz_size .tgz, $folder_size dir, $nr_files files, "
  187. echo "$nr_folders folders"
  188. #-----------------------------------------------------------------------------
  189. hecho "Check permissions (chmod)"
  190. # Find files with wrong permissions
  191. chmod_folder=$(find . -type d -not -perm 0755 -mindepth 1)
  192. chmod_file=$( find . -type f -not -perm 0644)
  193. chmod_file2=$( find . -type f -not -perm 0644 -and -not -perm 0755)
  194. # Exclude known executables from file permission check
  195. chmod_file=$(echo "$chmod_file" | egrep -vw \
  196. '\./(extras/(html-update.sh|t2tmake.rb|t2tconv|gensite|dynartslides)|txt2tags|test/run.py|test/(art|sample)/run.sh|po/tools/(pygettext.py|(update-pot?|stats).sh))$')
  197. # Show results
  198. hecho '--- !644 files' ; test -n "$chmod_file" && echo "$chmod_file"
  199. hecho '--- !755 folders' ; test -n "$chmod_folder" && echo "$chmod_folder"
  200. hecho '--- !644 !755 files' ; test -n "$chmod_file2" && echo "$chmod_file2"
  201. #-----------------------------------------------------------------------------
  202. hecho "List added/removed files"
  203. # Save package contents listing
  204. $DIST/list-package-files.sh "$TGZ" > $FILES
  205. # Save the file names from the package listings
  206. this_version_files=$(sed 's|.* txt2tags-.../||' "$FILES")
  207. prev_version_files=$(sed 's|.* txt2tags-.../||' $(find $DIST/files | tail -n 2 | sed -n 1p))
  208. # Discover new and removed files for this release
  209. files_diff=$(
  210. diff -U 0 <(echo "$prev_version_files") <(echo "$this_version_files") |
  211. grep '^[+-][^+-]' |
  212. diffc
  213. )
  214. # Show results
  215. test -n "$files_diff" && echo "$files_diff"
  216. #-----------------------------------------------------------------------------
  217. hecho '--- Search Mac hidden files'
  218. grep -F ._ $FILES