From 22f0bb22c5a5405bdfb3aaf3ce2ae555c83e4cc6 Mon Sep 17 00:00:00 2001 From: eyck Date: Sat, 28 Jul 2001 07:54:52 +0000 Subject: update to perl debconf. fixed problem with configure. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1399 b3059339-0415-0410-9bf9-f77b7e298cf2 --- debian/config | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/postinst | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ debian/templates | 32 ++++++++++++++++++ 3 files changed, 218 insertions(+) create mode 100755 debian/config create mode 100755 debian/postinst create mode 100644 debian/templates (limited to 'debian') diff --git a/debian/config b/debian/config new file mode 100755 index 0000000000..e78546ec40 --- /dev/null +++ b/debian/config @@ -0,0 +1,98 @@ +#!/usr/bin/perl -w + +# Script to configure mplayer +# based on etherconf by John Goerzen + +use Debian::DebConf::Client::ConfModule qw(:all); + +my $version = version(2.0); +title('MPlayer Configuration'); +my $PRIORITY = 'high'; +#TODO: 'medium' +my $next = 'mainmenu'; +my $isediting = 0; + +my @nextargs = (); + +checkupgrade(); # Find out if we have to upgrade. +mainloop(letsgo()); + +sub checkupgrade { + open(MCFG, "; + return 1 if ($line =~ /mplayer DEBCONF AREA/); + exit(0) if (input($PRIORITY, 'mplayer/replace-existing-files') eq "question skipped"); + go(); + if (get('mplayer/replace-existing-files') eq 'false') { + input($PRIORITY, 'mplayer/replace-existing-files-bail'); + go(); + exit(); + } + close MCFG; +} + +sub mainloop { + $next = shift @_; + do { + my @retval = &$next(@nextargs); + # if ($retval[0] eq 'BACK') { + # $retval[0] = $backups{$next}; + # } + ($next, @nextargs) = @retval; + } while ($next ne 'Exit'); +} + +sub letsgo { +#useless! + return "configure"; +} + +sub configure { + subst("mplayer/voutput", "vochoices", "xv, xmga, mga, x11, gl, sdl"); + # db_subst mplayer/output vo xc,xmga,mga,x11,gl,sdl + exit(0) if (input($PRIORITY, "mplayer/voutput") eq "question skipped"); + go(); + exit 0 unless (get("mplayer/voutput") eq 'true'); + #return 'audioout'; + return 'mainmenu'; +} + +sub mainmenu { + go(); # To catch spare things from before + my @choices = ( + 'Video Output: ' . scalar(get("mplayer/voutput"))); + #, + $choices = join(', ', @choices); + $isediting = 1; + + subst('mplayer/mainmenu', 'choices', $choices); + input($PRIORITY, 'mplayer/mainmenu'); + go(); + + my $selection = get('mplayer/mainmenu'); + if ($selection =~ /^Exit/) { + return 'Exit'; + } + + # Set to redisplay. + fset('mplayer/mainmenu', 'isdefault', 'true'); + + $_ = $selection; + + return 'configure' if /^Video/; +# return 'aoutput' if /^Aoutput/; + return 'Exit'; +} + +sub editreturn { + my @args = @_; + return 'mainmenu' if $isediting; + return @args; +} + +sub editfix { + my $template = shift @_; + if ($isediting) { + fset($template, 'isdefault', 'true'); + } +} diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000000..8853b8f73a --- /dev/null +++ b/debian/postinst @@ -0,0 +1,88 @@ +#!/usr/bin/perl -w + +# mplayer postinst + +require ConfHelper; + +use Debian::DebConf::Client::ConfModule qw(:all); +use IO::Handle; +use Fcntl; +my $version = version(1.0); +my @savedolddata = (); +my $didupgrade = 0; + +dealwithupgrades(); + +# We add lo0 right now, useful in case we exit anyway. + +my $mcfg = new ConfHelper('mplayer', "/etc/mplayer.conf"); +$mcfg->setconfarea(" +#MPlayer config file generated by .deb package. +#ffactor = 0.9 +#fs = yes +"); + +########################################################################### + +debug("Configuring video output driver..."); + +my $dcarea = <<"EOF"; +# MPlayer config file, + +# MPlayer video output driver, configured by mplayer.deb +EOF + + $dcarea .= "vo=" . scalar(get("mplayer/voutput")); +$dcarea .= "\n"; + +$mcfg->setconfarea($dcarea); + +if ($didupgrade) { + $interfaces->setotherarea_DANGEROUS(@savedolddata); +} + +#%################################### + +exit unless (get("mplayer/configure") eq 'true'); +exit unless (fget("mplayer/configure", "isdefault") eq 'false'); + + + +sub dealwithupgrades { + open(OLDCONF, "hasconfarea()); + undef $mconf; + + if ((get('mplayer/replace-existing-files') eq 'true') && + (fget('mplayer/replace-existing-files', 'isdefault') eq 'false')) { + print STDERR "Upgrading...\n"; +#? saveolddata("/etc/network/interfaces", "pppconf"); + $didupgrade = 1; + for my $file ("/etc/mplayer.conf" + #, "/etc/mplayer/fonts/sth + ) { + debug("Deleting $file"); + unlink $file; + } + } else { + print STDERR "Upgrade refused, exiting.\n"; + exit 0; + } +} + +# Gets any debconf area for other packages and saves it off. + +sub saveolddata { + my ($file, $package) = @_; + my $conf = new ConfHelper($package, $file); + push(@savedolddata, $conf->{startline} . "\n"); + push(@savedolddata, $conf->getconfarea()); + push(@savedolddata, $conf->{endline} . "\n"); +} + +sub debug { + print STDERR @_, "\n"; +} diff --git a/debian/templates b/debian/templates new file mode 100644 index 0000000000..eb095f81ae --- /dev/null +++ b/debian/templates @@ -0,0 +1,32 @@ +Template: mplayer/replace-existing-files +Type: boolean +Default: true +Description: Upgrade existing system? + It looks like you've configured your mplayer already. + If you'd like to configure it with this program, I'll have + to delete the old configuration. Do you want to continue + configuration with this program? If you say "yes", I'll go ahead + and delete your old configuration and you can create it anew with + this program. + +Template: mplayer/replace-existing-files-bail +Type: note +Description: Files not replaced + I'm going to exit now since you don't want me to replace your + existing files. If you change your mind later, you can run + dpkg-reconfigure mplayer. + +Template: mplayer/mainmenu +Type: select +Choices: ${choices}, Exit +Description: MPlayer Main Menu + From this menu, you can modify any of the settings for your device. + Simply select the item you'd like to change to modify it. + When you are done, select Exit. + +Template: mplayer/voutput +Type: select +Choices: ${vochoices}, x11 +Description: MPlayer Video Output + Yada yada.. + -- cgit v1.2.3