blob: b016e366c313be7ab2bbac0f36569f567036f7b0 [file] [log] [blame]
Justab5753c1999-12-18 23:05:58 +00001#! /usr/bin/env python
Justf898c411999-12-18 23:28:54 +00002#
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#
just0b99c892000-02-13 17:36:44 +00007# $Id: mktarball.py,v 1.7 2000-02-13 17:36:44 just Exp $
Justf898c411999-12-18 23:28:54 +00008#
9
Justab5753c1999-12-18 23:05:58 +000010
Just39ee0f51999-12-18 23:09:30 +000011import os, sys
Justab5753c1999-12-18 23:05:58 +000012
just0b99c892000-02-13 17:36:44 +000013program = os.path.normpath(sys.argv[0])
14script = os.path.join(os.getcwd(), program)
justb14adec1999-12-18 23:56:14 +000015srcdir, scriptname = os.path.split(script)
16wdir, src = os.path.split(srcdir)
just0b99c892000-02-13 17:36:44 +000017
18destdir = None
19if 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
justb14adec1999-12-18 23:56:14 +000023os.chdir(wdir)
24
Justab5753c1999-12-18 23:05:58 +000025tar = src + ".tar"
26gz = tar + ".gz"
Justab5753c1999-12-18 23:05:58 +000027
justc3d34ae1999-12-18 23:25:16 +000028print "source:", src
just0b99c892000-02-13 17:36:44 +000029print "dest:", gz
justc3d34ae1999-12-18 23:25:16 +000030
justb14adec1999-12-18 23:56:14 +000031os.system('tar --exclude=CVS --exclude=%s -cf %s %s' % (scriptname, tar, src))
Just7dd75ab1999-12-18 23:10:58 +000032os.system('gzip -9v %s' % tar)
just0b99c892000-02-13 17:36:44 +000033
34if destdir:
35 print "destination directory:", destdir
36 os.system('mv %s %s' % (gz, destdir))
37