X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fruby.git;a=blobdiff_plain;f=tools%2Fmake-chisedb-tarball.rb;fp=tools%2Fmake-chisedb-tarball.rb;h=111ac8f3ea1b99553facaf1d72e704c1513bb284;hp=68830eb3ab0f0d062c1966b03ce536e2ad22625a;hb=85d5c7d449c81b6e0fdb3838cad47bb80cef80bd;hpb=e5da67dfc1d1a291fcec457c9b68b5774c9ab300 diff --git a/tools/make-chisedb-tarball.rb b/tools/make-chisedb-tarball.rb index 68830eb..111ac8f 100755 --- a/tools/make-chisedb-tarball.rb +++ b/tools/make-chisedb-tarball.rb @@ -5,45 +5,50 @@ $LOAD_PATH.unshift("..") require "find" require "pathname" require "fileutils" -require "chise/util" +require "chise/path" +require "chise/qp" def usage() - print "Usage: make-chisedb-tarball.rb \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 " + 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)