$LOAD_PATH.unshift("..")
require "find"
+require "pathname"
+require "fileutils"
require "chise/util"
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"
+ print "% ./make-chisedb-tarball.rb /usr/local/lib/xemacs-21.4.14/i686-pc-linux /var/tmp\n"
exit
end
def main(argv)
usage if argv.length < 1
dir = argv.shift
- unless FileTest.directory?(dir+"/chise-db")
- print "no chise-db here. #{dir}\n"
+ path = dir.path
+ dbpath = dir+"chise-db"
+ unless dbpath.directory?
+ print "no chise-db here. #{dbpath.to_s}\n"
usage
end
tmpdir = argv.shift
tmpdir = "/var/tmp" if tmpdir.nil?
+ tmppath = tmpdir.path
orgdir = Dir.pwd
- Dir.chdir(tmpdir) # \93K\93\96\82Èdir\82É\88Ú\93®\82µ\82Ä\82©\82ç
- system "cp -a #{dir}/chise-db ." # \82Ü\82¸\82»\82Ìdirectory\82É\96â\93\9a\96³\97p\82Å\91S\95\94\83R\83s\81[\82·\82é\81B
-
- Find.find("."){|f|
- if f =~ /([*?<>])/ # Windows\82É\82¨\82¯\82é\8bÖ\8e~\95¶\8e\9a\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82½\82ç\81A\92u\8a·\82·\82é
- nf = CHISE.unix_to_win(f)
- cmd = "mv '#{f}' '#{nf}'"
- #print cmd, "\n"
- system cmd
- end
- }
- system "tar czf chise-db.tar.gz chise-db"
- system "mv chise-db.tar.gz #{orgdir}"
- system "rm -rf #{tmpdir}/chise-db"
+ 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
+ }
+
+ system "tar czf chise-db.tar.gz chise-db"
+ system "mv chise-db.tar.gz #{orgdir}"
+ system "rm -rf #{tmpdir}/chise-db"
+
+ }
end
main(ARGV)