Projet

Général

Profil

EnvoleBonnesPratiques » Historique » Version 34

Gérald Schwartzmann, 20/05/2010 14:33

1 21 Gérald Schwartzmann
h2. !http://dev-eole.ac-dijon.fr/attachments/download/9/puce.png! Environnement Libre Ouvert Evolutif - Envole
2 21 Gérald Schwartzmann
{{include(eole:menu)}}
3 1 Gérald Schwartzmann
4 1 Gérald Schwartzmann
h1. Les Bonnes Pratiques
5 22 Gérald Schwartzmann
6 22 Gérald Schwartzmann
{{include(ModeleEbauche)}}
7 6 Gérald Schwartzmann
8 7 Gérald Schwartzmann
h2. Documentations, sources et articles wiki
9 8 Gérald Schwartzmann
10 12 Gérald Schwartzmann
Voici "Les bonnes pratiques sur le nommage des applications EOLE":http://eole.orion.education.fr/wiki/index.php/DocumentationDokiel
11 6 Gérald Schwartzmann
12 9 Gérald Schwartzmann
h2. Git
13 6 Gérald Schwartzmann
14 7 Gérald Schwartzmann
h3. Placement
15 1 Gérald Schwartzmann
16 11 Gérald Schwartzmann
Les applications de Envole sont des sous-projets de "Envole":http://dev-eole.ac-dijon.fr/projects/envole .
17 13 Gérald Schwartzmann
Dans le dépôt ils apparaissent les un à côté des autres (à plat).
18 1 Gérald Schwartzmann
19 13 Gérald Schwartzmann
h3. Les Bonnes Pratiques
20 25 Gérald Schwartzmann
21 27 Gérald Schwartzmann
"Les Bonnes Pratiques de Git généralité et autres":http://dev-eole.ac-dijon.fr/projects/eole-interne/wiki/GitBonnesPratiques
22 1 Gérald Schwartzmann
23 27 Gérald Schwartzmann
Lorsque le master existe il contient les sources de la première version du paquet.
24 27 Gérald Schwartzmann
Créer une nouvelle branche en vue d'ajouter des développements
25 27 Gérald Schwartzmann
26 27 Gérald Schwartzmann
<pre>
27 27 Gérald Schwartzmann
$ git checkout -b devel
28 27 Gérald Schwartzmann
$ git push --all
29 27 Gérald Schwartzmann
</pre>
30 27 Gérald Schwartzmann
31 32 Gérald Schwartzmann
h3. prompt sympa pour git
32 32 Gérald Schwartzmann
33 32 Gérald Schwartzmann
Ajouter les lignes suivantes à votre .bashrc pour un peu plus de confort
34 32 Gérald Schwartzmann
35 32 Gérald Schwartzmann
<pre>
36 32 Gérald Schwartzmann
toUpper() {
37 32 Gérald Schwartzmann
          echo $1 | tr "[:lower:]" "[:upper:]"
38 32 Gérald Schwartzmann
}
39 32 Gérald Schwartzmann
40 32 Gérald Schwartzmann
parse_git_branch() {
41 32 Gérald Schwartzmann
        branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'`
42 32 Gérald Schwartzmann
        if [ "$branch" != "" ];then
43 32 Gérald Schwartzmann
                label=`toUpper $branch`
44 32 Gérald Schwartzmann
        fi
45 32 Gérald Schwartzmann
        echo $label
46 32 Gérald Schwartzmann
}
47 32 Gérald Schwartzmann
</pre>
48 32 Gérald Schwartzmann
49 1 Gérald Schwartzmann
h3. Nommage
50 8 Gérald Schwartzmann
51 14 Gérald Schwartzmann
Le nom des sous-projets doivent être en minuscule
52 6 Gérald Schwartzmann
53 13 Gérald Schwartzmann
Exemple dans la liste des sous-projets : http://dev-eole.ac-dijon.fr/projects/envole
54 6 Gérald Schwartzmann
55 14 Gérald Schwartzmann
h3. Structure du Master
56 6 Gérald Schwartzmann
57 14 Gérald Schwartzmann
Puisque votre développement n'est pas la branche d'un projet déjà existant on réalise un master.<br />
58 14 Gérald Schwartzmann
Pour cela il faut créer selon les besoins de votre application les fichiers et répertoires suivant :
59 6 Gérald Schwartzmann
 - Makefile
60 6 Gérald Schwartzmann
 - debian/
61 6 Gérald Schwartzmann
 - dicos/
62 6 Gérald Schwartzmann
 - mysql/
63 6 Gérald Schwartzmann
 - patch/
64 6 Gérald Schwartzmann
 - sso/
65 6 Gérald Schwartzmann
 - source_de_votre_appli_num_de_version/
66 6 Gérald Schwartzmann
 - tmpls/
