2 # $Id: release_update.sh,v 1.10 2005/03/21 13:56:29 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)"
17 warn " -z|--zip Create *.zip archive"
18 warn " --move-dist Move *.ini.php => *.ini-dist.php"
19 warn " --copy-dist Move, and Copy *.ini.php <= *.ini-dist.php"
23 # Common functions ------------------------------------------
24 warn(){ echo "$*" 1>&2 ; }
25 err() { warn "Error: $*" ; exit 1 ; }
28 test $# -gt 0 && { echo -n "\"$1\"" ; shift ; }
29 while [ $# -gt 0 ] ; do echo -n " \"$1\"" ; shift ; done ; echo
33 test "$__debug" || return 0 # (DEBUG)
34 _msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
39 [1-9].[0-9] | [1-9].[0-9] ) tag="r$1" ;;
40 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$1" ;;
41 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$1" ;;
42 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$1" ;;
43 [1-9].[0-9].[0-9]_[1-9] | [1-9].[0-9].[0-9][0-9]_[1-9] ) tag="r$1" ;;
44 HEAD | r1_3_3_branch ) tag="$rel" ;;
45 '' ) usage ; return 1 ;;
46 * ) warn "Error: Invalid string: $1" ; usage ; return 1 ;;
48 echo "$tag" | tr '.' '_'
54 find . -type d | while read line; do chmod 755 "$line"; done
55 find . -type f | while read line; do chmod 644 "$line"; done
56 # Add write permission for PukiWiki
57 chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null
58 chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel 2>/dev/null
62 # Default variables -----------------------------------------
65 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
69 # Function verifying arguments ------------------------------
72 trace 'getopt()' "$@" # (DEBUG)
76 -[hH]|--help ) echo _help _exit ;;
77 --debug ) echo _debug ;;
78 -z|--zip ) echo _zip ;;
79 --copy-dist ) echo _copy_dist ;;
80 --move-dist ) echo _move_dist ;;
81 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
82 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
89 # Working start ---------------------------------------------
91 # Show arguments in one line (DEBUG)
92 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
93 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
97 while [ $# -gt 0 ] ; do
98 chs="` getopt "$@" `" || err "Syntax error with '$1'"
99 trace '$chs ' "$chs" # (DEBUG)
106 _CVSROOT) CVSROOT="$2" ;;
107 _* ) shift ; eval "_$ch"=on ;;
114 if [ $# -eq 0 ] ; then usage ; exit ; fi
116 # Argument check --------------------------------------------
120 if [ "x$rel_from" = "x$rel_to" ] ; then
121 warn "Error: VERSION_FROM and VERSION_TO is equivalent"
125 tag_from="` check_versiontag "$rel_from" `" || exit
126 tag_to="` check_versiontag "$rel_to" `" || exit
128 # -----------------------------------------------------------
130 # Checkout the module with VERSION_FROM
131 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
132 echo cvs -z3 -d "$CVSROOT" co -r "$tag_from" -d "$pkg_dir" "$mod"
133 cvs -z3 -d "$CVSROOT" co -r "$tag_from" -d "$pkg_dir" "$mod"
134 test -d "$pkg_dir" || err "There isn't a directory: $pkg_dir"
136 # Merge VERSION_FROM to VERSION_TO
138 echo cvs up -dP -j "$tag_from" -j "$tag_to"
139 cvs up -dP -j "$tag_from" -j "$tag_to"
141 # Cleanup backup files by cvs
142 find . -type f -name ".#*" | xargs rm -f
145 # Remove files those are not Added or Modified
146 echo -n "Remove files those are not Added or Modified ..."
149 find . -type f | grep -v /CVS/ | while read line ; do
150 result="` cvs -nq up "$line" 2>/dev/null | grep '^[AM] ' | cut -b 3- `"
151 test "x$result" != "x" || rm -f "$line"
157 # Remove CVS directories
158 echo "Remove CVS directories ..."
159 find "$pkg_dir" -type d -name "CVS" | xargs rm -Rf
161 # Remove '.cvsignore' if exists
162 echo find "$pkg_dir" -type f -name '.cvsignore' -delete
163 find "$pkg_dir" -type f -name '.cvsignore' -delete
165 # Remove emptied directories (twice)
166 find "$pkg_dir" -type d -empty | xargs rmdir
167 find "$pkg_dir" -type d -empty | xargs rmdir
169 # Move / Copy *.ini.php files
170 if [ 'x' != "x$__copy_dist$__move_dist" ] ; then
173 find . -type f -name "*.ini.php" | while read file; do
174 dist_file="` echo "$file" | sed 's/ini\.php$/ini-dist.php/' `"
175 mv -f "$file" "$dist_file"
176 test "$__copy_dist" && cp -f "$dist_file" "$file"
187 echo tar cf - "$pkg_dir" \| gzip -9 \> "update_$rel_to.tar.gz"
188 tar cf - "$pkg_dir" | gzip -9 > "update_$rel_to.tar.gz"
191 echo zip -r9 "update_$rel_to.zip" "$pkg_dir"
192 zip -r9 "update_$rel_to.zip" "$pkg_dir"
195 #echo rm -Rf "$pkg_dir"