2 # $Id: release_update.sh,v 1.12 2005/12/10 08:27:00 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 warn "USAGE: $_name [options] VERSION_FROM VERSION_TO (VERSION = '1.4.3_rc1' like)"
17 warn " -p|--patch Create a large patch file"
18 warn " -z|--zip Create *.zip archive"
19 warn " --move-dist Move *.ini.php => *.ini-dist.php"
20 warn " --copy-dist Move, and Copy *.ini.php <= *.ini-dist.php"
24 # Common functions ------------------------------------------
25 warn(){ echo "$*" 1>&2 ; }
26 err() { warn "Error: $*" ; exit 1 ; }
29 test $# -gt 0 && { echo -n "\"$1\"" ; shift ; }
30 while [ $# -gt 0 ] ; do echo -n " \"$1\"" ; shift ; done ; echo
34 test "$__debug" || return 0 # (DEBUG)
35 _msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
40 [1-9].[0-9] | [1-9].[0-9] ) tag="r$1" ;;
41 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$1" ;;
42 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$1" ;;
43 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$1" ;;
44 [1-9].[0-9].[0-9]_[1-9] | [1-9].[0-9].[0-9][0-9]_[1-9] ) tag="r$1" ;;
45 HEAD | r1_3_3_branch ) tag="$rel" ;;
46 '' ) usage ; return 1 ;;
47 * ) warn "Error: Invalid string: $1" ; usage ; return 1 ;;
49 echo "$tag" | tr '.' '_'
55 find . -type d | while read line; do chmod 755 "$line"; done
56 find . -type f | while read line; do chmod 644 "$line"; done
57 # Add write permission for PukiWiki
58 chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null
59 chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel 2>/dev/null
63 # Default variables -----------------------------------------
66 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
70 # Function verifying arguments ------------------------------
73 trace 'getopt()' "$@" # (DEBUG)
77 -[hH]|--help ) echo _help _exit ;;
78 --debug ) echo _debug ;;
79 -p|--patch ) echo _patch ;;
80 -z|--zip ) echo _zip ;;
81 --copy-dist ) echo _copy_dist ;;
82 --move-dist ) echo _move_dist ;;
83 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
84 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
91 # Working start ---------------------------------------------
93 # Show arguments in one line (DEBUG)
94 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
95 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
99 while [ $# -gt 0 ] ; do
100 chs="` getopt "$@" `" || err "Syntax error with '$1'"
101 trace '$chs ' "$chs" # (DEBUG)
108 _CVSROOT) CVSROOT="$2" ;;
109 _* ) shift ; eval "_$ch"=on ;;
116 if [ $# -eq 0 ] ; then usage ; exit ; fi
118 # Argument check --------------------------------------------
122 if [ "x$rel_from" = "x$rel_to" ] ; then
123 warn "Error: VERSION_FROM and VERSION_TO is equivalent"
127 tag_from="` check_versiontag "$rel_from" `" || exit
128 tag_to="` check_versiontag "$rel_to" `" || exit
130 # -----------------------------------------------------------
134 file="${mod}-${tag_from}-${tag_to}.diff.gz"
135 test ! -f "$file" || err "There's already a file: $file"
138 echo cvs -z3 -d "$CVSROOT" rdiff -u -r "$tag_from" -r "$tag_to" "$mod"
139 cvs -z3 -d "$CVSROOT" rdiff -u -r "$tag_from" -r "$tag_to" "$mod" | gzip -9 > "$file"
145 # Checkout the module with VERSION_FROM
146 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
147 echo cvs -z3 -d "$CVSROOT" co -r "$tag_from" -d "$pkg_dir" "$mod"
148 cvs -z3 -d "$CVSROOT" co -r "$tag_from" -d "$pkg_dir" "$mod"
149 test -d "$pkg_dir" || err "There isn't a directory: $pkg_dir"
152 # Merge VERSION_FROM to VERSION_TO
154 echo cvs up -dP -j "$tag_from" -j "$tag_to"
155 cvs up -dP -j "$tag_from" -j "$tag_to"
157 # Cleanup backup files by cvs
158 find . -type f -name ".#*" | xargs rm -f
161 # Remove files those are not Added or Modified
162 echo -n "Remove files those are not Added or Modified ..."
165 find . -type f | grep -v /CVS/ | while read line ; do
166 result="` cvs -nq up "$line" 2>/dev/null | grep '^[AM] ' | cut -b 3- `"
167 test "x$result" != "x" || rm -f "$line"
173 # Remove CVS directories
174 echo "Remove CVS directories ..."
175 find "$pkg_dir" -type d -name "CVS" | xargs rm -Rf
177 # Remove '.cvsignore' if exists
178 echo find "$pkg_dir" -type f -name '.cvsignore' -delete
179 find "$pkg_dir" -type f -name '.cvsignore' -delete
181 # Remove emptied directories (twice)
182 find "$pkg_dir" -type d -empty | xargs rmdir
183 find "$pkg_dir" -type d -empty | xargs rmdir
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"
203 echo tar cf - "$pkg_dir" \| gzip -9 \> "update_$rel_to.tar.gz"
204 tar cf - "$pkg_dir" | gzip -9 > "update_$rel_to.tar.gz"
207 echo zip -r9 "update_$rel_to.zip" "$pkg_dir"
208 zip -r9 "update_$rel_to.zip" "$pkg_dir"
211 #echo rm -Rf "$pkg_dir"