2 # $Id: release.sh,v 1.16 2005/03/21 11:43:49 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 " -z|--zip Create *.zip archive"
20 warn " --move-dist Move *.ini.php => *.ini-dist.php"
21 warn " --copy-dist Move, and Copy *.ini.php <= *.ini-dist.php"
25 # Common functions ------------------------------------------
26 warn(){ echo "$*" 1>&2 ; }
27 err() { warn "Error: $*" ; exit 1 ; }
30 test $# -gt 0 && { echo -n "\"$1\"" ; shift ; }
31 while [ $# -gt 0 ] ; do echo -n " \"$1\"" ; shift ; done ; echo
35 test "$__debug" || return 0 # (DEBUG)
36 _msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
39 # Default variables -----------------------------------------
43 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
45 # Function verifying arguments ------------------------------
48 trace 'getopt()' "$@" # (DEBUG)
52 -[hH]|--help ) echo _help _exit ;;
53 --debug ) echo _debug ;;
54 --nopkg ) echo _nopkg ;;
55 -z|--zip ) echo _zip ;;
56 --copy-dist ) echo _copy_dist ;;
57 --move-dist ) echo _move_dist ;;
58 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
59 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
66 # Working start ---------------------------------------------
68 # Show arguments in one line (DEBUG)
69 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
70 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
74 while [ $# -gt 0 ] ; do
75 chs="` getopt "$@" `" || err "Syntax error with '$1'"
76 trace '$chs ' "$chs" # (DEBUG)
84 _CVSROOT) CVSROOT="$2" ;;
86 _* ) shift ; eval "_$ch"=on ;;
93 if [ $# -eq 0 ] ; then usage ; exit ; fi
95 # Archiver check --------------------------------------------
99 which tar || err "tar not found"
100 which gzip || err "gzip not found"
102 which zip || err "zip not found"
105 # Argument check --------------------------------------------
108 pkg_dir="${mod}-${rel}"
110 [1-9].[0-9] | [1-9].[0-9] ) tag="r$rel" ;;
111 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$rel" ;;
112 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$rel" ;;
113 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$rel" ;;
114 [1-9].[0-9].[0-9]_[1-9] | [1-9].[0-9].[0-9][0-9]_[1-9] ) tag="r$rel" ;;
115 HEAD | r1_3_3_branch ) tag="$rel" ;;
118 tag="` echo "$tag" | tr '.' '_' `"
120 # Export the module -----------------------------------------
122 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
124 echo cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
125 cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
127 #echo cvs -z3 -d "$CVSROOT" -q co -r "$tag" -d "$pkg_dir" "$mod"
128 # cvs -z3 -d "$CVSROOT" -q co -r "$tag" -d "$pkg_dir" "$mod"
130 test -d "$pkg_dir" || err "There is'nt a directory: $pkg_dir"
132 # Remove '.cvsignore' if exists -----------------------------
133 echo find "$pkg_dir" -type f -name '.cvsignore' -delete
134 find "$pkg_dir" -type f -name '.cvsignore' -delete
136 # chmod -----------------------------------------------------
140 find . -type d | while read line; do
143 find . -type f | while read line; do
147 # Add write permission for PukiWiki
148 chmod 777 attach backup cache counter diff trackback wiki*
149 chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel
152 # Create a package ------------------------------------------
154 test ! -z "$__nopkg" && exit 0
161 then tar cf - "$target" | gzip -9 > "$target".tgz
162 else zip -r9 "$target.zip" "$target"
168 then gzip -9 *.en.txt
170 for list in *.en.txt ; do
171 zip -9 "$list".zip "$list"
177 # Move / Copy *.ini.php files
178 if [ 'x' != "x$__copy_dist$__move_dist" ] ; then
181 find . -type f -name "*.ini.php" | while read file; do
182 dist_file="` echo "$file" | sed 's/ini\.php$/ini-dist.php/' `"
183 mv -f "$file" "$dist_file"
184 test "$__copy_dist" && cp -f "$dist_file" "$file"
192 echo tar cf - "$pkg_dir" \| gzip -9 \> "$pkg_dir.tar.gz"
193 tar cf - "$pkg_dir" | gzip -9 > "$pkg_dir.tar.gz"
196 echo zip -r9 "$pkg_dir.zip" "$pkg_dir"
197 zip -r9 "$pkg_dir.zip" "$pkg_dir"