Just | ab5753c | 1999-12-18 23:05:58 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
Just | f898c41 | 1999-12-18 23:28:54 +0000 | [diff] [blame] | 2 | # |
| 3 | # Script to make a compressed tar archive of the directory |
| 4 | # the script is living in, excluding CVS directories and the |
| 5 | # script itself. |
| 6 | # |
jvr | 3b18bda | 2001-08-10 16:49:17 +0000 | [diff] [blame] | 7 | # $Id: mktarball.py,v 1.8 2001-08-10 16:49:17 jvr Exp $ |
Just | f898c41 | 1999-12-18 23:28:54 +0000 | [diff] [blame] | 8 | # |
| 9 | |
Just | ab5753c | 1999-12-18 23:05:58 +0000 | [diff] [blame] | 10 | |
Just | 39ee0f5 | 1999-12-18 23:09:30 +0000 | [diff] [blame] | 11 | import os, sys |
Just | ab5753c | 1999-12-18 23:05:58 +0000 | [diff] [blame] | 12 | |
jvr | 3b18bda | 2001-08-10 16:49:17 +0000 | [diff] [blame] | 13 | |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 14 | program = os.path.normpath(sys.argv[0]) |
| 15 | script = os.path.join(os.getcwd(), program) |
just | b14adec | 1999-12-18 23:56:14 +0000 | [diff] [blame] | 16 | srcdir, scriptname = os.path.split(script) |
| 17 | wdir, src = os.path.split(srcdir) |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 18 | |
jvr | 3b18bda | 2001-08-10 16:49:17 +0000 | [diff] [blame] | 19 | try: |
| 20 | execfile(os.path.join(srcdir, "Lib", "fontTools", "__init__.py")) |
| 21 | version # make sure we now have a variable named "version" |
| 22 | except (IOError, NameError): |
| 23 | version = None |
| 24 | |
| 25 | |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 26 | destdir = None |
| 27 | if sys.argv[1:]: |
| 28 | destdir = os.path.normpath(os.path.join(os.getcwd(), sys.argv[1])) |
| 29 | assert os.path.isdir(destdir), "destination is not an existing directory" |
| 30 | |
just | b14adec | 1999-12-18 23:56:14 +0000 | [diff] [blame] | 31 | os.chdir(wdir) |
| 32 | |
jvr | 3b18bda | 2001-08-10 16:49:17 +0000 | [diff] [blame] | 33 | if version: |
| 34 | tar = src + "-%s.tar" % version |
| 35 | else: |
| 36 | tar = src + ".tar" |
Just | ab5753c | 1999-12-18 23:05:58 +0000 | [diff] [blame] | 37 | gz = tar + ".gz" |
Just | ab5753c | 1999-12-18 23:05:58 +0000 | [diff] [blame] | 38 | |
just | c3d34ae | 1999-12-18 23:25:16 +0000 | [diff] [blame] | 39 | print "source:", src |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 40 | print "dest:", gz |
just | c3d34ae | 1999-12-18 23:25:16 +0000 | [diff] [blame] | 41 | |
just | b14adec | 1999-12-18 23:56:14 +0000 | [diff] [blame] | 42 | os.system('tar --exclude=CVS --exclude=%s -cf %s %s' % (scriptname, tar, src)) |
Just | 7dd75ab | 1999-12-18 23:10:58 +0000 | [diff] [blame] | 43 | os.system('gzip -9v %s' % tar) |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 44 | |
| 45 | if destdir: |
| 46 | print "destination directory:", destdir |
| 47 | os.system('mv %s %s' % (gz, destdir)) |
| 48 | |