forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
201 lines (155 loc) · 6.08 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# build vars
TAG_NAME := $(shell test -d .git && git describe --abbrev=0 --tags upstream/master)_mm
SHA := $(shell test -d .git && git rev-parse --short HEAD)
COMMIT := $(SHA)
# hide commit for releases
ifeq ($(RELEASE),1)
COMMIT :=
endif
VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA))
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
BUILD_TAGS := -tags=release
TESLA_CLIENT_ID := ${TESLA_CLIENT_ID}
LD_FLAGS := -X github.com/evcc-io/evcc/server.Version=$(VERSION) -X github.com/evcc-io/evcc/server.Commit=$(COMMIT) -X github.com/evcc-io/evcc/vehicle/tesla-vehicle-command.TESLA_CLIENT_ID=$(TESLA_CLIENT_ID) -s -w
BUILD_ARGS := -trimpath -ldflags='$(LD_FLAGS)'
# docker
DOCKER_IMAGE := evcc/evcc
PLATFORM := linux/amd64,linux/arm64,linux/arm/v6
# gokrazy image
IMAGE_FILE := evcc_$(TAG_NAME).image
IMAGE_OPTIONS := -hostname evcc -http_port 8080 github.com/gokrazy/serial-busybox github.com/gokrazy/breakglass github.com/gokrazy/mkfs github.com/gokrazy/wifi github.com/evcc-io/evcc
# deb
PACKAGES = ./release
# asn1-patch
GOROOT := $(shell go env GOROOT)
CURRDIR := $(shell pwd)
default:: ui build
all:: clean install install-ui ui assets lint test-ui lint-ui test build
clean::
rm -rf dist/
install::
go install $$(go list -e -f '{{join .Imports " "}}' tools.go)
install-ui::
npm ci
ui::
npm run build
assets::
go generate ./...
docs::
go generate github.com/evcc-io/evcc/util/templates/...
lint::
golangci-lint run
lint-ui::
npm run lint
test-ui::
npm test
toml::
go run packaging/toml.go
test::
@echo "Running testsuite"
CGO_ENABLED=0 go test $(BUILD_TAGS) ./...
porcelain::
gofmt -w -l $$(find . -name '*.go')
go mod tidy
test -z "$$(git status --porcelain)" || (git status; git diff; false)
build::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
CGO_ENABLED=0 go build -v $(BUILD_TAGS) $(BUILD_ARGS)
snapshot::
goreleaser --snapshot --skip-publish --clean
release::
goreleaser --clean
docker::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
docker buildx build --platform $(PLATFORM) --tag $(DOCKER_IMAGE):testing .
publish-testing::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
docker buildx build --platform $(PLATFORM) --tag $(DOCKER_IMAGE):testing --push .
publish-nightly::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
docker buildx build --platform $(PLATFORM) --tag $(DOCKER_IMAGE):nightly --push .
publish-release::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
docker buildx build --build-arg RELEASE=1 --platform $(PLATFORM) --tag $(DOCKER_IMAGE):latest --tag $(DOCKER_IMAGE):$(VERSION) --push .
apt-nightly::
$(foreach file, $(wildcard $(PACKAGES)/*.deb), \
cloudsmith push deb evcc/unstable/any-distro/any-version $(file); \
)
apt-release::
$(foreach file, $(wildcard $(PACKAGES)/*.deb), \
cloudsmith push deb evcc/stable/any-distro/any-version $(file); \
)
# gokrazy image
gokrazy::
go install github.com/gokrazy/tools/cmd/gokr-packer@main
mkdir -p flags/github.com/gokrazy/breakglass
echo "-forward=private-network" > flags/github.com/gokrazy/breakglass/flags.txt
mkdir -p env/github.com/evcc-io/evcc
echo "EVCC_NETWORK_PORT=80" > env/github.com/evcc-io/evcc/env.txt
echo "EVCC_DATABASE_DSN=/perm/evcc.db" >> env/github.com/evcc-io/evcc/env.txt
mkdir -p buildflags/github.com/evcc-io/evcc
echo "$(BUILD_TAGS),gokrazy" > buildflags/github.com/evcc-io/evcc/buildflags.txt
echo "-ldflags=$(LD_FLAGS)" >> buildflags/github.com/evcc-io/evcc/buildflags.txt
gokr-packer -hostname evcc -http_port 8080 -overwrite=$(IMAGE_FILE) -target_storage_bytes=1258299392 $(IMAGE_OPTIONS)
# gzip -f $(IMAGE_FILE)
gokrazy-run::
MACHINE=arm64 IMAGE_FILE=$(IMAGE_FILE) ./packaging/gokrazy/run.sh
gokrazy-update::
gokr-packer -update yes $(IMAGE_OPTIONS)
soc::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
go build $(BUILD_TAGS) $(BUILD_ARGS) github.com/evcc-io/evcc/cmd/soc
raspberrypi:
@echo Version: $(VERSION) $(BUILD_DATE)
# mm make all without tests
make clean install install-ui ui assets build
# make mac version
mv evcc evcc_mac
# make raspberry version
env GOOS=linux GOARCH=arm go build -v $(BUILD_TAGS) $(BUILD_ARGS)
# copy new evcc to raspberry
scp -3 -B -C -l 163840 evcc pi@raspberrypi:~/bin/evcc_new
# prepare restart of service
# ssh pi@raspberrypi 'sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"; sudo chmod 0755 ~/bin/evcc_new;'
ssh pi@raspberrypi 'sudo chmod 0755 ~/bin/evcc_new;'
# rename new/old evcc and restart already running service
# mm skip until solution for tesla : ssh pi@raspberrypi 'mv ~/bin/evcc ~/bin/evcc_prev; mv ~/bin/evcc_new ~/bin/evcc; sudo systemctl restart evcc.service;'
sync-with-andig-and-deploy:
# show commits in browser
open https://github.com/evcc-io/evcc/commits/master
@echo "Proceed with build? (Y|n)"
@read line; if [ "$$line" != "Y" ]; then echo aborting; exit 1 ; fi
@echo building...
# following may show error if remote upstream alread configured
# git remote add upstream https://github.com/andig/evcc.git
# show github remote streams
git remote -v
# get new changes
git fetch upstream
# local branch
git checkout master
# get changes
git merge upstream/master --no-edit --no-commit
go mod vendor
# build and deploy
make raspberrypi
# delete dist folder changes
git restore dist
git clean -d -f dist
# push new files
git add -A
git commit -am "merge with evcc upstream"
git push origin master
# update sync detection file
ssh pi@raspberrypi 'sudo echo -1 > ~/etc/check_fork.state'
# patch asn1.go to allow Elli buggy certificates to be accepted with EEBUS
patch-asn1-sudo:
# echo $(GOROOT)
cat $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
sudo patch -N -t -d $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte -i $(CURRDIR)/packaging/patch/asn1.diff
cat $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
patch-asn1::
# echo $(GOROOT)
cat $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
patch -N -t -d $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte -i $(CURRDIR)/packaging/patch/asn1.diff
cat $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"