better reporting; update mode
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 9 Jan 2012 03:33:39 +0000 (03:33 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 9 Jan 2012 03:33:39 +0000 (03:33 +0000)
update-xfonts-traditional

index 4b71d14..d34157f 100755 (executable)
@@ -214,18 +214,20 @@ sub processfontdir ($) {
        die "$fontdir $!" unless $!==&ENOENT;
        return;
     }
+    my $changed = 0;
     my $olddone = do "$fontdir/$donefile";
     if (!$olddone) {
        die "$fontdir $! $@ " unless $!==&ENOENT;
        $olddone = { };
+       $changed = 1;
     }
     my $newdone = { };
     my $log = new IO::File "$fontdir/$logfile", "w" 
        or die "$fontdir/$logfile $!";
     my %outfiles; # bitmask: 1 /*exists*/ | 2 /*wanted*/
-    my $changed;
     my $updated=0;
     my $reported=0;
+    my $anypcfs=0;
 
     flush $reportfh or die $!;
     while (my $dent = scalar readdir FD) {
@@ -245,6 +247,8 @@ sub processfontdir ($) {
            next;
        }
        die "$fontdir $dent" unless -f _;
+       $anypcfs++;
+
        my $stats = join ' ', ((stat _)[1,7,9,10]);
        my $tdone = $olddone->{$dent};
        my $outdent = $fontprefix.$dent;
@@ -265,9 +269,9 @@ sub processfontdir ($) {
                or die "$fontdir $outdent $!";
            $updated++;
            $outfiles{$outdent} |= 3;
-           $changed = 1;
        }
        $newdone->{$dent} = $stats;
+       $changed = 1;
     }
     my $affected=0;
     foreach my $olddent (keys %outfiles) {
@@ -279,7 +283,7 @@ sub processfontdir ($) {
        unlink "$fontdir/$olddent" or die "$fontdir $olddent $!";
        $changed = 1;
     }
-    if (!%$newdone) {
+    if (!$anypcfs) {
        unlink "$fontdir/$logfile" or die "$fontdir $!";
        unlink "$fontdir/$donefile" or $!==&ENOENT or die "$fontdir $!";
     } elsif ($changed) {
@@ -366,6 +370,14 @@ define_mode('process-fonttrees', sub {
     }
 });
 
+define_mode('update', sub {
+    die "no arguments allowed with --postinst\n" unless !@ARGV;
+    loadfoundries();
+    foreach my $d (@fonttrees) {
+       processfonttree($d);
+    }
+});
+
 Getopt::Long::Configure(qw(bundling));
 GetOptions(@options) or exit 127;