67 6 Gérald Schwartzmann
 - etc/
68 6 Gérald Schwartzmann
69 14 Gérald Schwartzmann
Exemple : http://dev-eole.ac-dijon.fr/projects/dokuwiki/repository
70 6 Gérald Schwartzmann
71 7 Gérald Schwartzmann
h2. Les fichiers templates
72 8 Gérald Schwartzmann
73 6 Gérald Schwartzmann
Le nom d'un fichier templétisé ne doit pas porté le même nom qu'un autre pour cela il faut préfixer le nom du fichier avec le nom de l'application.
74 6 Gérald Schwartzmann
75 6 Gérald Schwartzmann
Exemple du fichier config.php qui est présent dans une bonne partie des applications :
76 6 Gérald Schwartzmann
77 6 Gérald Schwartzmann
taskfreak_config.php
78 6 Gérald Schwartzmann
79 7 Gérald Schwartzmann
h2. Dico
80 8 Gérald Schwartzmann
81 7 Gérald Schwartzmann
h3. Nommage
82 8 Gérald Schwartzmann
83 6 Gérald Schwartzmann
Les applications du socle
84 6 Gérald Schwartzmann
<pre>5x_nom_de_l_application.xml</pre>
85 6 Gérald Schwartzmann
Les applications supplémentaires au socle
86 6 Gérald Schwartzmann
<pre>6x_nom_de_l_application.xml</pre>
87 6 Gérald Schwartzmann
x étant supérieur à 0
88 6 Gérald Schwartzmann
89 7 Gérald Schwartzmann
h3. construction du fichier
90 8 Gérald Schwartzmann
91 15 Gérald Schwartzmann
{{include(ModeleFixme)}}
92 6 Gérald Schwartzmann
93 7 Gérald Schwartzmann
h2. Paquetage
94 8 Gérald Schwartzmann
95 24 Gérald Schwartzmann
h3. nommage du paquet
96 25 Gérald Schwartzmann
97 6 Gérald Schwartzmann
eole-nom_de_l_application
98 24 Gérald Schwartzmann
99 24 Gérald Schwartzmann
h3. fichiers postinst postrm
100 25 Gérald Schwartzmann
101 24 Gérald Schwartzmann
dans les fichiers postinst et postrm il faut utiliser des chemins absolus pour les commandes :
102 26 Gérald Schwartzmann
<pre>/bin/cp</pre>
103 6 Gérald Schwartzmann
104 7 Gérald Schwartzmann
h2. Apache
105 1 Gérald Schwartzmann
106 15 Gérald Schwartzmann
h3. nommage du fichier de conf dans sites-enabled
107 15 Gérald Schwartzmann
108 6 Gérald Schwartzmann
Un fichier de conf apache par application :
109 1 Gérald Schwartzmann
<pre>apache-nom_de_l_application.conf</pre>
110 15 Gérald Schwartzmann
111 15 Gérald Schwartzmann
h3. contenu du fichier de conf dans sites-enabled
112 15 Gérald Schwartzmann
113 19 Gérald Schwartzmann
Le chemin de l'application doit être son nom
114 19 Gérald Schwartzmann
115 16 Gérald Schwartzmann
Si un projet ne contient pas de .htaccess il faut ajouter la directive *AllowOverride None*.
116 16 Gérald Schwartzmann
Celle-ci permet de diminuer le délai d'attente en lui évitant de partir à la recherche de fichier .htaccess dans chaque répertoire qu'il visite.
117 16 Gérald Schwartzmann
118 18 Gérald Schwartzmann
Date d'expiration du cache proxy ou navigateur.
119 18 Gérald Schwartzmann
Régler correctement et finement le cache des clients permet d'éviter un grand nombre de requête.
120 18 Gérald Schwartzmann
En prévision de l'activation du *mod_expires* sur le serveur Apache, on peut ajouter la directive *ExpiresActive On* suivit de directive *ExpiresByType type "durée de vie dans le cache"*
121 18 Gérald Schwartzmann
122 18 Gérald Schwartzmann
<pre>
123 18 Gérald Schwartzmann
<IfModule mod_expires.c>
124 18 Gérald Schwartzmann
                ExpiresActive On
125 18 Gérald Schwartzmann
                ExpiresByType text/html "access plus 1 day"
126 18 Gérald Schwartzmann
</IfModule>
127 18 Gérald Schwartzmann
</pre>
128 18 Gérald Schwartzmann
129 18 Gérald Schwartzmann
Exemple complet d'un fichier de configuration d'une application :
130 16 Gérald Schwartzmann
131 16 Gérald Schwartzmann
<pre>
132 16 Gérald Schwartzmann
# Envole Infos
133 16 Gérald Schwartzmann
# Equipe EOLE
134 16 Gérald Schwartzmann
Alias /envole-infos /var/www/html/envole-infos
135 16 Gérald Schwartzmann
<Directory "/var/www/html/envole-infos">
136 17 Gérald Schwartzmann
        AllowOverride None
