build.sh: Add support for specifying modules for recovery/charger

Currently, the same modules.load file is used for normal boot,
recovery/fastbootd and charger modes during first-stage init. This
means that during normal boot, the modules that are needed for
recovery and charger modes are loaded during first-stage init, which
is not required.

Add support for specifying a list of modules that are required for
booting into recovery or charger mode, in addition to the set of modules
loaded during first-stage init. This introduces two new environment
variables called MODULES_RECOVERY_LIST and MODULES_CHARGER_LIST, which
point to files that contain lists the modules that are needed for
booting into recovery or charger mode respectively, in addition
to the modules required for first-stage init (defined by MODULES_LIST).

Defining MODULES_[RECOVERY/CHARGER]_LIST also produces a file named
modules.load.[recovery/charger] in the initramfs, which init uses
instead of modules.load when booting into recovery or charger mode
respectively to load the first-stage init and recovery and charger modules.

In case of normal boot, init will use the modules.load
file, which will only contain the modules needed for first
stage init, and the recovery and charger modules will be loaded
from the vendor_dlkm partition during second-stage init.

Note: This patch is a squash of the following commits from the main
branch to avoid introducing regressions:

d08605f4c795 ("kleaf: Add support for specifying modules for recovery/charger")
8565b2e637df ("build_utils.sh: Fix typos for recovery and charger list variables")
3f67b5ffe134 ("build_utils.sh: Ensure depmod runs on all modules last")

Bug: 266752750
Bug: 356349753
Change-Id: I11503b11683ef64cf0933b8641959ea5acd63ab1
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
(cherry picked from commit b9ba4b67e90b85d01eb2f9cebf62830a73574cd9)
[isaacmanjarres: Re-wrote some of the commit message/implemented it
as part of kleaf. Also added tests for the new attributes.]
(cherry picked from commit d08605f4c795e05d8569e975affd2736e430a555)
[isaacmanjarres: Re-wrote some of the commit message/implemented
all functionality in build.sh, since build_utils.sh does not
exist on this branch. Also included squashed fixes as part of the
commit message.]
1 file changed