On 24 May 2012 17:11,  <[email protected]> wrote:
> Revision 4670 Author boklm Date 2012-05-24 17:11:32 +0200 (Thu, 24 May 2012)
>
> Log Message
>
> replace with a perl script using URPM parse_synthesis
>
> Modified Paths
>
> release/trunk/src-rpm-list
>
> Modified: release/trunk/src-rpm-list
> ===================================================================
> --- release/trunk/src-rpm-list        2012-05-24 14:17:29 UTC (rev 4669)
> +++ release/trunk/src-rpm-list        2012-05-24 15:11:32 UTC (rev 4670)
> @@ -1,25 +1,38 @@
> -#!/bin/sh
> +#!/usr/bin/perl -w
>
> -# This take a root SRPMS directory as argument, and print the list of
> -# package names on stdout
> +# This script takes a root SRPMS directory as argument, and print the
> +# list of package names on stdout
>
> -function list_srpms()
> +use strict;
> +use URPM;
> +use Data::Dump qw/dump/;

You don't use Data::Dump (and you probably meant Data::Dumper since Data::Dump
is not installed by default)

> +sub list_pkgnames
>  {
> -    local dir="$1"
> +    my ($synthesis_file, $res) = @_;
> +    my $urpm = new URPM;
> +    $urpm->parse_synthesis($synthesis_file);
> +    $urpm->traverse(
> +     sub {
> +         $res->{$_[0]->name()} = 1;
> +     }
> +    );
> +}
>
> -    urpmf --distrib "$dir" --qf '%name' .
> +exit 1 unless @ARGV == 1;
> +my $srpmsdir = $ARGV[0];
> +my @medias = qw/core nonfree tainted/;
> +my @submedias = qw/release updates updates_testing/;
> +
> +my %res;
> +for my $media (@medias) {
> +    for my $submedia (@submedias) {
> +     
> list_pkgnames("$srpmsdir/$media/$submedia/media_info/synthesis.hdlist.cz",
> +         \%res);
> +    }
>  }

Also you're hardcoding media names, which is not nice.
Just do this:

my %res;
foreach (glob("$srpmsdir/*/*/media_info/synthesis.hdlist.cz")) {
    list_pkgnames($_, \%res);
}

Also you should run perl_checker on it.

You don't need to recreate a URPM object for each synthesis:
See attached version

Attachment: u.pl
Description: Binary data

Reply via email to