Make sure we unmount stale proc mounts on the chroot host.

(cherry picked from commit 722949f475fbd71cb9c0b036d394e0c1c7e9d26e)
Make sure test results are collected even in the case of failure.

We do this by making it part of the test step itself.

(cherry picked from commit b1e2bfa21fb707f5fb9f55bb881ddf329b50845b)
Add environment printout to detect-environment, for debugging.

(cherry picked from commit 854c8aa8332ffd6f0de74d22bc2ab43b37097896)
Helper packages for Debian-based development.

Add contrib/cf-deb-dep/ to automate pulling in needed Debian packages
and help with keeping up to date on what's needed.

(cherry picked from commit 95fa10c83414e7149e84f9956761c38be6c18944)
Don't complain about an already running CFEngine.

Move the stop section to the beginning of the pre-script, so that the
port checks come afterwards.

(cherry picked from commit e4ace02de4e0b5cf4bcf14b4e9f0e317bc071399)
Make sure libvirt doesn't try to pick up the system libcurl.

It will fail later because the package will not contain libvirt.

(cherry picked from commit 4120a6b643719bfc40df281215becbc7a8aa8406)
Redmine #6581: Fix upgrade overwriting config files with templates.

This required several things:

- Almost all of the post script was only executed on install, not
  upgrade. Now most (but not all) sections are performed on both.
- The config files contain the private keys, but we don't have a
  dedicated file for them, so we need to fish them out of the config
  files, store them somewhere, and then restore them after the file
  has been upgraded.
- Lots of indentation corrections.
- Don't regenerate new SSL certificate if we already have one.

(cherry picked from commit ca6ecd701e92734aebc3b7748bd5676066cafe35)
Redmine #6581: Don't perform uninstall steps if we are upgrading.

This fixes the daemons being stopped after an upgrade.

Note that this will only have an effect when we upgrade from a package
that includes this change, because the uninstall script is always
taken from the *old* package. Hence, the earliest package that this
change will have any effect for, is the second version that includes
the change, which at the time of writing is probably going to be
3.6.3.

(cherry picked from commit 8dd4e122c107f59b014055b09ed0b0b5e43553ed)
Redmine #6581: Make sure that daemons are restarted when upgrading.

(cherry picked from commit f6d14ef3a18e78bfc900add29f8104638244bd87)