2 # $Id: release_update.sh,v 1.7 2005/03/21 12:28:38 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: `basename $0` VERSION_FROM VERSION_TO (VERSION = '1.4.3_rc1' like)"
19 # Common functions ------------------------------------------
20 warn(){ echo "$*" 1>&2 ; }
21 err() { warn "Error: $*" ; exit 1 ; }
24 test $# -gt 0 && { echo -n "\"$1\"" ; shift ; }
25 while [ $# -gt 0 ] ; do echo -n " \"$1\"" ; shift ; done ; echo
29 test "$__debug" || return 0 # (DEBUG)
30 _msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
35 [1-9].[0-9] | [1-9].[0-9] ) tag="r$1" ;;
36 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$1" ;;
37 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$1" ;;
38 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$1" ;;
39 [1-9].[0-9].[0-9]_[1-9] | [1-9].[0-9].[0-9][0-9]_[1-9] ) tag="r$1" ;;
40 HEAD | r1_3_3_branch ) tag="$rel" ;;
41 '' ) usage ; return 1 ;;
42 * ) warn "Error: Invalid string: $1" ; usage ; return 1 ;;
44 echo "$tag" | tr '.' '_'
47 # Default variables -----------------------------------------
50 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
54 # Function verifying arguments ------------------------------
57 trace 'getopt()' "$@" # (DEBUG)
61 -[hH]|--help ) echo _help _exit ;;
62 --debug ) echo _debug ;;
63 #-z|--zip ) echo _zip ;;
64 #--copy-dist ) echo _copy_dist ;;
65 #--move-dist ) echo _move_dist ;;
66 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
67 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
74 # Working start ---------------------------------------------
76 # Show arguments in one line (DEBUG)
77 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
78 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
82 while [ $# -gt 0 ] ; do
83 chs="` getopt "$@" `" || err "Syntax error with '$1'"
84 trace '$chs ' "$chs" # (DEBUG)
91 _CVSROOT) CVSROOT="$2" ;;
92 _* ) shift ; eval "_$ch"=on ;;
99 if [ $# -eq 0 ] ; then usage ; exit ; fi
101 # Argument check --------------------------------------------
105 if [ "x$rel_from" = "x$rel_to" ] ; then
106 warn "Error: VERSION_FROM and VERSION_TO is equivalent"
110 tag_from="` check_versiontag "$rel_from" `" || exit
111 tag_to="` check_versiontag "$rel_to" `" || exit
113 # -----------------------------------------------------------
115 # Checkout the module with VERSION_FROM
116 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
117 echo cvs -z3 -d "$CVSROOT" co -r "$tag_from" -d "$pkg_dir" "$mod"
118 cvs -z3 -d "$CVSROOT" co -r "$tag_from" -d "$pkg_dir" "$mod"
119 test -d "$pkg_dir" || err "There isn't a directory: $pkg_dir"
121 # Merge VERSION_FROM to VERSION_TO
123 echo cvs up -dP -j "$tag_from" -j "$tag_to"
124 cvs up -dP -j "$tag_from" -j "$tag_to"
126 # Cleanup backup files by cvs
127 find . -type f -name ".#*" | xargs rm -f
130 # Remove files those are not Added or Modified
133 find . -type f | grep -v /CVS/ | while read line ; do
134 result="` cvs -nq up "$line" 2>/dev/null | grep '^[AM] ' | cut -b 3- `"
135 test "x$result" != "x" || rm -f "$line"
141 # Remove CVS directories
142 find "$pkg_dir" -type d -name "CVS" | xargs rm -Rf
144 # Remove '.cvsignore' if exists
145 echo find "$pkg_dir" -type f -name '.cvsignore' -delete
146 find "$pkg_dir" -type f -name '.cvsignore' -delete
148 # Remove emptied directories
149 find "$pkg_dir" -type d -empty | xargs rmdir
150 find "$pkg_dir" -type d -empty | xargs rmdir
156 find . -type d | while read line; do
159 find . -type f | while read line; do
163 # Add write permission for PukiWiki
164 chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null
165 chmod 666 wiki*/*.txt cache/*.dat 2>/dev/null
170 echo tar cf - "$pkg_dir" \| gzip -9 \> "update_$rel_to.tar.gz"
171 tar cf - "$pkg_dir" | gzip -9 > "update_$rel_to.tar.gz"
174 #echo zip -r9 "update_$rel_to.zip" "$pkg_dir"
175 # zip -r9 "update_$rel_to.zip" "$pkg_dir"
177 #echo rm -Rf "$pkg_dir"