summaryrefslogtreecommitdiffstats
path: root/meta/classes/rootfsdebugfiles.bbclass
blob: a558871e99facf6c94850f84e33aa61aa50906b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
}