From d4bbc30a1160f87d6ea584e41e058376a9ce7e1e Mon Sep 17 00:00:00 2001
From: James Slagle <jslagle@redhat.com>
Date: Tue, 2 Sep 2014 16:39:46 -0400
Subject: [PATCH] Add element-manifest

Add an element that writes a manifest of all the elements used in the
image build.

Change-Id: Icd1863fa9ece1c303208d20b2da46f59c23d7512
---
 elements/element-manifest/README.md                       | 7 +++++++
 elements/element-manifest/element-deps                    | 1 +
 .../extra-data.d/75-inject-element-manifest               | 8 ++++++++
 3 files changed, 16 insertions(+)
 create mode 100644 elements/element-manifest/README.md
 create mode 100644 elements/element-manifest/element-deps
 create mode 100755 elements/element-manifest/extra-data.d/75-inject-element-manifest

diff --git a/elements/element-manifest/README.md b/elements/element-manifest/README.md
new file mode 100644
index 000000000..b65a30370
--- /dev/null
+++ b/elements/element-manifest/README.md
@@ -0,0 +1,7 @@
+element-manifest
+================
+
+Writes a manifest file that is the full list of elements that were used to
+build the image. The file path can be overriden by setting
+$DIB\_ELEMENT\_MANIFEST\_PATH, and defaults to
+/etc/dib-manifests/element-manifest.
diff --git a/elements/element-manifest/element-deps b/elements/element-manifest/element-deps
new file mode 100644
index 000000000..c890ea152
--- /dev/null
+++ b/elements/element-manifest/element-deps
@@ -0,0 +1 @@
+manifests
diff --git a/elements/element-manifest/extra-data.d/75-inject-element-manifest b/elements/element-manifest/extra-data.d/75-inject-element-manifest
new file mode 100755
index 000000000..a16f5be76
--- /dev/null
+++ b/elements/element-manifest/extra-data.d/75-inject-element-manifest
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -eux
+set -o pipefail
+
+DIB_ELEMENT_MANIFEST_PATH=${DIB_ELEMENT_MANIFEST_PATH:-"$DIB_MANIFEST_IMAGE_DIR/dib-element-manifest"}
+sudo mkdir -p $TMP_MOUNT_PATH/$(dirname $DIB_ELEMENT_MANIFEST_PATH)
+sudo /bin/bash -c "echo $IMAGE_ELEMENT | tr ' ' '\n' > $TMP_MOUNT_PATH/$DIB_ELEMENT_MANIFEST_PATH"