forked from LineageOS/android_device_htc_flounder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
releasetools.py
51 lines (47 loc) · 2.01 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
import common
import hashlib
import struct
def GetImageEdifyScript(zip, partition, filename):
file_size = zip.getinfo("RADIO/%s" % filename).file_size
sha1 = hashlib.sha1()
sha1.update(zip.read("RADIO/%s" % filename))
return ('ifelse((sha1_check(read_file("EMMC:%s:%d:%s")) != ""),'
'(ui_print("%s already up to date")),'
'(package_extract_file("%s", "%s")));'
% (partition, file_size, sha1.hexdigest(), partition, filename, partition))
def FullOTA_InstallEnd(info):
try:
firmware_img = info.input_zip.read("RADIO/bootloader.img")
except KeyError:
print "no bootloader.img in target_files; skipping install"
else:
info.script.Print("Writing bootloader.img...")
common.ZipWriteStr(info.output_zip, "bootloader.img", firmware_img)
info.script.AppendExtra(GetImageEdifyScript(info.input_zip,
"/dev/block/platform/sdhci-tegra.3/by-name/OTA", "bootloader.img"));
try:
vendor_img = info.input_zip.read("RADIO/vendor.img")
except KeyError:
print "no vendor.img in target_files; skipping install"
else:
info.script.Print("Writing vendor.img...")
common.ZipWriteStr(info.output_zip, "vendor.img", vendor_img)
info.script.AppendExtra(GetImageEdifyScript(info.input_zip,
"/dev/block/platform/sdhci-tegra.3/by-name/VNR", "vendor.img"));
def IncrementalOTA_InstallEnd(info):
try:
source_firmware_img = info.source_zip.read("RADIO/bootloader.img")
except KeyError:
print "no bootloader.img in source_files; skipping install"
else:
try:
target_firmware_img = info.target_zip.read("RADIO/bootloader.img")
except KeyError:
print "no bootloader.img in target_files; skipping install"
else:
if source_firmware_img == target_firmware_img:
return
info.script.Print("Writing bootloader.img...")
common.ZipWriteStr(info.output_zip, "bootloader.img", target_firmware_img)
info.script.AppendExtra(
'package_extract_file("bootloader.img", "/dev/block/platform/sdhci-tegra.3/by-name/OTA");')