From be6a66d54b326084e8060a4548737059b4ff9349 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Thu, 11 Jul 2024 15:43:44 +0900 Subject: [PATCH] Add install_in_root to prebuilt_root module This is to support installing to real root "/", not a root of partition (e.g. "/system/"). Bug: 351258461 Test: build Change-Id: I56993aceddfd988d2d10040f50f838b89c9bdc67 --- android/neverallow.go | 1 + etc/prebuilt_etc.go | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/android/neverallow.go b/android/neverallow.go index 62c5e595e..ef4b8b8b6 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -237,6 +237,7 @@ func createInitFirstStageRules() []Rule { Without("name", "init_first_stage"). Without("name", "init_first_stage.microdroid"). With("install_in_root", "true"). + NotModuleType("prebuilt_root"). Because("install_in_root is only for init_first_stage."), } } diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go index d04b2d1f1..fc6d1f74e 100644 --- a/etc/prebuilt_etc.go +++ b/etc/prebuilt_etc.go @@ -126,6 +126,15 @@ type prebuiltSubdirProperties struct { Relative_install_path *string `android:"arch_variant"` } +type prebuiltRootProperties struct { + // Install this module to the root directory, without partition subdirs. When this module is + // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will + // then be copied to the root of system.img. When this module is packaged by other modules like + // android_filesystem, this module will be installed to the root ("/"), unlike normal + // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/"). + Install_in_root *bool +} + type PrebuiltEtcModule interface { android.Module @@ -140,7 +149,12 @@ type PrebuiltEtc struct { android.ModuleBase android.DefaultableModuleBase - properties prebuiltEtcProperties + properties prebuiltEtcProperties + + // rootProperties is used to return the value of the InstallInRoot() method. Currently, only + // prebuilt_avb and prebuilt_root modules use this. + rootProperties prebuiltRootProperties + subdirProperties prebuiltSubdirProperties sourceFilePaths android.Paths @@ -156,9 +170,6 @@ type PrebuiltEtc struct { additionalDependencies *android.Paths usedSrcsProperty bool - // installInRoot is used to return the value of the InstallInRoot() method. The default value is false. - // Currently, only prebuilt_avb can be set to true. - installInRoot bool makeClass string } @@ -246,7 +257,7 @@ func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) b } func (p *PrebuiltEtc) InstallInRoot() bool { - return p.installInRoot + return proptools.Bool(p.rootProperties.Install_in_root) } func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { @@ -502,21 +513,20 @@ func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase { func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) { p.installDirBase = dirBase - p.installInRoot = false p.AddProperties(&p.properties) p.AddProperties(&p.subdirProperties) } func InitPrebuiltRootModule(p *PrebuiltEtc) { p.installDirBase = "." - p.installInRoot = false p.AddProperties(&p.properties) + p.AddProperties(&p.rootProperties) } func InitPrebuiltAvbModule(p *PrebuiltEtc) { p.installDirBase = "avb" - p.installInRoot = true p.AddProperties(&p.properties) + p.rootProperties.Install_in_root = proptools.BoolPtr(true) } // prebuilt_etc is for a prebuilt artifact that is installed in