[420] | 1 | #!/usr/bin/env python
|
---|
| 2 | #--------------------------------#
|
---|
| 3 | # Author: V.garonne #
|
---|
| 4 | # Mail: garonne@lal.in2p3.fr #
|
---|
| 5 | # Description: script to export #
|
---|
| 6 | # a CMT release to the web site #
|
---|
| 7 | #--------------------------------#
|
---|
| 8 |
|
---|
| 9 | import sys, os
|
---|
| 10 | import string
|
---|
| 11 | import commands
|
---|
| 12 | import shutil
|
---|
| 13 | import socket
|
---|
| 14 | import tarfile, gzip
|
---|
| 15 | import threading
|
---|
| 16 |
|
---|
| 17 | # my own stuffs
|
---|
| 18 | from utils.ssh_session import *
|
---|
| 19 | from p3 import decrypt
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | # for package version dependant
|
---|
| 23 | import tarfile
|
---|
| 24 |
|
---|
| 25 | # My own python 'tar -xvzf' in waiting python 2.5...
|
---|
| 26 | def extractall(tarball, path="."):
|
---|
| 27 | tar = tarfile.open(tarball)
|
---|
| 28 | directories = []
|
---|
| 29 | for tarinfo in tar:
|
---|
| 30 | if tarinfo.isdir():
|
---|
| 31 | try:
|
---|
| 32 | os.makedirs(os.path.join(path, tarinfo.name), 0777)
|
---|
| 33 | except EnvironmentError:
|
---|
| 34 | pass
|
---|
| 35 | directories.append(tarinfo)
|
---|
| 36 | else:
|
---|
| 37 | tar.extract(tarinfo, path)
|
---|
| 38 |
|
---|
| 39 | # Reverse sort directories.
|
---|
| 40 | directories.sort (lambda a, b: cmp(a.name, b.name))
|
---|
| 41 | directories.reverse()
|
---|
| 42 |
|
---|
| 43 | # Set correct owner, mtime and filemode on directories.
|
---|
| 44 | for tarinfo in directories:
|
---|
| 45 | path = os.path.join(path, tarinfo.name)
|
---|
| 46 | tar.chown(tarinfo, path)
|
---|
| 47 | #tar.utime(tarinfo, path)
|
---|
| 48 | #tar.chmod(tarinfo, path)
|
---|
| 49 | tar.close()
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | #--------------------# MAIN #-------------------------#
|
---|
| 53 | #if __name__ == '__main__':
|
---|
| 54 | def cmt_export_binaries (version):
|
---|
| 55 | # variables
|
---|
| 56 | proxy = '.cmtproxy'
|
---|
| 57 | preambule = 'cmt_export > '
|
---|
| 58 | platforms = [
|
---|
| 59 | 'Linux-i686',
|
---|
| 60 | 'Linux-x86_64',
|
---|
| 61 | 'Linux-ia64',
|
---|
| 62 | 'VisualC',
|
---|
| 63 | 'CYGWIN_NT-5.1-i686',
|
---|
| 64 | 'Darwin-PowerMacintosh',
|
---|
| 65 | ]
|
---|
| 66 |
|
---|
| 67 | if not os.path.exists (proxy):
|
---|
| 68 | print preambule + 'First create the proxy'
|
---|
| 69 | sys.exit(-1)
|
---|
| 70 | pool = eval(decrypt('.cmtproxy'))
|
---|
| 71 | machine = 'Linux-i686'
|
---|
| 72 | host = pool[machine]['machine']
|
---|
| 73 | user = pool[machine]['user']
|
---|
| 74 | pwd = pool[machine] ['pwd']
|
---|
| 75 | session = ssh_session (user=user, host=host, password=pwd, verbose=1)
|
---|
| 76 |
|
---|
| 77 | for platform in platforms:
|
---|
| 78 | file = 'CMT'+version+platform+'.tar.gz'
|
---|
| 79 | if os.path.exists(file):
|
---|
| 80 | print file
|
---|
| 81 | extractall(tarball=file)
|
---|
| 82 |
|
---|
| 83 | path = '/afs/cern.ch/sw/contrib/CMT/'
|
---|
| 84 | session.scp ('CMT/'+version, path,'r')
|
---|
| 85 | session.ssh ('cd '+path+'/'+version+'/mgr; ./INSTALL')
|
---|
| 86 |
|
---|
| 87 | for platform in platforms:
|
---|
| 88 | if platform != 'VisualC':
|
---|
| 89 | cmd = "ln -s "+" "+path+'/'+version+'/'+platform+'/cmt.exe'+" "+path+'/'+version+'/'+platform+'/cmt'
|
---|
| 90 | session.ssh (cmd)
|
---|
| 91 |
|
---|
| 92 | platforms = ['OSF1-alpha',]
|
---|
| 93 | for platform in platforms:
|
---|
| 94 | file = 'CMT'+version+platform+'.tar.gz'
|
---|
| 95 | if os.path.exists(file):
|
---|
| 96 | print file
|
---|
| 97 | extractall(tarball=file)
|
---|
| 98 |
|
---|
| 99 | machine = 'OSF1-alpha'
|
---|
| 100 | host = "lx.lal.in2p3.fr" # pool[machine]['machine']
|
---|
| 101 | user = pool[machine]['user']
|
---|
| 102 | pwd = pool[machine] ['pwd']
|
---|
| 103 | session = ssh_session (user=user, host=host, password=pwd, verbose=1)
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | path = '/lal/CMT'
|
---|
| 107 | session.scp ('CMT/'+version, path,'r')
|
---|
| 108 | cmd = "ln -s "+" "+path+'/'+version+'/'+platform+'/cmt.exe'+" "+path+'/'+version+'/'+platform+'/cmt'
|
---|
| 109 | session.ssh (cmd)
|
---|
| 110 | session.ssh ('cd '+path+'/'+version+'/mgr; ./INSTALL')
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | shutil.rmtree ('CMT')
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | #----------------------- End Of File --------------------------# |
---|