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 | # |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 7 | # $Id: mktarball.py,v 1.7 2000-02-13 17:36:44 just 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 | |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 13 | program = os.path.normpath(sys.argv[0]) |
| 14 | script = os.path.join(os.getcwd(), program) |
just | b14adec | 1999-12-18 23:56:14 +0000 | [diff] [blame] | 15 | srcdir, scriptname = os.path.split(script) |
| 16 | wdir, src = os.path.split(srcdir) |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 17 | |
| 18 | destdir = None |
| 19 | if sys.argv[1:]: |
| 20 | destdir = os.path.normpath(os.path.join(os.getcwd(), sys.argv[1])) |
| 21 | assert os.path.isdir(destdir), "destination is not an existing directory" |
| 22 | |
just | b14adec | 1999-12-18 23:56:14 +0000 | [diff] [blame] | 23 | os.chdir(wdir) |
| 24 | |
Just | ab5753c | 1999-12-18 23:05:58 +0000 | [diff] [blame] | 25 | tar = src + ".tar" |
| 26 | gz = tar + ".gz" |
Just | ab5753c | 1999-12-18 23:05:58 +0000 | [diff] [blame] | 27 | |
just | c3d34ae | 1999-12-18 23:25:16 +0000 | [diff] [blame] | 28 | print "source:", src |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 29 | print "dest:", gz |
just | c3d34ae | 1999-12-18 23:25:16 +0000 | [diff] [blame] | 30 | |
just | b14adec | 1999-12-18 23:56:14 +0000 | [diff] [blame] | 31 | os.system('tar --exclude=CVS --exclude=%s -cf %s %s' % (scriptname, tar, src)) |
Just | 7dd75ab | 1999-12-18 23:10:58 +0000 | [diff] [blame] | 32 | os.system('gzip -9v %s' % tar) |
just | 0b99c89 | 2000-02-13 17:36:44 +0000 | [diff] [blame] | 33 | |
| 34 | if destdir: |
| 35 | print "destination directory:", destdir |
| 36 | os.system('mv %s %s' % (gz, destdir)) |
| 37 | |