PageRenderTime 69ms CodeModel.GetById 28ms app.highlight 35ms RepoModel.GetById 1ms app.codeStats 0ms

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