I've been spending quite a bit of time at work lately trying to port APT to FreeBSD, and upgrading/improving the existing dpkg port. We want to use these tools for distributing our in-house software to production servers. I'm also sort of hoping that this will lay the groundwork for distributing open source software packages for FreeBSD as .deb files, installable with apt-get, so there may some day be an alternative to the existing FreeBSD Ports system (I like ports well enough, but using APT would be really nice for a lot of reasons).
Anyway, both APT and dpkg are some of the least portable pieces of software I've ever seen. There is a lot of hard coding of paths for dependencies and where to install stuff, which is really unnecessary since they're already using autotools. They could just set these paths using things like --prefix in configure scripts, or let the shell determine the path to some executable that is being called rather than hard coding /usr/bin/foo. There is also a lot of dependence on GNU-specific features in utilities that FreeBSD has its own implementations of, like md5sum (FreeBSD has md5) and patch. FreeBSD patch specifically wasn't working until I installed GNU patch (and tweaked dpkg so it'd use that instead of the FreeBSD version). I thought this snippet from dpkg-source's code was particularly amusing:
# Make sure patch doesn't get any funny ideas
delete $ENV{'POSIXLY_CORRECT'};
Uh-huh, complying with POSIX sure is a funny idea...