new parameter addspacechars
[swftools.git] / lib / pdf / inject-xpdf.pl
1 #!/usr/bin/perl
2
3 $filename = $ARGV[0];
4
5 $filename or die "no filename";
6
7 $basename = $filename;
8 $basename =~ s/.tar.gz$//g;
9 $directory = $basename;
10
11 mkdir("$directory");
12 mkdir("$directory/tmp/");
13
14 chdir("$directory/tmp/") or die;
15
16 print "Extracting $filename\n";
17 system("tar -zxf ../../$filename") and die;
18 system("find . -type f -exec mv {} .. \\;") and die;
19 chdir("..");
20 system("find . -type d -exec rmdir {} \\; 2> /dev/null");
21
22 print "Applying security patches...\n";
23 for($a=1;$a<10;$a++) {
24     $patchname = "../${basename}pl$a.patch";
25     if(-f $patchname) {
26         print "*pl$a.patch\n";
27         system("patch -s < $patchname") and die;
28     }
29 }
30
31 $c = 'find . \( -name "*.cc" -or -name "*.h" -or -name "*.c" \) -exec cp {} {}.orig \;';
32 print "$c\n";
33 system($c);
34
35 system("patch < ../xpdf-changes.patch 2>&1 | grep -i failed");
36 chdir("..");
37 system("rm -f xpdf");
38 system("ln -s $directory xpdf");
39
40 open(fi, ">switch");
41
42 print fi <<EOF
43 #!/bin/sh
44
45 VERSION=\$1
46 PS3="choose> "
47
48 if test "x\$VERSION" = "x";then
49     select V in stable latest;do VERSION="\$V";break;done
50 fi
51 if test "x\$VERSION" = "xstable";then
52     echo "Switching to stable version"
53     rm -f xpdf
54     ln -s xpdf-3.02 xpdf
55 elif test "x\$VERSION" = "xlatest";then
56     echo "Switching to latest version"
57     rm -f xpdf
58     ln -s $directory xpdf
59 fi
60 EOF
61 ;
62 close(fi);
63 system("chmod a+x switch");
64
65