1*92b42cb3SPatrick Williams# 2*92b42cb3SPatrick Williams# Copyright OpenEmbedded Contributors 3*92b42cb3SPatrick Williams# 4*92b42cb3SPatrick Williams# SPDX-License-Identifier: MIT 5*92b42cb3SPatrick Williams# 6*92b42cb3SPatrick Williams 7*92b42cb3SPatrick Williams# This class installs additional files found on the build host 8*92b42cb3SPatrick Williams# directly into the rootfs. 9*92b42cb3SPatrick Williams# 10*92b42cb3SPatrick Williams# One use case is to install a constant ssh host key in 11*92b42cb3SPatrick Williams# an image that gets created for just one machine. This 12*92b42cb3SPatrick Williams# solves two issues: 13*92b42cb3SPatrick Williams# - host key generation on the device can stall when the 14*92b42cb3SPatrick Williams# kernel has not gathered enough entropy yet (seen in practice 15*92b42cb3SPatrick Williams# under qemu) 16*92b42cb3SPatrick Williams# - ssh complains by default when the host key changes 17*92b42cb3SPatrick Williams# 18*92b42cb3SPatrick Williams# For dropbear, with the ssh host key store along side the local.conf: 19*92b42cb3SPatrick Williams# 1. Extend local.conf: 20*92b42cb3SPatrick Williams# INHERIT += "rootfsdebugfiles" 21*92b42cb3SPatrick Williams# ROOTFS_DEBUG_FILES += "${TOPDIR}/conf/dropbear_rsa_host_key ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key ;" 22*92b42cb3SPatrick Williams# 2. Boot the image once, copy the dropbear_rsa_host_key from 23*92b42cb3SPatrick Williams# the device into your build conf directory. 24*92b42cb3SPatrick Williams# 3. A optional parameter can be used to set file mode 25*92b42cb3SPatrick Williams# of the copied target, for instance: 26*92b42cb3SPatrick Williams# ROOTFS_DEBUG_FILES += "${TOPDIR}/conf/dropbear_rsa_host_key ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key 0600;" 27*92b42cb3SPatrick Williams# in case they might be required to have a specific mode. (Shoundn't be too open, for example) 28*92b42cb3SPatrick Williams# 29*92b42cb3SPatrick Williams# Do not use for production images! It bypasses several 30*92b42cb3SPatrick Williams# core build mechanisms (updating the image when one 31*92b42cb3SPatrick Williams# of the files changes, license tracking in the image 32*92b42cb3SPatrick Williams# manifest, ...). 33*92b42cb3SPatrick Williams 34*92b42cb3SPatrick WilliamsROOTFS_DEBUG_FILES ?= "" 35*92b42cb3SPatrick WilliamsROOTFS_DEBUG_FILES[doc] = "Lists additional files or directories to be installed with 'cp -a' in the format 'source1 target1;source2 target2;...'" 36*92b42cb3SPatrick Williams 37*92b42cb3SPatrick WilliamsROOTFS_POSTPROCESS_COMMAND += "rootfs_debug_files;" 38*92b42cb3SPatrick Williamsrootfs_debug_files () { 39*92b42cb3SPatrick Williams #!/bin/sh -e 40*92b42cb3SPatrick Williams echo "${ROOTFS_DEBUG_FILES}" | sed -e 's/;/\n/g' | while read source target mode; do 41*92b42cb3SPatrick Williams if [ -e "$source" ]; then 42*92b42cb3SPatrick Williams mkdir -p $(dirname $target) 43*92b42cb3SPatrick Williams cp -a $source $target 44*92b42cb3SPatrick Williams [ -n "$mode" ] && chmod $mode $target 45*92b42cb3SPatrick Williams fi 46*92b42cb3SPatrick Williams done 47*92b42cb3SPatrick Williams} 48