This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
releasetools.py
72 lines (58 loc) · 2.25 KB
/
releasetools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright (C) 2009 The Android Open Source Project
# Copyright (C) 2019 The Mokee Open Source Project
# Copyright (C) 2019 The LineageOS Open Source Project
#
# SPDX-License-Identifier: Apache-2.0
import common
def FullOTA_InstallEnd(info):
OTA_InstallEnd(info, False)
def IncrementalOTA_InstallEnd(info):
OTA_InstallEnd(info, True)
def AddImageOnly(info, basename, incremental, firmware):
if incremental:
input_zip = info.source_zip
else:
input_zip = info.input_zip
if firmware:
data = input_zip.read("RADIO/" + basename)
else:
data = input_zip.read("IMAGES/" + basename)
common.ZipWriteStr(info.output_zip, basename, data)
def AddImage(info, basename, dest, incremental):
AddImageOnly(info, basename, incremental, False)
info.script.Print("Patching {} image unconditionally...".format(dest.split('/')[-1]))
info.script.AppendExtra('package_extract_file("%s", "%s");' % (basename, dest))
def OTA_InstallEnd(info, incremental):
AddImage(info, "vbmeta.img", "/dev/block/platform/bootdevice/by-name/vbmeta", incremental)
bin_map = {
'logo': ['logo']
}
img_map = {
'audio_dsp': ['audio_dsp'],
'cam_vpu1': ['cam_vpu1'],
'cam_vpu2': ['cam_vpu2'],
'cam_vpu3': ['cam_vpu3'],
'dtbo': ['dtbo'],
'gz': ['gz1', 'gz2'],
'lk': ['lk', 'lk2'],
'md1img': ['md1img'],
'scp': ['scp1', 'scp2'],
'spmfw': ['spmfw'],
'sspm': ['sspm_1', 'sspm_2'],
'tee': ['tee1', 'tee2']
}
pl = 'preloader_ufs'
pl_part = ['sda', 'sdb']
fw_cmd = 'ui_print("Patching radio images unconditionally...");\n'
AddImageOnly(info, "{}.img".format(pl), incremental, True)
for part in pl_part:
fw_cmd += 'package_extract_file("{}.img", "/dev/block/{}");\n'.format(pl, part)
for img in img_map.keys():
AddImageOnly(info, '{}.img'.format(img), incremental, True)
for part in img_map[img]:
fw_cmd += 'package_extract_file("{}.img", "/dev/block/platform/bootdevice/by-name/{}");\n'.format(img, part)
for _bin in bin_map.keys():
AddImageOnly(info, '{}.bin'.format(_bin), incremental, True)
for part in bin_map[_bin]:
fw_cmd += 'package_extract_file("{}.bin", "/dev/block/platform/bootdevice/by-name/{}");\n'.format(_bin, part)
info.script.AppendExtra(fw_cmd)