<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
 <HEAD>
   <TITLE> [Mageia-dev] [soft-commits] [4670] replace with a perl script	using URPM parse_synthesis
   </TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20%5Bsoft-commits%5D%20%5B4670%5D%20replace%20with%20a%20perl%20script%0A%09using%20URPM%20parse_synthesis&In-Reply-To=%3CCAONrEta597cFZHiK0rsUoQjv-pDYzkOyXXJdpKf1aGsjpFhKkw%40mail.gmail.com%3E">
   <META NAME="robots" CONTENT="index,nofollow">
   <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
   <LINK REL="Previous"  HREF="015821.html">
   <LINK REL="Next"  HREF="015809.html">
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[Mageia-dev] [soft-commits] [4670] replace with a perl script	using URPM parse_synthesis</H1>
    <B>Thierry Vignaud</B> 
    <A HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20%5Bsoft-commits%5D%20%5B4670%5D%20replace%20with%20a%20perl%20script%0A%09using%20URPM%20parse_synthesis&In-Reply-To=%3CCAONrEta597cFZHiK0rsUoQjv-pDYzkOyXXJdpKf1aGsjpFhKkw%40mail.gmail.com%3E"
       TITLE="[Mageia-dev] [soft-commits] [4670] replace with a perl script	using URPM parse_synthesis">thierry.vignaud at gmail.com
       </A><BR>
    <I>Thu May 24 17:42:27 CEST 2012</I>
    <P><UL>
        <LI>Previous message: <A HREF="015821.html">[Mageia-dev] Mageia 2 DVD 64bits install is broken
</A></li>
        <LI>Next message: <A HREF="015809.html">[Mageia-dev] Cauldron?
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#15807">[ date ]</a>
              <a href="thread.html#15807">[ thread ]</a>
              <a href="subject.html#15807">[ subject ]</a>
              <a href="author.html#15807">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>On 24 May 2012 17:11,  &lt;<A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">root at mageia.org</A>&gt; wrote:
&gt;<i> Revision 4670 Author boklm Date 2012-05-24 17:11:32 +0200 (Thu, 24 May 2012)
</I>&gt;<i>
</I>&gt;<i> Log Message
</I>&gt;<i>
</I>&gt;<i> replace with a perl script using URPM parse_synthesis
</I>&gt;<i>
</I>&gt;<i> Modified Paths
</I>&gt;<i>
</I>&gt;<i> release/trunk/src-rpm-list
</I>&gt;<i>
</I>&gt;<i> Modified: release/trunk/src-rpm-list
</I>&gt;<i> ===================================================================
</I>&gt;<i> --- release/trunk/src-rpm-list	2012-05-24 14:17:29 UTC (rev 4669)
</I>&gt;<i> +++ release/trunk/src-rpm-list	2012-05-24 15:11:32 UTC (rev 4670)
</I>&gt;<i> @@ -1,25 +1,38 @@
</I>&gt;<i> -#!/bin/sh
</I>&gt;<i> +#!/usr/bin/perl -w
</I>&gt;<i>
</I>&gt;<i> -# This take a root SRPMS directory as argument, and print the list of
</I>&gt;<i> -# package names on stdout
</I>&gt;<i> +# This script takes a root SRPMS directory as argument, and print the
</I>&gt;<i> +# list of package names on stdout
</I>&gt;<i>
</I>&gt;<i> -function list_srpms()
</I>&gt;<i> +use strict;
</I>&gt;<i> +use URPM;
</I>&gt;<i> +use Data::Dump qw/dump/;
</I>
You don't use Data::Dump (and you probably meant Data::Dumper since Data::Dump
is not installed by default)

&gt;<i> +sub list_pkgnames
</I>&gt;<i>  {
</I>&gt;<i> -    local dir=&quot;$1&quot;
</I>&gt;<i> +    my ($synthesis_file, $res) = @_;
</I>&gt;<i> +    my $urpm = new URPM;
</I>&gt;<i> +    $urpm-&gt;parse_synthesis($synthesis_file);
</I>&gt;<i> +    $urpm-&gt;traverse(
</I>&gt;<i> +	sub {
</I>&gt;<i> +	    $res-&gt;{$_[0]-&gt;name()} = 1;
</I>&gt;<i> +	}
</I>&gt;<i> +    );
</I>&gt;<i> +}
</I>&gt;<i>
</I>&gt;<i> -    urpmf --distrib &quot;$dir&quot; --qf '%name' .
</I>&gt;<i> +exit 1 unless @ARGV == 1;
</I>&gt;<i> +my $srpmsdir = $ARGV[0];
</I>&gt;<i> +my @medias = qw/core nonfree tainted/;
</I>&gt;<i> +my @submedias = qw/release updates updates_testing/;
</I>&gt;<i> +
</I>&gt;<i> +my %res;
</I>&gt;<i> +for my $media (@medias) {
</I>&gt;<i> +    for my $submedia (@submedias) {
</I>&gt;<i> +	list_pkgnames(&quot;$srpmsdir/$media/$submedia/media_info/synthesis.hdlist.cz&quot;,
</I>&gt;<i> +	    \%res);
</I>&gt;<i> +    }
</I>&gt;<i>  }
</I>
Also you're hardcoding media names, which is not nice.
Just do this:

my %res;
foreach (glob(&quot;$srpmsdir/*/*/media_info/synthesis.hdlist.cz&quot;)) {
    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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: u.pl
Type: application/octet-stream
Size: 402 bytes
Desc: not available
URL: &lt;/pipermail/mageia-dev/attachments/20120524/bf498b23/attachment.obj&gt;
</PRE>






































<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI>Previous message: <A HREF="015821.html">[Mageia-dev] Mageia 2 DVD 64bits install is broken
</A></li>
	<LI>Next message: <A HREF="015809.html">[Mageia-dev] Cauldron?
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#15807">[ date ]</a>
              <a href="thread.html#15807">[ thread ]</a>
              <a href="subject.html#15807">[ subject ]</a>
              <a href="author.html#15807">[ author ]</a>
         </LI>
       </UL>

<hr>
<a href="https://www.mageia.org/mailman/listinfo/mageia-dev">More information about the Mageia-dev
mailing list</a><br>
</body></html>