11import os
2+ import shutil
3+ import gzip
24from datetime import date
35
46def genOtaBin (path ):
@@ -24,6 +26,11 @@ def genOtaBin(path):
2426 with open (path + "ota.bin" , "wb" ) as f :
2527 f .write (bytearray (arr ))
2628
29+ # write gzip firmware file
30+ def gzip_bin (bin_file , gzip_file ):
31+ with open (bin_file ,"rb" ) as fp :
32+ with gzip .open (gzip_file , "wb" , compresslevel = 9 ) as f :
33+ shutil .copyfileobj (fp , f )
2734
2835def readVersion (path , infile ):
2936 f = open (path + infile , "r" )
@@ -48,16 +55,19 @@ def readVersion(path, infile):
4855 src = path + ".pio/build/esp8266-release/firmware.bin"
4956 dst = path + "firmware/" + versionout
5057 os .rename (src , dst )
58+ gzip_bin (dst , dst + ".gz" )
5159
5260 versionout = version [:- 1 ] + "_esp8266_1m_" + sha + ".bin"
5361 src = path + ".pio/build/esp8285-release/firmware.bin"
5462 dst = path + "firmware/" + versionout
5563 os .rename (src , dst )
64+ gzip_bin (dst , dst + ".gz" )
5665
5766 versionout = version [:- 1 ] + "_esp32_" + sha + ".bin"
5867 src = path + ".pio/build/esp32-wroom32-release/firmware.bin"
5968 dst = path + "firmware/" + versionout
6069 os .rename (src , dst )
70+ gzip_bin (dst , dst + ".gz" )
6171
6272 # other ESP32 bin files
6373 src = path + ".pio/build/esp32-wroom32-release/"
0 commit comments