* add ha_addons repository to cscode workspace * Issue220 ha addon dokumentation update (#232) * initial DOCS.md for Addon * links to Mosquitto and Adguard * replaced _ by . for PV-Strings * mentioned add-on installation method in README.md * fix most of the markdown linter warnings * add missing alt texts * added nice add repository to my Home Assistant badges --------- Co-authored-by: Michael Metz <michael.metz@siemens.com> Co-authored-by: Stefan Allius <stefan.allius@t-online.de> * S allius/issue216 (#235) * improve docker run - establish multistage Dockerfile - build a python wheel for all needed packages - remove unneeded tools like apk for runtime * pin versions, fix hadolint warnings * merge from dev-0.12 --------- Co-authored-by: Michael Metz <michael.metz@siemens.com> * Issue220 ha addon dokumentation update (#245) * revised config disclaimer * add newline at end of file to fix linter warning --------- Co-authored-by: Michael Metz <michael.metz@siemens.com> * 238 ha addon repository check (#244) * move Makefile and bake file into parent folder * build config.yaml from template * use Makefile instead of build shell script * ignore temporary or created files * add rules for building the add-on repository * add rel version of add-on * add jinja2-cli * ignore inverter replays which a older than 1 day (#246) * S allius/issue7 (#248) * report alarm and fault bitfield to ha * define the alarm and fault names * configure log path and max number of daily log files (#243) * configure log path and max number of daily log files * don't use a subfolder for configs * use make instead of a build script * mount /homeassistant/tsun-proxy * Add venv to base image * give write access to mounted folder * intial checkin, ignore SC1091 * set advanced and stage value in config.yaml * fix typo * added watchdog and removed Port 8127 from mapping * fixed typo and use new add-on repro - change the install button to install from https://github.com/s-allius/ha-addons * add addon-rel target * disable watchdog due to exceptions in the ha supervisor * update changelog --------- Co-authored-by: Michael Metz <michael.metz@siemens.com> * Update README.md (#251) install `https://github.com/s-allius/ha-addons` as repro for our add-on * add german language file (#253) * fix return type get_extra_info in FakeWriter * move global startup code into main methdod * pin version of base image * avoid forwarding to a private (lokal) IP addr (#256) * avoid forwarding to a private (lokal) IP addr * test DNS resolver issues * increase test coverage * update changelog * fix client_mode configuration block (#252) * fix client_mode block * add client mode * fix tests with client_mode values * log client_mode configuration * add forward flag for client_mode * improve startup logging * added client_mode example * adjusted translation files * AT commands added * typo * missing "PLUS" * link to config details * improve log msg for config problems * improve log msg on config errors * improve log msg for config problems * copy CHANGELOG.md into add-on repro --------- Co-authored-by: Michael Metz <michael.metz@siemens.com> * rename "ConfigErr" to match naming convention * disable test coverage for __main__ * update changelog version 0.12 --------- Co-authored-by: metzi <147942647+mime24@users.noreply.github.com> Co-authored-by: Michael Metz <michael.metz@siemens.com>
137 lines
3.9 KiB
Makefile
137 lines
3.9 KiB
Makefile
#!make
|
|
include ../.env
|
|
|
|
.PHONY: debug dev build clean rootfs repro rc rel
|
|
|
|
SHELL = /bin/sh
|
|
JINJA = jinja2
|
|
IMAGE = tsun-gen3-addon
|
|
|
|
|
|
# Folders
|
|
SRC=../app
|
|
SRC_PROXY=$(SRC)/src
|
|
CNF_PROXY=$(SRC)/config
|
|
|
|
ADDON_PATH = ha_addon
|
|
DST=$(ADDON_PATH)/rootfs
|
|
DST_PROXY=$(DST)/home/proxy
|
|
|
|
INST_BASE=../../ha-addons/ha-addons
|
|
|
|
TEMPL=templates
|
|
|
|
# collect source files
|
|
SRC_FILES := $(wildcard $(SRC_PROXY)/*.py)\
|
|
$(wildcard $(SRC_PROXY)/*.ini)\
|
|
$(wildcard $(SRC_PROXY)/cnf/*.py)\
|
|
$(wildcard $(SRC_PROXY)/gen3/*.py)\
|
|
$(wildcard $(SRC_PROXY)/gen3plus/*.py)
|
|
CNF_FILES := $(wildcard $(CNF_PROXY)/*.toml)
|
|
|
|
# determine destination files
|
|
TARGET_FILES = $(SRC_FILES:$(SRC_PROXY)/%=$(DST_PROXY)/%)
|
|
CONFIG_FILES = $(CNF_FILES:$(CNF_PROXY)/%=$(DST_PROXY)/%)
|
|
|
|
export BUILD_DATE := ${shell date -Iminutes}
|
|
VERSION := $(shell cat $(SRC)/.version)
|
|
export MAJOR := $(shell echo $(VERSION) | cut -f1 -d.)
|
|
|
|
PUBLIC_URL := $(shell echo $(PUBLIC_CONTAINER_REGISTRY) | cut -f1 -d/)
|
|
PUBLIC_USER :=$(shell echo $(PUBLIC_CONTAINER_REGISTRY) | cut -f2 -d/)
|
|
|
|
|
|
dev debug: build
|
|
@echo version: $(VERSION) build-date: $(BUILD_DATE) image: $(PRIVAT_CONTAINER_REGISTRY)$(IMAGE)
|
|
export VERSION=$(VERSION)-$@ && \
|
|
export IMAGE=$(PRIVAT_CONTAINER_REGISTRY)$(IMAGE) && \
|
|
docker buildx bake -f docker-bake.hcl $@
|
|
|
|
rc rel: build
|
|
@echo version: $(VERSION) build-date: $(BUILD_DATE) image: $(PUBLIC_CONTAINER_REGISTRY)$(IMAGE)
|
|
@echo login at $(PUBLIC_URL) as $(PUBLIC_USER)
|
|
@DO_LOGIN="$(shell echo $(PUBLIC_CR_KEY) | docker login $(PUBLIC_URL) -u $(PUBLIC_USER) --password-stdin)"
|
|
export VERSION=$(VERSION)-$@ && \
|
|
export IMAGE=$(PUBLIC_CONTAINER_REGISTRY)$(IMAGE) && \
|
|
docker buildx bake -f docker-bake.hcl $@
|
|
|
|
|
|
build: rootfs $(ADDON_PATH)/config.yaml repro
|
|
|
|
clean:
|
|
rm -r -f $(DST_PROXY)
|
|
rm -f $(DST)/requirements.txt
|
|
rm -f $(ADDON_PATH)/config.yaml
|
|
rm -f $(TEMPL)/.data.json
|
|
|
|
#
|
|
# Build rootfs and config.yaml as local add-on
|
|
# The rootfs is needed to build the add-on Dockercontainers
|
|
#
|
|
|
|
rootfs: $(TARGET_FILES) $(CONFIG_FILES) $(DST)/requirements.txt
|
|
|
|
STAGE=dev
|
|
debug : STAGE=debug
|
|
rc : STAGE=rc
|
|
rel : STAGE=rel
|
|
|
|
$(CONFIG_FILES): $(DST_PROXY)/% : $(CNF_PROXY)/%
|
|
@echo Copy $< to $@
|
|
@mkdir -p $(@D)
|
|
@cp $< $@
|
|
|
|
$(TARGET_FILES): $(DST_PROXY)/% : $(SRC_PROXY)/%
|
|
@echo Copy $< to $@
|
|
@mkdir -p $(@D)
|
|
@cp $< $@
|
|
|
|
$(DST)/requirements.txt : $(SRC)/requirements.txt
|
|
@echo Copy $< to $@
|
|
@cp $< $@
|
|
|
|
$(ADDON_PATH)/%.yaml: $(TEMPL)/%.jinja $(TEMPL)/.data.json
|
|
$(JINJA) --strict --format=json $^ -o $@
|
|
|
|
$(TEMPL)/.data.json: FORCE
|
|
rsync --checksum $(TEMPL)/$(STAGE)_data.json $@
|
|
|
|
FORCE : ;
|
|
|
|
|
|
#
|
|
# Build repository for Home Assistant Add-On
|
|
#
|
|
|
|
INST=$(INST_BASE)/ha_addon_dev
|
|
repro_files = DOCS.md icon.png logo.png translations/de.yaml translations/en.yaml
|
|
repro_root = CHANGELOG.md
|
|
repro_templates = config.yaml
|
|
repro_subdirs = translations
|
|
repro_vers = debug dev rel
|
|
|
|
repro_all_files := $(foreach dir,$(repro_vers), $(foreach file,$(repro_files),$(INST_BASE)/ha_addon_$(dir)/$(file)))
|
|
repro_root_files := $(foreach dir,$(repro_vers), $(foreach file,$(repro_root),$(INST_BASE)/ha_addon_$(dir)/$(file)))
|
|
repro_all_templates := $(foreach dir,$(repro_vers), $(foreach file,$(repro_templates),$(INST_BASE)/ha_addon_$(dir)/$(file)))
|
|
repro_all_subdirs := $(foreach dir,$(repro_vers), $(foreach file,$(repro_subdirs),$(INST_BASE)/ha_addon_$(dir)/$(file)))
|
|
|
|
repro: $(repro_all_subdirs) $(repro_all_templates) $(repro_all_files) $(repro_root_files)
|
|
|
|
$(repro_all_subdirs) :
|
|
mkdir -p $@
|
|
|
|
$(repro_all_templates) : $(INST_BASE)/ha_addon_%/config.yaml: $(TEMPL)/config.jinja $(TEMPL)/%_data.json $(SRC)/.version
|
|
$(JINJA) --strict -D AppVersion=$(VERSION) $< $(filter %.json,$^) -o $@
|
|
|
|
$(repro_root_files) : %/CHANGELOG.md : ../CHANGELOG.md
|
|
cp $< $@
|
|
|
|
$(filter $(INST_BASE)/ha_addon_debug/%,$(repro_all_files)) : $(INST_BASE)/ha_addon_debug/% : ha_addon/%
|
|
cp $< $@
|
|
$(filter $(INST_BASE)/ha_addon_dev/%,$(repro_all_files)) : $(INST_BASE)/ha_addon_dev/% : ha_addon/%
|
|
cp $< $@
|
|
$(filter $(INST_BASE)/ha_addon_rel/%,$(repro_all_files)) : $(INST_BASE)/ha_addon_rel/% : ha_addon/%
|
|
cp $< $@
|
|
|
|
|