mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-07 14:15:53 +02:00
Merge pull request #467 from sVnsation/ota-gzip
compress firmware bin with gzip for ota
This commit is contained in:
commit
34d6791522
1 changed files with 10 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
import gzip
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
def genOtaBin(path):
|
def genOtaBin(path):
|
||||||
|
@ -24,6 +26,11 @@ def genOtaBin(path):
|
||||||
with open(path + "ota.bin", "wb") as f:
|
with open(path + "ota.bin", "wb") as f:
|
||||||
f.write(bytearray(arr))
|
f.write(bytearray(arr))
|
||||||
|
|
||||||
|
# write gzip firmware file
|
||||||
|
def gzip_bin(bin_file, gzip_file):
|
||||||
|
with open(bin_file,"rb") as fp:
|
||||||
|
with gzip.open(gzip_file, "wb", compresslevel = 9) as f:
|
||||||
|
shutil.copyfileobj(fp, f)
|
||||||
|
|
||||||
def readVersion(path, infile):
|
def readVersion(path, infile):
|
||||||
f = open(path + infile, "r")
|
f = open(path + infile, "r")
|
||||||
|
@ -48,16 +55,19 @@ def readVersion(path, infile):
|
||||||
src = path + ".pio/build/esp8266-release/firmware.bin"
|
src = path + ".pio/build/esp8266-release/firmware.bin"
|
||||||
dst = path + "firmware/" + versionout
|
dst = path + "firmware/" + versionout
|
||||||
os.rename(src, dst)
|
os.rename(src, dst)
|
||||||
|
gzip_bin(dst, dst + ".gz")
|
||||||
|
|
||||||
versionout = version[:-1] + "_esp8266_1m_" + sha + ".bin"
|
versionout = version[:-1] + "_esp8266_1m_" + sha + ".bin"
|
||||||
src = path + ".pio/build/esp8285-release/firmware.bin"
|
src = path + ".pio/build/esp8285-release/firmware.bin"
|
||||||
dst = path + "firmware/" + versionout
|
dst = path + "firmware/" + versionout
|
||||||
os.rename(src, dst)
|
os.rename(src, dst)
|
||||||
|
gzip_bin(dst, dst + ".gz")
|
||||||
|
|
||||||
versionout = version[:-1] + "_esp32_" + sha + ".bin"
|
versionout = version[:-1] + "_esp32_" + sha + ".bin"
|
||||||
src = path + ".pio/build/esp32-wroom32-release/firmware.bin"
|
src = path + ".pio/build/esp32-wroom32-release/firmware.bin"
|
||||||
dst = path + "firmware/" + versionout
|
dst = path + "firmware/" + versionout
|
||||||
os.rename(src, dst)
|
os.rename(src, dst)
|
||||||
|
gzip_bin(dst, dst + ".gz")
|
||||||
|
|
||||||
# other ESP32 bin files
|
# other ESP32 bin files
|
||||||
src = path + ".pio/build/esp32-wroom32-release/"
|
src = path + ".pio/build/esp32-wroom32-release/"
|
||||||
|
|
Loading…
Add table
Reference in a new issue