github.com/slspeek/camlistore_namedsearch@v0.0.0-20140519202248-ed6f70f7721a/dev/camfix.pl (about)

     1  #!/usr/bin/perl
     2  
     3  my $file = shift;
     4  die "$file doesn't exist" unless -e $file;
     5  
     6  open(my $fh, $file) or die "failed: $!\n";
     7  my $c = do { local $/; <$fh> };
     8  close($fh);
     9  
    10  my $changes = 0;
    11  
    12  $changes = 1 if $c =~ s!^(\s+)\"camli/(.+)\"!$1\"camlistore.org/pkg/$2\"!mg;
    13  $changes = 1 if $c =~ s!^(\s+)\"camlistore/(.+)\"!$1\"camlistore.org/$2\"!mg;
    14  $changes = 1 if $c =~ s!^(\s+_ )\"camlistore/(.+)\"!$1\"camlistore.org/$2\"!mg;
    15  $changes = 1 if $c =~ s!/pkg/pkg/!/pkg/!g;
    16  $changes = 1 if $c =~ s!camlistore.org/pkg/third_party/!camlistore.org/third_party/!g;
    17  
    18  exit 0 unless $changes;
    19  
    20  open(my $fh, ">$file") or die;
    21  print $fh $c;
    22  close($fh);
    23  print STDERR "rewrote $file\n";