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

Re: Recherche volontaire pour classer les paquets



Martin Quinson wrote:
> Tres impressionnant.

Merci, ta commande shell ci-dessous et ton script le sont aussi.

[...]

> wget -o /dev/null -O -
> ftp://ftp.debian.org/debian/dists/sarge/main/source/Sources.gz|\ gunzip|\
>  grep-dctrl -F Files -s Package -v orig.tar.gz|\
>  sed 's/Package: //'
>
> trouve 817 paquets (binaires).
>
> Vous pensez que ca peut etre une information interressante ?

Denis, je pense que tu dois maintenant avoir a peu près tout ce qu'il te faut 
au niveau scripts, non ?

Ci joint il y a une nouvelle version un peu amméliorée de mon script.

A+,
Christian.
#! /usr/bin/perl -w

use strict;
use Getopt::Std;

# Get the options
our($opt_b, $opt_s, $opt_t);
getopts('bst:');
$opt_t = '/tmp' unless ($opt_t);
($opt_b, $opt_s) = (1, 1) unless ($opt_b or $opt_s);

# Check args
&print_usage() unless ($ARGV[0]);

my $cvs_root = $ARGV[0];

if (uc($cvs_root) eq 'KDE') {
  $cvs_root = ':pserver:anonymous@anoncvs.kde.org:/home/kde';
}

# Go to a temp dir
chdir($opt_t);

# Get the binary and source packages
my ($bins, $srcs) = &get_pkgs($cvs_root);

# Print the packages
print "packages : @$bins \n\n" if ($opt_b);
print "sources : @$srcs \n\n" if ($opt_s);

sub print_usage {
  print STDERR "Usage: $0 [options] cvsroot \n";
  print STDERR "options: -b : print binary packages\n";
  print STDERR "         -s : print source packages\n";
  print STDERR "         -t temp : use <temp> as a temporary directory\n";
  exit(1);
}

sub get_pkgs {
  my ($cvsroot) = @_;

  ##
  # Get the modules from the CVS repository
  ##

  # Get the CVSROOT/modules file from the repository
  `cvs -z3 -d $cvsroot checkout CVSROOT/modules`;

  # Read the modules in that file
  open MODULES, 'CVSROOT/modules' or die "Could not open CVSROOT/modules !\n";
  my @modules = <MODULES>;
  close MODULES;

  # Delete that file
  `rm -rf CVSROOT`;

  # Clean up the modules
  @modules = grep { chomp; s/^(\S+)\s*.*$/$1/ } @modules;

  ##
  # Get the packages from the modules
  ##

  my @packages = ();
  my @sources = ();
  foreach my $mod (@modules) {

    # Get the debian/control file from each module if possible
    `cvs -z3 -d $cvsroot checkout '$mod/debian/control' &> /dev/null`;

    # Read that file
    if (open CONTROL, "$mod/debian/control") {
      my @infos = <CONTROL>;
      close CONTROL;

      # Delete that file
      `rm -rf '$mod'`;

      # Clean up the infos
      chomp @infos;

      # Find the packages in that file
      my @bin = grep { s/^Package: (\S+)\s*$/$1/ } @infos;

      # Add them to the packages list
      push @packages, @bin;

      # Find the sources in that file
      my @src = grep { s/^Source: (\S+)\s*$/$1/ } @infos;

      # Add them to the sources list
      push @sources, @src;
    }
  }

  return (\@packages, \@sources);
}

Reply to: