2 # $Id: release.sh,v 1.34 2011/06/05 14:22:24 henoheno Exp $
3 # $CVSKNIT_Id: release.sh,v 1.11 2004/05/28 14:26:24 henoheno Exp $
4 # Release automation script for PukiWiki
5 # ==========================================================
6 Copyright='(C) 2002-2004,2011 minix-up project, All Rights Reserved'
7 Homepage='http://cvsknit.sourceforge.net/'
8 License='(also revised)BSD Licnese, NO WARRANTY'
11 # Name and Usage --------------------------------------------
12 _name="` basename $0 `"
15 trace 'usage()' || return # (DEBUG)
16 warn "Usage: $_name [options] VERSION_TAG (1.4.3_rc1 like)"
18 warn " --nopkg Suppress creating archive (Extract and chmod only)"
19 warn " --norm --nopkg, and remove nothing (.cvsignore etc)"
20 warn " --co --norm, and use 'checkout' command instead of 'export'"
21 warn " --utf8 Create UTF-8 converted archive (EXPERIMENTAL)"
22 warn " -z|--zip Create *.zip archive"
23 warn " --move-dist Move *.ini.php => *.ini-dist.php"
24 warn " --copy-dist Move, and Copy *.ini.php <= *.ini-dist.php"
28 # Common functions ------------------------------------------
29 warn(){ echo "$*" 1>&2 ; }
30 err() { warn "Error: $*" ; exit 1 ; }
33 test $# -gt 0 && { echo -n "\"$1\"" ; shift ; }
34 while [ $# -gt 0 ] ; do echo -n " \"$1\"" ; shift ; done ; echo
38 test "$__debug" || return 0 # (DEBUG)
39 _msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
44 [1-9].[0-9] | [1-9].[0-9] ) tag="r$1" ;;
45 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$1" ;;
46 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$1" ;;
47 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$1" ;;
48 [1-9].[0-9].[0-9]_[1-9] | [1-9].[0-9].[0-9][0-9]_[1-9] ) tag="r$1" ;;
49 [1-9].[0-9].[0-9]_[1-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[1-9]_[a-z]* ) tag="r$1" ;;
50 HEAD | r1_3_3_branch | branch_r1* ) tag="$rel" ;;
51 '' ) usage ; return 1 ;;
52 * ) warn "Error: Invalid string: $1" ; usage ; return 1 ;;
54 echo "$tag" | tr '.' '_'
60 find . -type d | while read line; do chmod 755 "$line"; done
61 find . -type f | while read line; do chmod 644 "$line"; done
62 # Add write permission for PukiWiki
63 chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null
64 chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel 2>/dev/null
68 # Default variables -----------------------------------------
72 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
74 # Function verifying arguments ------------------------------
77 trace 'getopt()' "$@" # (DEBUG)
81 -[hH]|--help ) echo _help _exit ;;
82 --debug ) echo _debug 1 ;;
83 --nopkg ) echo _nopkg 1 ;;
84 --norm|--noremove ) echo _nopkg _noremove 1 ;;
85 --co|--checkout ) echo _nopkg _noremove _checkout 1 ;;
86 -z|--zip ) echo _zip 1 ;;
87 --ut|--utf|--utf8|--utf-8 ) echo _utf8 1 ;;
88 --copy-dist ) echo _copy_dist 1 ;;
89 --move-dist ) echo _move_dist 1 ;;
90 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
91 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
98 # Working start ---------------------------------------------
100 # Show arguments in one line (DEBUG)
101 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
102 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
106 while [ $# -gt 0 ] ; do
107 chs="` getopt "$@" `" || err "Syntax error with '$1'"
108 trace '$chs ' "$chs" # (DEBUG)
116 _CVSROOT) CVSROOT="$2" ;;
118 _* ) eval "_$ch"=on ;;
125 if [ $# -eq 0 ] ; then usage ; exit ; fi
127 # Utility check ---------------------------------------------
129 if [ "$__utf8" ] ; then
132 which nkf || err "nkf version 2.0 or later (UTF-8 enabled) not found"
133 nkf_version="` nkf -v 2>&1 | sed -e '/^Network Kanji Filter/!d' -e 's/.* Version \([1-9]\).*/\1/' `"
134 if [ "$nkf_version" = '1' -o "$nkf_version" = '0' ] ; then
135 err "nkf found but not seems 2.x (UTF-8 enabled) or later"
141 then err "encls not found"
143 php="` which php `" || err "php-cli not found"
144 encls="$php `pwd`/$encls"
148 for list in "$@" ; do
149 # NOTE: Specify '-E'(From EUC-JP) otherwise skin file will be collapsed
150 nkf -Ew "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list" && echo " $list"
153 convert_EUCJP2UTF8(){
154 for list in "$@" ; do
155 # Very rough conversion!
156 #sed 's/EUC-JP/UTF-8/g' "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list"
157 sed 's#^//UTF-8:##' "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list"
164 which tar || err "tar not found"
165 which gzip || err "gzip not found"
167 which zip || err "zip not found"
170 # Argument check --------------------------------------------
173 tag="` check_versiontag "$rel" `" || exit 1
174 pkg_dir="${mod}-${rel}"
176 if [ "$__utf8" ] ; then
177 pkg_dir="${pkg_dir}_utf8"
180 # Export the module -----------------------------------------
182 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
184 if [ -z "$__checkout" ]
189 echo cvs -z3 -d "$CVSROOT" -q "$cmd" -r "$tag" -d "$pkg_dir" "$mod"
190 cvs -z3 -d "$CVSROOT" -q "$cmd" -r "$tag" -d "$pkg_dir" "$mod"
192 test -d "$pkg_dir" || err "There isn't a directory: $pkg_dir"
194 # Remove '.cvsignore' if exists -----------------------------
195 test -z "$__noremove" && {
196 echo find "$pkg_dir" -type f -name '.cvsignore' "| xargs rm -f"
197 find "$pkg_dir" -type f -name '.cvsignore' | xargs rm -f
200 # Conversion ------------------------------------------------
202 if [ "$__utf8" ] ; then
203 echo "Converting EUC-JP => UTF-8 ..."
204 find "$pkg_dir" -type f \( -name "*.txt" -or -name "*.php" -or -name "*.lng" -or -name "*.dat" -or -name "*.ref" \) |
207 "$pkg_dir"/zh-CN.lng.php ) ;; # UTF-8 already, Do nothing
208 * ) convert "$line" ;;
212 # Replace 'EUC-JP' => 'UTF-8'
214 convert_EUCJP2UTF8 lib/init.php skin/pukiwiki.skin*.php
217 # Filename encoded 'encoded-EUC-JP' to 'encoded-UTF-8'
218 echo "Renaming encoded-EUC-JP => encoded-UTF-8 ..."
220 for dir in wiki wiki.en cache; do
222 ls *.txt *.ref *.rel 2>/dev/null | while read line; do
223 target="`$encls "$line" 2>/dev/null`" || exit 1
224 if [ "x$line" != "x$target" ] ; then
225 echo " " mv "$dir/$line" "$dir/$target"
226 mv "$line" "$target" || exit 1
234 # chmod -----------------------------------------------------
238 # Create a package ------------------------------------------
240 test ! -z "$__nopkg" && exit 0
247 then tar cf - "$target" | gzip -9 > "$target".tgz
248 else zip -r9 "$target.zip" "$target"
254 then gzip -9 *.en.txt
256 for list in *.en.txt ; do
257 zip -9 "$list".zip "$list"
263 # Move / Copy *.ini.php files
264 if [ 'x' != "x$__copy_dist$__move_dist" ] ; then
267 find . -type f -name "*.ini.php" | while read file; do
268 dist_file="` echo "$file" | sed 's/ini\.php$/ini-dist.php/' `"
269 mv -f "$file" "$dist_file"
270 test "$__copy_dist" && cp -f "$dist_file" "$file"
278 echo tar cf - "$pkg_dir" \| gzip -9 \> "$pkg_dir.tar.gz"
279 tar cf - "$pkg_dir" | gzip -9 > "$pkg_dir.tar.gz"
282 echo zip -r9 "$pkg_dir.zip" "$pkg_dir"
283 zip -r9 "$pkg_dir.zip" "$pkg_dir"