[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Checking for old tex packages .....

Christian Schwarz <schwarz@monet.m.isar.de> writes:


> But this is just the way the old script is working (AFAIK)--and it's
> definitely too slow.

dpkg -l is quite fast; but it _will_ get things wrong with long
package names.  (I think it will still notice that there are or are
not installed packages.)

> What's your (Carey) problem with my script? dpkg-perl is thought as a
> programming interface to dpkg--so it's quite compatible. And it's way
> faster than the old one. (Of course, if you have a better idea, please let
> me know.)

I didn't quite realise that Dpkg::Package::List was (or will be,
looking at the code) that standard.  I quite often use dpkg -l myself
from the command line to check whether particular packages are
installed (e.g. dpkg -l 'libc*'), so it was the first thing I thought
of for speeding up the installation.

I've decided I do like the Perl script, but I've done a bit of
rewriting to make it more "concise" (i.e. I've used map and grep) and
to make it really work.  (You could fix this by changing $pkg to $p
after "Search for old packages".)

      Carey Evans  <*>  http://home.clear.net.nz/pages/c.evans/

kernel: Warning: possible SYN flooding. Sending cookies. 
kernel: validated probe(100007f, 100007f, 11557, 5010, -1645409555) 
#!/usr/bin/perl -w

my @OLDPACKAGES = qw(amsfonts amslatex amstex babel bibtex dviljk dvipsk
		     kpathsea kpathsea-dev latex latex2e-doc ltxgraph ltxmisc
		     ltxtool makeindex mfbasfnt mfbin mfdcfnt mfnfss ntgclass
		     oldgerman pandora ps2pk psnfss texbin texi2html texinfo
		     texlib texpsfnt textfm xdvik tetex tetexlib tetexdoc);

my @OLDPACKAGES2 = qw(mflib xypic);

# ---end-of-configuration-part---

use strict;
use Carp;
use Dpkg::Package::List;

# ---

package Dpkg::Package::List;

sub croak {

# ---

package main;

print "\n checking for old TeX packages...";

# Read dpkg's status file
my $list = new Dpkg::Package::List('filename' => '/var/lib/dpkg/status');

# Convert package list to hash
my %pkgs = map {$_->{'package'} => $_} @{$list->packages()};

# Search for old packages
my @oldpkg = grep {
  exists $pkgs{$_} and $pkgs{$_}{'status'} !~ /ok not-installed/
my @oldpkg2 = grep {
  exists $pkgs{$_} and $pkgs{$_}{'status'} !~ /ok not-installed/

unless (@oldpkg or  @oldpkg2) {
  print " none.\n";
  exit 0;

print <<"__EOT__";

I see that you have one or more of the pre-1.3 TeX packages installed:
 @oldpkg @oldpkg2

# ...to be continued...

Reply to: