xpdf-3.02 fixes
[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 --verbose < ../xpdf-changes.patch") and die;
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
35 if test "x\$VERSION" = "xstable";then
36     echo "Switching to stable version"
37     rm -f xpdf
38     ln -s xpdf-3.02 xpdf
39 elif test "x\$VERSION" = "xlatest";then
40     echo "Switching to latest version"
41     rm -f xpdf
42     ln -s $directory xpdf
43 fi
44 EOF
45 ;
46 close(fi);
47 system("chmod a+x switch");
48