locked_user sundialsvc4 has asked for the wisdom of the Perl Monks concerning the following question:

Is there a well-defined way to optimize an autobundle such that prerequisites are automatically sorted to the head of the list?   Another way to say it is, “is there an ‘official’ way, and if not, what’s the best unofficial one?”

The default ordering of bundle entries is, of course, alphabetical.   But, to quote a very simple example, “YAML begins with Y.”   The most-desirable algorithm would, so to speak, “bubble-sort” the entries so that common prerequisites would be ordered to the front of the list.   Therefore, modules which know how to compensate for the absence of a package won’t have to do that when the essential problem is that the package merely hasn’t been installed yet because its name has not yet come up.

Replies are listed 'Best First'.
Re: Optimizing an autobundle?
by Anonymous Monk on Sep 12, 2011 at 20:18 UTC
Re: Optimizing an autobundle?
by atcroft (Abbot) on Sep 13, 2011 at 14:27 UTC

    I know in the past I've used the code found in Order your autobundle by dependency, for the same reasons you mention.

    Hope that helps (and I look forward to the responses to this thread).

Re: Optimizing an autobundle?
by zengargoyle (Deacon) on Sep 14, 2011 at 15:31 UTC

    I have a rough start that I'm working on. Roughly I use a CPAN::Mini minicpan, a mod::CPAN::SQLite database, and attempt to pull prereqs information from the META.{json,yml} files (via Archive::Tar) and order with Graph's topological_sort.

    It mostly worked, but depends on modules having proper and good dependency info in their META.

    Since I'm planning on the great "do 5.10.x, 5.12.x, 5.14.x (OMG our work Perl is ancient!) migration path (across Solaris sparc/x86 and Linux and maybe OS X no less (screw Windows))... I worked out a better way for my purposes. I hacked up a cpan shell that logs every successful distribution installed (even the automatically followed ones) in a nice asked_for_this, dist_name, dist_version, dist_file_path, install_date tuple. That way after building the first install, I can filter and replay the remaining installs in the same CPAN calculated order.

    My priorities were to get some basic CPAN pimping and then the various hard XS stuff (SNMP, DBDs, SSL, XML, stuff that uses external libraries that we have installed in strange places) out of the way first before blowing through all the other easy XS and PP things.

    If you're just interested in not having CPAN stop, just configure it to automatically follow dependencies and stop on failure. It will still fail when it's going to fail and do all the work for you when it works (which is usually unless your system is as weird as mine).