Bug 454756 - Disable DelayedStop for Arm flashplayer. r+sr=jst.
[mozilla-central.git] / client.py
blob90b13073fa8bc2c38431d79a4dbcdbfc63b892ad
1 #!/usr/bin/python
3 NSPR_DIRS = ('nsprpub',)
4 NSS_DIRS = ('dbm',
5 'security/nss',
6 'security/coreconf',
7 'security/dbm')
9 import os
10 import sys
11 import datetime
12 import shutil
13 from optparse import OptionParser
15 topsrcdir = os.path.dirname(__file__)
16 if topsrcdir == '':
17 topsrcdir = '.'
19 try:
20 from subprocess import check_call
21 except ImportError:
22 import subprocess
23 def check_call(*popenargs, **kwargs):
24 retcode = subprocess.call(*popenargs, **kwargs)
25 if retcode:
26 cmd = kwargs.get("args")
27 if cmd is None:
28 cmd = popenargs[0]
29 raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))
31 def check_call_noisy(cmd, *args, **kwargs):
32 print "Executing command:", cmd
33 check_call(cmd, *args, **kwargs)
35 def do_hg_pull(dir, repository, hg):
36 fulldir = os.path.join(topsrcdir, dir)
37 # clone if the dir doesn't exist, pull if it does
38 if not os.path.exists(fulldir):
39 fulldir = os.path.join(topsrcdir, dir)
40 check_call_noisy([hg, 'clone', repository, fulldir])
41 else:
42 cmd = [hg, 'pull', '-u', '-R', fulldir]
43 if repository is not None:
44 cmd.append(repository)
45 check_call_noisy(cmd)
46 check_call([hg, 'parent', '-R', fulldir,
47 '--template=Updated to revision {node}.\n'])
49 def do_cvs_export(modules, tag, cvsroot, cvs):
50 """Check out a CVS directory without CVS metadata, using "export"
51 modules is a list of directories to check out, e.g. ['nsprpub']
52 """
53 for module in modules:
54 fullpath = os.path.join(topsrcdir, module)
55 if os.path.exists(fullpath):
56 print "Removing '%s'" % fullpath
57 shutil.rmtree(fullpath)
59 (parent, leaf) = os.path.split(module)
60 print "CVS export begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
61 check_call_noisy([cvs, '-d', cvsroot,
62 'export', '-r', tag, '-d', leaf,
63 'mozilla/%s' % module],
64 cwd=os.path.join(topsrcdir, parent))
65 print "CVS export end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
67 o = OptionParser(usage="client.py [options] update_nspr tagname | update_nss tagname")
68 o.add_option("--skip-mozilla", dest="skip_mozilla",
69 action="store_true", default=False,
70 help="Obsolete")
72 o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'),
73 help="The location of the cvs binary")
74 o.add_option("--cvsroot", dest="cvsroot",
75 default=os.environ.get('CVSROOT', ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'),
76 help="The CVSROOT (default: :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot")
78 try:
79 options, args = o.parse_args()
80 action = args[0]
81 except IndexError:
82 o.print_help()
83 sys.exit(2)
85 if action in ('checkout', 'co'):
86 print >>sys.stderr, "Warning: client.py checkout is obsolete."
87 pass
88 elif action in ('update_nspr'):
89 tag, = args[1:]
90 do_cvs_export(NSPR_DIRS, tag, options.cvsroot, options.cvs)
91 elif action in ('update_nss'):
92 tag, = args[1:]
93 do_cvs_export(NSS_DIRS, tag, options.cvsroot, options.cvs)
94 else:
95 o.print_help()
96 sys.exit(2)