create .orig files
[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 $directory = $filename;
8 $directory =~ s/.tar.gz$//g;
9
10 mkdir("$directory");
11 mkdir("$directory/tmp/");
12
13 chdir("$directory/tmp/") or die;
14 system("tar -zxvf ../../$filename") and die;
15 system("find -type f -exec mv {} .. \\;") and die;
16 chdir("..");
17 system("find -type d -exec rmdir {} \\; 2> /dev/null");
18 system("patch < ../xpdf-changes.patch");
19 chdir("..");
20 system("rm -f xpdf");
21 system("ln -s $directory xpdf");
22
23 open(fi, ">switch");
24
25 print fi <<EOF
26 #!/bin/sh
27
28 VERSION=\$1
29 PS3="choose> "
30
31 if test "x\$VERSION" = "x";then
32     select V in stable latest;do VERSION="\$V";break;done
33 fi
34 case $VERSION
35
36 if test "x\$VERSION" = "xstable";then
37     echo "Switching to stable version"
38     rm -f xpdf
39     ln -s xpdf-3.02 xpdf
40 elif test "x\$VERSION" = "xlatest";then
41     echo "Switching to latest version"
42     rm -f xpdf
43     ln -s $directory xpdf
44 fi
45 EOF
46 ;
47 close(fi);
48 system("chmod a+x switch");
49
50 $c = 'find '.$directory.' \( -name "*.cc" -or -name "*.h" -or -name "*.c" \) -exec cp {} {}.orig \;';
51 print "$c\n";
52 system($c);
53