[DEV] create end point binary for windows OK

This commit is contained in:
Edouard DUPIN 2015-04-22 23:58:32 +02:00
parent a40a25dba5
commit 8a654def1b

View File

@ -81,25 +81,41 @@ class Target(lutinTarget.Target):
finalBin = self.get_final_folder() + "/" + pkgName + self.suffix_binary finalBin = self.get_final_folder() + "/" + pkgName + self.suffix_binary
tools.create_directory_of_file(finalBin); tools.create_directory_of_file(finalBin);
debug.print_element("pkg", finalBin, "<==", pkgName + self.suffix_binary) debug.print_element("pkg", finalBin, "<==", pkgName + self.suffix_binary)
#open output file
tmpFile = open(finalBin, 'wb') tmpFile = open(finalBin, 'wb')
# read all executable binary
dataExecutable = tools.file_read_data(binPath, binary=True) dataExecutable = tools.file_read_data(binPath, binary=True)
# wrte binary to the output
tmpFile.write(dataExecutable) tmpFile.write(dataExecutable)
residualToAllign = len(dataExecutable) - int(len(dataExecutable)/32)*32 #align data in the 32 Bytes position (prevent zip align error)
for iii in range(1,residualToAllign): residualToAllign = 32 + 32 - (len(dataExecutable) - int(len(dataExecutable)/32)*32)
tmpFile.write(b'j'); for iii in range(0,residualToAllign):
tmpFile.write(b'\0');
positionOfZip = len(dataExecutable) + residualToAllign; positionOfZip = len(dataExecutable) + residualToAllign;
# write a control TAG
tmpFile.write(b'***START DATA***');
# write all the zip file
debug.print_element("pkg", finalBin, "<==", "data.zip") debug.print_element("pkg", finalBin, "<==", "data.zip")
dataData = tools.file_read_data(zipPath, binary=True) dataData = tools.file_read_data(zipPath, binary=True)
tmpFile.write(dataData) tmpFile.write(dataData)
#align data in the 32 Bytes position (to be fun"
tmpLen = len(dataData) + positionOfZip tmpLen = len(dataData) + positionOfZip
residualToAllign = tmpLen - int(tmpLen/32)*32 residualToAllign = 32 + 32 - (tmpLen - int(tmpLen/32)*32)
for iii in range(1,residualToAllign): for iii in range(0,residualToAllign):
tmpFile.write(b'j'); tmpFile.write(b'\0');
tmpFile.write(bin(positionOfZip)) # write a control TAG
tmpFile.write(b'*** END DATA ***');
# reserved AREA (can be use later for extra value ...)
for iii in range(0,8):
tmpFile.write(b'\0');
# write the position of the zip file (TAG position)
h = '{0:016x}'.format(positionOfZip)
s = ('0'*(len(h) % 2) + h).decode('hex')
tmpFile.write(s)
# package is done
tmpFile.flush() tmpFile.flush()
tmpFile.close() tmpFile.close()
debug.info("zip position=" + str(positionOfZip)) debug.verbose("zip position=" + str(positionOfZip) + " = 0x" + h)
def install_package(self, pkgName): def install_package(self, pkgName):
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")