-
Notifications
You must be signed in to change notification settings - Fork 24
/
subst.in
executable file
·47 lines (39 loc) · 1.02 KB
/
subst.in
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
#!/usr/bin/perl -w
my ${exec_prefix};
my ${prefix};
${prefix}="@prefix@";
${exec_prefix}="@exec_prefix@";
while ($f = shift @ARGV) {
if (-x "/bin/mktemp") {
$TEMP = `/bin/mktemp $f.$$.XXXXXX`;
die 'Cannot make temporary file $TEMP' if($?);
chomp $TEMP;
} else {
$XXXXXX = rand;
$TEMP = "$f.$$.$XXXXXX";
}
open(IN,"<$f.in");
open(OUT,">$TEMP") || die 'Cannot make temporary file $TEMP';
while (<IN>) {
s|\@nsca_user\@|@nsca_user@|g;
s|\@nsca_grp\@|@nsca_grp@|g;
s|\@nsca_port\@|@nsca_port@|g;
s|\@log_facility\@|@log_facility@|g;
s|\@libexecdir\@|@libexecdir@|g; # put all --with-vars before directories
s|\@localstatedir\@|@localstatedir@|g;
s|\@sysconfdir\@|@sysconfdir@|g;
s|\@datadir\@|@datadir@|g;
s|\@sbindir\@|@sbindir@|g;
s|\@bindir\@|@bindir@|g;
s|\$\{exec_prefix\}|@exec_prefix@|g; # must be next to last
s|\$\{prefix\}|@prefix@|g; # must be last
print OUT $_;
}
close IN;
close OUT;
if ((! -e $f) || (`diff $f $TEMP`)) {
`mv $TEMP $f`;
} else {
unlink $TEMP;
}
}