Debug: expansions: refactor ascii-art/UTF8; mark up space & nl
[exim.git] / test / patchexim
1 #! /usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use Getopt::Std;
6
7 ###############################################################################
8 # This is an auxiliary script that is part of the Exim test suite. It must be #
9 # run as root, and is normally called from the main controlling script. Its   #
10 # job is to make a copy of Exim, suitably patched so that it can run in the   #
11 # test harness. See further comments in the main script.                      #
12 #                                                                             #
13 # The only argument to this script is the name of the Exim binary that is to  #
14 # be copied. The script must be run in the correct current directory.         #
15 #                                                                             #
16 # One option, -o <outfile> can be given.  Default is "eximdir/exim"           #
17 ###############################################################################
18
19 our ($opt_o);
20 getopts('o:');
21
22 my $outfile = defined($opt_o) ? $opt_o : 'eximdir/exim';
23
24 open(IN, $ARGV[0]) || die "** Failed to open $ARGV[0]: $!\n";
25 open(OUT, ">$outfile") || die "** Failed to open $outfile: $!\n";
26
27 while(<IN>)
28   {
29   s/>>>running<<</<<<testing>>>/;
30   s{
31     (\d+[_.]\d+                       # major.minor
32     (?:[_.]\d+)?                      # optional security-patchlevel
33     (?:[_.]\d+)?                      # optional patchlevel
34     (?:[_-]RC\d+|[_-]?dev(?:start)?)? # optional RC or dev(start)
35     (?:(?:[_-]\d+)?                   # git tag distance
36        [-_][[:xdigit:]]+)?            # git id
37     (?:[-_]XX)?\0                     # git dirty bit
38     <<eximversion>>                   # marker
39     )
40    }
41    {"x.yz\0" . ("*" x (length($1) - 5))}xe;
42   print OUT;
43   }
44
45 close(IN);
46 close(OUT);
47
48 chmod 04755, $outfile;
49
50 # End of patchexim script