summaryrefslogtreecommitdiffstats
path: root/ldap/cm/fixNSPerlInf.pl
blob: 9e0fd3cf6533ec0bbfaef074dd907f3492f9bcc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

# the first argument is the full path and filename of ths nsperl.inf file
# the second argument is the name of the sub component to use

$infile = $ARGV[0];
$outfile = $ARGV[0] . ".tmp";
open(IN, $infile) or die "Error: could not read file $infile: $!";
open(OUT, ">$outfile") or die "Error: could not write file $outfile: $!";

$PRINT = 1;
while (<IN>) {
  if (/^Components\s*=\s*/) {
    if ($' =~ /$ARGV[1]/) {
      $_ = "Components=$ARGV[1]\n";
    } else {
      die "Error: the version of nsPerl in $infile does not contain $ARGV[1]\n";
    }
  }
  if (/^Archive=/) {
	$_ = "Archive=nsperl561.zip\n";
  }
  if (/^\[(\w+)\]/) {
    if (($1 eq $ARGV[1]) || ($1 eq General)) {
      $PRINT = 1;
    } else {
      $PRINT = 0;
    }
  }

  if ($PRINT) {
    if (/^Description/) {
	  s/The Sun \| Netscape Alliance/Fedora/g;
	  s/iPlanet/Fedora/g;
    } elsif (/^Vendor/) {
	  s/The Sun \| Netscape Alliance/Fedora/g;
    }
    print OUT;
    if (/^RunPostInstall/) {
      print OUT "Checked=TRUE\nVisible=FALSE\n";
    }
  }
}

close OUT;
close IN;

unlink $infile;
rename $outfile, $infile;