| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
$JPS2PS_DIR = "/opt/syracuse/app/jps2ps/"; |
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
$PPS_DIR = $JPS2PS_DIR . "pps/"; |
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
$PACKAGE_DIR = $JPS2PS_DIR . "package/"; |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
$lit_cles = $JPS2PS_DIR . "lit_cles.pl"; |
|---|
| 18 |
$lit_appels = $JPS2PS_DIR . "lit_appels.pl"; |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
sub affiche_tableau { |
|---|
| 22 |
my ($reftableau) = @_ ; |
|---|
| 23 |
foreach $mot (@$reftableau) { |
|---|
| 24 |
print (" " . $mot . "\n"); |
|---|
| 25 |
}; |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
sub affiche_tableau_terminal { |
|---|
| 30 |
my ($reftableau) = @_ ; |
|---|
| 31 |
foreach $mot (@$reftableau) { |
|---|
| 32 |
print ("\"$mot\", "); |
|---|
| 33 |
}; |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
sub affiche_hachage { |
|---|
| 38 |
my (%keytofile) = @_; |
|---|
| 39 |
foreach $cle (keys %keytofile) { |
|---|
| 40 |
print ("cle : $cle\n"); |
|---|
| 41 |
print ("fichiers : \n"); |
|---|
| 42 |
&affiche_tableau ($keytofile {$cle}); |
|---|
| 43 |
}; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
sub affiche_hachage_terminal { |
|---|
| 48 |
my (%keytofile) = @_; |
|---|
| 49 |
foreach $cle (keys %keytofile) { |
|---|
| 50 |
print (" \"$cle\" => ["); |
|---|
| 51 |
&affiche_tableau_terminal ($keytofile {$cle}); |
|---|
| 52 |
print ("],\n"); |
|---|
| 53 |
}; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
sub cree_listpps_file { |
|---|
| 59 |
$listpps_file = "/tmp/listpps.pl"; |
|---|
| 60 |
|
|---|
| 61 |
open (FILE, ">$listpps_file") or die "impossible d'ouvrir $listpps_file"; |
|---|
| 62 |
select (FILE); |
|---|
| 63 |
print<<Fin_Code; |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
\$PPS_DIR = \$JPS2PS_DIR . "pps/"; |
|---|
| 67 |
\$PACKAGE_DIR = \$JPS2PS_DIR . "package/"; |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
Fin_Code |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
@les_fichiers = `cd $PPS_DIR \; find ./ -name "*.pps"`; |
|---|
| 79 |
foreach (@les_fichiers) { |
|---|
| 80 |
$_ =~ s/\.\///; |
|---|
| 81 |
}; |
|---|
| 82 |
|
|---|
| 83 |
foreach $element (@les_fichiers) { |
|---|
| 84 |
$element =~ s/\n//; |
|---|
| 85 |
$pps_name = $element; |
|---|
| 86 |
$pps_name =~ s/\.pps//; |
|---|
| 87 |
print ("\$" . $pps_name . " = \$PPS_DIR \. \"" . $element . "\";\n"); |
|---|
| 88 |
}; |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
@les_package = `cd $PACKAGE_DIR \; find ./ -name "*.pps"`; |
|---|
| 94 |
foreach (@les_package) { |
|---|
| 95 |
$_ =~ s/\.\///; |
|---|
| 96 |
}; |
|---|
| 97 |
|
|---|
| 98 |
foreach $element (@les_package) { |
|---|
| 99 |
$element =~ s/\n//; |
|---|
| 100 |
$pkg_name = $element; |
|---|
| 101 |
$pkg_name =~ s/\.pps//; |
|---|
| 102 |
print ("\$" . $pkg_name . " = \$PACKAGE_DIR \. \"" . $element . "\";\n"); |
|---|
| 103 |
}; |
|---|
| 104 |
|
|---|
| 105 |
print ("1;\n"); |
|---|
| 106 |
close (FILE); |
|---|
| 107 |
}; |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
sub cree_priorite_file { |
|---|
| 116 |
$priorite_file = "/tmp/priorite.pl"; |
|---|
| 117 |
|
|---|
| 118 |
open (FILE, ">$priorite_file") or die "impossible d'ouvrir $priorite_file"; |
|---|
| 119 |
select (FILE); |
|---|
| 120 |
print<<Fin_Code; |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
\@cles = ( |
|---|
| 133 |
Fin_Code |
|---|
| 134 |
|
|---|
| 135 |
@les_fichiers = `cd $PPS_DIR \; find ./ -name "*.pps"`; |
|---|
| 136 |
foreach (@les_fichiers) { |
|---|
| 137 |
$_ =~ s/\.\///; |
|---|
| 138 |
}; |
|---|
| 139 |
foreach $element (@les_fichiers) { |
|---|
| 140 |
$element =~ s/\n//; |
|---|
| 141 |
$pps_name = $element; |
|---|
| 142 |
$pps_name =~ s/\.pps//; |
|---|
| 143 |
print ("\"" . $pps_name . "\",\n"); |
|---|
| 144 |
}; |
|---|
| 145 |
|
|---|
| 146 |
@les_package = `cd $PACKAGE_DIR \; find ./ -name "*.pps"`; |
|---|
| 147 |
foreach (@les_package) { |
|---|
| 148 |
$_ =~ s/\.\///; |
|---|
| 149 |
}; |
|---|
| 150 |
foreach $element (@les_package) { |
|---|
| 151 |
$element =~ s/\n//; |
|---|
| 152 |
$pkg_name = $element; |
|---|
| 153 |
$pkg_name =~ s/\.pps//; |
|---|
| 154 |
print ("\"" . $pkg_name . "\",\n"); |
|---|
| 155 |
}; |
|---|
| 156 |
print ("\);\n1;\n"); |
|---|
| 157 |
close (FILE); |
|---|
| 158 |
}; |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
&cree_listpps_file; |
|---|
| 167 |
&cree_priorite_file; |
|---|
| 168 |
|
|---|
| 169 |
%keytofile = (); |
|---|
| 170 |
%filetoappels = (); |
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
foreach $pps (@les_fichiers) { |
|---|
| 176 |
@cles = `cd $PPS_DIR \; $lit_cles $pps`; |
|---|
| 177 |
$pps_name = $pps; |
|---|
| 178 |
$pps_name =~ s/\.pps//; |
|---|
| 179 |
$pps_name =~ s/\n//; |
|---|
| 180 |
foreach $cle (@cles) { |
|---|
| 181 |
$cle =~ s/\n//; |
|---|
| 182 |
$keytofile {$cle} = ["$pps_name"]; |
|---|
| 183 |
}; |
|---|
| 184 |
}; |
|---|
| 185 |
|
|---|
| 186 |
foreach $pkg (@les_package) { |
|---|
| 187 |
$pkg_name = $pkg; |
|---|
| 188 |
$pkg_name =~ s/\.pps//; |
|---|
| 189 |
$cle = "use" . "$pkg_name"; |
|---|
| 190 |
$keytofile {$cle} = ["$pkg_name"]; |
|---|
| 191 |
}; |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
foreach $pps (@les_fichiers) { |
|---|
| 196 |
@appels = `cd $PPS_DIR \; $lit_appels $pps`; |
|---|
| 197 |
$pps_name = $pps; |
|---|
| 198 |
$pps_name =~ s/\.pps//; |
|---|
| 199 |
$pps_name =~ s/\n//; |
|---|
| 200 |
foreach (@appels) { |
|---|
| 201 |
$_ =~ s/\n//; |
|---|
| 202 |
}; |
|---|
| 203 |
$filetoappels {$pps_name} = [ @appels ]; |
|---|
| 204 |
}; |
|---|
| 205 |
|
|---|
| 206 |
foreach $pkg (@les_package) { |
|---|
| 207 |
@appels = `cd $PACKAGE_DIR \; $lit_appels $pkg`; |
|---|
| 208 |
$pkg_name = $pkg; |
|---|
| 209 |
$pkg_name =~ s/\.pps//; |
|---|
| 210 |
$pkg_name =~ s/\n//; |
|---|
| 211 |
foreach (@appels) { |
|---|
| 212 |
$_ =~ s/\n//; |
|---|
| 213 |
}; |
|---|
| 214 |
$filetoappels {$pkg_name} = [ @appels ]; |
|---|
| 215 |
}; |
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
sub fait_une_passe { |
|---|
| 222 |
$modif = 0; |
|---|
| 223 |
foreach $word (keys %keytofile) { |
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
$pps_name = $keytofile {"$word"} [0]; |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
$reftab = $filetoappels {"$pps_name"}; |
|---|
| 232 |
@tab = @$reftab; |
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
$i = 0; |
|---|
| 236 |
$n = 1 + $#tab; |
|---|
| 237 |
while ($i < $n) { |
|---|
| 238 |
|
|---|
| 239 |
$nom = @$reftab [$i]; |
|---|
| 240 |
if (exists ($keytofile{$nom})) { |
|---|
| 241 |
@appel = (); |
|---|
| 242 |
@appel = @{ $keytofile {"$word"} }; |
|---|
| 243 |
$taille1 = $#appel; |
|---|
| 244 |
push (@{ $keytofile {"$word"}} , @{ $keytofile {"$nom"}}); |
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
%deja_vu = (); |
|---|
| 248 |
@uniques = (); |
|---|
| 249 |
@appel = (); |
|---|
| 250 |
@appel = @{ $keytofile {"$word"} }; |
|---|
| 251 |
foreach $objet (@appel) { |
|---|
| 252 |
unless ($deja_vu{$objet}) { |
|---|
| 253 |
$deja_vu{$objet} = 1; |
|---|
| 254 |
push (@uniques, $objet); |
|---|
| 255 |
} |
|---|
| 256 |
} |
|---|
| 257 |
$taille2 = $#uniques; |
|---|
| 258 |
|
|---|
| 259 |
$keytofile {"$word"} = [ @uniques ]; |
|---|
| 260 |
if ($taille2 > $taille1) { |
|---|
| 261 |
$modif = 1; |
|---|
| 262 |
}; |
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
}; |
|---|
| 269 |
$i++; |
|---|
| 270 |
} |
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
}; |
|---|
| 274 |
}; |
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
$modif = 1; |
|---|
| 278 |
while ($modif =~ 1) { |
|---|
| 279 |
&fait_une_passe (); |
|---|
| 280 |
}; |
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
sub cree_dephash_file { |
|---|
| 285 |
|
|---|
| 286 |
$dephash_file = "/tmp/dephash.pl"; |
|---|
| 287 |
|
|---|
| 288 |
open (FILE, ">$dephash_file") or die "impossible d'ouvrir $dephash_file"; |
|---|
| 289 |
select (FILE); |
|---|
| 290 |
print<<Fin_Code; |
|---|
| 291 |
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
%dependances = ( |
|---|
| 300 |
Fin_Code |
|---|
| 301 |
|
|---|
| 302 |
&affiche_hachage_terminal (%keytofile); |
|---|
| 303 |
|
|---|
| 304 |
print (" \);\n 1;"); |
|---|
| 305 |
close (FILE); |
|---|
| 306 |
}; |
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
&cree_dephash_file (); |
|---|
| 316 |
|
|---|
| 317 |
`mv $dephash_file $JPS2PS_DIR`; |
|---|
| 318 |
`mv $listpps_file $JPS2PS_DIR`; |
|---|
| 319 |
`mv $priorite_file $JPS2PS_DIR`; |
|---|
| 320 |
|
|---|
| 321 |
1; |
|---|