OSDN Git Service

Integrate creating upgrade patch to pack.sh
[pukiwiki/pukiwiki_devel.git] / release.sh
index feab943..f325130 100755 (executable)
@@ -1,12 +1,14 @@
 #!/bin/sh
-# $Id: release.sh,v 1.35 2011/06/05 14:22:51 henoheno Exp $
-# $CVSKNIT_Id: release.sh,v 1.11 2004/05/28 14:26:24 henoheno Exp $
+
+# release.sh
+#
 #  Release automation script for PukiWiki
 #  ==========================================================
    Copyright='(C) 2002-2004,2011 minix-up project, All Rights Reserved'
    Homepage='http://cvsknit.sourceforge.net/'
    License='(also revised)BSD Licnese, NO WARRANTY'
 #
+set -ex
 
 # Name and Usage --------------------------------------------
 _name="` basename $0 `"
@@ -18,7 +20,9 @@ usage(){
   warn  "    --nopkg     Suppress creating archive (Extract and chmod only)"
   warn  "    --norm      --nopkg, and remove nothing (.cvsignore etc)"
   warn  "    --co        --norm, and use 'checkout' command instead of 'export'"
-  warn  "    --utf8      Create UTF-8 converted archive (EXPERIMENTAL)"
+  warn  "    --utf8      Create UTF-8 converted archive"
+  warn  "    --eucjp     Create EUC_JP converted archive"
+  warn  "    --fromeucjp Indicate source charset is EUC_JP"
   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"
@@ -63,8 +67,8 @@ chmod_pkg(){
     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
+    chmod 777 attach backup cache counter diff wiki* 2>/dev/null
+    chmod 666 wiki*/*.txt 2>/dev/null
   )
 }
 
@@ -88,6 +92,8 @@ getopt(){ _arg=noarg
   --co|--checkout   ) echo _nopkg _noremove _checkout 1 ;;
   -z|--zip     ) echo _zip 1      ;;
   --ut|--utf|--utf8|--utf-8 ) echo _utf8 1  ;;
+  --eucjp ) echo _eucjp 1 ;;
+  --fromeucjp ) echo _fromeucjp 1 ;;
   --copy-dist  ) echo _copy_dist 1 ;;
   --move-dist  ) echo _move_dist 1 ;;
   -d  ) echo _CVSROOT 2 ; _arg="$2" ;;
@@ -134,7 +140,12 @@ if [ $# -eq 0 ] ; then usage ; exit ; fi
 
 # Utility check ---------------------------------------------
 
-if [ "$__utf8" ] ; then
+# Convert UTF-8 -> EUC_JP or EUC_JP -> UTF-8
+if [ \( "$__eucjp" -a ! "$__fromeucjp" \) -o \( "$__utf8" -a "$__fromeucjp" \) ] ; then
+  __charconv=1
+fi
+
+if [ "$__charconv" ] ; then
 
   # nkf
   which nkf || err "nkf version 2.0 or later (UTF-8 enabled) not found"
@@ -153,9 +164,13 @@ if [ "$__utf8" ] ; then
   fi
 
   convert(){
+    __nkfopt="--ic=eucJP-ms -w"
+    if [ "$__eucjp" ] ; then
+      __nkfopt="--ic=UTF8 --oc=eucJP-ms"
+    fi
     for list in "$@" ; do
       # NOTE: Specify '-E'(From EUC-JP) otherwise skin file will be collapsed
-      nkf --ic=eucJP-ms -w "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list" && echo "  $list"
+      nkf $__nkfopt "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list" && echo "  $list"
     done
   }
   convert_EUCJP2UTF8(){
@@ -165,6 +180,18 @@ if [ "$__utf8" ] ; then
       sed 's#^//UTF-8:##' "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list"
     done
   }
+  convert_UTF82EUCJP(){
+    for list in "$@" ; do
+      # Very rough conversion!
+      #sed 's/UTF-8/EUC-JP/g' "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list"
+      # This is very specific logic for PukiWiki 1.5.x source code
+      sed -i 's#^define('\''PKWK_UTF8_ENABLE'\'', *1);#//UTF-8:\0#' "$list"
+      sed -i 's#^case \+'\''ko'\'': *define('\''MB_LANGUAGE'\'', *'\''Korean'\''#//UTF-8:\0#' "$list"
+      sed -i 's#^[^a-zA-Z]*// *See *BugTrack2/13 *for *all#//UTF-8:\0#' "$list"
+      sed -i 's#^[^a-zA-Z]*// *and *give *us *your *report#//UTF-8:\0#' "$list"
+
+    done
+  }
 fi > /dev/null
 
 if [ -z "$__zip" ]
@@ -231,18 +258,31 @@ test -z "$__noremove" && {
   fi
   echo find "$pkg_dir" -type f -name '.cvsignore' "| xargs rm -f"
        find "$pkg_dir" -type f -name '.cvsignore' | xargs rm -f
+  echo find "$pkg_dir" -type f -name '.gitignore' -exec rm -f {} \;
+       find "$pkg_dir" -type f -name '.gitignore' -exec rm -f {} \;
+  echo find "$pkg_dir" -type f -name '.eslintrc.json' -exec rm -f {} \;
+       find "$pkg_dir" -type f -name '.eslintrc.json' -exec rm -f {} \;
+  echo find "$pkg_dir" -type f -name 'package.json' -exec rm -f {} \;
+       find "$pkg_dir" -type f -name 'package.json' -exec rm -f {} \;
 }
 
 # Get back original files ----------------------------------
-mv $pkg_dir/wiki/_526563656E744368616E676573.txt $pkg_dir/wiki/526563656E744368616E676573.txt
-mv $pkg_dir/cache/_recent.dat $pkg_dir/cache/recent.dat
-
+if [ -f "$pkg_dir/wiki/_526563656E744368616E676573.txt" ] ; then
+  mv $pkg_dir/wiki/_526563656E744368616E676573.txt $pkg_dir/wiki/526563656E744368616E676573.txt
+fi
+if [ -f "$pkg_dir/cache/_recent.dat" ] ; then
+  mv $pkg_dir/cache/_recent.dat $pkg_dir/cache/recent.dat
+fi
 
 
 # Conversion ------------------------------------------------
 
-if [ "$__utf8" ] ; then
-  echo "Converting EUC-JP => UTF-8 ..."
+if [ "$__charconv" ] ; then
+  if [ "$__utf8" ] ; then
+    echo "Converting EUC-JP => UTF-8 ..."
+  else
+    echo "Converting UTF-8 => EUC-JP ..."
+  fi
   find "$pkg_dir" -type f \( -name "*.txt" -or -name "*.php" -or -name "*.lng"  -or -name "*.dat" -or -name "*.ref" \) |
   while read line; do
     case "$line" in
@@ -251,26 +291,33 @@ if [ "$__utf8" ] ; then
     esac
   done
 
-  # Replace 'EUC-JP' => 'UTF-8'
-  ( cd "$pkg_dir" &&
-    convert_EUCJP2UTF8 lib/init.php skin/pukiwiki.skin*.php
-  )
+  if [ "$__utf8" ] ; then
+    # Replace 'EUC-JP' => 'UTF-8'
+    ( cd "$pkg_dir" &&
+      convert_EUCJP2UTF8 lib/init.php skin/pukiwiki.skin*.php
+    )
+  else
+    # Replace 'UTF-8' => 'EUC-JP'
+    ( cd "$pkg_dir" &&
+      convert_UTF82EUCJP lib/init.php skin/pukiwiki.skin*.php
+    )
+  fi
 
   # Filename encoded 'encoded-EUC-JP' to 'encoded-UTF-8'
   echo "Renaming encoded-EUC-JP => encoded-UTF-8 ..."
-  ( cd "$pkg_dir" &&
-    for dir in wiki wiki.en cache; do
-      ( cd "$dir" &&
-        ls *.txt *.ref *.rel 2>/dev/null | while read line; do
-         target="`$encls "$line" 2>/dev/null`" || exit 1
-         if [ "x$line" != "x$target" ] ; then
-            echo " " mv "$dir/$line" "$dir/$target"
-                     mv "$line" "$target" || exit 1
-         fi
-        done
-      ) || exit 1
-    done
-  ) || err "stop."
+#  ( cd "$pkg_dir" &&
+#    for dir in wiki wiki.en cache; do
+#      ( cd "$dir" &&
+#        ls *.txt *.ref *.rel 2>/dev/null | while read line; do
+#        target="`$encls "$line" 2>/dev/null`" || exit 1
+#        if [ "x$line" != "x$target" ] ; then
+#            echo " " mv "$dir/$line" "$dir/$target"
+#                     mv "$line" "$target" || exit 1
+#        fi
+#        done
+#      ) || exit 1
+#    done
+#  ) || err "stop."
 fi
 
 # chmod -----------------------------------------------------