[Bio] / FigKernelPackages / P2Pupdate.pm Repository:
ViewVC logotype

Annotation of /FigKernelPackages/P2Pupdate.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.27 - (view) (download) (as text)

1 : efrank 1.1 package P2Pupdate;
2 :    
3 :     use FIG_Config;
4 :     use FIG;
5 :     use Carp;
6 :     use Data::Dumper;
7 :     use Cwd;
8 :    
9 :     =pod
10 :    
11 :     =head1 updating code
12 :    
13 :     This routine packages what is needed to upgrade an older system to the
14 :     current code. Code releases are numered
15 :    
16 :     p1n1.p2n2.p3n3...
17 :    
18 :     where "." is added at the point the code moved to another branch of
19 :     the tree. FIG, who provided the initial release of the SEED, will
20 :     number all of their code releases as
21 :    
22 :     FIGn
23 :    
24 :     where n is an integer. Suppose that between releases 13 and 14 a
25 :     second group (which we will term "Idiots" for convenience) took
26 :     release 13 and wished to branch the code tree. At that point, they
27 :     would name their first release as
28 :    
29 :     FIG13.Idiots1
30 :    
31 :     We are, of course, being both cavalier and nasty when we make such a
32 :     reference. We do, however, wish to express the view that it will
33 :     benefit everyone to attempt to reconcile differences and maintain a
34 :     single code progression as long as possible. There are often good
35 :     reasons to part ways, but we urge people to think carefully before
36 :     taking such a step.
37 :    
38 :     Two code releases
39 :    
40 :     i1.i2.i3...in
41 :     and j1.j2.j3...jm with m <= n
42 :    
43 :     are compatible iff
44 :    
45 :     ip == jp for p < m, and
46 :     jm and im have the same "source" and
47 :     jm <= im
48 :    
49 :     A new code release must have the property that it can bring any
50 :     "older" compatible release up to its release.
51 :    
52 :     Note that there is an issue relating to the code to build/install packages.
53 :     Since a system may be radically restructured between releases of code, the
54 :     code to build a "package" and the code to "install" a package are radically
55 :     separated. For example, the code in P2Pupdate.pm for building an assignment
56 :     package and the code for installing an assignment package both apply to the
57 :     release of code current on the system containing P2Pupdate.pm. In fact, the
58 :     code releases may be quite different on two synchronizing systems.
59 :    
60 :     To make things work the following rules must be observed:
61 :    
62 :     1. a code release is a tar file containing VERSION, Packages,
63 :     bin/ToolTemplates, and CGI/ToolTemplates. The installing system needs
64 :     to place these at the appropriate spots, and then run bring_system_up_to_date,
65 :     which is supposed to do any required restructuring.
66 :    
67 :     2. an assignments package is a tar file containing a single directory. The directory
68 :     contains subdirectories -- one per genome. Each genome subdirectory contains zero
69 :     or more files. The name of the file is the "user" and the contents will be the
70 :     assignments made by that user.
71 :    
72 :     3. an annotations package is a tar file containing a single directory. The files in
73 :     the directory are named by genome. They contain the annotations for the genome.
74 :    
75 :     =cut
76 :    
77 :     =pod
78 :    
79 :     =head1 what_code_do_I_have
80 :    
81 :     usage: &what_code_do_I_have($fig_base)
82 :    
83 :     This just returns the current version of the code.
84 :    
85 :     =cut
86 :    
87 :     sub what_code_do_I_have {
88 :     my($fig_base) = @_;
89 :    
90 :     my $version = `cat $fig_base/VERSION`;
91 :     chop $version;
92 :     return $version;
93 :     }
94 :    
95 :     =pod
96 :    
97 :     =head1 updatable_code
98 :    
99 :     usage: &updatable_code_code($v1,$v2)
100 :    
101 :     This just returns true iff the two versions of code are compatible and $v1
102 :     is "more recent".
103 :    
104 :     =cut
105 :    
106 :     sub updatable_code {
107 :     my($v1,$v2) = @_;
108 :     my($i,$v1p,$v1n,$v2p,$v2n);
109 :    
110 :     my @v1 = split(/\./,$v1);
111 :     my @v2 = split(/\./,$v2);
112 :     if (@v1 < @v2) { return 0 }
113 :    
114 :     for ($i=0; ($i < $#v2) && ($v1[$i] eq $v2[$i]); $i++) {}
115 :     if ($i == $#v2)
116 :     {
117 :     $v1[$i] =~ /^(.*[^\d])(\d+)$/;
118 :     $v1p = $1;
119 :     $v1n = $2;
120 :    
121 :     $v2[$i] =~ /^(.*[^\d])(\d+)$/;
122 :     $v2p = $1;
123 :     $v2n = $2;
124 :    
125 :     return (($v2p eq $v1p) && ($v2n < $v1n));
126 :     }
127 :     return 0;
128 :     }
129 :    
130 :     =pod
131 :    
132 :     =head1 package_code
133 :    
134 :     usage: &package_code($fig_disk,$file)
135 :    
136 :     $fig_base must be an absolute filename (begins with "/") giving the FIG from which
137 :     the updated code release will be taken.
138 :    
139 :     $file must be an absolute filename where the "code package" will be built.
140 :    
141 :     =cut
142 :    
143 :     sub package_code {
144 :     my($fig_disk,$file) = @_;
145 :    
146 :     &force_absolute($fig_disk);
147 :     &force_absolute($file);
148 : overbeek 1.2 my @tmp = `cat $fig_disk/CURRENT_RELEASE`;
149 :     my $current_release = $tmp[0];
150 :     chop $current_release;
151 :    
152 :     &FIG::run("cd $fig_disk/dist/releases; tar czf $file $current_release");
153 : efrank 1.1 }
154 :    
155 :     sub force_absolute {
156 :     my($file) = @_;
157 :    
158 :     if (substr($file,0,1) ne "/")
159 :     {
160 : overbeek 1.2 print "Error: Please use absolute file names (i.e., /Users/fig/... or /home/fig/...)\n";
161 :     exit;
162 : efrank 1.1 }
163 :     }
164 :    
165 :     =pod
166 :    
167 :     =head1 install_code
168 :    
169 :     usage: &install_code($fig_disk,$package)
170 :    
171 :     $fig_disk must be an absolute filename (begins with "/") giving the FIG to be updated.
172 :    
173 :     $package must be an absolute filename where the "code package" from which to make
174 :     the update exists.
175 :    
176 :     Note that this routine does not check that the updated code is compatible, or even less
177 :     current. It is assumed that upper level logic is doing that.
178 :    
179 :     =cut
180 :    
181 :     sub install_code {
182 :     my($fig_disk,$package) = @_;
183 :     my $fig_base = "$fig_disk/FIG";
184 :     &force_absolute($fig_base);
185 :     &force_absolute($package);
186 :    
187 :     if (getcwd() !~ /FIGdisk$/) { print die "Sorry, you must run this while in $FIG_Config::fig_disk" }
188 :    
189 :    
190 :     (! -d "$fig_disk/BackupCode") || &FIG::run("rm -rf $fig_disk/BackupCode");
191 :     mkdir("$fig_disk/BackupCode",0777) || die "Could not make the BackupCode directory";
192 :     (! -d "$fig_disk/BackupEnv") || &FIG::run("rm -rf $fig_disk/BackupEnv");
193 :     mkdir("$fig_disk/BackupEnv",0777) || die "Could not make the BackupEnv directory";
194 :    
195 :     my $version = &what_code_do_I_have($fig_base);
196 :     &FIG::run("cd $fig_disk; mv README install lib man env src $fig_disk/BackupEnv");
197 :     &FIG::run("cd $fig_base; mv VERSION Packages CGI $fig_disk/BackupCode");
198 :     print STDERR "made backups\n";
199 :    
200 :     &FIG::run("cd $fig_disk; tar xzf $package");
201 :     print STDERR "untarred new code\n";
202 :    
203 :     &fix_config("$fig_base/Packages/FIG_Config.pm","$fig_disk/BackupCode/Packages/FIG_Config.pm");
204 :     &FIG::run("cd $fig_base/bin; touch ToolTemplates/*/*; make all");
205 :     &FIG::run("cd $fig_base/CGI; touch ToolTemplates/*/*; make all");
206 :     print STDERR "installed new bin and CGI\n";
207 :    
208 :     &FIG::run("bring_system_up_to_date $version");
209 :     }
210 :    
211 :     =pod
212 :    
213 :     =head1 package_lightweight_code
214 :    
215 :     usage: &package_lightweight_code($fig_disk,$file)
216 :    
217 :     $fig_base must be an absolute filename (begins with "/") giving the FIG from which
218 :     the updated code release will be taken.
219 :    
220 :     $file must be an absolute filename where the "code package" will be built.
221 :    
222 :     =cut
223 :    
224 :     sub package_lightweight_code {
225 :     my($fig_disk,$file) = @_;
226 :    
227 :     &force_absolute($fig_disk);
228 :     &force_absolute($file);
229 : overbeek 1.2 my @tmp = `cat $fig_disk/CURRENT_RELEASE`;
230 :     my $current_release = $tmp[0];
231 :     chop $current_release;
232 :    
233 :     &FIG::run("cd $fig_disk/dist/releases; tar czf $file $current_release");
234 : efrank 1.1 }
235 :    
236 :     =pod
237 :    
238 :     =head1 install_lightweight_code
239 :    
240 :     usage: &install_lightweight_code($fig_disk,$package)
241 :    
242 :     $fig_disk must be an absolute filename (begins with "/") giving the FIG to be updated.
243 :    
244 :     $package must be an absolute filename where the "code package" from which to make
245 :     the update exists.
246 :    
247 :     Note that this routine does not check that the updated code is compatible, or even less
248 :     current. It is assumed that upper level logic is doing that.
249 :    
250 :     =cut
251 :    
252 :     sub install_lightweight_code {
253 :     my($fig_disk,$package) = @_;
254 :     my $fig_base = "$fig_disk/FIG";
255 :     &force_absolute($fig_base);
256 :     &force_absolute($package);
257 :    
258 : overbeek 1.2 if (! mkdir("$fig_disk/Tmp$$",0777))
259 :     {
260 :     print "Error: could not make $fig_disk/Tmp$$\n";
261 :     exit;
262 :     }
263 : efrank 1.1
264 : overbeek 1.2 &FIG::run("cd $fig_disk/Tmp$$; tar xzf $package");
265 :     if (! opendir(TMP,"$fig_disk/Tmp$$"))
266 :     {
267 :     print "Error: could not open $fig_disk/Tmp$$\n";
268 :     exit;
269 :     }
270 : efrank 1.1
271 : overbeek 1.2 my @rels = grep { $_ !~ /^\./ } readdir(TMP);
272 :     closedir(TMP);
273 :     if (@rels != 1)
274 :     {
275 :     print "Error: Bad code package: $package\n";
276 :     exit;
277 :     }
278 : efrank 1.1
279 : overbeek 1.2 my $new_release = $rels[0];
280 :     if (-d "$fig_disk/dist/releases/$new_release")
281 :     {
282 :     print "Error: $new_release already exists; we are doing nothing\n";
283 :     exit;
284 :     }
285 : efrank 1.1
286 : efrank 1.3 &FIG::run("mv $fig_disk/Tmp$$/$new_release $fig_disk/dist/releases");
287 :     &FIG::run("rm -rf $fig_disk/Tmp$$");
288 : olson 1.22
289 :     #
290 :     # Ugh. For now, find the arch in the fig config file $fig_disk/config/fig-user-env.sh"
291 :     #
292 :    
293 :     my $arch;
294 :     open(FH, "<$fig_disk/config/fig-user-env.sh");
295 :     while (<FH>)
296 :     {
297 :     if (/RTARCH="(.*)"/)
298 :     {
299 :     $arch = $1;
300 :     last;
301 :     }
302 :     }
303 :     close(FH);
304 :    
305 :     if ($arch eq "")
306 :     {
307 :     die "Couldn't determine SEED install architecture, not switching to release.";
308 :     }
309 :    
310 :     $ENV{RTARCH} = $arch;
311 :    
312 : efrank 1.9 &FIG::run("$FIG_Config::bin/switch_to_release $new_release");
313 : efrank 1.1 }
314 :    
315 :    
316 :     sub fix_config {
317 :     my($new,$old) = @_;
318 :     my($line,$i);
319 :    
320 :     my @new = `cat $new`;
321 :     foreach $line (`cat $old`)
322 :     {
323 :     if ($line =~ /^(\S+)\s+\=/)
324 :     {
325 :     $var = $1;
326 :     $varQ = quotemeta $var;
327 :    
328 :     for ($i=0; ($i < $#new) && ($new[$i] !~ /^$varQ\s+\=/); $i++) {}
329 :     if ($i == $#new)
330 :     {
331 :     splice(@new,$i,0,$line);
332 :     }
333 :     else
334 :     {
335 :     splice(@new,$i,1,$line);
336 :     }
337 :     }
338 :     }
339 :     open(NEW,">$new") || confess "could not overwrite $new";
340 :     foreach $line (@new)
341 :     {
342 :     print NEW $line;
343 :     }
344 :     close(NEW);
345 :     }
346 :    
347 :     =pod
348 :    
349 :     =head1 what_genomes_will_I_sync
350 :    
351 :     usage: &what_genomes_will_I_sync($fig_base,$who)
352 :    
353 :     This routine returns the list of genome IDs that you are willing to sync with $who.
354 :    
355 :     =cut
356 :    
357 :     sub what_genomes_will_I_sync {
358 :     my($fig_base,$who) = @_;
359 :    
360 :     # This is the promiscuous version - it will sync all genomes with anyone.
361 :    
362 :     opendir(GENOMES,"$fig_base/Data/Organisms") || die "could not open $fig_base/Data/Organisms";
363 :     my @genomes = grep { $_ =~ /^\d+\.\d+$/ } readdir(GENOMES);
364 :     closedir(GENOMES);
365 :     return @genomes;
366 :     }
367 :    
368 :     =pod
369 :    
370 :     =head1 package_annotations
371 :    
372 :     usage: &package_annotations($fig_base,$genomes,$file)
373 :    
374 :     $fig_base must be an absolute filename (begins with "/") giving the FIG from which
375 :     the updated code release will be taken.
376 :    
377 :     $genomes is a pointer to a list of genome IDs that will be exchanged.
378 :    
379 :     $file must be an absolute filename where the "annotation package" will be built.
380 :    
381 :     =cut
382 :    
383 :     sub package_annotations {
384 :     my($fig_base,$genomes,$file) = @_;
385 :    
386 :     &force_absolute($fig_base);
387 :     &force_absolute($file);
388 :     if (-d "$fig_base/Tmp/Annotations") { system "rm -rf $fig_base/Tmp/Annotations" }
389 :     mkdir("$fig_base/Tmp/Annotations",0777) || die "could not make $fig_base/Tmp/Annotations";
390 :     foreach $genome (@$genomes)
391 :     {
392 :     if (-s "$fig_base/Data/Organisms/$genome/annotations")
393 :     {
394 :     &FIG::run("cp $fig_base/Data/Organisms/$genome/annotations $fig_base/Tmp/Annotations/$genome");
395 :     }
396 :     }
397 :     &FIG::run("chmod -R 777 $fig_base/Tmp/Annotations");
398 : efrank 1.15
399 :     if (opendir(ANN,"$fig_base/Tmp/Annotations"))
400 :     {
401 :     my @tmp = grep { $_ !~ /^\./ } readdir(ANN);
402 :     closedir(ANN);
403 :     if (@tmp > 0)
404 :     {
405 :     &FIG::run("cd $fig_base/Tmp/Annotations; tar czf $file *");
406 :     }
407 :     else
408 :     {
409 :     system "touch $file";
410 :     }
411 :     }
412 : efrank 1.1 system "rm -rf $fig_base/Tmp/Annotations";
413 :     }
414 :    
415 :     =pod
416 :    
417 :     =head1 install_annotations
418 :    
419 :     usage: &install_annotations($fig_disk,$package)
420 :    
421 :     $fig_disk must be an absolute filename (begins with "/") giving the FIG to be updated.
422 :    
423 :     $package must be an absolute filename where the "annotations package" from which to make
424 :     the update exists.
425 :    
426 :     =cut
427 :    
428 :     sub install_annotations {
429 : efrank 1.12 my($fig_disk,$from,$package) = @_;
430 : efrank 1.1 my($genome);
431 :    
432 :     &force_absolute($fig_disk);
433 :     &force_absolute($package);
434 : efrank 1.15 if (! -s $package) { return }
435 :    
436 : efrank 1.1 if (-d "$fig_disk/BackupAnnotations") { system "rm -rf $fig_disk/BackupAnnotations" }
437 :     mkdir("$fig_disk/BackupAnnotations",0777);
438 :     mkdir("$fig_disk/BackupAnnotations/New",0777);
439 :     &FIG::run("cd $fig_disk/BackupAnnotations/New; tar xzf $package");
440 :     opendir(TMP,"$fig_disk/BackupAnnotations/New") || die "could not open $fig_disk/BackupAnnotations/New";
441 :     my @genomes = grep { $_ =~ /^\d+\.\d+$/ } readdir(TMP);
442 :     closedir(TMP);
443 :     foreach $genome (@genomes)
444 :     {
445 : efrank 1.14 next if (! -d "$fig_disk/FIG/Data/organisms/$genome");
446 : efrank 1.13
447 : efrank 1.1 print STDERR "installing $fig_disk/FIG/Data/Organisms/$genome/annotations\n";
448 :     if (-s "$fig_disk/FIG/Data/Organisms/$genome/annotations")
449 :     {
450 :     &FIG::run("cp -p $fig_disk/FIG/Data/Organisms/$genome/annotations $fig_disk/BackupAnnotations/$genome");
451 : efrank 1.9 &FIG::run("$FIG_Config::bin/merge_annotations $fig_disk/BackupAnnotations/$genome $fig_disk/BackupAnnotations/New/$genome > $fig_disk/FIG/Data/Organisms/$genome/annotations");
452 : efrank 1.1 }
453 :     else
454 :     {
455 :     &FIG::run("cp $fig_disk/BackupAnnotations/New/$genome $fig_disk/FIG/Data/Organisms/$genome/annotations");
456 :     }
457 :     chmod 0777,"$fig_disk/FIG/Data/Organisms/$genome/annotations";
458 :     }
459 : efrank 1.9 &FIG::run("$FIG_Config::bin/index_annotations");
460 : efrank 1.1 }
461 :    
462 :     =pod
463 :    
464 :     =head1 restore_annotations
465 :    
466 :     usage: &restore_annotations($fig_disk);
467 :    
468 :     $fig_disk must be an absolute filename (begins with "/") giving the FIG to be updated.
469 :    
470 :     =cut
471 :    
472 :     sub restore_annotations {
473 :     my($fig_disk) = @_;
474 :    
475 :     &force_absolute($fig_disk);
476 :     (-d "$fig_disk/BackupAnnotations") || die "could not find an active backup";
477 :     opendir(TMP,"$fig_disk/BackupAnnotations") || die "could not open $fig_disk/BackupAnnotations";
478 :     my @genomes = grep { $_ =~ /^\d+\.\d+$/ } readdir(TMP);
479 :     closedir(TMP);
480 :     foreach $genome (@genomes)
481 :     {
482 :     unlink("$fig_disk/FIG/Data/Organisms/$genome/annotations");
483 :     &FIG::run("cp $fig_disk/BackupAnnotations/$genome $fig_disk/FIG/Data/Organisms/$genome/annotations");
484 :     system "chmod 777 $fig_disk/FIG/Data/Organisms/$genome/annotations";
485 :     }
486 : efrank 1.9 &FIG::run("$FIG_Config::bin/index_annotations");
487 : efrank 1.1 }
488 :    
489 :     =pod
490 :    
491 :     =head1 package_aassignments
492 :    
493 : overbeek 1.20 usage: package_assignments($fig,$user,$who,$date,$genomes,$file)
494 : efrank 1.1
495 : overbeek 1.20 $user designates the user wishing to get the assignments
496 : efrank 1.1
497 : overbeek 1.5 $who designates whose assignments you want (defaults to "master")
498 :    
499 :     $date if given indicates a point in time (get assignments after that point)
500 :    
501 : efrank 1.1 $genomes is a pointer to a list of genome IDs that will be exchanged.
502 :    
503 :     $file must be an absolute filename where the "assignment package" will be built.
504 :    
505 :     =cut
506 :    
507 :     sub package_assignments {
508 : overbeek 1.20 my($fig,$user,$who,$date,$genomes,$file) = @_;
509 : overbeek 1.27 my($genome,$x,$org,$curr,$peg);
510 : overbeek 1.4 $who = $who ? $who : "master";
511 : overbeek 1.7 $date = $date ? $date : 0;
512 : overbeek 1.27
513 : overbeek 1.20 if (open(ASSIGNMENTS,">$file"))
514 : efrank 1.1 {
515 : overbeek 1.20 print ASSIGNMENTS "$user\t$who\t$date\n";
516 : overbeek 1.27 my @assignments = sort { $a->[0] cmp $b->[0] } $fig->assignments_made($genomes,$who,$date);
517 :     foreach $x (@assignments)
518 : efrank 1.1 {
519 : overbeek 1.20 print ASSIGNMENTS join("\t",@$x),"\n";
520 : overbeek 1.4 }
521 : overbeek 1.27 print ASSIGNMENTS "//\n";
522 :    
523 :     foreach $x (@assignments)
524 :     {
525 :     ($peg,undef) = @$x;
526 :     my $seq = $self->get_translation($peg);
527 :     &FIG::display_id_and_seq($peg,\$seq,\*ASSIGNMENTS);
528 :     }
529 :     close(ASSIGNMENTS);
530 : efrank 1.1 }
531 :     }
532 :    
533 :     =pod
534 :    
535 :     =head1 install_assignments
536 :    
537 : overbeek 1.20 usage: &install_assignments($package)
538 : efrank 1.1
539 : overbeek 1.20 $package must be a filename where the "assignments package" from which to make
540 :     the assignment set exists
541 : efrank 1.1
542 :     =cut
543 :    
544 :     sub install_assignments {
545 : overbeek 1.20 my($package) = @_;
546 : efrank 1.1 my($genome);
547 :    
548 : overbeek 1.20 open(IN,"<$package") || die "could not open $package";
549 :     my $line = <IN>;
550 :     chop $line;
551 :     ($user,$who,$date) = split(/\t/,$line);
552 : olson 1.26 $userR = $user;
553 :     $userR =~ s/^master://;
554 :     &FIG::verify_dir("$FIG_Config::data/Assignments/$userR");
555 : overbeek 1.21 my $file = &FIG::epoch_to_readable($date) . ":$who";
556 : overbeek 1.20 $file =~ s/\//-/g;
557 : olson 1.26 open(OUT,">$FIG_Config::data/Assignments/$userR/$file")
558 :     || die "could not open $FIG_Config::data/Assignments/$userR/$file";
559 : overbeek 1.20 while (defined($line = <IN>))
560 :     {
561 :     print OUT $line;
562 :     }
563 :     close(IN);
564 :     close(OUT);
565 : olson 1.26 if (! -s "$FIG_Config::data/Assignments/$userR/$file") { unlink("$FIG_Config::data/Assignments/$userR/$file") }
566 : efrank 1.1 }
567 :    
568 :     =pod
569 :    
570 :     =head1 package_translation_rules
571 :    
572 :     usage: &package_translation_rules($fig_base,$file)
573 :    
574 :     $fig_base must be an absolute filename (begins with "/") giving the FIG from which
575 :     the updated code release will be taken.
576 :    
577 :     $file must be an absolute filename where the "translation_rules package" will be built.
578 :    
579 :     =cut
580 :    
581 :     sub package_translation_rules {
582 :     my($fig_base,$file) = @_;
583 :    
584 :     &force_absolute($fig_base);
585 :     &force_absolute($file);
586 :     &FIG::run("cp $fig_base/Data/Global/function.synonyms $file");
587 :     }
588 :    
589 :     =pod
590 :    
591 :     =head1 install_translation_rules
592 :    
593 : efrank 1.10 usage: &install_translation_rules($fig_disk,$from,$package)
594 : efrank 1.1
595 :     $fig_disk must be an absolute filename (begins with "/") giving the FIG to be updated.
596 :    
597 :     $package must be an absolute filename where the "translation_rules package" from which to make
598 :     the update exists.
599 :    
600 :     =cut
601 :    
602 :     sub install_translation_rules {
603 : efrank 1.10 my($fig_disk,$from,$package) = @_;
604 : efrank 1.1
605 :     my $file = "$fig_disk/FIG/Data/Global/function.synonyms";
606 :     &force_absolute($fig_disk);
607 :     if (-d "$fig_disk/BackupTranslation_Rules") { system "rm -rf $fig_disk/BackupTranslation_Rules" }
608 :     mkdir("$fig_disk/BackupTranslation_Rules",0777);
609 : efrank 1.11 chmod 0777,"$fig_disk/BackupTranslation_Rules";
610 : efrank 1.1 if (-s $file)
611 :     {
612 :     &FIG::run("cp $file $fig_disk/BackupTranslation_Rules");
613 :     }
614 : efrank 1.10 &FIG::run("$FIG_Config::bin/merge_translation_rules $fig_disk/BackupTranslation_Rules/function.synonyms $package $from > $file");
615 : efrank 1.1 chmod 0777,$file;
616 :     }
617 :    
618 :     =pod
619 :    
620 :     =head1 restore_translation_rules
621 :    
622 :     usage: &restore_translation_rules($fig_disk);
623 :    
624 :     $fig_disk must be an absolute filename (begins with "/") giving the FIG to be updated.
625 :    
626 :     =cut
627 :    
628 :     sub restore_translation_rules {
629 :     my($fig_disk) = @_;
630 :    
631 :     &force_absolute($fig_disk);
632 :    
633 :     my $file = "$fig_disk/FIG/Data/Global/function.synonyms";
634 :     (-s "$fig_disk/BackupTranslation_Rules/function.synonyms") || die "could not find an active backup";
635 :     if (-s "$fig_disk/BackupTranslation_Rules/function.synonyms")
636 :     {
637 :     &FIG::run("cp $fig_disk/BackupTranslation_Rules/function.synonyms $file");
638 :     chmod 0777, $file;
639 :     }
640 :     }
641 :    
642 : overbeek 1.23 sub package_subsystems {
643 : overbeek 1.27 my($file,$just_exchangable) = @_;
644 : overbeek 1.23 my($ssa);
645 :    
646 : overbeek 1.27 $just_exchangable = defined($just_exchangable) ? $just_exchangable : 1;
647 :     my @exchangable = grep { (! $just_exchangable) || $fig->is_exchangable_subsystem($_) }
648 :     $fig->all_subsystems;
649 :    
650 : overbeek 1.23 my $fig = new FIG;
651 : overbeek 1.24 if ((@exchangable > 0) && open(SUB,">$file"))
652 : overbeek 1.23 {
653 : overbeek 1.24 foreach $ssa (@exchangable)
654 : overbeek 1.23 {
655 : overbeek 1.25 # print STDERR "writing $ssa to $file\n";
656 :     my($spreadsheet,$notes) = $fig->exportable_subsystem($ssa);
657 : overbeek 1.23 print SUB join("",@$spreadsheet),join("",@$notes),"########################\n";
658 :     }
659 :     close(SUB);
660 :     }
661 : overbeek 1.25 else
662 :     {
663 :     # print STDERR &Dumper(\@exchangable,$file);
664 :     }
665 : overbeek 1.23 }
666 :    
667 : efrank 1.1 1

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3