1398
|
1 #!/usr/bin/perl -w
|
|
2
|
|
3 # mplayer postinst
|
|
4
|
|
5 require ConfHelper;
|
|
6
|
|
7 use Debian::DebConf::Client::ConfModule qw(:all);
|
|
8 use IO::Handle;
|
|
9 use Fcntl;
|
|
10 my $version = version(1.0);
|
|
11 my @savedolddata = ();
|
|
12 my $didupgrade = 0;
|
|
13
|
|
14 dealwithupgrades();
|
|
15
|
|
16 # We add lo0 right now, useful in case we exit anyway.
|
|
17
|
|
18 my $mcfg = new ConfHelper('mplayer', "/etc/mplayer.conf");
|
|
19 $mcfg->setconfarea("
|
|
20 #MPlayer config file generated by .deb package.
|
|
21 #ffactor = 0.9
|
|
22 #fs = yes
|
|
23 ");
|
|
24
|
|
25 ###########################################################################
|
|
26
|
|
27 debug("Configuring video output driver...");
|
|
28
|
|
29 my $dcarea = <<"EOF";
|
|
30 # MPlayer config file,
|
|
31
|
|
32 # MPlayer video output driver, configured by mplayer.deb
|
|
33 EOF
|
|
34
|
|
35 $dcarea .= "vo=" . scalar(get("mplayer/voutput"));
|
|
36 $dcarea .= "\n";
|
|
37
|
|
38 $mcfg->setconfarea($dcarea);
|
|
39
|
|
40 if ($didupgrade) {
|
1458
|
41 $mcfg->setotherarea_DANGEROUS(@savedolddata);
|
1398
|
42 }
|
|
43
|
|
44 #%###################################
|
|
45
|
|
46 exit unless (get("mplayer/configure") eq 'true');
|
|
47 exit unless (fget("mplayer/configure", "isdefault") eq 'false');
|
|
48
|
1442
|
49 #%##################################
|
|
50 get("mplayer/cfgnote");
|
|
51
|
1398
|
52
|
|
53
|
|
54 sub dealwithupgrades {
|
|
55 open(OLDCONF, "</etc/mplayer.conf") || return 1;
|
|
56 close OLDCONF;
|
|
57
|
|
58 my $mconf = new ConfHelper("mplayer", "/etc/mplayer.conf");
|
|
59 return 1 if ($mconf->hasconfarea());
|
|
60 undef $mconf;
|
|
61
|
|
62 if ((get('mplayer/replace-existing-files') eq 'true') &&
|
|
63 (fget('mplayer/replace-existing-files', 'isdefault') eq 'false')) {
|
|
64 print STDERR "Upgrading...\n";
|
|
65 #? saveolddata("/etc/network/interfaces", "pppconf");
|
|
66 $didupgrade = 1;
|
|
67 for my $file ("/etc/mplayer.conf"
|
|
68 #, "/etc/mplayer/fonts/sth
|
|
69 ) {
|
|
70 debug("Deleting $file");
|
|
71 unlink $file;
|
|
72 }
|
|
73 } else {
|
|
74 print STDERR "Upgrade refused, exiting.\n";
|
|
75 exit 0;
|
|
76 }
|
|
77 }
|
|
78
|
|
79 # Gets any debconf area for other packages and saves it off.
|
|
80
|
|
81 sub saveolddata {
|
|
82 my ($file, $package) = @_;
|
|
83 my $conf = new ConfHelper($package, $file);
|
|
84 push(@savedolddata, $conf->{startline} . "\n");
|
|
85 push(@savedolddata, $conf->getconfarea());
|
|
86 push(@savedolddata, $conf->{endline} . "\n");
|
|
87 }
|
|
88
|
|
89 sub debug {
|
|
90 print STDERR @_, "\n";
|
|
91 }
|