Debian: Support additional debootstrap arguments

Add support for supplying a custom keyring and debootstrap script
using two new environment variables:

* DIB_DEBIAN_KEYRING - Path to a gpg keyring.
* DIB_DEBIAN_DEBOOTSTRAP_SCRIPT - Path to a alternative debootstrap
  script.

Change-Id: I42e8832b435b8a77b0681b5bc9d9332bbe860cd5
Parameterise PXE kernel and initrd selection

When using custom-built kernels, their filenames may not necessarily
follow the standard naming conventions for the stock systems in question.

This patch permits the specification of an alternative pattern to use
when looking for the correct kernel to construct the PXE images from.

Example:
  export DIB_BAREMETAL_KERNEL_PATTERN="kernel*jang"
  export DIB_BAREMETAL_INITRD_PATTERN="initrd*jang"

Change-Id: I86e5254051addd5e89dd4e363e9bba117e65353d
Tidy up SuSE kernel selection

This is just removing a C&P line that only ever returns a single result.

Change-Id: Iad37e982412a9199d86d9b4481cc14a85eef704e
Create an element to allow using a dpkg manifest

Enable reusing of a dpkg manifest to pin package versions at build
time

Change-Id: I23e83268d282c972b335a8cf0dfc45030a0ab4ff
Fix package removal

Shift first to drop the first commandline argument (-e).

Change-Id: I73a0100484b6443ad5bdf500dd032af20eac7d3b
Factor out error behavior in dib-lint

Currently when dib-lint finds a problem it does something like:

 echo "ERROR: Problem found"
 rc=1

This is repetitive and error-prone since it's easy to forget to set
rc to actually fail the check.  This change makes those two steps
a single function call.

Change-Id: I40b5bf39348a69add1f955c49f310e3bda21be0e
Add new cloud-init-datasources element

This moves cloud-init data source configuration to a general purpose
cloud-init-datasources element that can be used to explicitly configure
the list of cloud-init sources that will be queried on first boot.

cloud-init-nocloud now depends on this new element to configure the
datasource_list while continuing to prep the image for a nocloud first boot.

Change-Id: Ibcc3b86d6ca567a23f89b7a1a36bc713e444ef68
Closes-bug: #1316475
Check return code of element-info

Ensure the return code of element-info is actually checked by moving the
export IMAGE_ELEMENT to the subsequent line.

A recent change (Ic0a061995e2ae708c95a535cba6237bff58f7d93) exported the
IMAGE_ELEMENT variable. This caused the return code of element-info to not
actually be checked, since the export command is now checked instead and
almost always will return 0.

This caused a misleading error message when using diskimage-builder with an
unknown element since the script didn't exit when it should have:
$ bin/disk-image-create -a amd64 foobar vm
Building elements: base  foobar vm
ERROR: Element 'foobar' not found in 'bin/../elements'
Expanded element dependencies to:
Building in /var/tmp/image.DuIDY1lW
Please include at least one distribution root element.

Change-Id: I3d9c02bf0b1a4f320280185dd3fab0697d2c92f2
Add manifests to .gitignore

A common use case is to run diskimage-builder directly from the git
checkout.  This leaves manifests and .d directories behind for each
image build in the current directory, so add these to .gitignore.

Change-Id: Id4b432d30dead830b0886bccb762c4e3922b52e1
Correct the wrong rename in rhel element

There is a substitution of suffix in rhel element, like
rhel-guest-image-6.5-20140121.0.x86_64.qcow2 to
rhel-guest-image-6.5-20140121.0.x86_64.raw

The convert is correct but the substitution of the suffix is wrong.

${PARAMETER#PATTERN} will match the string from the beginning and generate rhel-guest-image-6.5-20140121.0.x86_64.qcow2.raw

We should use ${PARAMETER%PATTERN} instead, which is from the end.

Change-Id: Ic45a3f800058ea9e5d746ff543c068a54632407d
Remove uneeded code from pkg-map

This patch removes a couple of lines of redundant code.  In Python,
the get method on a dictionary defaults the return value to None,
so the method never raises a key error.

https://docs.python.org/2/library/stdtypes.html#typesmapping

Change-Id: I180877f9be23d373cd63771bb3682d6587ec6fac
Only use Ec2 cloud-init data source for Ubuntu

Default to only having cloud-init query Ec2 on first boot for Ubuntu,
until cloud-init has been SRU'd to fix the CloudSigma data source issue
that causes Trusty boots to hang.

Change-Id: Icb3734d5ae78f4a0a6c0fae1af4a2ce3c809308c
Partial-bug: #1316475
Reinstate Trusty as default for Ubuntu

Now that issues associated with this bump have been addressed
elsewhere, reinstate trusty as the default DIB_RELEASE for
the ubuntu element.  Also adds a note about memory requirements
to the ramdisk element.

Change-Id: Ia89c83ba0ee4ad3bd89b833ba0db08135eac63ed
Replacing deploy to deploy-baremetal in README.md

Now that deploy has been renamed to deploy-baremetal, README.md needs
to be updated to refer to the new elements.

Change-Id: I7c0d5bfe158628ea1faf2c2914ee7f532d172a28
Add missing dollar

Check is missing a dollar leading to an error on deploy ramdisk
consoles when booting .

Change-Id: Id61af0f7abbc353e0750580b80e448820cc17b10
Rename old image file instead of rewrite it

If we have the old image file with same name as new image file
we shouldn't rewrite it, just need to rename old.
Uses date number in old image name.

Fixes TODO in lib/common-functions

Change-Id: Ica58a0f4435217912bddf950322299d2ed2889f3
Ensure dib-run-parts profiling works with py3 and py2

This change adjusts the "inline" python function used to profile
run-parts duration to make it run successfully on both py2 and py3

Change-Id: Ib5287a56b8e2b3e882dca489192f01d9f01cd8ba
map-services: add openvswitch

OVS service is called:
 - openvswitch-switch on Debian/Ubuntu
 - openvswitch on RHEL/Fedora

This changes is needed to get the neutron element to work
on Debian/Ubuntu with systemd:
  I6e3df30dc3a6918f3a949a7dac47289ede5c3d1f

Change-Id: I2748a9db7f8ee456698187a9646bc7cda2256fe7
Merge "Add new cloud-init-datasources element"
dpkg: local cache for .deb files

With this patch, /var/cache/apt/archives directory content is preserved.
The directory is actually a bind mount of the
~/.cache/image-create/apt/$DISTRO_NAME directory, much like what we do
for ccache.
You can use DIB_APT_LOCAL_CACHE=0 to disable this behavior.

This trivial change improve performance A LOT (>30%), even if a local
HTTP proxy because:
 - there is no need to copy again and again the same files
 - we avoid network latency

The patch has been tested with Debian and Ubuntu with every elements
from the tripleo-image-elements repository, the final size of the cache
directory is about 700MB per distribution subdirectory.

Change-Id: I4fab499493f734c7c546d4d23b1a98f0e7523a39