2 # $Id: release.sh,v 1.21 2005/04/18 13:30:05 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 " --co --norm, and use 'checkout' command instead of 'export'"
21 warn " -z|--zip Create *.zip archive"
22 warn " --move-dist Move *.ini.php => *.ini-dist.php"
23 warn " --copy-dist Move, and Copy *.ini.php <= *.ini-dist.php"
27 # Common functions ------------------------------------------
28 warn(){ echo "$*" 1>&2 ; }
29 err() { warn "Error: $*" ; exit 1 ; }
32 test $# -gt 0 && { echo -n "\"$1\"" ; shift ; }
33 while [ $# -gt 0 ] ; do echo -n " \"$1\"" ; shift ; done ; echo
37 test "$__debug" || return 0 # (DEBUG)
38 _msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
43 [1-9].[0-9] | [1-9].[0-9] ) tag="r$1" ;;
44 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$1" ;;
45 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$1" ;;
46 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$1" ;;
47 [1-9].[0-9].[0-9]_[1-9] | [1-9].[0-9].[0-9][0-9]_[1-9] ) tag="r$1" ;;
48 HEAD | r1_3_3_branch ) tag="$rel" ;;
49 '' ) usage ; return 1 ;;
50 * ) warn "Error: Invalid string: $1" ; usage ; return 1 ;;
52 echo "$tag" | tr '.' '_'
58 find . -type d | while read line; do chmod 755 "$line"; done
59 find . -type f | while read line; do chmod 644 "$line"; done
60 # Add write permission for PukiWiki
61 chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null
62 chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel 2>/dev/null
66 # Default variables -----------------------------------------
70 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
72 # Function verifying arguments ------------------------------
75 trace 'getopt()' "$@" # (DEBUG)
79 -[hH]|--help ) echo _help _exit ;;
80 --debug ) echo _debug 1 ;;
81 --nopkg ) echo _nopkg 1 ;;
82 --norm|--noremove ) echo _nopkg _noremove 1 ;;
83 --co|--checkout ) echo _nopkg _noremove _checkout 1 ;;
84 -z|--zip ) echo _zip 1 ;;
85 --copy-dist ) echo _copy_dist 1 ;;
86 --move-dist ) echo _move_dist 1 ;;
87 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
88 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
95 # Working start ---------------------------------------------
97 # Show arguments in one line (DEBUG)
98 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
99 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
103 while [ $# -gt 0 ] ; do
104 chs="` getopt "$@" `" || err "Syntax error with '$1'"
105 trace '$chs ' "$chs" # (DEBUG)
113 _CVSROOT) CVSROOT="$2" ;;
115 _* ) eval "_$ch"=on ;;
122 if [ $# -eq 0 ] ; then usage ; exit ; fi
124 # Archiver check --------------------------------------------
128 which tar || err "tar not found"
129 which gzip || err "gzip not found"
131 which zip || err "zip not found"
134 # Argument check --------------------------------------------
137 tag="` check_versiontag "$rel" `"
138 pkg_dir="${mod}-${rel}"
140 # Export the module -----------------------------------------
142 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
144 if [ -z "$__checkout" ]
149 echo cvs -z3 -d "$CVSROOT" -q "$cmd" -r "$tag" -d "$pkg_dir" "$mod"
150 cvs -z3 -d "$CVSROOT" -q "$cmd" -r "$tag" -d "$pkg_dir" "$mod"
152 test -d "$pkg_dir" || err "There isn't a directory: $pkg_dir"
154 # Remove '.cvsignore' if exists -----------------------------
155 test -z "$__noremove" && {
156 echo find "$pkg_dir" -type f -name '.cvsignore' "| xargs rm -f"
157 find "$pkg_dir" -type f -name '.cvsignore' | xargs rm -f
160 # chmod -----------------------------------------------------
164 # Create a package ------------------------------------------
166 test ! -z "$__nopkg" && exit 0
173 then tar cf - "$target" | gzip -9 > "$target".tgz
174 else zip -r9 "$target.zip" "$target"
180 then gzip -9 *.en.txt
182 for list in *.en.txt ; do
183 zip -9 "$list".zip "$list"
189 # Move / Copy *.ini.php files
190 if [ 'x' != "x$__copy_dist$__move_dist" ] ; then
193 find . -type f -name "*.ini.php" | while read file; do
194 dist_file="` echo "$file" | sed 's/ini\.php$/ini-dist.php/' `"
195 mv -f "$file" "$dist_file"
196 test "$__copy_dist" && cp -f "$dist_file" "$file"
204 echo tar cf - "$pkg_dir" \| gzip -9 \> "$pkg_dir.tar.gz"
205 tar cf - "$pkg_dir" | gzip -9 > "$pkg_dir.tar.gz"
208 echo zip -r9 "$pkg_dir.zip" "$pkg_dir"
209 zip -r9 "$pkg_dir.zip" "$pkg_dir"