For Debian, just run a shellcommand:
/usr/bin/apt-get --yes install packagename
where 'packagename' is somethng like libc6 and not libc6_1.9.6-2.deb,
and all required dependencies will be fetched and installed also.
I had a problem with apt-get not finding required commands due to
the path cfengine runs shellcommands with, and ended up calling a
wrapper script. I admit I didn't spend much time looking into how
cfengine sets its shellcommand path, so there may be a better way.
You also need to be careful about debconf promptings and dpkg's
conffile-replace-or-keep questions. This is something close to what
I'm currently using, running it as a shellcommand:
http://thebackrow.net/~harpo/debian/cfengine/
autoapt.pl assumes some things about your hostname conventions, but it
should be straightforward enough to hack. In the long term I should
probably modify it to use CFALLCLASSES or whatever.
It also assumes you're going to keep the old versions of your
conffiles -- all the conffiles I care about are managed by my cfengine
setup anyway -- and that you're happy with the default debconf answers
or have already modified them via something like debconf-copydb.