aboutsummaryrefslogtreecommitdiffstats
path: root/perl.req-from-meta
blob: 31052597cac72f5b19c6cf9fd4e55ad5486bbf11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl

use strict;
use warnings;

use JSON qw{ from_json };
use YAML qw{ Load      };

# slurp the file
my $path = shift;
open my $fh, '<', $path or die "can't open $path: $!";
my $data = do { local $/; <$fh> };
close $fh;

# parse meta - either yaml or json
my $meta = $path =~ /\.yml$/
    ? Load( $data )
    : from_json( $data );

# dump the requires with their version
my $requires = $meta->{"meta-spec"}{version} >= 2
    ? $meta->{prereqs}{runtime}{requires}
    : $meta->{requires};
foreach my $module ( sort keys %$requires ) {
    next if $module eq 'perl'; # minimum perl version
    my $version = $requires->{$module};
    if ( $version == 0 ) {
        print "perl($module)\n";
    } else {
        my $v = qx{ rpm --eval '%perl_convert_version $version' };
        print "perl($module) >= $v";
    }
}

exit;

=head1 NAME

perl.req-from-meta - extract requires from meta file

=head1 SYNOPSIS

    $ perl.req-from-meta /path/to/META.yml
    $ perl.req-from-meta /path/to/META.json

=head1 DESCRIPTION

This script will extract Perl requirements from the distribution meta
file. For each such requires, it'll convert the minimum version to
follow Mageia perl versioning (using C<%perl_convert_version>), and
print them as:

    perl(Foo::Bar)
    perl(App::Frobnizer) >= 1.23.456

Minimum perl version are skipped.
ref='#n21'>21 22 23 24 25 26 27 28 29 30 31 32
/*
 * Guillaume Cottenceau (gc@mandrakesoft.com)
 *
 * Copyright 2000 MandrakeSoft
 *
 * This software may be freely redistributed under the terms of the GNU
 * public license.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/*
 * This is supposed to replace the redhat "kickstart", by name but
 * also by design (no code pollution).
 *
 */

#ifndef _AUTOMATIC_H_
#define _AUTOMATIC_H_

#include "stage1.h"

void grab_automatic_params(char * line);

enum return_type ask_from_list_auto(char *msg, char ** elems, char ** choice, char * auto_param, char ** elems_auto);
enum return_type ask_from_list_comments_auto(char *msg, char ** elems, char ** elems_comments, char ** choice, char * auto_param, char ** elems_auto);
enum return_type ask_from_entries_auto(char *msg, char ** questions, char *** answers, int entry_size, char ** questions_auto, void (*callback_func)(char ** strings));

#endif