diff --git a/debian/config b/debian/config index 5a342d139c..ab3c8c1b5b 100755 --- a/debian/config +++ b/debian/config @@ -1,99 +1,52 @@ -#!/usr/bin/perl -w +#!/bin/sh -# Script to configure mplayer -# based on etherconf by John Goerzen +CONFIGFILE=/etc/mplayer/mplayer.conf -use Debconf::Client::ConfModule qw(:all); +set -e + +# Source debconf library. +. /usr/share/debconf/confmodule + +if test -r $CONFIGFILE && ! grep -q '### mplayer DEBCONF AREA' $CONFIGFILE +then + db_input medium 'mplayer/replace-existing-files' || true + db_go || true + if [ "$RET" != "true" ]; then + exit 0 + fi + db_get 'mplayer/replace-existing-files' || true +fi + +########################################## find fonts +#default font (if available) +BESTFONT=/usr/share/fonts/truetype/Arial.ttf +[ -r $BESTFONT ] || BESTFONT=/usr/share/fonts/truetype/freefont/FreeSans.ttf + +t=$(tempfile -p fonts ) +find /usr/share/fonts/ /?/?in*/?ont* -type f -iname '*.ttf' -maxdepth 3 2> /dev/null > $t || true + +if test -s $t +then + fonts=$( awk '{print a $0;a=", "}' $t || true ) + db_subst "mplayer/ttfont" ttfontchoices $fonts || true + ## suppose the question is skipped: give a default + a=$BESTFONT + [ -r $BESTFONT ] || a=$(head -1 $t) + db_subst "mplayer/ttfont" ttfontdefault $a || true + + db_input medium mplayer/ttfont || true + if [ "$?" = 30 ] ; then + db_set mplayer/ttfont $a || true + fi +else + db_input medium "mplayer/no-ttfont" || true +fi + +rm $t + +db_go || true + +############################################################ -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, xvidix"); - # 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'); - } -} +exit 0 diff --git a/debian/postinst b/debian/postinst index 5a0d46da22..e8fb6367ab 100755 --- a/debian/postinst +++ b/debian/postinst @@ -7,44 +7,20 @@ require ConfHelper; use Debconf::Client::ConfModule qw(:all); use IO::Handle; use Fcntl; -my $version = version(1.0); -my @savedolddata = (); +my $version = version(2.0); my $didupgrade = 0; dealwithupgrades(); my $mcfg = new ConfHelper('mplayer', "/etc/mplayer/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 video output driver, configured by mplayer.deb -EOF - - $dcarea .= "vo=" . scalar(get("mplayer/voutput")); - $dcarea .= ",\n"; +my $dcarea = "" ; +my $font = scalar(get("mplayer/ttfont")) ; + $dcarea .= "#truetype font\nfont=" . $font . "\n" if $font; $mcfg->setconfarea($dcarea); -if ($didupgrade) { - $mcfg->setotherarea_DANGEROUS(@savedolddata); -} - -#%################################### - -exit unless (get("mplayer/configure") eq 'true'); -exit unless (fget("mplayer/configure", "isdefault") eq 'false'); - -#%################################## -get("mplayer/cfgnote"); - sub dealwithupgrades { @@ -57,31 +33,17 @@ sub dealwithupgrades { 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/mplayer.conf" - #, "/etc/mplayer/fonts/sth - ) { - debug("Deleting $file"); - unlink $file; + for my $file ("/etc/mplayer/mplayer.conf" ) { + debug("Moving away $file"); + rename($file,$file . ".old"); } } else { - print STDERR "Upgrade refused, exiting.\n"; + debug("Upgrade refused, exiting"); 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"; } @@ -89,6 +51,8 @@ sub debug { # pass control to debhelper scripts.. # -system <