DL9SAU-TTGO-T-Beam-LoRa-APRS/tools/buildscript_versioning.py

65 wiersze
1.8 KiB
Python
Czysty Zwykły widok Historia

2021-02-18 16:59:18 +00:00
FILENAME_BUILDNO = '.pio/versioning'
FILENAME_VERSION_H = 'include/version.h'
2021-03-24 19:42:14 +00:00
version = 'v0.3.'
2021-02-18 16:59:18 +00:00
import datetime
2021-04-20 15:25:22 +00:00
from subprocess import *
2021-02-18 16:59:18 +00:00
build_no = 0
try:
with open(FILENAME_BUILDNO) as f:
build_no = int(f.readline()) + 1
except:
print('Starting build number from 1..')
build_no = 1
with open(FILENAME_BUILDNO, 'w+') as f:
f.write(str(build_no))
print('Build number: {}'.format(build_no))
2021-04-20 15:25:22 +00:00
version_full = version + str(build_no)
try:
git_id = Popen('git rev-parse --short HEAD', stdout=PIPE, shell=True).stdout.read().strip().decode('ascii')
version_full = "%s-%s" % (version_full, git_id)
except:
local aprsis-filter, bugfix, vers_xxshort_bn, no gif 1.1 local aprsis-filter 1.1 Filter type (local, optional) Local aprsis-filter incoming for packet-types. We observed that if you have a server-site filter, i.e. for receive private messages only, 20km around you (t/m/MYCALL/20), aprsis sends also some location positions of users (if you heard them on RF), and even if \>20km away. Also we have seen packets of type objects telemetry, etc. With this option, you can filter incoming aprsis-packets localy in order to prevent them from gating to RF. Valid filters are poimqstunwb (Position packets, objects, items, message, query, status, telemetry, user-defined, NWS, weather, bulletin (bulletins are aprs-messages prefixed with BLN'). You can invert the filter ('all except ...') by adding a leading '-', i.e. '-mws'. If you leave this field empty, aprsis local filter is disabled. => [-]poimqstunwb 1.2 Filter 'words' (local, optional) Local aprsis-filter incoming for 'words': if this word is part of the header or message body of a packet coming from aprsis, the packet is filtered out. You can sepearate multiple word-filters by space. Leave empty to disable a word filter. Many thanks go to Tomasz SP2ATJ for this idea and nice discussions and intensively testing. 2. bugfix During "save" of the config via web-interface, we call setup_phase2_soft_reconfiguration() String Tcall is changed. OledHdr had a reference to Tcall. OledHdr needs to be updated. Else there's a very rare race condition (only observed one time in 3 years) where writedisplaytext(OledHdr,OledLine1,OledLine2,OledLine3,OledLine4,OledLine5); crashed during accessing OledHdr. OledHdr = String(Tcall); sould make a local copy. OledLines1-5 are also set explicit to "" now. 3. VERS_XXSHORT_BN buildscript_versioning.py generates BUILD_NUMBER, VERSION, VERSION_SHORT, etc. We compute the build_nr with base62 (0-9, a-z, A-Z) This gives us room for (62**2)-1 = 3843 builds between git commits. Should be enough. git_id short is 7 bytes. length of 5 has hopefully enough entropy. VERS_XXSHORT_BN may also be sent on RF -> We keep it short. 8 bytes now, (5 bytes git id, 2 bytes base62-encoded build_no) instead of typically 3 bytes before. Why we need both? 1. git-id: you can determine which was the git head when you checked out, and what has changed since then 2. During developmment / testing, build-nr increases each compiler run - but the git id only changes after git push. build_no helps you to distinguish, which version of a compler run you currently use. VERSION had a date resolution of 1 microsecond. -> now cutting string after the minute value. 4. style.css I decided to remove the #logo ("background-image"), which is a base64- encoded inline gif. We need space for the flash, because the code reached 100% of it's size!! If we have a solution, the logo comes back. Other options: - don't compile with -DENABLE_SYSLOG, or the like - re-partition. Other firmmware-developers did this. But I'm a bit sceptical to do this. Signed-off-by: Thomas Osterried <dl9sau@darc.de>
2024-03-17 04:42:21 +00:00
#git_id = "0000000"
git_id = "No_GIT.."
2021-04-20 15:25:22 +00:00
pass
local aprsis-filter, bugfix, vers_xxshort_bn, no gif 1.1 local aprsis-filter 1.1 Filter type (local, optional) Local aprsis-filter incoming for packet-types. We observed that if you have a server-site filter, i.e. for receive private messages only, 20km around you (t/m/MYCALL/20), aprsis sends also some location positions of users (if you heard them on RF), and even if \>20km away. Also we have seen packets of type objects telemetry, etc. With this option, you can filter incoming aprsis-packets localy in order to prevent them from gating to RF. Valid filters are poimqstunwb (Position packets, objects, items, message, query, status, telemetry, user-defined, NWS, weather, bulletin (bulletins are aprs-messages prefixed with BLN'). You can invert the filter ('all except ...') by adding a leading '-', i.e. '-mws'. If you leave this field empty, aprsis local filter is disabled. => [-]poimqstunwb 1.2 Filter 'words' (local, optional) Local aprsis-filter incoming for 'words': if this word is part of the header or message body of a packet coming from aprsis, the packet is filtered out. You can sepearate multiple word-filters by space. Leave empty to disable a word filter. Many thanks go to Tomasz SP2ATJ for this idea and nice discussions and intensively testing. 2. bugfix During "save" of the config via web-interface, we call setup_phase2_soft_reconfiguration() String Tcall is changed. OledHdr had a reference to Tcall. OledHdr needs to be updated. Else there's a very rare race condition (only observed one time in 3 years) where writedisplaytext(OledHdr,OledLine1,OledLine2,OledLine3,OledLine4,OledLine5); crashed during accessing OledHdr. OledHdr = String(Tcall); sould make a local copy. OledLines1-5 are also set explicit to "" now. 3. VERS_XXSHORT_BN buildscript_versioning.py generates BUILD_NUMBER, VERSION, VERSION_SHORT, etc. We compute the build_nr with base62 (0-9, a-z, A-Z) This gives us room for (62**2)-1 = 3843 builds between git commits. Should be enough. git_id short is 7 bytes. length of 5 has hopefully enough entropy. VERS_XXSHORT_BN may also be sent on RF -> We keep it short. 8 bytes now, (5 bytes git id, 2 bytes base62-encoded build_no) instead of typically 3 bytes before. Why we need both? 1. git-id: you can determine which was the git head when you checked out, and what has changed since then 2. During developmment / testing, build-nr increases each compiler run - but the git id only changes after git push. build_no helps you to distinguish, which version of a compler run you currently use. VERSION had a date resolution of 1 microsecond. -> now cutting string after the minute value. 4. style.css I decided to remove the #logo ("background-image"), which is a base64- encoded inline gif. We need space for the flash, because the code reached 100% of it's size!! If we have a solution, the logo comes back. Other options: - don't compile with -DENABLE_SYSLOG, or the like - re-partition. Other firmmware-developers did this. But I'm a bit sceptical to do this. Signed-off-by: Thomas Osterried <dl9sau@darc.de>
2024-03-17 04:42:21 +00:00
date_now = "%.16s" % datetime.datetime.now()
version_string = "{} - {}".format(version_full, date_now)
# dl9sau: build_no in base62 -> base62 (0-9, a-z, A-Z)
# This gives us room for (62**2)-1 = 3843 builds between git commits. Should be enough
# git_id: length of 5 has hopefully enough entropy.
# VERS_XXSHORT_BN may also be sent on RF -> We keep it short. 8 bytes now, instead of typically 3 bytes before.
s="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
bnA=s[(int(build_no / len(s))) % len(s)]
bnB=s[build_no % len(s)]
vers_xxshort_bn="%.5s.%c%c" % (git_id, bnA, bnB)
2021-02-18 16:59:18 +00:00
hf = """
#ifndef BUILD_NUMBER
#define BUILD_NUMBER "{}"
#endif
#ifndef VERSION
#define VERSION "{}"
#endif
#ifndef VERSION_SHORT
#define VERSION_SHORT "{}"
#endif
local aprsis-filter, bugfix, vers_xxshort_bn, no gif 1.1 local aprsis-filter 1.1 Filter type (local, optional) Local aprsis-filter incoming for packet-types. We observed that if you have a server-site filter, i.e. for receive private messages only, 20km around you (t/m/MYCALL/20), aprsis sends also some location positions of users (if you heard them on RF), and even if \>20km away. Also we have seen packets of type objects telemetry, etc. With this option, you can filter incoming aprsis-packets localy in order to prevent them from gating to RF. Valid filters are poimqstunwb (Position packets, objects, items, message, query, status, telemetry, user-defined, NWS, weather, bulletin (bulletins are aprs-messages prefixed with BLN'). You can invert the filter ('all except ...') by adding a leading '-', i.e. '-mws'. If you leave this field empty, aprsis local filter is disabled. => [-]poimqstunwb 1.2 Filter 'words' (local, optional) Local aprsis-filter incoming for 'words': if this word is part of the header or message body of a packet coming from aprsis, the packet is filtered out. You can sepearate multiple word-filters by space. Leave empty to disable a word filter. Many thanks go to Tomasz SP2ATJ for this idea and nice discussions and intensively testing. 2. bugfix During "save" of the config via web-interface, we call setup_phase2_soft_reconfiguration() String Tcall is changed. OledHdr had a reference to Tcall. OledHdr needs to be updated. Else there's a very rare race condition (only observed one time in 3 years) where writedisplaytext(OledHdr,OledLine1,OledLine2,OledLine3,OledLine4,OledLine5); crashed during accessing OledHdr. OledHdr = String(Tcall); sould make a local copy. OledLines1-5 are also set explicit to "" now. 3. VERS_XXSHORT_BN buildscript_versioning.py generates BUILD_NUMBER, VERSION, VERSION_SHORT, etc. We compute the build_nr with base62 (0-9, a-z, A-Z) This gives us room for (62**2)-1 = 3843 builds between git commits. Should be enough. git_id short is 7 bytes. length of 5 has hopefully enough entropy. VERS_XXSHORT_BN may also be sent on RF -> We keep it short. 8 bytes now, (5 bytes git id, 2 bytes base62-encoded build_no) instead of typically 3 bytes before. Why we need both? 1. git-id: you can determine which was the git head when you checked out, and what has changed since then 2. During developmment / testing, build-nr increases each compiler run - but the git id only changes after git push. build_no helps you to distinguish, which version of a compler run you currently use. VERSION had a date resolution of 1 microsecond. -> now cutting string after the minute value. 4. style.css I decided to remove the #logo ("background-image"), which is a base64- encoded inline gif. We need space for the flash, because the code reached 100% of it's size!! If we have a solution, the logo comes back. Other options: - don't compile with -DENABLE_SYSLOG, or the like - re-partition. Other firmmware-developers did this. But I'm a bit sceptical to do this. Signed-off-by: Thomas Osterried <dl9sau@darc.de>
2024-03-17 04:42:21 +00:00
#ifndef VERS_XXSHORT_BN
#define VERS_XXSHORT_BN "{}"
#endif
""".format(build_no, version_string, version_full, vers_xxshort_bn)
2021-02-18 16:59:18 +00:00
with open(FILENAME_VERSION_H, 'w+') as f:
f.write(hf)
with open("data_embed/index.html", "r") as f:
index_html_content = f.read()
index_html_content = index_html_content.replace('<!--VERSION-->', version_string)
with open("data_embed/index.html.out", "w") as f:
f.write(index_html_content)