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