From 768c5e188c1b4bff01da14a49b96b51301db4c03 Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Fri, 15 Sep 2017 11:54:01 +1000
Subject: [PATCH] Create /etc/machine-id for fedora

As described in the comment, we need to create the /etc/machine-id for
the image-based build when systemd isn't updated (as is usually the
case for a new distro)

Work on clearing this out continues, but this brings it to parity with
fedora-minimal.

Change-Id: Icbbbabb4114d4d95909648d8e39a6bae6d2a7b7b
Depends-On: I761e425f8a658669d9b8a70ce4260cec263ea51a
---
 .../fedora/pre-install.d/02-set-machine-id    | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100755 diskimage_builder/elements/fedora/pre-install.d/02-set-machine-id

diff --git a/diskimage_builder/elements/fedora/pre-install.d/02-set-machine-id b/diskimage_builder/elements/fedora/pre-install.d/02-set-machine-id
new file mode 100755
index 000000000..ac0a80f45
--- /dev/null
+++ b/diskimage_builder/elements/fedora/pre-install.d/02-set-machine-id
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
+    set -x
+fi
+set -eu
+set -o pipefail
+
+# The systemd .spec file does this in %post [1] and it turns out that
+# (in what is possibly a bug [2]) that kernel install requires
+# /etc/machine-id.  This affects "fedora" (the image-based build) if
+# there is no systemd update to install ... with "fedora-minimal" we
+# are always installing into the chroot so, so %post always runs and
+# this is always run
+#
+# [1] https://src.fedoraproject.org/rpms/systemd/blob/master/f/systemd.spec
+# [2] https://bugzilla.redhat.com/show_bug.cgi?id=1486124
+
+systemd-machine-id-setup