1999-08-02 20:19:17 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
"""%(program)s - script to create the latex source distribution
|
|
|
|
|
|
|
|
usage:
|
|
|
|
%(program)s [-t|--tools] release [tag]
|
|
|
|
|
|
|
|
with -t|--tools: doesn't include the documents, only the framework
|
|
|
|
|
|
|
|
without [tag]: generate from the current version that's checked in
|
|
|
|
(*NOT* what's in the current directory!)
|
|
|
|
|
|
|
|
with [tag]: generate from the named tag
|
|
|
|
"""
|
|
|
|
#* should be modified to get the Python version number automatically
|
|
|
|
# from the Makefile or someplace.
|
|
|
|
|
|
|
|
import getopt
|
|
|
|
import glob
|
|
|
|
import os
|
2000-10-10 19:35:40 +00:00
|
|
|
import re
|
1999-08-02 20:19:17 +00:00
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
import tempfile
|
|
|
|
|
2000-10-10 19:35:40 +00:00
|
|
|
import cvsinfo
|
|
|
|
|
1999-08-02 20:19:17 +00:00
|
|
|
|
|
|
|
quiet = 0
|
2000-10-10 19:35:40 +00:00
|
|
|
rx = re.compile(r":ext:(?:[a-zA-Z0-9]+)@cvs\.([a-zA-Z0-9]+).sourceforge.net:"
|
|
|
|
r"/cvsroot/\1")
|
1999-08-02 20:19:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
global quiet
|
|
|
|
try:
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "abgtzq",
|
|
|
|
["all", "bzip2", "gzip", "tools", "zip",
|
|
|
|
"quiet"])
|
|
|
|
except getopt.error, e:
|
|
|
|
usage(warning=str(e))
|
|
|
|
sys.exit(2)
|
|
|
|
if len(args) not in (1, 2):
|
|
|
|
usage(warning="wrong number of parameters")
|
|
|
|
sys.exit(2)
|
|
|
|
tools = 0
|
|
|
|
formats = {}
|
|
|
|
for opt, arg in opts:
|
|
|
|
if opt in ("-t", "--tools"):
|
|
|
|
tools = 1
|
|
|
|
elif opt in ("-q", "--quiet"):
|
|
|
|
quiet = quiet + 1
|
|
|
|
elif opt in ("-b", "--bzip2"):
|
|
|
|
formats["bzip2"] = 1
|
|
|
|
elif opt in ("-g", "--gzip"):
|
|
|
|
formats["gzip"] = 1
|
|
|
|
elif opt in ("-z", "--zip"):
|
|
|
|
formats["zip"] = 1
|
|
|
|
elif opt in ("-a", "--all"):
|
|
|
|
formats["bzip2"] = 1
|
|
|
|
formats["gzip"] = 1
|
|
|
|
formats["zip"] = 1
|
|
|
|
if formats:
|
|
|
|
# make order human-predictable
|
2001-01-22 21:34:20 +00:00
|
|
|
formats = formats.keys()
|
1999-08-02 20:19:17 +00:00
|
|
|
formats.sort()
|
|
|
|
else:
|
|
|
|
formats = ["gzip"]
|
|
|
|
release = args[0]
|
|
|
|
cvstag = None
|
|
|
|
if len(args) > 1:
|
|
|
|
cvstag = args[1]
|
|
|
|
tempdir = tempfile.mktemp()
|
|
|
|
os.mkdir(tempdir)
|
2000-10-10 19:35:40 +00:00
|
|
|
pkgdir = os.path.join(tempdir, "Python-" + release)
|
|
|
|
os.mkdir(pkgdir)
|
|
|
|
pwd = os.getcwd()
|
|
|
|
mydir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
|
|
|
info = cvsinfo.RepositoryInfo(mydir)
|
|
|
|
cvsroot = info.get_cvsroot()
|
|
|
|
m = rx.match(cvsroot)
|
|
|
|
if m:
|
|
|
|
# If this is an authenticated SourceForge repository, convert to
|
|
|
|
# anonymous usage for the export/checkout, since that avoids the
|
|
|
|
# SSH overhead.
|
|
|
|
group = m.group(1)
|
|
|
|
cvsroot = ":pserver:anonymous@cvs.%s.sourceforge.net:/cvsroot/%s" \
|
|
|
|
% (group, group)
|
|
|
|
# For some reason, SourceForge/CVS doesn't seem to care that we
|
|
|
|
# might not have done a "cvs login" to the anonymous server.
|
|
|
|
# That avoids a lot of painful gunk here.
|
|
|
|
os.chdir(pkgdir)
|
|
|
|
if not quiet:
|
|
|
|
print "--- current directory is:", pkgdir
|
1999-08-02 20:19:17 +00:00
|
|
|
if cvstag:
|
2000-10-10 19:35:40 +00:00
|
|
|
run("cvs -d%s export -r %s -d Doc python/dist/src/Doc"
|
|
|
|
% (cvsroot, cvstag))
|
1999-08-02 20:19:17 +00:00
|
|
|
else:
|
2000-10-10 19:35:40 +00:00
|
|
|
run("cvs -Q -d%s checkout -d Doc python/dist/src/Doc" % cvsroot)
|
1999-08-02 20:19:17 +00:00
|
|
|
# remove CVS directories
|
2001-02-02 15:48:00 +00:00
|
|
|
for p in ('*/CVS', '*/*/CVS', '*/*/*/CVS'):
|
1999-08-02 20:19:17 +00:00
|
|
|
map(shutil.rmtree, glob.glob(p))
|
2001-02-02 15:48:00 +00:00
|
|
|
for f in ('.cvsignore', '*/.cvsignore'):
|
|
|
|
map(os.unlink, glob.glob(f))
|
2001-01-22 21:34:20 +00:00
|
|
|
LICENSE = os.path.normpath(
|
|
|
|
os.path.join(mydir, os.pardir, os.pardir, "LICENSE"))
|
|
|
|
shutil.copyfile(LICENSE, "Doc/LICENSE")
|
1999-08-02 20:19:17 +00:00
|
|
|
if tools:
|
2000-10-10 19:35:40 +00:00
|
|
|
archive = "doctools-" + release
|
1999-08-02 20:19:17 +00:00
|
|
|
# we don't want the actual documents in this case:
|
2000-10-10 19:35:40 +00:00
|
|
|
for d in ("api", "dist", "doc", "ext", "inst",
|
|
|
|
"lib", "mac", "ref", "tut"):
|
|
|
|
shutil.rmtree(os.path.join(os.path.join(pkgdir, "Doc"), d))
|
1999-08-02 20:19:17 +00:00
|
|
|
else:
|
|
|
|
archive = "latex-" + release
|
|
|
|
|
|
|
|
# XXX should also remove the .cvsignore files at this point
|
|
|
|
|
|
|
|
os.chdir(tempdir)
|
2000-10-10 19:35:40 +00:00
|
|
|
archive = os.path.join(pwd, archive)
|
1999-08-02 20:19:17 +00:00
|
|
|
for format in formats:
|
|
|
|
if format == "bzip2":
|
|
|
|
run("tar cf - Python-%s | bzip2 -9 >%s.tar.bz2"
|
|
|
|
% (release, archive))
|
|
|
|
elif format == "gzip":
|
|
|
|
run("tar cf - Python-%s | gzip -9 >%s.tgz"
|
|
|
|
% (release, archive))
|
|
|
|
elif format == "zip":
|
2000-04-03 04:19:14 +00:00
|
|
|
if os.path.exists(archive + ".zip"):
|
|
|
|
os.unlink(archive + ".zip")
|
|
|
|
run("zip -q -r9 %s.zip Python-%s"
|
1999-08-02 20:19:17 +00:00
|
|
|
% (archive, release))
|
|
|
|
|
|
|
|
# clean up the work area:
|
2000-10-10 19:35:40 +00:00
|
|
|
os.chdir(pwd)
|
1999-08-02 20:19:17 +00:00
|
|
|
shutil.rmtree(tempdir)
|
|
|
|
|
|
|
|
|
|
|
|
def run(cmd):
|
|
|
|
if quiet < 2:
|
|
|
|
print "+++", cmd
|
|
|
|
if quiet:
|
2000-10-10 19:35:40 +00:00
|
|
|
cmd = "%s >/dev/null" % cmd
|
1999-08-02 20:19:17 +00:00
|
|
|
rc = os.system(cmd)
|
|
|
|
if rc:
|
|
|
|
sys.exit(rc)
|
|
|
|
|
|
|
|
|
|
|
|
def usage(warning=None):
|
|
|
|
stdout = sys.stdout
|
|
|
|
sys.stdout = sys.stderr
|
|
|
|
program = os.path.basename(sys.argv[0])
|
|
|
|
try:
|
|
|
|
if warning:
|
|
|
|
print "%s: %s\n" % (program, warning)
|
|
|
|
print __doc__ % {"program": program}
|
|
|
|
finally:
|
|
|
|
sys.stdout = stdout
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|