fixed bug in switch script generation
[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 if test "x\$VERSION" = "xstable";then
35     echo "Switching to stable version"
36     rm -f xpdf
37     ln -s xpdf-3.02 xpdf
38 elif test "x\$VERSION" = "xlatest";then
39     echo "Switching to latest version"
40     rm -f xpdf
41     ln -s $directory xpdf
42 fi
43 EOF
44 ;
45 close(fi);
46 system("chmod a+x switch");
47
48 $c = 'find '.$directory.' \( -name "*.cc" -or -name "*.h" -or -name "*.c" \) -exec cp {} {}.orig \;';
49 print "$c\n";
50 system($c);
51