2 # $Id: release.sh,v 1.13 2005/02/15 14:20:20 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"
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 "$@" `"
37 # Default variables -----------------------------------------
41 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
43 # Function verifying arguments ------------------------------
46 trace 'getopt()' "$@" # (DEBUG)
50 -[hH]|--help ) echo _help _exit ;;
51 --debug ) echo _debug ;;
52 --nopkg ) echo _nopkg ;;
53 -z|--zip ) echo _zip ;;
54 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
55 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
62 # Working start ---------------------------------------------
64 # Show arguments in one line (DEBUG)
65 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
66 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
70 while [ $# -gt 0 ] ; do
71 chs="` getopt "$@" `" || err "Syntax error with '$1'"
72 trace '$chs ' "$chs" # (DEBUG)
80 _CVSROOT) CVSROOT="$2" ;;
82 _* ) shift ; eval "_$ch"=on ;;
89 if [ $# -eq 0 ] ; then usage ; exit ; fi
91 # Archiver check --------------------------------------------
95 which tar || err "tar not found"
96 which gzip || err "gzip not found"
98 which zip || err "zip not found"
101 # Argument check --------------------------------------------
104 pkg_dir="${mod}-${rel}"
106 [1-9].[0-9] | [1-9].[0-9] ) tag="r$rel" ;;
107 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$rel" ;;
108 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$rel" ;;
109 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$rel" ;;
110 HEAD | r1_3_3_branch ) tag="$rel" ;;
113 tag="` echo "$tag" | tr '.' '_' `"
115 # Export the module -----------------------------------------
117 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
119 echo cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
120 cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
122 test -d "$pkg_dir" || err "There is'nt a directory: $pkg_dir"
124 # Remove '.cvsignore' if exists -----------------------------
125 echo find "$pkg_dir" -type f -name '.cvsignore' -delete
126 find "$pkg_dir" -type f -name '.cvsignore' -delete
128 # chmod -----------------------------------------------------
132 find . -type d | while read line; do
135 find . -type f | while read line; do
139 # Add write permission for PukiWiki
140 chmod 777 attach backup cache counter diff trackback wiki*
141 chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel
144 # Create a package ------------------------------------------
146 test ! -z "$__nopkg" && exit 0
153 then tar cf - "$target" | gzip -9 > "$target".tgz
154 else zip -r9 "$target.zip" "$target"
160 then gzip -9 *.en.txt
162 for list in *.en.txt ; do
163 zip -9 "$list".zip "$list"
172 echo tar cf - "$pkg_dir" \| gzip -9 \> "$pkg_dir.tar.gz"
173 tar cf - "$pkg_dir" | gzip -9 > "$pkg_dir.tar.gz"
176 echo zip -r9 "$pkg_dir.zip" "$pkg_dir"
177 zip -r9 "$pkg_dir.zip" "$pkg_dir"