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