Extending PkgWatcher to work with Other Operating Systems

So now I’ve Announced PkgWatcher people are actually starting to use it, the optimistic curs! The first question’s already come in and it’s one I can actually answer: how do you extend it to work on other operating systems?

It’s actually pretty easy, first you need to make an addition in installed_packages. This function works out which OS you’re running on and returns the respective subroutine that understands your package manager. Which brings us on to step 2.

You now need to add that sub, the two existing examples are pretty simple and show two possible approaches. The goal is to have the function return an array of all the packages installed; how you get this is up to you. But please don’t shell out and use awk, pkgwatcher is a perl program after all. And that’s it, two small bits of code and you should be up and running.