~ubuntu-branches/ubuntu/oneiric/openafs/oneiric-201305130334

« back to all changes in this revision

Viewing changes to src/packaging/MacOS/csrvdbmerge.pl

  • Committer: Bazaar Package Importer
  • Author(s): Russ Allbery
  • Date: 2008-09-22 19:07:02 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080922190702-59m13d7kn6gkw32d
Tags: 1.4.7.dfsg1-6
* Apply upstream patch to free /proc entries in the correct order.
  Thanks, Marc Dionne.  (Closes: #493914)
* Apply upstream deltas to support 2.6.27 kernels and to stop using
  COMMON_KERN_CFLAGS for all 2.6 kernels uniformly, which fixes
  problems on amd64 with newer kernels.  Thanks, Björn Torkelsson.
  (LP: #267504)
* Translation updates:
  - Swedish, thanks Martin Bagge.  (Closes: #493120)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
# CellServDB merging script
3
 
# only tested on darwin systems
4
 
 
5
 
use File::Copy;
6
 
use IO::File;
7
 
use Fcntl;
8
 
use strict;
9
 
 
10
 
 
11
 
sub doit {
12
 
  my ($cur,$in,$last,$new);
13
 
  my ($line, $oline, $cell, $pos, $which);
14
 
  my %cellstat;
15
 
 
16
 
  $cur=new IO::File '<CellServDB';
17
 
  $last=new IO::File '<CellServDB.master.last';
18
 
  
19
 
  while (defined($line=<$cur>)) {
20
 
    if ($line =~ /^>([-a-zA-Z0-9\._]+)\s/) {
21
 
      if ($cell) {
22
 
        $oline=<$last>;
23
 
        if ($oline && $oline !~ /^>/) { # fewer servers in user's file than master
24
 
          $cellstat{$cell} = 1;
25
 
        }
26
 
      }
27
 
      $cell=$1;
28
 
      $cellstat{$cell}=2; 
29
 
      # start at the beginning of the old file, and find $cell
30
 
      $last->seek(0,SEEK_SET);
31
 
      while (<$last>) {
32
 
        if (/>$cell\s/) { # note that we don't compare the cell comments
33
 
          $cellstat{$cell}=0; 
34
 
          last;
35
 
        }
36
 
      }
37
 
      next;
38
 
    }
39
 
    if (! $cell) {
40
 
      die "First CellServDB line isn't a cell\n";
41
 
    }
42
 
    next if ($cellstat{$cell} == 2); # cell only in local CellServDB
43
 
    next if ($cellstat{$cell} == 1); # already found a local change
44
 
    $oline=<$last>;
45
 
    if ($oline =~ /^>/) { # more servers in user's file than master
46
 
      $last->setpos($pos);
47
 
      $cellstat{$cell} = 1;
48
 
      next;
49
 
    }
50
 
    next if ($line eq $oline);
51
 
    $cellstat{$cell} = 1;
52
 
  }
53
 
  close($last);
54
 
  $cur->seek(0,SEEK_SET);
55
 
  $cur=new IO::File '<CellServDB' or die "No CellServDB: $!\n";
56
 
  $in=new IO::File '<CellServDB.master' or die "No CellServDB.master: $!\n";
57
 
  $new=new IO::File '>CellServDB.NEW' or die "Cannot create output CellServDB: $!\n";
58
 
  while (defined($line=<$cur>)) {
59
 
    if ($line =~ /^>([-a-zA-Z0-9\._]+)\s/) {
60
 
      $cell=$1;
61
 
      $which=$cellstat{$cell};
62
 
      unless ($which) {
63
 
        $in->seek(0,SEEK_SET);
64
 
        while (<$in>) {
65
 
          if (/>$cell\s/) {
66
 
            last;
67
 
          }
68
 
        }
69
 
        if (defined($_)) {
70
 
          print $new $_;
71
 
          while (defined($line=<$in>) && $line !~ /^>/) {
72
 
            print $new $line;
73
 
          }
74
 
        } 
75
 
      }
76
 
    }
77
 
    if (! $cell) {
78
 
      die "First CellServDB line isn't a cell\n";
79
 
    }
80
 
    if ($which) {
81
 
      print $new $line;
82
 
    }
83
 
  }
84
 
  close($in);
85
 
  close($cur);
86
 
  close($new);
87
 
  rename('CellServDB.NEW', 'CellServDB');
88
 
  copy('CellServDB.master', 'CellServDB.master.last');
89
 
}
90
 
 
91
 
doit;