summaryrefslogtreecommitdiff
path: root/debian/substitute-conffile.pl
blob: 7dd23363ece5012ef64cb994f6a02c7eca204d05 (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
#! /usr/bin/perl -p

# This is needed for a nasty preinst hack to work around a bug in sarge's
# version of dpkg. It substitutes the literal text of conffiles into preinst
# scripts so that they can be used when moving conffiles between packages.

BEGIN {
    %texts = ();
    while (@ARGV > 1) {
	my $name = $ARGV[0];
	shift;
	local *FILE;
	open FILE, '<', $ARGV[0];
	local $/ = undef;
	my $text = <FILE>;
	close FILE;
	# Quote for the shell.
	$text =~ s/'/'\\''/g;
	shift;
	$texts{$name} = $text;
    }
}

for my $name (keys %texts) {
    s/\@$name\@/'$texts{$name}'/g;
}