Installing The Whole Enchilada From Pinto
Several Pinto users have asked how to install all the modules in any given stack within their repository. At first, my response was to create a Task module that declared all the dependencies you need, and let your installer unwind the dependencies from there. Or better still, organize your app itself into a CPAN-style distribution with the dependencies declared in a META file, and then stick it into your Pinto repository.
But not everyone was thrilled about those ideas. Some folks just want to stash stuff in the repository and then say "install it all". And now you can! Read on to learn more...
Pinto 0.094 introduces a roots
command that lists the root nodes of the dependency graph which encompasses all the distributions in the stack. In other words, it tells you what you need to install to get everything in the stack.
Given the list of roots, you can let your installer do its magic and unwind all the dependencies for you. This is much better than explicitly trying to install each and every distribution in the stack, because you may not actually want to install optional or build-time dependencies. Here are a couple examples of what you can do:
Install all distributions in the stack in one shot:
pinto -r /myrepo roots | cpanm --mirror-only --mirror file:///myrepo
Generate a basic cpanfile
that would install all distributions in the stack:
pinto -r /myrepo roots -f 'requires q{%M};' > cpanfile
There are some caveats though. Some distributions use dynamic configuration, so the actual modules that need to be installed isn't really knowable until you actually install them. Pinto only knows about the dependencies that are declared in the META files. So the list of roots is not always completely accurate. But if anything, the list is too long rather than tool short, so the impact isn't terrible.
And attempting to install all distributions in a stack does not always make sense in the first place. If your stack contains dependencies for a Win32 system and you're trying to install them on a Linux box, it obviously isn't going to work. For that reason, I suggest using separate stacks for each OS you deploy your app too. Pinto has several other commands that help you manage dependencies across multiple stacks.
So this makes it easy to treat your Pinto repository as a simple stash for distributions. In effect, the stack itself becomes your canonical dependency list, so you don't have to maintain a separate META file or anything like that. This isn't necessarily the best way to record dependencies, but for some, I think it is adequate (or at least, very convenient).
I plan to add a similar feature to Stratopan once this latest release of Pinto has proven itself.
Happy holidays!
Leave a comment