1999-12-18 23:05:58 +00:00
|
|
|
#! /usr/bin/env python
|
1999-12-18 23:28:54 +00:00
|
|
|
#
|
|
|
|
# Script to make a compressed tar archive of the directory
|
|
|
|
# the script is living in, excluding CVS directories and the
|
|
|
|
# script itself.
|
|
|
|
#
|
2000-02-13 17:36:44 +00:00
|
|
|
# $Id: mktarball.py,v 1.7 2000-02-13 17:36:44 just Exp $
|
1999-12-18 23:28:54 +00:00
|
|
|
#
|
|
|
|
|
1999-12-18 23:05:58 +00:00
|
|
|
|
1999-12-18 23:09:30 +00:00
|
|
|
import os, sys
|
|
|
|
|
2000-02-13 17:36:44 +00:00
|
|
|
program = os.path.normpath(sys.argv[0])
|
|
|
|
script = os.path.join(os.getcwd(), program)
|
1999-12-18 23:56:14 +00:00
|
|
|
srcdir, scriptname = os.path.split(script)
|
|
|
|
wdir, src = os.path.split(srcdir)
|
2000-02-13 17:36:44 +00:00
|
|
|
|
|
|
|
destdir = None
|
|
|
|
if sys.argv[1:]:
|
|
|
|
destdir = os.path.normpath(os.path.join(os.getcwd(), sys.argv[1]))
|
|
|
|
assert os.path.isdir(destdir), "destination is not an existing directory"
|
|
|
|
|
1999-12-18 23:56:14 +00:00
|
|
|
os.chdir(wdir)
|
|
|
|
|
1999-12-18 23:05:58 +00:00
|
|
|
tar = src + ".tar"
|
|
|
|
gz = tar + ".gz"
|
|
|
|
|
1999-12-18 23:25:16 +00:00
|
|
|
print "source:", src
|
2000-02-13 17:36:44 +00:00
|
|
|
print "dest:", gz
|
1999-12-18 23:25:16 +00:00
|
|
|
|
1999-12-18 23:56:14 +00:00
|
|
|
os.system('tar --exclude=CVS --exclude=%s -cf %s %s' % (scriptname, tar, src))
|
1999-12-18 23:10:58 +00:00
|
|
|
os.system('gzip -9v %s' % tar)
|
2000-02-13 17:36:44 +00:00
|
|
|
|
|
|
|
if destdir:
|
|
|
|
print "destination directory:", destdir
|
|
|
|
os.system('mv %s %s' % (gz, destdir))
|
|
|
|
|