本文針對python3更新, 並解決上次博客中的一些問題. 參考MIUI9線刷包精簡: https://blog.csdn.net/zhuyu4839/article/details/77979255
1. md5文件更新直接使用: flash_gen_md5_list.py, 此文件更新內容:
刪除第31行: file = os.path.join(path, file)或者在前面加#
2. crc校驗文件生成, 使用: flash_gen_crc_list.py
更新110行左右(不同機型線刷包的該文件可能不一樣, 後面不贅述):
for i in xrange(1,total_chunks+1):
爲:
for i in range(1,total_chunks+1):
更新180行左右:
try:
爲:
with open(sparsecrclist, 'w') as fs, open(crclist, 'w') as f:
更新第203行左右# need get the sparsecount之後的三行:
cmdarg = './flash_gen_resparsecount' + ' -S ' + str(max_download_size) + ' ' + filepath
cmd = os.path.join(thispath, cmdarg)
count = get_sparse_count(cmd)
爲:
count = size // max_download_size
if size % max_download_size > 0:
count += 1 #注意這行比上一行多縮進4個空格
倒數四行刪除或者在前面加#
except Exception as e:
os.remove(crclist)
os.remove(sparsecrclist)
raise
安裝好python3並關聯py文件直接雙擊運行即可自動生成crclist.txt和sparsecrclist.txt文件.
注: 原線刷包flash_gen_crc_list.py文件運行需要依賴flash_gen_resparsecount(此文件爲Linux下可執行文件), 按此方法更新後解決.