Salome HOME
PN : surcharge de isvalid
[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+"AsterSTA7"
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('../Ihm',os.path.join(path_distrib,'Ihm'),['*.py'])
41    copyfiles('../Extensions',os.path.join(path_distrib,'Extensions'),['*.py'])
42    copyfiles('../Misc',os.path.join(path_distrib,'Misc'),['*.py'])
43    copyfiles('../Accas',os.path.join(path_distrib,'Accas'),['*.py'])
44    # AIDE
45    copyfiles('../AIDE',os.path.join(path_distrib,'AIDE'),['*.py'])
46    copyfiles('../AIDE/fichiers',os.path.join(path_distrib,'AIDE','fichiers'),['*'])
47    copyfiles('.',os.path.join(path_distrib,'AIDE','fichiers'),['INSTALL','NEWS'])
48    copyfiles('../Editeur',os.path.join(path_distrib,'AIDE','fichiers'),['faqs.txt'])
49    # Code_Aster
50    copyfiles('../Aster',os.path.join(path_distrib,'Aster'),['prefs.py',
51                                                             'editeur.ini',
52                                                             'eficas_aster.py',
53                                                            ])
54    copyfiles('Cata/pre74',os.path.join(path_distrib,'Aster','Cata','pre74'),['*.py'])
55    copyfiles('Cata/cataSTA5',os.path.join(path_distrib,'Aster','Cata','cataSTA5'),['*.py'])
56    copyfiles('Cata/cataSTA6',os.path.join(path_distrib,'Aster','Cata','cataSTA6'),['*.py'])
57
58    copyfiles('../convert',os.path.join(path_distrib,'convert'),['*.py'])
59    copyfiles('../convert/Parserv5',os.path.join(path_distrib,'convert','Parserv5'),['*.py'])
60
61    copyfiles('../generator',os.path.join(path_distrib,'generator'),['*.py'])
62
63    copyfiles('../Editeur/icons',os.path.join(path_distrib,'Editeur','icons'),['*.gif'])
64
65    copyfiles(os.path.join(path_Noyau,'Noyau'),os.path.join(path_distrib,'Noyau'),['*.py'])
66    copyfiles(os.path.join(path_Noyau,'Validation'),os.path.join(path_distrib,'Validation'),['*.py'])
67    copyfiles(os.path.join(path_Noyau,'Cata'),os.path.join(path_distrib,'Aster','Cata'),['*.py',
68                                                                                        ])
69    copyfiles(os.path.join(path_Noyau,'Macro'),os.path.join(path_distrib,'Aster','Cata','Macro'),['*.py'])
70    copyfiles(os.path.join(path_Noyau,'Accas'),os.path.join(path_distrib,'Aster'),['properties.py'])
71
72    copyfiles('../Tools',os.path.join(path_distrib,'Tools'),['*.py'])
73    copyfiles('../Tools/foztools',os.path.join(path_distrib,'Tools','foztools'),['*.py'])
74    
75    tarball= maketarball('dist',nom_distrib,nom_distrib)
76    try:
77       shutil.copy(tarball,dir_download)
78    except:
79       print "Repertoire de download inconnu : ",dir_download
80
81    try:
82       shutil.copytree(path_TextTools,os.path.join(path_distrib,'Tools','TextTools'))
83    except:
84       print "Impossible de recuperer mxTextTools : ",dir_download
85       sys.exit(1)
86
87    zipfile= makezipfile('dist',nom_distrib,nom_distrib)
88    try:
89       shutil.copy(zipfile,dir_download)
90    except:
91       print "Repertoire de download inconnu : ",dir_download
92
93 def make_dir(dir_cible):
94    if type(dir_cible) is not types.StringType:
95       raise "make_dir : dir_cible doit etre une string (%s)" % `dir_cible`
96    head,tail=os.path.split(dir_cible)
97    tails=[tail]
98    while head and tail and not os.path.isdir(head):
99       head,tail=os.path.split(head)
100       tails.insert(0, tail)
101
102    for d in tails:
103       head = os.path.join(head, d)
104       if not os.path.isdir(head):os.mkdir(head)
105
106
107 def copyfiles(dir_origin,dir_cible,listfiles):
108    if not os.path.isdir(dir_cible):make_dir(dir_cible)
109    for glob_files in listfiles:
110       for file in glob.glob(os.path.join(dir_origin,glob_files)):
111          shutil.copy(file,dir_cible)
112
113 def maketarball(dir_trav,dir_cible,nom_tar):
114    prev=os.getcwd()
115    print prev
116    os.chdir(dir_trav)
117    os.system("tar -cf "+nom_tar+".tar "+dir_cible)
118    os.system("gzip -f9 "+nom_tar+".tar ")
119    os.chdir(prev)
120    return os.path.join(dir_trav,nom_tar+".tar.gz")
121
122 def makezipfile(dir_trav,dir_cible,nom_tar):
123    prev=os.getcwd()
124    os.chdir(dir_trav)
125    os.system("zip -rq "+nom_tar+".zip "+dir_cible)
126    os.chdir(prev)
127    return os.path.join(dir_trav,nom_tar+".zip")
128
129 main()
130