|
1
|
|
|
#!/usr/bin/env python3 |
|
2
|
5 |
|
"""This module is used for creation of TCL autoloaders.""" |
|
3
|
|
|
|
|
4
|
5 |
|
import os # path work |
|
5
|
5 |
|
import shutil # file copying |
|
6
|
|
|
|
|
7
|
5 |
|
from bbarchivist import bbconstants # versions/constants |
|
8
|
|
|
|
|
9
|
5 |
|
__author__ = "Thurask" |
|
10
|
5 |
|
__license__ = "WTFPL v2" |
|
11
|
5 |
|
__copyright__ = "2018 Thurask" |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
5 |
|
def point_point_copy(inpath, outpath, filename): |
|
15
|
|
|
""" |
|
16
|
|
|
Copy a file from one absolute path to another. |
|
17
|
|
|
|
|
18
|
|
|
:param inpath: Input path. |
|
19
|
|
|
:type inpath: str |
|
20
|
|
|
|
|
21
|
|
|
:param outpath: Output path. |
|
22
|
|
|
:type outpath: str |
|
23
|
|
|
|
|
24
|
|
|
:param filename: Filename. |
|
25
|
|
|
:type filename: str |
|
26
|
|
|
""" |
|
27
|
5 |
|
shutil.copy(os.path.join(inpath, filename), os.path.join(outpath, filename)) |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
5 |
|
def point_point_bulk(inpath, outpath, files): |
|
31
|
|
|
""" |
|
32
|
|
|
Copy a list of files from one absolute path to another. |
|
33
|
|
|
|
|
34
|
|
|
:param inpath: Input path. |
|
35
|
|
|
:type inpath: str |
|
36
|
|
|
|
|
37
|
|
|
:param outpath: Output path. |
|
38
|
|
|
:type outpath: str |
|
39
|
|
|
|
|
40
|
|
|
:param files: List of filenames. |
|
41
|
|
|
:type files: list(str) |
|
42
|
|
|
""" |
|
43
|
5 |
|
for file in files: |
|
44
|
5 |
|
point_point_copy(inpath, outpath, file) |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
5 |
|
def generate_tclloader_script(dirname, batchfile, shfile, wipe=True): |
|
48
|
|
|
""" |
|
49
|
|
|
Copy script files from site-packages to loader directory. |
|
50
|
|
|
|
|
51
|
|
|
:param dirname: Name for final directory and loader. |
|
52
|
|
|
:type dirname: str |
|
53
|
|
|
|
|
54
|
|
|
:param batchfile: Path to flashall.bat. |
|
55
|
|
|
:type batchfile: str |
|
56
|
|
|
|
|
57
|
|
|
:param shfile: Path to flashall.sh. |
|
58
|
|
|
:type shfile: str |
|
59
|
|
|
|
|
60
|
|
|
:param wipe: If the final loader wipes userdata. Default is True. |
|
61
|
|
|
:type wipe: bool |
|
62
|
|
|
""" |
|
63
|
5 |
|
shutil.copy(batchfile, os.path.join(dirname, "flashall.bat")) |
|
64
|
5 |
|
shutil.copy(shfile, os.path.join(dirname, "flashall.sh")) |
|
65
|
5 |
|
if not wipe: |
|
66
|
5 |
|
tclloader_nowipe(os.path.join(dirname, "flashall.bat")) |
|
67
|
5 |
|
tclloader_nowipe(os.path.join(dirname, "flashall.sh")) |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
5 |
|
def tclloader_nowipe(infile): |
|
71
|
|
|
""" |
|
72
|
|
|
Modify a script file to strike references to wiping the phone. |
|
73
|
|
|
|
|
74
|
|
|
:param infile: Path to script file to modify. |
|
75
|
|
|
:type infile: str |
|
76
|
|
|
""" |
|
77
|
5 |
|
filterout = ("oem securewipe", "flash userdata") |
|
78
|
5 |
|
with open(infile, "r+", newline="") as afile: |
|
79
|
5 |
|
content = afile.read() |
|
80
|
5 |
|
afile.seek(0) |
|
81
|
5 |
|
for line in content.split("\n"): |
|
82
|
5 |
|
if not any(part in line for part in filterout): |
|
83
|
5 |
|
afile.write(line + "\n") |
|
84
|
5 |
|
afile.truncate() |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
5 |
|
def generate_google_host(hostin, hostout): |
|
88
|
|
|
""" |
|
89
|
|
|
Generate host directory from Google platform tools, i.e. fastboot. |
|
90
|
|
|
|
|
91
|
|
|
:param hostin: Directory containing files to copy. |
|
92
|
|
|
:type hostin: str |
|
93
|
|
|
|
|
94
|
|
|
:param hostout: Directory that files are to be copied to. |
|
95
|
|
|
:type hostout: str |
|
96
|
|
|
""" |
|
97
|
5 |
|
platforms = ["linux", "windows", "darwin"] |
|
98
|
5 |
|
inouts = {os.path.join(hostin, plat, "platform-tools"): os.path.join(hostout, "{0}-x86".format(plat), "bin") for plat in platforms} |
|
99
|
5 |
|
for infile, outfile in inouts.items(): |
|
100
|
5 |
|
shutil.copytree(infile, outfile) |
|
101
|
|
|
|
|
102
|
|
|
|
|
103
|
5 |
|
def generate_tclloader_host(hostin, hostout): |
|
104
|
|
|
""" |
|
105
|
|
|
Generate host directory from autoloader template, i.e. fastboot. |
|
106
|
|
|
|
|
107
|
|
|
:param hostin: Directory containing files to copy. |
|
108
|
|
|
:type hostin: str |
|
109
|
|
|
|
|
110
|
|
|
:param hostout: Directory that files are to be copied to. |
|
111
|
|
|
:type hostout: str |
|
112
|
|
|
""" |
|
113
|
5 |
|
os.makedirs(os.path.join(hostout, "darwin-x86", "bin")) |
|
114
|
5 |
|
os.makedirs(os.path.join(hostout, "linux-x86", "bin")) |
|
115
|
5 |
|
os.makedirs(os.path.join(hostout, "windows-x86", "bin")) |
|
116
|
5 |
|
macfile = os.path.join("darwin-x86", "bin", "fastboot") |
|
117
|
5 |
|
linfile = os.path.join("linux-x86", "bin", "fastboot") |
|
118
|
5 |
|
winx = ["AdbWinApi.dll", "AdbWinUsbApi.dll", "fastboot.exe"] |
|
119
|
5 |
|
winfiles = [os.path.join("windows-x86", "bin", x) for x in winx] |
|
120
|
5 |
|
winfiles.extend([linfile, macfile]) |
|
121
|
5 |
|
point_point_bulk(hostin, hostout, winfiles) |
|
122
|
|
|
|
|
123
|
|
|
|
|
124
|
5 |
|
def generate_tclloader_sig(sigin, sigout): |
|
125
|
|
|
""" |
|
126
|
|
|
Generate common signature files. |
|
127
|
|
|
|
|
128
|
|
|
:param sigin: Directory containing files to copy. |
|
129
|
|
|
:type sigin: str |
|
130
|
|
|
|
|
131
|
|
|
:param sigout: Directory that files are to be copied to. |
|
132
|
|
|
:type sigout: str |
|
133
|
|
|
""" |
|
134
|
5 |
|
for entry in ["boot", "recovery"]: |
|
135
|
5 |
|
shutil.copy(os.path.join(sigin, "{0}.img.production.sig".format(entry)), os.path.join(sigout, "{0}.img.sig".format(entry))) |
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
5 |
|
def generate_tclloader_csig(sigin, sigout, carrier): |
|
139
|
|
|
""" |
|
140
|
|
|
Generate carrier variant signature files. |
|
141
|
|
|
|
|
142
|
|
|
:param sigin: Directory containing files to copy. |
|
143
|
|
|
:type sigin: str |
|
144
|
|
|
|
|
145
|
|
|
:param sigout: Directory that files are to be copied to. |
|
146
|
|
|
:type sigout: str |
|
147
|
|
|
|
|
148
|
|
|
:param carrier: Carrier to check: att, sprint, china, vzw |
|
149
|
|
|
:type carrier: str |
|
150
|
|
|
""" |
|
151
|
5 |
|
for entry in ["boot", "recovery"]: |
|
152
|
5 |
|
shutil.copy(os.path.join(sigin, "{1}.img.production-{0}.sig".format(carrier, entry)), os.path.join(sigout, "{1}.img{0}.sig".format(carrier, entry))) |
|
153
|
|
|
|
|
154
|
|
|
|
|
155
|
5 |
|
def generate_tclloader_carriers(sigin, sigout): |
|
156
|
|
|
""" |
|
157
|
|
|
Collect carrier variant signature files. |
|
158
|
|
|
|
|
159
|
|
|
:param sigin: Directory containing files to copy. |
|
160
|
|
|
:type sigin: str |
|
161
|
|
|
|
|
162
|
|
|
:param sigout: Directory that files are to be copied to. |
|
163
|
|
|
:type sigout: str |
|
164
|
|
|
""" |
|
165
|
5 |
|
prods = set(x.split("-")[-1].split(".")[0] for x in os.listdir(sigin) if "production-" in x) - {"boot", "recovery"} |
|
166
|
5 |
|
if prods: |
|
167
|
5 |
|
generate_tclloader_carriter(sigin, sigout, prods) |
|
168
|
|
|
|
|
169
|
|
|
|
|
170
|
5 |
|
def generate_tclloader_carriter(sigin, sigout, prods): |
|
171
|
|
|
""" |
|
172
|
|
|
Iterate carrier variant signature files. |
|
173
|
|
|
|
|
174
|
|
|
:param sigin: Directory containing files to copy. |
|
175
|
|
|
:type sigin: str |
|
176
|
|
|
|
|
177
|
|
|
:param sigout: Directory that files are to be copied to. |
|
178
|
|
|
:type sigout: str |
|
179
|
|
|
|
|
180
|
|
|
:param prods: Set of carriers. |
|
181
|
|
|
:type prods: set(str) |
|
182
|
|
|
""" |
|
183
|
5 |
|
for carr in prods: |
|
184
|
5 |
|
generate_tclloader_csig(sigin, sigout, carr) |
|
185
|
|
|
|
|
186
|
|
|
|
|
187
|
5 |
|
def generate_tclloader_mbn(mbnin, mbnout, platform): |
|
188
|
|
|
""" |
|
189
|
|
|
Generate mbn files. |
|
190
|
|
|
|
|
191
|
|
|
:param mbnin: Directory containing files to copy. |
|
192
|
|
|
:type mbnin: str |
|
193
|
|
|
|
|
194
|
|
|
:param mbnout: Directory that files are to be copied to. |
|
195
|
|
|
:type mbnout: str |
|
196
|
|
|
|
|
197
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
198
|
|
|
:type platform: str |
|
199
|
|
|
""" |
|
200
|
5 |
|
files = generate_tclloader_platmbn(platform) |
|
201
|
5 |
|
point_point_bulk(mbnin, mbnout, files) |
|
202
|
|
|
|
|
203
|
|
|
|
|
204
|
5 |
|
def generate_tclloader_omniset(omnin, omnilist, prefix, suffix, filt): |
|
205
|
|
|
""" |
|
206
|
|
|
Generic function to generate sets. |
|
207
|
|
|
|
|
208
|
|
|
:param omnin: Directory containing files to copy. |
|
209
|
|
|
:type omnin: str |
|
210
|
|
|
|
|
211
|
|
|
:param omnilist: List of variants. |
|
212
|
|
|
:type omnilist: list(str) |
|
213
|
|
|
|
|
214
|
|
|
:param prefix: Prefix, before items in list. |
|
215
|
|
|
:type prefix: str |
|
216
|
|
|
|
|
217
|
|
|
:param suffix: Suffix, after items in list. |
|
218
|
|
|
:type suffix: str |
|
219
|
|
|
|
|
220
|
|
|
:param filt: Filter, required to pick file out of directory listing. |
|
221
|
|
|
:type filt: str |
|
222
|
|
|
""" |
|
223
|
5 |
|
omfiles = set(os.path.join(omnin, "{1}{0}{2}".format(omni, prefix, suffix)) for omni in omnilist) |
|
224
|
5 |
|
infiles = set(os.path.join(omnin, filex) for filex in os.listdir(omnin) if filt in filex) |
|
225
|
5 |
|
return omfiles, infiles |
|
226
|
|
|
|
|
227
|
|
|
|
|
228
|
5 |
|
def generate_tclloader_oemset(oemin, oems): |
|
229
|
|
|
""" |
|
230
|
|
|
Generate sets for OEM variants. |
|
231
|
|
|
|
|
232
|
|
|
:param oemin: Directory containing files to copy. |
|
233
|
|
|
:type oemin: str |
|
234
|
|
|
|
|
235
|
|
|
:param oems: List of OEM variants. |
|
236
|
|
|
:type oems: list(str) |
|
237
|
|
|
""" |
|
238
|
5 |
|
ofiles, infiles = generate_tclloader_omniset(oemin, oems, "", ".img", "oem_") |
|
239
|
5 |
|
return ofiles, infiles |
|
240
|
|
|
|
|
241
|
|
|
|
|
242
|
5 |
|
def generate_tclloader_oemfilt(oemin, oems): |
|
243
|
|
|
""" |
|
244
|
|
|
Filter non-existent OEM variants. |
|
245
|
|
|
|
|
246
|
|
|
:param oemin: Directory containing files to copy. |
|
247
|
|
|
:type oemin: str |
|
248
|
|
|
|
|
249
|
|
|
:param oems: List of OEM variants. |
|
250
|
|
|
:type oems: list(str) |
|
251
|
|
|
""" |
|
252
|
5 |
|
ofiles, infiles = generate_tclloader_oemset(oemin, oems) |
|
253
|
5 |
|
coll = [os.path.basename(oemf).replace(".img", "") for oemf in ofiles - infiles] |
|
254
|
5 |
|
oems = [oemp for oemp in oems if oemp not in coll] |
|
255
|
5 |
|
return oems |
|
256
|
|
|
|
|
257
|
|
|
|
|
258
|
5 |
|
def generate_tclloader_radset(radin, rads): |
|
259
|
|
|
""" |
|
260
|
|
|
Generate sets for radio variants. |
|
261
|
|
|
|
|
262
|
|
|
:param radin: Directory containing files to copy. |
|
263
|
|
|
:type radin: str |
|
264
|
|
|
|
|
265
|
|
|
:param rads: List of radio variants. |
|
266
|
|
|
:type rads: list(str) |
|
267
|
|
|
""" |
|
268
|
5 |
|
rfiles, infiles = generate_tclloader_omniset(radin, rads, "NON-HLOS-", ".bin", "NON-HLOS-") |
|
269
|
5 |
|
return rfiles, infiles |
|
270
|
|
|
|
|
271
|
|
|
|
|
272
|
5 |
|
def generate_tclloader_radfilt(radin, rads): |
|
273
|
|
|
""" |
|
274
|
|
|
Filter non-existent radio variants. |
|
275
|
|
|
|
|
276
|
|
|
:param radin: Directory containing files to copy. |
|
277
|
|
|
:type radin: str |
|
278
|
|
|
|
|
279
|
|
|
:param rads: List of radio variants. |
|
280
|
|
|
:type rads: list(str) |
|
281
|
|
|
""" |
|
282
|
5 |
|
rfiles, infiles = generate_tclloader_radset(radin, rads) |
|
283
|
5 |
|
coll = [os.path.basename(radf).replace(".bin", "").replace("NON-HLOS-", "") for radf in rfiles - infiles] |
|
284
|
5 |
|
rads = [radp for radp in rads if radp not in coll] |
|
285
|
5 |
|
return rads |
|
286
|
|
|
|
|
287
|
|
|
|
|
288
|
5 |
|
def generate_tclloader_deps(platform): |
|
289
|
|
|
""" |
|
290
|
|
|
Generate platform-specific file names. |
|
291
|
|
|
|
|
292
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
293
|
|
|
:type platform: str |
|
294
|
|
|
""" |
|
295
|
5 |
|
if platform == "bbry_qc8953": # KEYone |
|
296
|
5 |
|
oems = ["oem_att", "oem_china", "oem_common", "oem_sprint", "oem_vzw", "oem_indonesia", "oem_russia"] |
|
297
|
5 |
|
radios = ["china", "dschina", "emea", "global", "india", "japan", "usa"] |
|
298
|
5 |
|
elif platform == "bbry_qc8953krypton": # Motion |
|
299
|
5 |
|
oems = ["oem_att", "oem_common", "oem_sprint", "oem_russia"] |
|
300
|
5 |
|
radios = ["americas", "cdma", "dscn", "dsglobal", "ssglobal"] |
|
301
|
5 |
|
elif platform == "bbry_sdm660": # KEY2 |
|
302
|
5 |
|
oems = ["oem_att", "oem_china", "oem_common", "oem_india", "oem_indonesia", "oem_sprint", "oem_russia"] |
|
303
|
5 |
|
radios = ["americas", "cn", "dsglobal", "dsjapan", "global", "japan"] |
|
304
|
5 |
|
return oems, radios |
|
305
|
|
|
|
|
306
|
|
|
|
|
307
|
5 |
|
def generate_tclloader_looseends(imgout, platform): |
|
308
|
|
|
""" |
|
309
|
|
|
Handle files that need to be handled. |
|
310
|
|
|
|
|
311
|
|
|
:param imgout: Directory that files are to be copied to. |
|
312
|
|
|
:type imgout: str |
|
313
|
|
|
|
|
314
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
315
|
|
|
:type platform: str |
|
316
|
|
|
""" |
|
317
|
5 |
|
if platform == "bbry_qc8953": # KEYone |
|
318
|
5 |
|
pass # no special exceptions |
|
319
|
5 |
|
elif platform == "bbry_qc8953krypton": # Motion |
|
320
|
5 |
|
looseends_krypton(imgout) |
|
321
|
5 |
|
elif platform == "bbry_sdm660": # KEY2 |
|
322
|
5 |
|
pass # TODO: KEY2 autoloader |
|
|
|
|
|
|
323
|
|
|
|
|
324
|
|
|
|
|
325
|
5 |
|
def looseends_krypton(imgout): |
|
326
|
|
|
""" |
|
327
|
|
|
Handle files that need to be handled, for the Motion platform. |
|
328
|
|
|
|
|
329
|
|
|
:param imgout: Directory that files are to be copied to. |
|
330
|
|
|
:type imgout: str |
|
331
|
|
|
""" |
|
332
|
5 |
|
oldglobal = os.path.join(imgout, "NON-HLOS-ssglobal.bin") |
|
333
|
5 |
|
newglobal = os.path.join(imgout, "NON-HLOS-global.bin") |
|
334
|
5 |
|
os.rename(oldglobal, newglobal) # SS intl model has different name than modem |
|
335
|
5 |
|
oldamericas = os.path.join(imgout, "NON-HLOS-americas.bin") |
|
336
|
5 |
|
newamericas = os.path.join(imgout, "NON-HLOS-dsamericas.bin") |
|
337
|
5 |
|
shutil.copy(oldamericas, newamericas) # DS/SS americas model use same modem |
|
338
|
|
|
|
|
339
|
|
|
|
|
340
|
5 |
|
def generate_tclloader_platimg(platform): |
|
341
|
|
|
""" |
|
342
|
|
|
Generate platform-specific .img files. |
|
343
|
|
|
|
|
344
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
345
|
|
|
:type platform: str |
|
346
|
|
|
""" |
|
347
|
5 |
|
imgs = ["recovery", "system", "userdata", "cache", "boot"] |
|
348
|
5 |
|
if "bbry_sdm660" in platform: |
|
349
|
5 |
|
imgs.append("vendor") |
|
350
|
5 |
|
return imgs |
|
351
|
|
|
|
|
352
|
|
|
|
|
353
|
5 |
|
def generate_tclloader_platmbn(platform): |
|
354
|
|
|
""" |
|
355
|
|
|
Generate platform-specific MBN files. |
|
356
|
|
|
|
|
357
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
358
|
|
|
:type platform: str |
|
359
|
|
|
""" |
|
360
|
5 |
|
if "bbry_sdm660" in platform: |
|
361
|
5 |
|
mbnx = ["devcfg.mbn", "pmic.elf", "xbl.elf", "rpm.mbn", "tz.mbn"] |
|
362
|
5 |
|
mbny = ["hyp.signed.mbn", "cmnlib.signed.mbn", "cmnlib64.signed.mbn", "keymaster64.signed.mbn", "mdtpsecapp.signed.mbn"] |
|
363
|
5 |
|
mbnz = [os.path.join("MBNs", mbn) for mbn in mbny] |
|
364
|
5 |
|
mbns = mbnx + mbnz |
|
365
|
5 |
|
elif "bbry_qc8953" in platform: |
|
366
|
5 |
|
mbns = ["devcfg.mbn", "devcfg_cn.mbn", "rpm.mbn", "tz.mbn"] |
|
367
|
|
|
else: |
|
368
|
5 |
|
mbns = [None] |
|
369
|
5 |
|
return mbns |
|
370
|
|
|
|
|
371
|
|
|
|
|
372
|
5 |
|
def generate_tclloader_platother(platform): |
|
373
|
|
|
""" |
|
374
|
|
|
Generate platform-specific other files. |
|
375
|
|
|
|
|
376
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
377
|
|
|
:type platform: str |
|
378
|
|
|
""" |
|
379
|
5 |
|
if "bbry_sdm660" in platform: |
|
380
|
5 |
|
others = ["dspso.bin", "BTFM.bin", "abl.elf"] |
|
381
|
5 |
|
elif "bbry_qc8953" in platform: |
|
382
|
5 |
|
others = ["adspso.bin", "emmc_appsboot.mbn", "sbl1_signed.mbn"] |
|
383
|
|
|
else: |
|
384
|
5 |
|
others = [None] |
|
385
|
5 |
|
return others |
|
386
|
|
|
|
|
387
|
|
|
|
|
388
|
5 |
|
def generate_tclloader_img(imgin, imgout, platform): |
|
389
|
|
|
""" |
|
390
|
|
|
Generate partition images and radios. |
|
391
|
|
|
|
|
392
|
|
|
:param imgin: Directory containing files to copy. |
|
393
|
|
|
:type imgin: str |
|
394
|
|
|
|
|
395
|
|
|
:param imgout: Directory that files are to be copied to. |
|
396
|
|
|
:type imgout: str |
|
397
|
|
|
|
|
398
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
399
|
|
|
:type platform: str |
|
400
|
|
|
""" |
|
401
|
5 |
|
imgs = generate_tclloader_platimg(platform) |
|
402
|
5 |
|
point_point_bulk(imgin, imgout, ["{0}.img".format(img) for img in imgs]) |
|
403
|
5 |
|
oems, radios = generate_tclloader_deps(platform) |
|
404
|
5 |
|
oems = generate_tclloader_oemfilt(imgin, oems) |
|
405
|
5 |
|
point_point_bulk(imgin, imgout, ["{0}.img".format(oem) for oem in oems]) |
|
406
|
5 |
|
radios = generate_tclloader_radfilt(imgin, radios) |
|
407
|
5 |
|
point_point_bulk(imgin, imgout, ["NON-HLOS-{0}.bin".format(rad) for rad in radios]) |
|
408
|
5 |
|
others = generate_tclloader_platother(platform) |
|
409
|
5 |
|
point_point_bulk(imgin, imgout, others) |
|
410
|
5 |
|
generate_tclloader_looseends(imgout, platform) |
|
411
|
|
|
|
|
412
|
|
|
|
|
413
|
5 |
|
def generate_tclloader_scripttype(platform): |
|
414
|
|
|
""" |
|
415
|
|
|
Get the right scripts for the right platform. |
|
416
|
|
|
|
|
417
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
418
|
|
|
:type platform: str |
|
419
|
|
|
""" |
|
420
|
5 |
|
if "bbry_sdm660" in platform: |
|
421
|
5 |
|
scripts = (bbconstants.FLASHBATBBF.location, bbconstants.FLASHSHBBF.location) |
|
422
|
5 |
|
elif "bbry_qc8953" in platform: |
|
423
|
5 |
|
scripts = (bbconstants.FLASHBAT.location, bbconstants.FLASHSH.location) |
|
424
|
|
|
else: |
|
425
|
5 |
|
scripts = (None, None) |
|
426
|
5 |
|
return scripts |
|
427
|
|
|
|
|
428
|
|
|
|
|
429
|
5 |
|
def generate_tclloader(localdir, dirname, platform, localtools=False, wipe=True): |
|
430
|
|
|
""" |
|
431
|
|
|
Generate Android loader from extracted template files. |
|
432
|
|
|
|
|
433
|
|
|
:param localdir: Directory containing extracted template files. |
|
434
|
|
|
:type localdir: str |
|
435
|
|
|
|
|
436
|
|
|
:param dirname: Name for final directory and loader. |
|
437
|
|
|
:type dirname: str |
|
438
|
|
|
|
|
439
|
|
|
:param platform: Platform type (i.e. subdirectory of target/product). |
|
440
|
|
|
:type platform: str |
|
441
|
|
|
|
|
442
|
|
|
:param localtools: If host files will be copied from a template rather than a download. Default is False. |
|
443
|
|
|
:type localtools: bool |
|
444
|
|
|
|
|
445
|
|
|
:param wipe: If the final loader wipes userdata. Default is True. |
|
446
|
|
|
:type wipe: bool |
|
447
|
|
|
""" |
|
448
|
5 |
|
if not os.path.exists(dirname): |
|
449
|
5 |
|
os.makedirs(dirname) |
|
450
|
5 |
|
hostdir = os.path.join(dirname, "host") |
|
451
|
5 |
|
os.makedirs(hostdir) |
|
452
|
5 |
|
imgdir = os.path.join(dirname, "img") |
|
453
|
5 |
|
os.makedirs(imgdir) |
|
454
|
5 |
|
platscripts = generate_tclloader_scripttype(platform) |
|
455
|
5 |
|
generate_tclloader_script(dirname, platscripts[0], platscripts[1], wipe) |
|
456
|
5 |
|
if localtools: |
|
457
|
5 |
|
hdir = os.path.join(localdir, "host") |
|
458
|
5 |
|
generate_tclloader_host(hdir, hostdir) |
|
459
|
|
|
else: |
|
460
|
5 |
|
platdir = "plattools" |
|
461
|
5 |
|
generate_google_host(platdir, hostdir) |
|
462
|
5 |
|
pdir = os.path.join(localdir, "target", "product", platform) |
|
463
|
5 |
|
generate_tclloader_img(pdir, imgdir, platform) |
|
464
|
5 |
|
sdir = os.path.join(pdir, "sig") |
|
465
|
5 |
|
generate_tclloader_sig(sdir, imgdir) |
|
466
|
5 |
|
generate_tclloader_carriers(sdir, imgdir) |
|
467
|
5 |
|
qdir = os.path.join(pdir, "qcbc") |
|
468
|
|
|
generate_tclloader_mbn(qdir, imgdir, platform) |
|
469
|
|
|
|