2007-05-22 20:07:17 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2009-09-23 17:57:22 +00:00
|
|
|
NSPR_DIRS = (('nsprpub', 'mozilla/nsprpub'),)
|
|
|
|
NSS_DIRS = (('dbm', 'mozilla/dbm'),
|
|
|
|
('security/nss', 'mozilla/security/nss'),
|
|
|
|
('security/coreconf', 'mozilla/security/coreconf'),
|
|
|
|
('security/dbm', 'mozilla/security/dbm'))
|
|
|
|
LIBFFI_DIRS = (('js/ctypes/libffi', 'libffi'),)
|
|
|
|
|
|
|
|
CVSROOT_MOZILLA = ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'
|
|
|
|
CVSROOT_LIBFFI = ':pserver:anoncvs@sources.redhat.com:/cvs/libffi'
|
2007-05-22 20:07:17 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2008-06-02 22:52:25 +00:00
|
|
|
import datetime
|
2008-06-06 12:34:40 +00:00
|
|
|
import shutil
|
2007-05-22 20:07:17 +00:00
|
|
|
from optparse import OptionParser
|
2008-11-13 15:37:04 +00:00
|
|
|
from build.util import check_call
|
2007-05-22 20:07:17 +00:00
|
|
|
|
|
|
|
topsrcdir = os.path.dirname(__file__)
|
|
|
|
if topsrcdir == '':
|
|
|
|
topsrcdir = '.'
|
|
|
|
|
2007-07-13 12:23:32 +00:00
|
|
|
def check_call_noisy(cmd, *args, **kwargs):
|
|
|
|
print "Executing command:", cmd
|
|
|
|
check_call(cmd, *args, **kwargs)
|
|
|
|
|
|
|
|
def do_hg_pull(dir, repository, hg):
|
2007-05-22 20:07:17 +00:00
|
|
|
fulldir = os.path.join(topsrcdir, dir)
|
2007-05-24 04:05:33 +00:00
|
|
|
# clone if the dir doesn't exist, pull if it does
|
|
|
|
if not os.path.exists(fulldir):
|
|
|
|
fulldir = os.path.join(topsrcdir, dir)
|
2007-07-13 12:23:32 +00:00
|
|
|
check_call_noisy([hg, 'clone', repository, fulldir])
|
2007-05-24 04:05:33 +00:00
|
|
|
else:
|
2007-07-13 12:23:32 +00:00
|
|
|
cmd = [hg, 'pull', '-u', '-R', fulldir]
|
|
|
|
if repository is not None:
|
|
|
|
cmd.append(repository)
|
|
|
|
check_call_noisy(cmd)
|
2008-06-02 22:52:25 +00:00
|
|
|
check_call([hg, 'parent', '-R', fulldir,
|
|
|
|
'--template=Updated to revision {node}.\n'])
|
2007-05-22 20:07:17 +00:00
|
|
|
|
2008-06-06 12:34:40 +00:00
|
|
|
def do_cvs_export(modules, tag, cvsroot, cvs):
|
|
|
|
"""Check out a CVS directory without CVS metadata, using "export"
|
2009-09-23 17:57:22 +00:00
|
|
|
modules is a list of directories to check out and the corresponding
|
|
|
|
cvs module, e.g. (('nsprpub', 'mozilla/nsprpub'))
|
2007-05-22 20:07:17 +00:00
|
|
|
"""
|
2009-09-23 17:57:22 +00:00
|
|
|
for module_tuple in modules:
|
|
|
|
module = module_tuple[0]
|
|
|
|
cvs_module = module_tuple[1]
|
2008-06-06 12:34:40 +00:00
|
|
|
fullpath = os.path.join(topsrcdir, module)
|
|
|
|
if os.path.exists(fullpath):
|
|
|
|
print "Removing '%s'" % fullpath
|
|
|
|
shutil.rmtree(fullpath)
|
|
|
|
|
2007-05-22 20:07:17 +00:00
|
|
|
(parent, leaf) = os.path.split(module)
|
2008-06-06 12:34:40 +00:00
|
|
|
print "CVS export begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
|
2007-07-13 12:23:32 +00:00
|
|
|
check_call_noisy([cvs, '-d', cvsroot,
|
2009-09-23 17:57:22 +00:00
|
|
|
'export', '-r', tag, '-d', leaf, cvs_module],
|
2007-07-13 12:23:32 +00:00
|
|
|
cwd=os.path.join(topsrcdir, parent))
|
2008-06-06 12:34:40 +00:00
|
|
|
print "CVS export end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
|
2007-05-22 20:07:17 +00:00
|
|
|
|
2009-09-23 17:57:22 +00:00
|
|
|
o = OptionParser(usage="client.py [options] update_nspr tagname | update_nss tagname | update_libffi tagname")
|
2007-12-21 21:49:52 +00:00
|
|
|
o.add_option("--skip-mozilla", dest="skip_mozilla",
|
|
|
|
action="store_true", default=False,
|
2008-06-06 12:34:40 +00:00
|
|
|
help="Obsolete")
|
2007-12-21 21:49:52 +00:00
|
|
|
|
2007-05-22 20:07:17 +00:00
|
|
|
o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'),
|
|
|
|
help="The location of the cvs binary")
|
|
|
|
o.add_option("--cvsroot", dest="cvsroot",
|
2009-09-23 17:57:22 +00:00
|
|
|
help="The CVSROOT (default for mozilla checkouts: %s)" % CVSROOT_MOZILLA)
|
2007-05-22 20:07:17 +00:00
|
|
|
|
|
|
|
try:
|
2008-06-06 12:34:40 +00:00
|
|
|
options, args = o.parse_args()
|
|
|
|
action = args[0]
|
|
|
|
except IndexError:
|
2007-05-22 20:07:17 +00:00
|
|
|
o.print_help()
|
|
|
|
sys.exit(2)
|
|
|
|
|
|
|
|
if action in ('checkout', 'co'):
|
2008-06-06 12:34:40 +00:00
|
|
|
print >>sys.stderr, "Warning: client.py checkout is obsolete."
|
|
|
|
pass
|
|
|
|
elif action in ('update_nspr'):
|
|
|
|
tag, = args[1:]
|
2009-09-23 17:57:22 +00:00
|
|
|
if not options.cvsroot:
|
|
|
|
options.cvsroot = os.environ.get('CVSROOT', CVSROOT_MOZILLA)
|
2008-06-06 12:34:40 +00:00
|
|
|
do_cvs_export(NSPR_DIRS, tag, options.cvsroot, options.cvs)
|
2010-03-09 13:54:09 +00:00
|
|
|
print >>file("nsprpub/TAG-INFO", "w"), tag
|
2008-06-06 12:34:40 +00:00
|
|
|
elif action in ('update_nss'):
|
|
|
|
tag, = args[1:]
|
2009-09-23 17:57:22 +00:00
|
|
|
if not options.cvsroot:
|
|
|
|
options.cvsroot = os.environ.get('CVSROOT', CVSROOT_MOZILLA)
|
2008-06-06 12:34:40 +00:00
|
|
|
do_cvs_export(NSS_DIRS, tag, options.cvsroot, options.cvs)
|
2010-03-09 13:54:09 +00:00
|
|
|
print >>file("security/nss/TAG-INFO", "w"), tag
|
2009-09-23 17:57:22 +00:00
|
|
|
elif action in ('update_libffi'):
|
|
|
|
tag, = args[1:]
|
|
|
|
if not options.cvsroot:
|
|
|
|
options.cvsroot = CVSROOT_LIBFFI
|
|
|
|
do_cvs_export(LIBFFI_DIRS, tag, options.cvsroot, options.cvs)
|
2007-05-22 20:07:17 +00:00
|
|
|
else:
|
|
|
|
o.print_help()
|
|
|
|
sys.exit(2)
|