Skip to content

Commit

Permalink
aospdtgen: Finish A/B support
Browse files Browse the repository at this point in the history
Change-Id: I03dbaf4d85221cf8da6d2de906e68b49040faeb9
  • Loading branch information
SebaUbuntu committed Mar 10, 2022
1 parent 6c608df commit 744011a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
15 changes: 15 additions & 0 deletions aospdtgen/devicetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ def __init__(self, path: Path):
break
self.fstab = Fstab(fstab)

# Let the partitions know their fstab entries if any
for partition in self.partitions:
partition.fill_fstab_entry(self.fstab)

# Get a list of A/B partitions
self.ab_partitions: list[PartitionModel] = []
if self.device_info.device_is_ab:
for fstab_entry in self.fstab.get_slotselect_partitions():
partition_model = PartitionModel.from_mount_point(fstab_entry.mount_point)
if partition_model is None:
continue

self.ab_partitions.append(partition_model)

# Get list of rootdir files
self.rootdir_bin_files = [file for file in self.vendor.files if file.relative_to(self.vendor.real_path).is_relative_to("bin") and file.suffix == ".sh"]
self.rootdir_etc_files = [file for file in self.vendor.files if file.relative_to(self.vendor.real_path).is_relative_to("etc/init/hw")]
Expand Down Expand Up @@ -188,6 +202,7 @@ def dump_to_folder(self, folder: Path):

def render_template(self, *args, comment_prefix: str = "#", **kwargs):
return render_template(*args,
ab_partitions=self.ab_partitions,
boot_configuration=self.boot_configuration,
comment_prefix=comment_prefix,
current_year=self.current_year,
Expand Down
6 changes: 5 additions & 1 deletion aospdtgen/templates/BoardConfig.mk.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ DEVICE_PATH := device/{{ device_info.manufacturer }}/{{ device_info.codename }}
{% if device_info.device_is_ab %}
# A/B
AB_OTA_UPDATER := true
AB_OTA_PARTITIONS += # TODO
AB_OTA_PARTITIONS +=
{%- for partition in ab_partitions %} \
{{ partition.name }}
{%- endfor %}

BOARD_USES_RECOVERY_AS_BOOT := true

{% endif %}
Expand Down
19 changes: 19 additions & 0 deletions aospdtgen/templates/device.mk.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ PRODUCT_PACKAGES += \
update_engine_sideload \
update_verifier

{% for partition in partitions %}
{% if partition.fstab_entry and partition.fstab_entry.is_slotselect() %}
{% if partition.model.name == "system" %}
AB_OTA_POSTINSTALL_CONFIG += \
RUN_POSTINSTALL_system=true \
POSTINSTALL_PATH_system=system/bin/otapreopt_script \
FILESYSTEM_TYPE_system={{ partition.fstab_entry.fs_type }} \
POSTINSTALL_OPTIONAL_system=true

{% elif partition.model.name == "vendor" %}
AB_OTA_POSTINSTALL_CONFIG += \
RUN_POSTINSTALL_vendor=true \
POSTINSTALL_PATH_vendor=bin/checkpoint_gc \
FILESYSTEM_TYPE_vendor={{ partition.fstab_entry.fs_type }} \
POSTINSTALL_OPTIONAL_vendor=true

{% endif %}
{% endif %}
{% endfor %}
PRODUCT_PACKAGES += \
checkpoint_gc \
otapreopt_script
Expand Down
8 changes: 8 additions & 0 deletions aospdtgen/utils/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import annotations
from aospdtgen.lib.libprop import BuildProp
from aospdtgen.proprietary_files.ignore import is_blob_allowed
from aospdtgen.utils.fstab import Fstab, FstabEntry
from pathlib import Path

(
Expand Down Expand Up @@ -95,6 +96,7 @@ def __init__(self, model: PartitionModel, real_path: Path, dump_path: Path):
self.dump_path = dump_path

self.files: list[Path] = []
self.fstab_entry: FstabEntry = None

self.build_prop = BuildProp()
for possible_paths in BUILD_PROP_LOCATION:
Expand All @@ -117,6 +119,12 @@ def fill_files(self, files: list[Path]):

self.files.append(file)

def fill_fstab_entry(self, fstab: Fstab):
for mount_point in self.model.mount_points:
self.fstab_entry = fstab.get_partition_by_mount_point(mount_point)
if self.fstab_entry is not None:
return

def get_formatted_file(self, file: Path):
return self.model.proprietary_files_prefix / file.relative_to(self.real_path)

Expand Down

0 comments on commit 744011a

Please sign in to comment.