2 # $Id: release.sh,v 1.10 2004/12/31 00:59:41 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 [-z] VERSION_TAG (1.4.3_rc1 like)"
18 warn " -z|--zip Create *.zip archive"
22 # Common functions ------------------------------------------
23 warn(){ echo "$*" 1>&2 ; }
24 err() { warn "Error: $*" ; exit 1 ; }
27 test $# -gt 0 && { echo -n "\"$1\"" ; shift ; }
28 while [ $# -gt 0 ] ; do echo -n " \"$1\"" ; shift ; done ; echo
32 test "$__debug" || return 0 # (DEBUG)
33 _msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
36 # Default variables -----------------------------------------
40 CVSROOT=":pserver:anonymous@cvs.sourceforge.jp:/cvsroot/$mod"
42 # Function verifying arguments ------------------------------
45 trace 'getopt()' "$@" # (DEBUG)
49 -[hH]|--help ) echo _help _exit ;;
50 --debug ) echo _debug ;;
51 -z|--zip ) echo _zip ;;
52 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
53 -* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
60 # Working start ---------------------------------------------
62 # Show arguments in one line (DEBUG)
63 case '--debug' in "$1"|"$3") false ;; * ) true ;; esac || {
64 test 'x--debug' = "x$1" && shift ; __debug=on ; trace 'Args ' "$@"
68 while [ $# -gt 0 ] ; do
69 chs="` getopt "$@" `" || err "Syntax error with '$1'"
70 trace '$chs ' "$chs" # (DEBUG)
78 _CVSROOT) CVSROOT="$2" ;;
80 _* ) shift ; eval "_$ch"=on ;;
87 if [ $# -eq 0 ] ; then usage ; exit ; fi
89 # Archiver check --------------------------------------------
93 which tar || err "tar not found"
94 which gzip || err "gzip not found"
96 which zip || err "zip not found"
99 # Argument check --------------------------------------------
102 pkg_dir="${mod}-${rel}"
104 [1-9].[0-9] | [1-9].[0-9] ) tag="r$rel" ;;
105 [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$rel" ;;
106 [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$rel" ;;
107 [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$rel" ;;
110 tag="` echo "$tag" | tr '.' '_' `"
112 # Export the module -----------------------------------------
114 test ! -d "$pkg_dir" || err "There's already a directory: $pkg_dir"
116 echo cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
117 cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
119 test -d "$pkg_dir" || err "There is'nt a directory: $pkg_dir"
121 # Remove '.cvsignore' if exists -----------------------------
122 echo find "$pkg_dir" -type f -name '.cvsignore' -delete
123 find "$pkg_dir" -type f -name '.cvsignore' -delete
125 # chmod -----------------------------------------------------
129 find . -type d | while read line; do
132 find . -type f | while read line; do
136 # Add write permission for PukiWiki
137 chmod 777 attach backup cache counter diff trackback wiki*
138 chmod 666 wiki*/*.txt cache/*.dat
141 # Compress --------------------------------------------------
147 then tar cf - "$target" | gzip -9 > "$target".tgz
148 else zip -r9 "$target.zip" "$target"
154 then gzip -9 *.en.txt
156 for list in *.en.txt ; do
157 zip -9 "$list".zip "$list"
166 echo tar cf - "$pkg_dir" \| gzip -9 \> "$pkg_dir.tar.gz"
167 tar cf - "$pkg_dir" | gzip -9 > "$pkg_dir.tar.gz"
170 echo zip -r9 "$pkg_dir.zip" "$pkg_dir"
171 zip -r9 "$pkg_dir.zip" "$pkg_dir"