-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathreleasetools.py
101 lines (90 loc) · 3.39 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright (C) 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Emit extra commands needed for Group during OTA installation
(installing the bootloader)."""
import struct
import common
def WriteCapsule(info):
info.script.AppendExtra('package_extract_file("capsule.bin", "/tmp/capsule.bin");')
info.script.AppendExtra("""flash_capsule("/tmp/capsule.bin");""")
def WriteEspUpdate(info):
info.script.AppendExtra('package_extract_file("esp.zip", "/tmp/esp.zip");')
info.script.AppendExtra("""flash_esp_update("/tmp/esp.zip");""")
def WriteDroidboot(info):
info.script.WriteRawImage("/fastboot", "droidboot.img")
def FullOTA_InstallEnd(info):
try:
capsule = info.input_zip.read("RADIO/capsule.bin")
except KeyError:
print "no capsule in target_files; skipping install"
else:
common.ZipWriteStr(info.output_zip, "capsule.bin", capsule)
WriteCapsule(info)
try:
esp = info.input_zip.read("RADIO/esp.zip")
except KeyError:
print "no esp in target_files; skipping install"
else:
common.ZipWriteStr(info.output_zip, "esp.zip", esp)
WriteEspUpdate(info)
try:
droidboot_img = info.input_zip.read("RADIO/droidboot.img")
except KeyError:
print "no droidboot.img in target_files; skipping install"
else:
common.ZipWriteStr(info.output_zip, "droidboot.img", droidboot_img)
WriteDroidboot(info)
def IncrementalOTA_InstallEnd(info):
try:
target_capsule = info.target_zip.read("RADIO/capsule.bin")
try:
source_capsule = info.source_zip.read("RADIO/capsule.bin")
except KeyError:
source_capsule = None
if source_capsule == target_capsule:
print "capsule unchanged; skipping"
else:
print "capsule changed; adding it"
common.ZipWriteStr(info.output_zip, "capsule.bin", target_capsule)
WriteCapsule(info)
except KeyError:
print "no capsule in target target_files; skipping install"
try:
target_esp = info.target_zip.read("RADIO/esp.zip")
try:
source_esp = info.source_zip.read("RADIO/esp.zip")
except KeyError:
source_esp = None
if source_esp == target_esp:
print "esp unchanged; skipping"
else:
print "esp changed; adding it"
common.ZipWriteStr(info.output_zip, "esp.zip", target_esp)
WriteEspUpdate(info)
except KeyError:
print "no esp in target target_files; skipping install"
try:
target_droidboot_img = info.target_zip.read("RADIO/droidboot.img")
try:
source_droidboot_img = info.source_zip.read("RADIO/droidboot.img")
except KeyError:
source_droidboot_img = None
if source_droidboot_img == target_droidboot_img:
print "droidboot unchanged; skipping"
else:
print "droidboot changed; adding it"
common.ZipWriteStr(info.output_zip, "droidboot.img", target_droidboot_img)
WriteDroidboot(info)
except KeyError:
print "no droidboot in target target_files; skipping install"