Features serve to extend the functionality of the make-initrd.
Features are located in the features directory.
Let's assume the feature name is mdadm. In this case, the directory structure
will be:
features/<NAME>
`- README.md
`- config.mk
`- rules.mk
`- pack.mk
`- data/
`- tests/
`- guess/
- README.md - this file contains the documentation of the feature that describes the functionality and parameters.
- config.mk - this file is always read. It should only contain the definition of feature-specific variables. In this file, the kernel is checked (if necessary).
- rules.mk - this file will be used if the
mdadmfeature is used. In this file that the real actions should be described. - data/ - this directory contains a piece of initramfs image that you want to put into the image "as is" (Optional).
- tests/ - the directory contains unit tests for the feature (Optional).
- guess/ - the directory contains a part of the guess subsystem (Optional).
Let's say in the image you need to put a mdadm utility, its configuration file and the data that the utility needs. To do this, we need to create a description of its resources:
MDAMD_RULES = \
/lib/udev/rules.d/63-md-raid-arrays.rules \
/lib/udev/rules.d/64-md-raid-assembly.rules
MDADM_CONF ?= $(SYSCONFDIR)/mdadm.conf
MDADM_PROGS = mdadm
MDADM_FILES = $(wildcard $(MDAMD_RULES) $(MDADM_CONF))
MDADM_DATADIR = $(FEATURESDIR)/mdadm/dataVariables do not need to be prefixed like this (MDADM_). It must be unique
among other features. Usually a prefix based on the feature name.
The MDADM_CONF variable is marked as overridden so that at the time of
initramfs image creation, you can specify a different configuration file.
The MDADM_DATADIR contains a path to data/ directory. In this directory we
will put additional files needed for this feature.
This file adds files to those required in the initramfs image. There are several special variables to do this.
PUT_FEATURE_DIRScontains a list of directories whose contents should be copied as is.PUT_FEATURE_FILEScontains a list of files that are copied to the image with the full path to the file. If a directory is placed in this list, then the directory will be copied with all the contents in it.PUT_FEATURE_PROGScontains a list of program names. These programs will be found in the PATH and copied to the image.PUT_FEATURE_PROGS_WILDCARDcontains a list of glob patterns for the full path to utilities in thePATH.PUT_FEATURE_LIBScontains a list of libraries that are copied to the image. The library will be copied with all linked dependencies.PUT_FEATURE_OPTIONAL_LIBSthis is the same asPUT_FEATURE_LIBSbut only if the library is not found the error does not happen.
PUT_FEATURE_DIRS += $(MDADM_DATADIR)
PUT_FEATURE_FILES += $(MDADM_FILES)
PUT_FEATURE_PROGS += $(MDADM_PROGS)All binary utilities will be copied along with a libraries with which they are linked.
This file contains the targets and variables used to package the generated
image. The pre-pack and post-pack targets are used to perform any actions
before or after the image is packed.