Salome HOME
CCAR: mise en coherence de Build_sd de mACRO_ETAPE avec celle de ETAPE
[tools/eficas.git] / Aster / alphasdist.py
1 """
2      Ce module sert à construire les distributions de versions alpha d'EFICAS en fonction
3      du tag CVS courant (Vx_yaz). Une version alpha est une version dont toutes les fonctionnalités
4      ne sont pas implémentées. On utilise pour ces versions, les packages Noyau Validation Cata et Macro
5      locaux.
6      Les distributions sont :
7       - un tar.gz pour UNIX ne contenant pas mxTextTools
8       - un zip pour Windows contenant mx TextTools préinstallé
9      L'utilisation de ce module est la suivante :
10       1- Se mettre dans un répertoire de travail
11       2- Configurer son environnement pour utiliser le référentiel CVS EFICAS
12       3- Exporter les sources d'Eficas par la commande :
13             cvs export -r TAG -d Eficas_export EficasV1_2
14          ou TAG est le tag CVS de la version que l'on veut distribuer (par exemple V1_3a1)
15       4- Aller dans le répertoire Eficas_export
16       4- Executer le script alphasdist.py
17              python alphasdist.py
18          Ce qui a pour effet de creer un repertoire dist contenant les 2 distributions
19          et de les copier dans le répertoire indiqué par dir_download s'il est accessible
20
21 """
22 import os,shutil,glob,sys
23 import types
24
25 version="$Name:  $"[7:-2] or 'Test1_3'
26 # ==========Path du noyau local           ====================
27 path_Noyau=".."
28 # ============================================================
29 nom_distrib="Eficas"+version+"AsterSTA6"
30 path_distrib=os.path.join("dist",nom_distrib)
31 path_TextTools="/home/eficas/pkg/mxTools/egenix2.0.2pourWindows/mx/TextTools"
32 dir_download= "/home/eficas/WWW/telechargement/eficas"
33
34 def main():
35    if os.path.isdir('dist'):shutil.rmtree('dist')
36
37    copyfiles('.',path_distrib,['LICENSE.TERMS','INSTALL'])
38
39    copyfiles('../Editeur',os.path.join(path_distrib,'Editeur'),['*.py','faqs.txt'])
40    copyfiles('../Ihm',os.path.join(path_distrib,'Ihm'),['*.py'])
41    copyfiles('../Extensions',os.path.join(path_distrib,'Extensions'),['*.py'])
42    copyfiles('../Accas',os.path.join(path_distrib,'Accas'),['*.py'])
43    copyfiles('../Macro',os.path.join(path_distrib,'Macro'),['*.py'])
44    copyfiles('../AIDE',os.path.join(path_distrib,'AIDE'),['*.py'])
45    copyfiles('../AIDE/fichiers',os.path.join(path_distrib,'AIDE/fichiers'),['*'])
46    copyfiles('../Aster',os.path.join(path_distrib,'Aster'),['prefs.py',
47                                                             'editeur.ini',
48                                                             'eficas_aster.py',
49                                                            ])
50    copyfiles('../convert',os.path.join(path_distrib,'convert'),['*.py'])
51    copyfiles('../convert/Parserv5',os.path.join(path_distrib,'convert','Parserv5'),['*.py'])
52
53    copyfiles('../generator',os.path.join(path_distrib,'generator'),['*.py'])
54
55    copyfiles('../Editeur/icons',os.path.join(path_distrib,'Editeur','icons'),['*.gif'])
56
57    copyfiles(os.path.join(path_Noyau,'Noyau'),os.path.join(path_distrib,'Noyau'),['*.py'])
58    copyfiles(os.path.join(path_Noyau,'Validation'),os.path.join(path_distrib,'Validation'),['*.py'])
59    copyfiles('../Aster/Cata',os.path.join(path_distrib,'Aster','Cata'),['*.py',
60                                                                                        ])
61
62    copyfiles('../Tools',os.path.join(path_distrib,'Tools'),['*.py'])
63    copyfiles('../Tools/foztools',os.path.join(path_distrib,'Tools','foztools'),['*.py'])
64    
65    tarball= maketarball('dist',nom_distrib,nom_distrib)
66    try:
67       shutil.copy(tarball,dir_download)
68    except:
69       print "Repertoire de download inconnu : ",dir_download
70
71    try:
72       shutil.copytree(path_TextTools,os.path.join(path_distrib,'Tools','TextTools'))
73    except:
74       print "Impossible de recuperer mxTextTools : ",dir_download
75       sys.exit(1)
76
77    zipfile= makezipfile('dist',nom_distrib,nom_distrib)
78    try:
79       shutil.copy(zipfile,dir_download)
80    except:
81       print "Repertoire de download inconnu : ",dir_download
82
83 def make_dir(dir_cible):
84    if type(dir_cible) is not types.StringType:
85       raise "make_dir : dir_cible doit etre une string (%s)" % `dir_cible`
86    head,tail=os.path.split(dir_cible)
87    tails=[tail]
88    while head and tail and not os.path.isdir(head):
89       head,tail=os.path.split(head)
90       tails.insert(0, tail)
91
92    for d in tails:
93       head = os.path.join(head, d)
94       if not os.path.isdir(head):os.mkdir(head)
95
96
97 def copyfiles(dir_origin,dir_cible,listfiles):
98    if not os.path.isdir(dir_cible):make_dir(dir_cible)
99    for glob_files in listfiles:
100       for file in glob.glob(os.path.join(dir_origin,glob_files)):
101          shutil.copy(file,dir_cible)
102
103 def maketarball(dir_trav,dir_cible,nom_tar):
104    prev=os.getcwd()
105    print prev
106    os.chdir(dir_trav)
107    os.system("tar -cf "+nom_tar+".tar "+dir_cible)
108    os.system("gzip -f9 "+nom_tar+".tar ")
109    os.chdir(prev)
110    return os.path.join(dir_trav,nom_tar+".tar.gz")
111
112 def makezipfile(dir_trav,dir_cible,nom_tar):
113    prev=os.getcwd()
114    os.chdir(dir_trav)
115    os.system("zip -rq "+nom_tar+".zip "+dir_cible)
116    os.chdir(prev)
117    return os.path.join(dir_trav,nom_tar+".zip")
118
119 main()
120