Salome HOME
CCAR: merge de la version 1.14 dans la branche principale
[tools/eficas.git] / Aster / sdist.py
1 # -*- coding: utf-8 -*-
2 """
3      Ce module sert à construire les distributions d'EFICAS en fonction
4      du tag CVS courant
5      Les distributions sont :
6       - un tar.gz pour UNIX ne contenant pas mxTextTools
7       - un zip pour Windows contenant mx TextTools préinstallé
8      L'utilisation de ce module est la suivante :
9       1- Se mettre dans un répertoire de travail
10       2- Configurer son environnement pour utiliser le référentiel CVS EFICAS
11       3- Exporter les sources d'EficasV1 par la commande :
12             cvs export -r TAG -d Eficas_export EficasV1
13          ou TAG est le tag CVS de la version que l'on veut distribuer (par exemple V1_1p1)
14       4- Copier le répertoire fourni par Aster (ACCAS6.2.0) au meme niveau que Eficas_export
15       5- Aller dans le répertoire Eficas_export
16       6- Executer le script sdist.py
17              python sdist.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_4'
26 # ==========Path du noyau fourni par Aster====================
27 path_Noyau="../../AccasAster"
28 # ============================================================
29 nom_distrib="Eficas"+version+"AsterSTA9"
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','NEWS'])
38
39    copyfiles('../Editeur',os.path.join(path_distrib,'Editeur'),['*.py','faqs.txt'])
40    copyfiles('../InterfaceTK',os.path.join(path_distrib,'InterfaceTK'),['*.py','faqs.txt'])
41    copyfiles('../InterfaceQT',os.path.join(path_distrib,'InterfaceQT'),['*.py'])
42    copyfiles('../Ui',os.path.join(path_distrib,'Ui'),['*.ui','makefile'])
43    copyfiles('../Traducteur',os.path.join(path_distrib,'Traducteur'),['*.py'])
44    copyfiles('../Ihm',os.path.join(path_distrib,'Ihm'),['*.py'])
45    copyfiles('../Extensions',os.path.join(path_distrib,'Extensions'),['*.py'])
46    copyfiles('../Misc',os.path.join(path_distrib,'Misc'),['*.py'])
47    copyfiles('../Accas',os.path.join(path_distrib,'Accas'),['*.py'])
48    # AIDE
49    copyfiles('../AIDE',os.path.join(path_distrib,'AIDE'),['*.py'])
50    copyfiles('../AIDE/fichiers',os.path.join(path_distrib,'AIDE','fichiers'),['*'])
51    copyfiles('.',os.path.join(path_distrib,'AIDE','fichiers'),['INSTALL','NEWS'])
52    copyfiles('../Editeur',os.path.join(path_distrib,'AIDE','fichiers'),['faqs.txt'])
53    # Code_Aster
54    copyfiles('../Aster',os.path.join(path_distrib,'Aster'),['prefs.py',
55                                                             'editeur.ini',
56                                                             'editeur_salome.ini',
57                                                             'eficas_aster.py',
58                                                             'test_eficas.py',
59                                                             'style.py',
60                                                             '__init__.py'
61                                                            ])
62
63    # Les Catalogues, Macros, Materiaux et SD
64    # copyfiles('Cata/Utilitai',os.path.join(path_distrib,'Aster','Cata','Utilitai'),['*.py'])
65    # copyfiles('Cata/pre74',os.path.join(path_distrib,'Aster','Cata','pre74'),['*.py'])
66
67    copyfiles('Cata/cataSTA6',os.path.join(path_distrib,'Aster','Cata','cataSTA6'),['*.py'])
68    copyfiles('Cata/cataSTA6/Macro',os.path.join(path_distrib,'Aster','Cata','cataSTA6','Macro'),['*.py'])
69
70    copyfiles('Cata/cataSTA7',os.path.join(path_distrib,'Aster','Cata','cataSTA7'),['*.py'])
71    copyfiles('Cata/cataSTA7/Macro',os.path.join(path_distrib,'Aster','Cata','cataSTA7','Macro'),['*.py'])
72    copyfiles('Cata/cataSTA7/materiau',os.path.join(path_distrib,'Aster','Cata','cataSTA7/materiau'),['README.py'])
73
74    copyfiles('Cata/cataSTA8',os.path.join(path_distrib,'Aster','Cata','cataSTA8'),['*.py'])
75    copyfiles('Cata/cataSTA8/Macro',os.path.join(path_distrib,'Aster','Cata','cataSTA8/Macro'),['*.py'])
76    copyfiles('Cata/cataSTA8/materiau',os.path.join(path_distrib,'Aster','Cata','cataSTA8/materiau'),['README.py'])
77
78    copyfiles('Cata/cataSTA9',os.path.join(path_distrib,'Aster','Cata','cataSTA9'),['*.py'])
79    copyfiles('Cata/cataSTA9/Macro',os.path.join(path_distrib,'Aster','Cata','cataSTA9/Macro'),['*.py'])
80    #copyfiles('Cata/cataSTA9/Messages',os.path.join(path_distrib,'Aster','Cata','cataSTA9/Messages'),['*.py'])
81    copyfiles('Cata/cataSTA9/materiau',os.path.join(path_distrib,'Aster','Cata','cataSTA9/materiau'),['README.py'])
82    copyfiles('Cata/cataSTA9/SD',os.path.join(path_distrib,'Aster','Cata','cataSTA9/SD'),['*.py'])
83
84    copyfiles('Cata',os.path.join(path_distrib,'Aster','Cata'),['*c_clefs_docu'])
85    copyfiles('../Aster/Cata',os.path.join(path_distrib,'Aster'),['aster.py',])
86
87    #                            ______________________
88
89    copyfiles('../convert',os.path.join(path_distrib,'convert'),['*.py'])
90    copyfiles('../convert/Parserv5',os.path.join(path_distrib,'convert','Parserv5'),['*.py'])
91    copyfiles('../generator',os.path.join(path_distrib,'generator'),['*.py'])
92    copyfiles('../Editeur/icons',os.path.join(path_distrib,'Editeur','icons'),['*.gif'])
93    copyfiles('../Editeur/Patrons',os.path.join(path_distrib,'Editeur','Patrons'),['*.com*'])
94    copyfiles('../Editeur/Patrons/ASTER',os.path.join(path_distrib,'Editeur','Patrons','ASTER'),['*.com*'])
95
96    copyfiles(os.path.join(path_Noyau,'Noyau'),os.path.join(path_distrib,'Noyau'),['*.py'])
97    copyfiles(os.path.join(path_Noyau,'Validation'),os.path.join(path_distrib,'Validation'),['*.py'])
98    copyfiles(os.path.join(path_Noyau,'Accas'),os.path.join(path_distrib,'Aster'),['properties.py'])
99    copyfiles(os.path.join(path_Noyau,'Cata'),os.path.join(path_distrib,'Aster','Cata'),['__init__.py',])
100    copyfiles(os.path.join(path_Noyau,'Macro'),os.path.join(path_distrib,'Aster','Cata','cataSTA9','Macro'),['.py'])
101    #os.system("mv "+path_distrib+"/Aster/Cata/cata_STA9.py "+path_distrib+"/Aster/Cata/cataSTA9/cata.py")
102
103    copyfiles('../Tools',os.path.join(path_distrib,'Tools'),['*.py'])
104    copyfiles('../Tools/foztools',os.path.join(path_distrib,'Tools','foztools'),['*.py'])
105    copyfiles('../Pmw',os.path.join(path_distrib,'Pmw'),['*.py'])
106    copyfiles('../Pmw/Pmw_1_2',os.path.join(path_distrib,'Pmw','Pmw_1_2'),['*.py'])
107    copyfiles('../Pmw/Pmw_1_2/lib',os.path.join(path_distrib,'Pmw','Pmw_1_2','lib'),['*.py','Pmw.def'])
108
109    
110    tarball= maketarball('dist',nom_distrib,nom_distrib)
111    try:
112       shutil.copy(tarball,dir_download)
113    except:
114       print "Repertoire de download inconnu : ",dir_download
115
116    shutil.copy('prefs.py.win',os.path.join(path_distrib,'Aster','prefs.py'))
117    shutil.copy('editeur.ini.win',os.path.join(path_distrib,'Aster','editeur.ini'))
118
119    try:
120       shutil.copytree(path_TextTools,os.path.join(path_distrib,'Tools','TextTools'))
121    except:
122       print "Impossible de recuperer mxTextTools : ",dir_download
123       sys.exit(1)
124
125    zipfile= makezipfile('dist',nom_distrib,nom_distrib)
126    try:
127       shutil.copy(zipfile,dir_download)
128    except:
129       print "Repertoire de download inconnu : ",dir_download
130
131 def make_dir(dir_cible):
132    if type(dir_cible) is not types.StringType:
133       raise "make_dir : dir_cible doit etre une string (%s)" % `dir_cible`
134    head,tail=os.path.split(dir_cible)
135    tails=[tail]
136    while head and tail and not os.path.isdir(head):
137       head,tail=os.path.split(head)
138       tails.insert(0, tail)
139
140    for d in tails:
141       head = os.path.join(head, d)
142       if not os.path.isdir(head):os.mkdir(head)
143
144
145 def copyfiles(dir_origin,dir_cible,listfiles):
146    if not os.path.isdir(dir_cible):make_dir(dir_cible)
147    for glob_files in listfiles:
148       for file in glob.glob(os.path.join(dir_origin,glob_files)):
149          shutil.copy(file,dir_cible)
150
151
152 def maketarball(dir_trav,dir_cible,nom_tar):
153    prev=os.getcwd()
154    print prev
155    os.chdir(dir_trav)
156    os.system("tar -cf "+nom_tar+".tar "+dir_cible)
157    os.system("gzip -f9 "+nom_tar+".tar ")
158    os.chdir(prev)
159    return os.path.join(dir_trav,nom_tar+".tar.gz")
160
161 def makezipfile(dir_trav,dir_cible,nom_tar):
162    prev=os.getcwd()
163    os.chdir(dir_trav)
164    os.system("zip -rq "+nom_tar+".zip "+dir_cible)
165    os.chdir(prev)
166    return os.path.join(dir_trav,nom_tar+".zip")
167
168 main()
169