require "find"
require "pathname"
require "fileutils"
-require "chise/util"
+require "chise/path"
+require "chise/qp"
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
- 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
- tmpdir = argv.shift
- tmpdir = "/var/tmp" if tmpdir.nil?
- tmppath = tmpdir.path
-
+ tmpdir = argv.shift || "/var/tmp"
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"
+ puts "."
+ print "mv it"
system "mv chise-db.tar.gz #{orgdir}"
+ puts "."
+ print "remove tmpdir/chise-db"
system "rm -rf #{tmpdir}/chise-db"
-
+ puts "."
}
end
main(ARGV)