[Buildroot] [PATCH 1/1] fs/cpio: add option to manually specify file list

Seamus Connor sconnor at lynx.com
Thu Oct 26 20:13:32 UTC 2017


I was thinking that a good improvement to this patch would be to specify 
the file list in a gitignore format.  That way you could just chop off 
the portions of the rootfs you dont need, or manually include the 
portions that you do need.


On 10/26/2017 12:16 PM, Seamus Connor wrote:
> For some systems it may be desireable to have an initramfs that is
> smaller than the full root filesystem. This commit adds support for
> creating an initramfs based on a manually specified set of files. It is
> up to the user to define a sensible set of files. This file list could
> either be statically created, or it could be created as the result of a
> pre-fs hook script.
>
> Signed-off-by: Seamus Connor <sconnor at lynx.com>
> ---
>   fs/cpio/Config.in | 30 ++++++++++++++++++++++++++++++
>   fs/cpio/cpio.mk   | 10 ++++++++++
>   2 files changed, 40 insertions(+)
>
> diff --git a/fs/cpio/Config.in b/fs/cpio/Config.in
> index 206baca677..21aa2c6fb8 100644
> --- a/fs/cpio/Config.in
> +++ b/fs/cpio/Config.in
> @@ -7,6 +7,36 @@ config BR2_TARGET_ROOTFS_CPIO
>   
>   if BR2_TARGET_ROOTFS_CPIO
>   
> +choice
> +	prompt "Seleted Fileset"
> +	default BR2_TARGET_ROOTFS_CPIO_INCLUDE_ALL
> +	help
> +	  Select the set of files to include in the cpio of the root filesystem.
> +	  This may either be all files installed to the target, or it may be a
> +	  subset defined in the custom file list.
> +
> +config BR2_TARGET_ROOTFS_CPIO_INCLUDE_ALL
> +	bool "Include all files from target"
> +	help
> +	  Include all files from the target directory in the root filesystem.
> +
> +config BR2_TARGET_ROOTFS_CPIO_INCLUDE_CUSTOM
> +	bool "Include a subset of files from target"
> +	help
> +	  Include a subset of the files from the target directory in the root filesystem.
> +	  This requires a custom file list to be defined.  The actual file list may be
> +	  generated by a user script defined as part of the pre-fs hook.
> +
> +endchoice
> +
> +config BR2_TARGET_ROOTFS_CPIO_CUSTOM_FILELIST
> +	string "path to a custom file list"
> +	depends on BR2_TARGET_ROOTFS_CPIO && BR2_TARGET_ROOTFS_CPIO_INCLUDE_CUSTOM
> +	help
> +	  This file defines the contents of the rootfilesystem.  All files and folders
> +	  created in the rootfilesystem must be defined here.  This file can be statically
> +	  defined, or created as part of the pre-fs hook.
> +
>   choice
>   	prompt "Compression method"
>   	default BR2_TARGET_ROOTFS_CPIO_NONE
> diff --git a/fs/cpio/cpio.mk b/fs/cpio/cpio.mk
> index e82167e512..984ff37895 100644
> --- a/fs/cpio/cpio.mk
> +++ b/fs/cpio/cpio.mk
> @@ -27,10 +27,20 @@ endif # BR2_ROOTFS_DEVICE_CREATION_STATIC
>   
>   ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_ADD_INIT
>   
> +ifeq ($(BR2_TARGET_ROOTFS_CPIO_INCLUDE_ALL),y)
> +
>   define ROOTFS_CPIO_CMD
>   	cd $(TARGET_DIR) && find . | cpio --quiet -o -H newc > $@
>   endef
>   
> +else
> +
> +define ROOTFS_CPIO_CMD
> +	cd $(TARGET_DIR) && cpio --quiet -o -H newc < $(BR2_TARGET_ROOTFS_CPIO_CUSTOM_FILELIST) > $@
> +endef
> +
> +endif
> +
>   $(BINARIES_DIR)/rootfs.cpio.uboot: $(BINARIES_DIR)/rootfs.cpio host-uboot-tools
>   	$(MKIMAGE) -A $(MKIMAGE_ARCH) -T ramdisk \
>   		-C none -d $<$(ROOTFS_CPIO_COMPRESS_EXT) $@




More information about the buildroot mailing list