i
[chise/ruby.git] / tools / make-chisedb-tarball.rb
index 68830eb..111ac8f 100755 (executable)
@@ -5,45 +5,50 @@ $LOAD_PATH.unshift("..")
 require "find"
 require "pathname"
 require "fileutils"
 require "find"
 require "pathname"
 require "fileutils"
-require "chise/util"
+require "chise/path"
+require "chise/qp"
 
 def usage()
 
 def usage()
-  print "Usage: make-chisedb-tarball.rb <directory of XEmacs CHISE> <tmp dir>\n"
-  print "% ./make-chisedb-tarball.rb /usr/local/lib/xemacs-21.4.14/i686-pc-linux /var/tmp\n"
+  puts "Usage: make-chisedb-tarball.rb <CHISE-DB dir> <tmp dir>"
+  puts "% ./make-chisedb-tarball.rb /usr/local/lib/xemacs-21.4.14/i686-pc-linux/chise-db /var/tmp"
   exit
 end
 
 def main(argv)
   usage if argv.length < 1
   dir = argv.shift
   exit
 end
 
 def main(argv)
   usage if argv.length < 1
   dir = argv.shift
-  path = dir.path
-  dbpath = dir+"chise-db"
-  unless dbpath.directory?
-    print "no chise-db here. #{dbpath.to_s}\n"
+  unless dir.path.directory?
+    print "no chise-db here. #{dir}\n"
     usage
   end
     usage
   end
-  tmpdir = argv.shift
-  tmpdir = "/var/tmp" if tmpdir.nil?
-  tmppath = tmpdir.path
-
+  tmpdir = argv.shift || "/var/tmp"
   orgdir = Dir.pwd
 
   orgdir = Dir.pwd
 
-  tmppath.chdir {
-    system "cp -a #{dir}/chise-db ." # copy all of the chise-db to the dir.
-
-    ".".path.find {|f|
-      if f =~ /([*?<>])/ # escape for Windows forbidden characters.
-       nf = f.escape_win_filename
-       cmd = "mv '#{f}' '#{nf}'"
-       #print cmd, "\n"
-       system cmd
-      end
-    }
+  print "copy all chise-db to tmpdir"
+  system "cp -a #{dir} #{tmpdir}" # 
+  puts "."
+
+  print "escape special characters"
+  Find.find(tmpdir+"/chise-db") {|f|
+    next if f.path.directory?
+    nf = f.path.escape.to_s
+    next if f == nf
+    cmd = "mv '#{f}' '#{nf}'"
+    #puts cmd
+    system cmd
+  }
+  puts "."
 
 
+  Dir.chdir(tmpdir){
+    print "make tarball"
     system "tar czf chise-db.tar.gz chise-db"
     system "tar czf chise-db.tar.gz chise-db"
+    puts "."
+    print "mv it"
     system "mv chise-db.tar.gz #{orgdir}"
     system "mv chise-db.tar.gz #{orgdir}"
+    puts "."
+    print "remove tmpdir/chise-db"
     system "rm -rf #{tmpdir}/chise-db"
     system "rm -rf #{tmpdir}/chise-db"
-
+    puts "."
   }
 end
 main(ARGV)
   }
 end
 main(ARGV)