3 NSPR_DIRS
= (('nsprpub', 'mozilla/nsprpub'),)
4 NSS_DIRS
= (('dbm', 'mozilla/dbm'),
5 ('security/nss', 'mozilla/security/nss'),
6 ('security/coreconf', 'mozilla/security/coreconf'),
7 ('security/dbm', 'mozilla/security/dbm'))
8 LIBFFI_DIRS
= (('js/ctypes/libffi', 'libffi'),)
10 CVSROOT_MOZILLA
= ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'
11 CVSROOT_LIBFFI
= ':pserver:anoncvs@sources.redhat.com:/cvs/libffi'
17 from optparse
import OptionParser
18 from build
.util
import check_call
20 topsrcdir
= os
.path
.dirname(__file__
)
24 def check_call_noisy(cmd
, *args
, **kwargs
):
25 print "Executing command:", cmd
26 check_call(cmd
, *args
, **kwargs
)
28 def do_hg_pull(dir, repository
, hg
):
29 fulldir
= os
.path
.join(topsrcdir
, dir)
30 # clone if the dir doesn't exist, pull if it does
31 if not os
.path
.exists(fulldir
):
32 fulldir
= os
.path
.join(topsrcdir
, dir)
33 check_call_noisy([hg
, 'clone', repository
, fulldir
])
35 cmd
= [hg
, 'pull', '-u', '-R', fulldir
]
36 if repository
is not None:
37 cmd
.append(repository
)
39 check_call([hg
, 'parent', '-R', fulldir
,
40 '--template=Updated to revision {node}.\n'])
42 def do_cvs_export(modules
, tag
, cvsroot
, cvs
):
43 """Check out a CVS directory without CVS metadata, using "export"
44 modules is a list of directories to check out and the corresponding
45 cvs module, e.g. (('nsprpub', 'mozilla/nsprpub'))
47 for module_tuple
in modules
:
48 module
= module_tuple
[0]
49 cvs_module
= module_tuple
[1]
50 fullpath
= os
.path
.join(topsrcdir
, module
)
51 if os
.path
.exists(fullpath
):
52 print "Removing '%s'" % fullpath
53 shutil
.rmtree(fullpath
)
55 (parent
, leaf
) = os
.path
.split(module
)
56 print "CVS export begin: " + datetime
.datetime
.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
57 check_call_noisy([cvs
, '-d', cvsroot
,
58 'export', '-r', tag
, '-d', leaf
, cvs_module
],
59 cwd
=os
.path
.join(topsrcdir
, parent
))
60 print "CVS export end: " + datetime
.datetime
.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
62 o
= OptionParser(usage
="client.py [options] update_nspr tagname | update_nss tagname | update_libffi tagname")
63 o
.add_option("--skip-mozilla", dest
="skip_mozilla",
64 action
="store_true", default
=False,
67 o
.add_option("--cvs", dest
="cvs", default
=os
.environ
.get('CVS', 'cvs'),
68 help="The location of the cvs binary")
69 o
.add_option("--cvsroot", dest
="cvsroot",
70 help="The CVSROOT (default for mozilla checkouts: %s)" % CVSROOT_MOZILLA
)
73 options
, args
= o
.parse_args()
79 if action
in ('checkout', 'co'):
80 print >>sys
.stderr
, "Warning: client.py checkout is obsolete."
82 elif action
in ('update_nspr'):
84 if not options
.cvsroot
:
85 options
.cvsroot
= os
.environ
.get('CVSROOT', CVSROOT_MOZILLA
)
86 do_cvs_export(NSPR_DIRS
, tag
, options
.cvsroot
, options
.cvs
)
87 elif action
in ('update_nss'):
89 if not options
.cvsroot
:
90 options
.cvsroot
= os
.environ
.get('CVSROOT', CVSROOT_MOZILLA
)
91 do_cvs_export(NSS_DIRS
, tag
, options
.cvsroot
, options
.cvs
)
92 elif action
in ('update_libffi'):
94 if not options
.cvsroot
:
95 options
.cvsroot
= CVSROOT_LIBFFI
96 do_cvs_export(LIBFFI_DIRS
, tag
, options
.cvsroot
, options
.cvs
)