Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • You know, I had a déjà vu when I read what you wrote about the Module::Collection thing. It's slightly different but solves a similar problem. Three points if you guess what I'm thinking of!

    Steffen

    P.S.: Where have you been in the past days?
    • Can't guess off the top of my head, other than maybe CPAN::Mini::Inject...

      As for where I've been, although I've moved into my new apartment, I can't get ADSL or wireless internet (or at least, not that doesn't suck hard) so I'm getting cable internet, which means a 1 week wait for the technician to turn up and connect it.

      Which should happen on Wednesday I believe.

      So for the last week I've been working in offline mode (although a client of mine was nice enough to donate a desk at their office that I'll be us
      • PAR::Repository does some of what you describe. The goals are different, but it also deals with scanning distributions, installing bunches, etc.

        Fortunately, PAR distro as simpler than CPAN distros :)
        • Hmm... if so, perhaps we should look at recycling/sharing some of the code between the two?
          • Hi,

            thought about this again. I might have been a little too quick in my reply. Well, there *are* common ideas in between the two projects. One of the things that triggered this was what you said about selecting specifically the newest versions of a module, etc. That's something PAR::Repository::Client does by default. The code is attached, but you'll realize that it's only as much code because it also deals with arch-type and perl-version which you shouldn't need to care about. PAR::Repository::* also takes a very ad-hoc route when it comes to dealing with multiple distributions at once. If any code/module you use require()s another package, it fetches that and applies the "newest version" thing again. By the way, that reminds me the I really should think about what happens with "use Foo 1.14;".

            So PAR::Repository could use a Module::Collection for some things, like insertion into a repository, but not the other way around. Right now, it just globs for distribution files unless you specify one.

            Hope this makes my thoughts clearer ;)

            I'm looking forward to see Module::Collection. Drop me a note if I can assist.

            Steffen

            sub prefered_distribution {
                    my $self = shift;
                    $self->{error} = undef;
                    my $ns = shift;
                    my $dists = shift;

                    return() if not keys %$dists;

                    my $this_pver = $Config::Config{version};
                    my $this_arch = $Config::Config{archname};

                    my @sorted;
                    foreach my $dist (keys %$dists) {
                            # distfile, version, distname, distver, arch, pver
                            my $ver = version->new($dists->{$dist}||0);
                            my ($n, $v, $a, $p) = PAR::Dist::parse_dist_name($dist);
                            next if not defined $a or not defined $p;
                            # skip the ones for other archs
                            next if $a ne $this_arch and $a ne 'any_arch';
                            next if $p ne $this_pver and $a ne 'any_version';

                            # as a fallback while sorting, prefer arch and pver
                            # specific dists to fallbacks
                            my $order_num =
                                    ($a eq 'any_arch' ? 2 : 0)
                                    + ($p eq 'any_version' ? 1 : 0);
                            push @sorted, [$dist, $ver, $order_num];
                    }
                    return() if not @sorted;

                    # sort by version, highest first.
                    @sorted =
                            sort {
                                    # sort version
                                    $b->[1] $a->[1]
                                            or
                                    # specific before any_version before any_arch before any_*
                                    $a->[2] $b->[2]
                            }
                            @sorted;

                    my $dist = shift @sorted;
                    return $dist->[0];
            }