From dd262fb12fe774d3e7700a090b48613f4d028f3e Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 13 Feb 2025 00:15:59 +0000 Subject: Generate $partition_filesystem_config.txt for target_files.zip These files will be packaged into META subdir of target_files.zip Some details - This CL adds the filesystem_config.txt files for system, vendor, ... Some other partitions like system_other are currently missing (different module type) - There is a subtle difference between the make and soong build rule. In the make rule, it uses $TARGET_OUT (all partitions) as the -D in `fs_config`. In the soong rule, this implementation passes the staging directory of the filesystem. This difference does not seem to have a difference on the final result. - Some filesystem_config are currently missing/not bit-identical. These include boot, init_boot. For these, we actually want to use the configs from their ramdisk filesystems. I will do this in a followup CL Test: diff'd target_files.zip The following files are identical except NOTICE.xml.gz entry - odm_dlkm, odm, product, system_dlkm, system_ext, vendor_dlkm, vendor The following files are _not_ identical in names and/or contents - boot_filesystem_config.txt - root_filesystem_config.txt - system_other_filesystem_config.txt - vendor_boot_filesystem_config.txt Bug: 388633394 Change-Id: I3a3997c0ffd8100c44b4a50a63bf0709a61d4472 --- filesystem/filesystem.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'filesystem/filesystem.go') diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 0381951ca..dd48c5d95 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -37,6 +37,7 @@ func init() { registerBuildComponents(android.InitRegistrationContext) registerMutators(android.InitRegistrationContext) pctx.HostBinToolVariable("fileslist", "fileslist") + pctx.HostBinToolVariable("fs_config", "fs_config") } func registerBuildComponents(ctx android.RegistrationContext) { @@ -72,6 +73,10 @@ var ( Command: `build/make/tools/fileslist_util.py -c ${in} > ${out}`, CommandDeps: []string{"build/make/tools/fileslist_util.py"}, }) + fsConfigRule = pctx.AndroidStaticRule("fs_config_rule", blueprint.RuleParams{ + Command: `(cd ${rootDir}; find . -type d | sed 's,$$,/,'; find . \! -type d) | cut -c 3- | sort | sed 's,^,${prefix},' | ${fs_config} -C -D ${rootDir} -R "${prefix}" > ${out}`, + CommandDeps: []string{"${fs_config}"}, + }, "rootDir", "prefix") ) type filesystem struct { @@ -421,6 +426,8 @@ type FilesystemInfo struct { ErofsCompressHints android.Path SelinuxFc android.Path + + FilesystemConfig android.Path } // FullInstallPathInfo contains information about the "full install" paths of all the files @@ -665,6 +672,7 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { }, ErofsCompressHints: erofsCompressHints, SelinuxFc: f.selinuxFc, + FilesystemConfig: f.generateFilesystemConfig(ctx, rootDir, rebasedDir), } android.SetProvider(ctx, FilesystemProvider, fsInfo) @@ -682,6 +690,30 @@ func (f *filesystem) fileystemStagingDirTimestamp(ctx android.ModuleContext) and return android.PathForModuleOut(ctx, "staging_dir.timestamp") } +func (f *filesystem) generateFilesystemConfig(ctx android.ModuleContext, rootDir android.Path, rebasedDir android.Path) android.Path { + rootDirString := rootDir.String() + prefix := f.partitionName() + "/" + if f.partitionName() == "system" { + rootDirString = rebasedDir.String() + } + if f.partitionName() == "ramdisk" || f.partitionName() == "recovery" { + // Hardcoded to match make behavior. + // https://cs.android.com/android/_/android/platform/build/+/2a0ef42a432d4da00201e8eb7697dcaa68fd2389:core/Makefile;l=6957-6962;drc=9ea8ad9232cef4d0a24d70133b1b9d2ce2defe5f;bpv=1;bpt=0 + prefix = "" + } + out := android.PathForModuleOut(ctx, "filesystem_config.txt") + ctx.Build(pctx, android.BuildParams{ + Rule: fsConfigRule, + Input: f.fileystemStagingDirTimestamp(ctx), // assemble the staging directory + Output: out, + Args: map[string]string{ + "rootDir": rootDirString, + "prefix": prefix, + }, + }) + return out +} + func (f *filesystem) setVbmetaPartitionProvider(ctx android.ModuleContext) { var extractedPublicKey android.ModuleOutPath if f.properties.Avb_private_key != nil { -- cgit v1.2.3-59-g8ed1b