137 16 Gérald Schwartzmann
        AddDefaultCharset UTF-8
138 16 Gérald Schwartzmann
        DirectoryIndex index.php
139 16 Gérald Schwartzmann
        Order Allow,Deny
140 16 Gérald Schwartzmann
        Allow from All
141 16 Gérald Schwartzmann
        <IfModule mod_expires.c>
142 16 Gérald Schwartzmann
                ExpiresActive On
143 16 Gérald Schwartzmann
                ExpiresByType text/html "access plus 1 day"
144 16 Gérald Schwartzmann
                ExpiresByType text/xml "access plus 1 day"
145 16 Gérald Schwartzmann
                ExpiresByType image/gif "access plus 1 week"
146 16 Gérald Schwartzmann
                ExpiresByType image/jpg "access plus 1 week"
147 16 Gérald Schwartzmann
                ExpiresByType image/png "access plus 1 week"
148 16 Gérald Schwartzmann
                ExpiresByType video/quicktime "access plus 1 month"
149 16 Gérald Schwartzmann
                ExpiresByType audio/mpeg "access plus 1 month"
150 16 Gérald Schwartzmann
                ExpiresByType application/pdf "access plus 1 month"
151 16 Gérald Schwartzmann
                ExpiresByType application/ps "access plus 1 month"
152 16 Gérald Schwartzmann
                ExpiresByType text/css "access plus 1 day"
153 16 Gérald Schwartzmann
                ExpiresByType application/x-shockwave-flash "access plus 1 day"
154 16 Gérald Schwartzmann
                ExpiresByType text/js "access plus 1 week"
155 16 Gérald Schwartzmann
                ExpiresByType text/javascript "access plus 1 week"
156 16 Gérald Schwartzmann
                ExpiresByType application/x-javascript "access plus 1 week"
157 16 Gérald Schwartzmann
                ExpiresByType image/x-icon "access plus 1 day"
158 16 Gérald Schwartzmann
        </IfModule>
