2 # $Id: release.sh,v 1.19 2005/04/17 05:04:13 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 minix-up project, All Rights Reserved'
7 Homepage='http://cvsknit.sourceforge.net/'
8 License='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 " -z|--zip Create *.zip archive"
21 warn " --move-dist Move *.ini.php => *.ini-dist.php"
22 warn " --copy-dist Move, and Copy *.ini.php <= *.ini-dist.php"
26 # Common functions ------------------------------------------
27 warn(){ echo "$*" 1>&2 ; }
28 err() { warn "Error: $*" ; exit 1 ; }
31 test $# -gt 0 && { echo -n "\"$1\"" ; shift ; }
32 while [ $# -gt 0 ] ; do echo -n " \"$1\"" ; shift ; done ; echo
36 test "$__debug" || return 0 # (DEBUG)
37 _msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
42 [1-9].[0-9] | [1-9].[0-9] ) tag="r$1" ;;
43 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$1" ;;
44 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$1" ;;
45 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$1" ;;
46 [1-9].[0-9].[0-9]_[1-9] | [1-9].[0-9].[0-9][0-9]_[1-9] ) tag="r$1" ;;
47 HEAD | r1_3_3_branch ) tag="$rel" ;;
48 '' ) usage ; return 1 ;;
49 * ) warn "Error: Invalid string: $1" ; usage ; return 1 ;;
51 echo "$tag" | tr '.' '_'
57 find . -type d | while read line; do chmod 755 "$line"; done
58 find . -type f | while read line; do chmod 644 "$line"; done
59 # Add write permission for PukiWiki
60 chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null
61 chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel 2>/dev/null
65 # Default variables -----------------------------------------
69 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
71 # Function verifying arguments ------------------------------
74 trace 'getopt()' "$@" # (DEBUG)
78 -[hH]|--help ) echo _help _exit ;;
79 --debug ) echo _debug ;;
80 --nopkg ) echo _nopkg ;;
81 --norm|--noremove ) echo _noremove ;;
82 -z|--zip ) echo _zip ;;
83 --copy-dist ) echo _copy_dist ;;
84 --move-dist ) echo _move_dist ;;
85 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
86 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
93 # Working start ---------------------------------------------
95 # Show arguments in one line (DEBUG)
96 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
97 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
101 while [ $# -gt 0 ] ; do
102 chs="` getopt "$@" `" || err "Syntax error with '$1'"
103 trace '$chs ' "$chs" # (DEBUG)
111 _CVSROOT) CVSROOT="$2" ;;
113 _* ) shift ; eval "_$ch"=on ;;
120 if [ $# -eq 0 ] ; then usage ; exit ; fi
122 # Archiver check --------------------------------------------
126 which tar || err "tar not found"
127 which gzip || err "gzip not found"
129 which zip || err "zip not found"
132 # Argument check --------------------------------------------
135 tag="` check_versiontag "$rel" `"
136 pkg_dir="${mod}-${rel}"
138 # Export the module -----------------------------------------
140 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
142 echo cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
143 cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
145 #echo cvs -z3 -d "$CVSROOT" -q co -r "$tag" -d "$pkg_dir" "$mod"
146 # cvs -z3 -d "$CVSROOT" -q co -r "$tag" -d "$pkg_dir" "$mod"
148 test -d "$pkg_dir" || err "There is'nt a directory: $pkg_dir"
150 # Remove '.cvsignore' if exists -----------------------------
151 test -z "$__noremove" && {
152 echo find "$pkg_dir" -type f -name '.cvsignore' "| xargs rm -f"
153 find "$pkg_dir" -type f -name '.cvsignore' | xargs rm -f
156 # chmod -----------------------------------------------------
160 # Create a package ------------------------------------------
162 test ! -z "$__nopkg$__noremove" && exit 0
169 then tar cf - "$target" | gzip -9 > "$target".tgz
170 else zip -r9 "$target.zip" "$target"
176 then gzip -9 *.en.txt
178 for list in *.en.txt ; do
179 zip -9 "$list".zip "$list"
185 # Move / Copy *.ini.php files
186 if [ 'x' != "x$__copy_dist$__move_dist" ] ; then
189 find . -type f -name "*.ini.php" | while read file; do
190 dist_file="` echo "$file" | sed 's/ini\.php$/ini-dist.php/' `"
191 mv -f "$file" "$dist_file"
192 test "$__copy_dist" && cp -f "$dist_file" "$file"
200 echo tar cf - "$pkg_dir" \| gzip -9 \> "$pkg_dir.tar.gz"
201 tar cf - "$pkg_dir" | gzip -9 > "$pkg_dir.tar.gz"
204 echo zip -r9 "$pkg_dir.zip" "$pkg_dir"
205 zip -r9 "$pkg_dir.zip" "$pkg_dir"