#!/bin/sh
-# $Id: release.sh,v 1.10 2004/12/31 00:59:41 henoheno Exp $
+# $Id: release.sh,v 1.17 2005/03/21 13:55:20 henoheno Exp $
# $CVSKNIT_Id: release.sh,v 1.11 2004/05/28 14:26:24 henoheno Exp $
# Release automation script for PukiWiki
# ==========================================================
usage(){
trace 'usage()' || return # (DEBUG)
- warn "Usage: $_name [-z] VERSION_TAG (1.4.3_rc1 like)"
+ warn "Usage: $_name [options] VERSION_TAG (1.4.3_rc1 like)"
warn " Options:"
- warn " -z|--zip Create *.zip archive"
+ warn " --nopkg Suppress creating archive (Extract and chmod only)"
+ warn " -z|--zip Create *.zip archive"
+ warn " --move-dist Move *.ini.php => *.ini-dist.php"
+ warn " --copy-dist Move, and Copy *.ini.php <= *.ini-dist.php"
return 1
}
_msg="$1" ; test $# -gt 0 && shift ; warn " $_msg : ` quote "$@" `"
}
+check_versiontag(){
+ case "$1" in
+ [1-9].[0-9] | [1-9].[0-9] ) tag="r$1" ;;
+ [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$1" ;;
+ [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$1" ;;
+ [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$1" ;;
+ [1-9].[0-9].[0-9]_[1-9] | [1-9].[0-9].[0-9][0-9]_[1-9] ) tag="r$1" ;;
+ HEAD | r1_3_3_branch ) tag="$rel" ;;
+ '' ) usage ; return 1 ;;
+ * ) warn "Error: Invalid string: $1" ; usage ; return 1 ;;
+ esac
+ echo "$tag" | tr '.' '_'
+}
+
+chmod_pkg(){
+ ( cd "$1"
+ # ALL: Read only
+ find . -type d | while read line; do chmod 755 "$line"; done
+ find . -type f | while read line; do chmod 644 "$line"; done
+ # Add write permission for PukiWiki
+ chmod 777 attach backup cache counter diff trackback wiki* 2>/dev/null
+ chmod 666 wiki*/*.txt cache/*.dat cache/*.ref cache/*.rel 2>/dev/null
+ )
+}
+
# Default variables -----------------------------------------
mod=pukiwiki
'' ) echo 1 ;;
-[hH]|--help ) echo _help _exit ;;
--debug ) echo _debug ;;
+ --nopkg ) echo _nopkg ;;
-z|--zip ) echo _zip ;;
+ --copy-dist ) echo _copy_dist ;;
+ --move-dist ) echo _move_dist ;;
-d ) echo _CVSROOT 2 ; _arg="$2" ;;
-* ) warn "Error: Unknown option \"$1\"" ; return 1 ;;
* ) echo OTHER ;;
# Argument check --------------------------------------------
rel="$1"
+tag="` check_versiontag "$rel" `"
pkg_dir="${mod}-${rel}"
-case "$rel" in
- [1-9].[0-9] | [1-9].[0-9] ) tag="r$rel" ;;
- [1-9].[0-9]_rc[1-9] | [1-9].[0-9]_rc[1-9] ) tag="r$rel" ;;
- [1-9].[0-9].[0-9] | [1-9].[0-9].[0-9][0-9] ) tag="r$rel" ;;
- [1-9].[0-9].[0-9]_[a-z]* | [1-9].[0-9].[0-9][0-9]_[a-z]* ) tag="r$rel" ;;
- * ) usage ; exit ;;
-esac
-tag="` echo "$tag" | tr '.' '_' `"
# Export the module -----------------------------------------
echo cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
cvs -z3 -d "$CVSROOT" -q export -r "$tag" -d "$pkg_dir" "$mod"
+#echo cvs -z3 -d "$CVSROOT" -q co -r "$tag" -d "$pkg_dir" "$mod"
+# cvs -z3 -d "$CVSROOT" -q co -r "$tag" -d "$pkg_dir" "$mod"
+
test -d "$pkg_dir" || err "There is'nt a directory: $pkg_dir"
# Remove '.cvsignore' if exists -----------------------------
find "$pkg_dir" -type f -name '.cvsignore' -delete
# chmod -----------------------------------------------------
-( cd "$pkg_dir"
- # ALL: Read only
- find . -type d | while read line; do
- chmod 755 "$line"
- done
- find . -type f | while read line; do
- chmod 644 "$line"
- done
+chmod_pkg "$pkg_dir"
- # Add write permission for PukiWiki
- chmod 777 attach backup cache counter diff trackback wiki*
- chmod 666 wiki*/*.txt cache/*.dat
-)
+# Create a package ------------------------------------------
+
+test ! -z "$__nopkg" && exit 0
-# Compress --------------------------------------------------
( cd "$pkg_dir"
# wiki.en/
fi
)
+# Move / Copy *.ini.php files
+if [ 'x' != "x$__copy_dist$__move_dist" ] ; then
+( cd "$pkg_dir"
+
+ find . -type f -name "*.ini.php" | while read file; do
+ dist_file="` echo "$file" | sed 's/ini\.php$/ini-dist.php/' `"
+ mv -f "$file" "$dist_file"
+ test "$__copy_dist" && cp -f "$dist_file" "$file"
+ done
+)
+fi
+
if [ -z "$__zip" ]
then
# Tar + gzip