159 16 Gérald Schwartzmann
</Directory>
160 16 Gérald Schwartzmann
</pre>
161 15 Gérald Schwartzmann
162 15 Gérald Schwartzmann
h3. les droits dans /var/www/html/
163 6 Gérald Schwartzmann
164 23 Gaston TJEBBES
Application des droits minimaux sur les répertoires:
165 1 Gérald Schwartzmann
166 23 Gaston TJEBBES
<pre>
167 23 Gaston TJEBBES
# Définition du propriétaire du répertoire
168 23 Gaston TJEBBES
/bin/chown -R root:www-data /var/www/html/votre_appli<br />
169 23 Gaston TJEBBES
# Définition des droits minimaux pour les répertoires (ont besoin d'être exécutables)
170 23 Gaston TJEBBES
/bin/chmod -R 750 /var/www/html/votre_appli<br />
171 23 Gaston TJEBBES
# Définition des droits minimaux pour les fichiers
172 23 Gaston TJEBBES
/usr/bin/find /var/www/html/votre_appli -type f -exec /bin/chmod ugo-x {} \;
173 23 Gaston TJEBBES
</pre>
174 23 Gaston TJEBBES
175 23 Gaston TJEBBES
Pour des raisons de sécurité seuls les fichiers nécessitant d'être modifiés par l'application sont éditables par l'utilisateur avec lequel est lancé apache à savoir www-data<br />
176 23 Gaston TJEBBES
<pre>
177 23 Gaston TJEBBES
/bin/chmod 770 /var/www/html/votre_appli/datas
178 23 Gaston TJEBBES
/bin/chmod 660 /var/www/html/votre_appli/datas/*.*
179 23 Gaston TJEBBES
</pre>
180 6 Gérald Schwartzmann
181 7 Gérald Schwartzmann
h2. Base de données
182 8 Gérald Schwartzmann
183 6 Gérald Schwartzmann
<pre>scribe-nom_de_l_application.sql</pre>
184 6 Gérald Schwartzmann
185 29 Gérald Schwartzmann
Si la bdd nécessite une templétisation il est préférable de découper la bdd en deux fichiers MySql.
186 29 Gérald Schwartzmann
L'un avec la partie à templétiser et l'autre avec le reste.
187 29 Gérald Schwartzmann
Cette découpe fait gagner un temps considérable lors du reconfigure.
188 7 Gérald Schwartzmann
189 28 Gérald Schwartzmann
h2. Stockage des données
190 6 Gérald Schwartzmann
191 29 Gérald Schwartzmann
Exemple de Dokuwiki
192 28 Gérald Schwartzmann
Pour être prise en charge par la sauvegarde Bacula les données des applications sont stockées dans :
193 28 Gérald Schwartzmann
<pre>
194 28 Gérald Schwartzmann
/home/www-data/var/www/html/nom_de_l'application
195 28 Gérald Schwartzmann
</pre>
196 27 Gérald Schwartzmann
197 27 Gérald Schwartzmann
h2. Commandes systèmes
198 27 Gérald Schwartzmann
199 27 Gérald Schwartzmann
==Création d'un patch==
200 27 Gérald Schwartzmann
<pre>diff -uNr toto/ toto.new/ > patch/toto.patch</pre>
201 27 Gérald Schwartzmann
202 27 Gérald Schwartzmann
==Application d'un patch==
203 27 Gérald Schwartzmann
<pre>patch -d /home/username/travail -p0 < toto.patch</pre>
204 27 Gérald Schwartzmann
205 27 Gérald Schwartzmann
==Changer le mot de passe PhpMyAdmin après un reconfigure==
206 27 Gérald Schwartzmann
<pre>mysql_pwd</pre>
207 27 Gérald Schwartzmann
208 29 Gérald Schwartzmann
Très pratique dans la conception de page web.
209 29 Gérald Schwartzmann
Console permettant le debbugage Javascript et Css:
210 27 Gérald Schwartzmann
[https://addons.mozilla.org/firefox/1843/ Firebug]
211 31 Gérald Schwartzmann
212 33 Gérald Schwartzmann
h2. Batterie de tests
213 33 Gérald Schwartzmann
214 33 Gérald Schwartzmann
h3. Tester la compilation du paquet (postinst, Makefile, ...)
215 33 Gérald Schwartzmann
216 33 Gérald Schwartzmann
Il est possible de tester la compilation de votre paquet sur une machine perso :
217 33 Gérald Schwartzmann
exporter vos sources :
218 33 Gérald Schwartzmann
<pre>
219 33 Gérald Schwartzmann
git archive nomDeBranche | tar -x -C /somewhere/else
220 33 Gérald Schwartzmann
</pre>
221 33 Gérald Schwartzmann
Se rendre dans le répertoire des sources et compiler
222 33 Gérald Schwartzmann
<pre>
223 33 Gérald Schwartzmann
fakeroot dpkg-buildpackage
224 33 Gérald Schwartzmann
</pre>
225 33 Gérald Schwartzmann
Le paquet est disponible dans le répertoire parent.
226 33 Gérald Schwartzmann
227 33 Gérald Schwartzmann
h3. Tester le paquet
228 34 Gérald Schwartzmann
229 33 Gérald Schwartzmann
Le nouveau paquet doit être testé en fresh install et en update (cas de figure où l'application est en production).
230 33 Gérald Schwartzmann
231 33 Gérald Schwartzmann
h3. Test de l'application
232 34 Gérald Schwartzmann
233 33 Gérald Schwartzmann
L'application doit être testé avec tous les types de comptes utilisateurs.
234 33 Gérald Schwartzmann
235 33 Gérald Schwartzmann
h2. Documentation
236 33 Gérald Schwartzmann
237 33 Gérald Schwartzmann
h3. Première mouture
238 33 Gérald Schwartzmann
239 33 Gérald Schwartzmann
Il faut documenter une application avant son passage en candidat.
240 33 Gérald Schwartzmann
Ouvrez un page wiki et y mettre les changements majeurs concernant
241 33 Gérald Schwartzmann
l'installation, les rôles, les consignes diverses ...
242 33 Gérald Schwartzmann
Ses informations doivent permettre doivent faciliter la vie au testeur.
243 33 Gérald Schwartzmann
244 33 Gérald Schwartzmann
h3. Finalisation
245 33 Gérald Schwartzmann
246 33 Gérald Schwartzmann
L'utilisateur doit trouver la doc à jour au moment où il en a besoin.
247 33 Gérald Schwartzmann
Aussi votre documentation doit être faite avant la sortie du paquet en stable.
248 33 Gérald Schwartzmann
Si vous n'avez pas accès au logiciel pour élaborer la doc, posez un signalement dans "Documentations" en mettant le lien vers la page wiki.
249 33 Gérald Schwartzmann
250 31 Gérald Schwartzmann
h2. Fioritures
251 31 Gérald Schwartzmann
252 31 Gérald Schwartzmann
Les couleurs pour uniformiser les applications.
253 31 Gérald Schwartzmann
jaune pâle max #fff999
254 31 Gérald Schwartzmann
jaune pâle mini #ffffcc
255 31 Gérald Schwartzmann
jaune orangé logo Eole #ffcc29
256 31 Gérald Schwartzmann
mauve logo Eole #57537e