1 |
#!/usr/bin/env python |
---|
2 |
|
---|
3 |
import tarfile |
---|
4 |
import os |
---|
5 |
import time |
---|
6 |
import shutil |
---|
7 |
|
---|
8 |
class MyTarFile(tarfile.TarFile): |
---|
9 |
def gettarinfo(self, name=None, arcname=None, fileobj=None): |
---|
10 |
info = tarfile.TarFile.gettarinfo(self, name, arcname, fileobj) |
---|
11 |
info.uid = info.gid = 0 |
---|
12 |
info.uname = "root" |
---|
13 |
info.gname = "wheel" |
---|
14 |
|
---|
15 |
if info.isdir(): |
---|
16 |
info.mtime = 0 |
---|
17 |
|
---|
18 |
return info |
---|
19 |
|
---|
20 |
def packageCvs(module, cvsModule, extras=['packs/build/autoconf'], cvsroot='/afs/dev.mit.edu/source/repository', date='tomorrow'): |
---|
21 |
os.system('attach macathena >/dev/null 2>/dev/null') |
---|
22 |
os.chdir('/mit/macathena/build') |
---|
23 |
|
---|
24 |
os.environ['CVSROOT'] = cvsroot |
---|
25 |
os.system('cvs -R export -D %s %s >/dev/null 2>/dev/null' % (date, cvsModule)) |
---|
26 |
|
---|
27 |
if extras: |
---|
28 |
for extra in extras: |
---|
29 |
os.system('cvs -R export -D %s -d %s %s >/dev/null 2>/dev/null' % (date, cvsModule, extra)) |
---|
30 |
|
---|
31 |
stamp = 0 |
---|
32 |
for root, dirs, files in os.walk(cvsModule): |
---|
33 |
if len(files) > 0: |
---|
34 |
stamp = max(stamp, max(os.stat('%s/%s' % (root, file))[8] for file in files)) |
---|
35 |
|
---|
36 |
tarball_time = time.strftime('%Y%m%d', time.localtime(stamp)) |
---|
37 |
tarball = '%s-%s' % (module, tarball_time) |
---|
38 |
os.rename(cvsModule, tarball) |
---|
39 |
|
---|
40 |
tar = MyTarFile.open('%s.tar.gz' % tarball, 'w:gz') |
---|
41 |
tar.add(tarball) |
---|
42 |
tar.close() |
---|
43 |
|
---|
44 |
shutil.move('%s.tar.gz' % tarball, '/mit/macathena/dist/') |
---|
45 |
shutil.rmtree('/mit/macathena/build/%s' % tarball) |
---|
46 |
|
---|
47 |
print 'Created /mit/macathena/dist/%s.tar.gz' % tarball |
---|
48 |
|
---|
49 |
modules = {'moira': ['moira', False, '/afs/athena.mit.edu/astaff/project/moiradev/repository'], |
---|
50 |
'libathdir': ['athena/lib/athdir'], |
---|
51 |
'athdir': ['athena/bin/athdir'], |
---|
52 |
'machtype': ['athena/bin/machtype'], |
---|
53 |
'attachandrun': ['athena/bin/attachandrun'], |
---|
54 |
'athrun': ['athena/bin/athrun'], |
---|
55 |
'athinfo': ['athena/bin/athinfo'], |
---|
56 |
'getcluster': ['athena/bin/getcluster', ['packs/build/autoconf', 'packs/build/aclocal.m4']], |
---|
57 |
'libxj': ['athena/lib/Xj'], |
---|
58 |
'libss': ['athena/lib/ss', ['packs/build/autoconf', 'packs/build/aclocal.m4', 'packs/build/libtool']], |
---|
59 |
'xcluster': ['athena/bin/xcluster', ['packs/build/autoconf', 'packs/build/aclocal.m4']], |
---|
60 |
'discuss': ['athena/bin/discuss']} |
---|
61 |
|
---|
62 |
if __name__ == '__main__': |
---|
63 |
import sys |
---|
64 |
|
---|
65 |
if sys.argv[1] == "all": |
---|
66 |
build = modules.keys() |
---|
67 |
else: |
---|
68 |
build = sys.argv[1:] |
---|
69 |
|
---|
70 |
for arg in build: |
---|
71 |
if modules.has_key(arg): |
---|
72 |
apply(packageCvs, [arg] + modules[arg]) |
---|
73 |
else: |
---|
74 |
print "Sorry - I don't know about the module %s" % arg |
---|