params = utils.processMmc(line) if params: # if params["action"] == "create": # nothing here if params["action"] == "write.boot": outputFile = utils.generateFileName(outputDirectory, params, ".img") utils.copyPart(inputFile, outputFile, int(offset, 16), int(size, 16)) print( "[i] Partition: {}\tOffset: {}\tSize {} ({}) -> {}".format( params["partition_name"], offset, size, utils.sizeStr(int(size, 16)), outputFile)) if params["action"] == "write.p": outputFile = os.path.join(outputDirectory, params["partition_name"] + ".img") utils.copyPart(inputFile, outputFile, int(offset, 16), int(size, 16)) print( "[i] Partition: {}\tOffset: {}\tSize {} ({}) -> {}".format( params["partition_name"], offset, size, utils.sizeStr(int(size, 16)), outputFile)) if params["action"] == "write.p.continue": outputFile = os.path.join(outputDirectory, params["partition_name"] + ".img") utils.copyPart(inputFile,
offset = params["offset"] size = params["size"] if re.match("^sparse_write", line): line = utils.applyEnv(line, env) params = utils.processSparseWrite(line) if params: if params["flash_type"] == "mmc": if not params["partition_name"] in counter: counter[params["partition_name"]] = 0 counter[params["partition_name"]] += 1 outputChunkSimgFile = os.path.join(outputDirectory, params["partition_name"] + str(counter[params["partition_name"]]) + ".simg") print ("[i] Partition: {}\tOffset: {}\tSize {} ({}) -> {}".format(params["partition_name"], offset, size, utils.sizeStr(int(size, 16)), outputChunkSimgFile)) utils.copyPart(inputFile, outputChunkSimgFile, int(offset, 16), int(size, 16)) if params["partition_name"] == "system": systemFiles.append(outputChunkSimgFile) if params["partition_name"] == "vendor": vendorFiles.append(outputChunkSimgFile) # delete chunk #os.remove(outputChunkSimgFile) #os.remove(outputChunkImgFile) if re.match("^%", line): print("the last line! systemParts: {} vendorParts: {}".format(counter["system"],counter["vendor"])) if counter["system"] > 0: infiles = "" for fname in systemFiles: