root/trunk/locker-bin/macathenaDist.py

Revision 65, 4.3 kB (checked in by broder, 16 years ago)

Added macathena-update to sources list

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