[oe-commits] Patrick Ohly : rootfsdebugfiles.bbclass: quick-and-dirty installation of additional files

git at git.openembedded.org git at git.openembedded.org
Tue Apr 21 11:48:23 UTC 2015


Module: openembedded-core.git
Branch: master-next
Commit: 783e90d4b05694713b07863fbd9d8d8b76257ba5
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=783e90d4b05694713b07863fbd9d8d8b76257ba5

Author: Patrick Ohly <patrick.ohly at intel.com>
Date:   Mon Apr 13 08:44:38 2015 -0700

rootfsdebugfiles.bbclass: quick-and-dirty installation of additional files

The main motivation for this class was the observation that
a) a core-image can hang under qemu when the kernel does not
   have enough entropy to generate the ssh host key
b) ssh complains about changing ssh host key files when
   rebooting the same machine with different images

For debugging it is okay to reuse an ssh host key generated on the device
before. There may be also similar use cases, so the class is generic enough to
also copy more than one file or directory, with dropbear_rsa_host_key given as
example.

The documentation and naming of the class makes it clear that it
should not be used for production images.

Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 meta/classes/rootfsdebugfiles.bbclass | 36 +++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/meta/classes/rootfsdebugfiles.bbclass b/meta/classes/rootfsdebugfiles.bbclass
new file mode 100644
index 0000000..a558871
--- /dev/null
+++ b/meta/classes/rootfsdebugfiles.bbclass
@@ -0,0 +1,36 @@
+# This class installs additional files found on the build host
+# directly into the rootfs.
+#
+# One use case is to install a constant ssh host key in
+# an image that gets created for just one machine. This
+# solves two issues:
+# - host key generation on the device can stall when the
+#   kernel has not gathered enough entropy yet (seen in practice
+#   under qemu)
+# - ssh complains by default when the host key changes
+#
+# For dropbear, with the ssh host key store along side the local.conf:
+# 1. Extend local.conf:
+#    INHERIT += "rootfsdebugfiles"
+#    ROOTFS_DEBUG_FILES += "${TOPDIR}/conf/dropbear_rsa_host_key ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key ;"
+# 2. Boot the image once, copy the dropbear_rsa_host_key from
+#    the device into your build conf directory.
+#
+# Do not use for production images! It bypasses several
+# core build mechanisms (updating the image when one
+# of the files changes, license tracking in the image
+# manifest, ...).
+
+ROOTFS_DEBUG_FILES ?= ""
+ROOTFS_DEBUG_FILES[doc] = "Lists additional files or directories to be installed with 'cp -a' in the format 'source1 target1;source2 target2;...'"
+
+ROOTFS_POSTPROCESS_COMMAND += "rootfs_debug_files ;"
+rootfs_debug_files () {
+   #!/bin/sh -e
+   echo "${ROOTFS_DEBUG_FILES}" | sed -e 's/;/\n/g' | while read source target; do
+      if [ -e "$source" ]; then
+         mkdir -p $(dirname $target)
+         cp -a $source $target
+      fi
+   done
+}



More information about the Openembedded-commits mailing list