68830eb3ab0f0d062c1966b03ce536e2ad22625a
[chise/ruby.git] / tools / make-chisedb-tarball.rb
1 #!/usr/bin/env ruby
2 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
3
4 $LOAD_PATH.unshift("..")
5 require "find"
6 require "pathname"
7 require "fileutils"
8 require "chise/util"
9
10 def usage()
11   print "Usage: make-chisedb-tarball.rb <directory of XEmacs CHISE> <tmp dir>\n"
12   print "% ./make-chisedb-tarball.rb /usr/local/lib/xemacs-21.4.14/i686-pc-linux /var/tmp\n"
13   exit
14 end
15
16 def main(argv)
17   usage if argv.length < 1
18   dir = argv.shift
19   path = dir.path
20   dbpath = dir+"chise-db"
21   unless dbpath.directory?
22     print "no chise-db here. #{dbpath.to_s}\n"
23     usage
24   end
25   tmpdir = argv.shift
26   tmpdir = "/var/tmp" if tmpdir.nil?
27   tmppath = tmpdir.path
28
29   orgdir = Dir.pwd
30
31   tmppath.chdir {
32     system "cp -a #{dir}/chise-db ." # copy all of the chise-db to the dir.
33
34     ".".path.find {|f|
35       if f =~ /([*?<>])/ # escape for Windows forbidden characters.
36         nf = f.escape_win_filename
37         cmd = "mv '#{f}' '#{nf}'"
38         #print cmd, "\n"
39         system cmd
40       end
41     }
42
43     system "tar czf chise-db.tar.gz chise-db"
44     system "mv chise-db.tar.gz #{orgdir}"
45     system "rm -rf #{tmpdir}/chise-db"
46
47   }
48 end
49 main(ARGV)