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