root/trunk/locker-bin/macathenaDist.py

Revision 46, 3.5 kB (checked in by broder, 17 years ago)

Changed macathenaDist.py to use Athena 10 svn as upstream when possible

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env python
2
3 import tarfile
4 import os
5 from os.path import basename
6 import time
7 import shutil
8
9 mtime = 0
10
11 class MyTarFile(tarfile.TarFile):
12         def gettarinfo(self, name=None, arcname=None, fileobj=None):
13                 info = tarfile.TarFile.gettarinfo(self, name, arcname, fileobj)
14                 info.uid = info.gid = 0
15                 info.uname = "root"
16                 info.gname = "wheel"
17                
18                 if info.isdir():
19                         info.mtime = mtime
20                
21                 return info
22
23 def packageSvn(module, svnModule, extras=[], svnroot='/afs/dev.mit.edu/source/svn-repos', revision='HEAD'):
24         os.system('attach macathena >/dev/null 2>/dev/null')
25         os.chdir('/mit/macathena/build')
26        
27         os.system('svn export -r %s file://%s/%s %s >/dev/null 2>&1' % (revision, svnroot, svnModule, module))
28        
29         for extra in extras:
30                 os.system('svn export -r %s file://%s/%s >/dev/null 2>&1' % (revision, svnroot, extra))
31                 os.system('mv %s %s' % (basename(extra), module))
32        
33         version_info = os.popen('svn info -r %s file://%s/%s' % (revision, svnroot, svnModule)).readlines()
34         for line in version_info:
35                 if line.startswith('Last Changed Date: '):
36                         time_string = line.strip().split(': ')[1][0:19]
37                 elif line.startswith('Last Changed Rev: '):
38                         revision = line.strip().split(': ')[1]
39        
40         mtime = int(time.strftime("%s", time.strptime(time_string, "%Y-%m-%d %H:%M:%S")))
41        
42         tarball = "%s-%s" % (module, revision)
43         os.rename(module, tarball)
44        
45         tar = MyTarFile.open('%s.tar.gz' % tarball, 'w:gz')
46         tar.add(tarball)
47         tar.close()
48        
49         shutil.move('%s.tar.gz' % tarball, '/mit/macathena/dist/')
50         shutil.rmtree('/mit/macathena/build/%s' % tarball)
51        
52         print 'Created /mit/macathena/dist/%s.tar.gz' % tarball
53
54 def packageCvs(module, cvsModule, extras=['packs/build/autoconf'], cvsroot='/afs/dev.mit.edu/source/repository', date='tomorrow'):
55         os.system('attach macathena >/dev/null 2>/dev/null')
56         os.chdir('/mit/macathena/build')
57        
58         os.environ['CVSROOT'] = cvsroot
59         os.system('cvs -R export -D %s %s >/dev/null 2>/dev/null' % (date, cvsModule))
60        
61         if extras:
62                 for extra in extras:
63                         os.system('cvs -R export -D %s -d %s %s >/dev/null 2>/dev/null' % (date, cvsModule, extra))
64        
65         stamp = 0
66         for root, dirs, files in os.walk(cvsModule):
67                 if len(files) > 0:
68                         stamp = max(stamp, max(os.stat('%s/%s' % (root, file))[8] for file in files))
69        
70         tarball_time = time.strftime('%Y%m%d', time.localtime(stamp))
71         tarball = '%s-%s' % (module, tarball_time)
72         os.rename(cvsModule, tarball)
73        
74         tar = MyTarFile.open('%s.tar.gz' % tarball, 'w:gz')
75         tar.add(tarball)
76         tar.close()
77        
78         shutil.move('%s.tar.gz' % tarball, '/mit/macathena/dist/')
79         shutil.rmtree('/mit/macathena/build/%s' % tarball)
80        
81         print 'Created /mit/macathena/dist/%s.tar.gz' % tarball
82
83 cvsModules = {'moira': ['moira', False, '/afs/athena.mit.edu/astaff/project/moiradev/repository']}
84
85 svnModules = {'libathdir': ['trunk/athena/lib/athdir'],
86         'athdir': ['trunk/athena/bin/athdir'],
87         'machtype': ['trunk/athena/bin/machtype'],
88         'attachandrun': ['trunk/athena/bin/attachandrun'],
89         'athrun': ['trunk/athena/bin/athrun'],
90         'athinfo': ['trunk/athena/bin/athinfo'],
91         'getcluster': ['trunk/athena/bin/getcluster', ['attic/packs/build/aclocal.m4']],
92         'libxj': ['trunk/athena/lib/Xj'],
93         'xcluster': ['trunk/athena/bin/xcluster', ['attic/packs/build/aclocal.m4']],
94         'discuss': ['trunk/athena/bin/discuss']}
95
96 if __name__ == '__main__':
97         import sys
98        
99         if sys.argv[1] == "all":
100                 build = cvsModules.keys() + svnModules.keys()
101         else:
102                 build = sys.argv[1:]
103        
104         for arg in build:
105                 if svnModules.has_key(arg):
106                         apply(packageSvn, [arg] + svnModules[arg])
107                 elif cvsModules.has_key(arg):
108                         apply(packageCvs, [arg] + cvsModules[arg])
109                 else:
110                         print "Sorry - I don't know about the module %s" % arg
Note: See TracBrowser for help on using the browser.