This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
131 lines (106 loc) · 3.77 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
DOCKER_NAME := c4dt/byzcoin
NAME := c4dt
DOW := $(shell date +%a)
# On Monday, get today's date. On all other days of the week, get last
# Monday's date
ifeq '$(DOW)' 'Mon'
DATE_COMPILE := $(shell date +%Y%m%d)
DATE_PREVIOUS := $(shell date --date "last Monday" +%Y%m%d || \
date -v Mon -v -7d %Y%m%d)
else
# mac date doesn't know about --date argument...
DATE_COMPILE := $(shell date --date "last Monday" +%Y%m%d || \
date -v Mon +%Y%m%d)
DATE_PREVIOUS := $(shell date --date "Monday a fortnight ago" +%Y%m%d || \
date -v Mon -v -7d +%Y%m%d)
endif
DOCKER_TAG = $(DATE_COMPILE)
LATEST_COMMIT = g$(shell git rev-parse --short HEAD)
BINARY_VERSION = $(NAME)-$(DATE_COMPILE)-$(LATEST_COMMIT)
# -s -w are for smaller binaries
# -X compiles the git tag into the binary
ldflags=-s -w -X main.gitTag=$(BINARY_VERSION)
print:
echo $(DOW)
echo $(DATE_COMPILE)
upstream:
mkdir upstream
upstream/cothority:
git clone https://github.com/dedis/cothority --depth 1 upstream/cothority
cd upstream/cothority && \
for d in $$(cat upstream_commits); do \
git fetch origin $$d && \
git cherry-pick $$d; \
done
upstream/onet:
git clone https://github.com/dedis/onet --depth 1 upstream/onet
upstream-update: upstream upstream/cothority upstream/onet
( cd upstream/cothority; git pull )
( cd upstream/onet; git pull )
.PHONY: pkg-clean pkg-update pkg-patch
pkg-clean:
rm -rf pkg
pkg-update: pkg-clean
mkdir -p pkg
for a in $$( cat pkg.files ); do \
echo "Copying files $$a"; \
d=pkg/$$( dirname $$a ); \
mkdir -p $$d; \
cp -a `eval echo upstream/$$a` $$d; \
done
cp -av pkg.base/* pkg
printf "\nreplace go.dedis.ch/onet/v3 => ../onet\n" >> pkg/cothority/go.mod
pkg-patch: BCA = pkg/cothority/byzcoin/bcadmin/main.go
pkg-patch:
sed -i.bak '/v3.eventlog/d' $(BCA)
sed -i.bak 's.v3/personhood.v3/personhood/contracts.' $(BCA)
rm $(BCA).bak
.PHONY: update test
update: upstream-update pkg-update pkg-patch
test:
cd cmd/byzcoin && ./test.sh -b
docker/byzcoin: cmd/byzcoin/main.go cmd/full/main.go $(shell find pkg)
docker run --rm -v "$$PWD":/usr/src/myapp \
-v "$$PWD"/.godocker:/go \
-w /usr/src/myapp golang:1.15 \
sh -c "go build -ldflags='$(ldflags)' ./cmd/byzcoin; \
go build -ldflags='$(ldflags)' ./cmd/full; \
cd pkg/cothority; go build -ldflags='$(ldflags)' ./byzcoin/bcadmin; \
go build -ldflags='$(ldflags)' ./personhood/phapp; \
cd scmgr; go build -ldflags='$(ldflags)' ."
mv pkg/cothority/bcadmin pkg/cothority/scmgr/scmgr pkg/cothority/phapp $(@D)
mv full docker
mv byzcoin $@
docker/built: docker/byzcoin.sh docker/Dockerfile docker/byzcoin
touch $@
.PHONY: docker docker-push-new docker-push-dow docker-push-all
docker: docker/built
docker build -t $(DOCKER_NAME):$(DOCKER_TAG) docker
docker-push-new: docker
for t in $(DOCKER_TAG) latest Mon; do \
docker tag $(DOCKER_NAME):$(DOCKER_TAG) $(DOCKER_NAME):$$t; \
docker push $(DOCKER_NAME):$$t; \
done
docker-push-dow:
docker pull $(DOCKER_NAME):$(DOCKER_TAG)
docker tag $(DOCKER_NAME):$(DOCKER_TAG) $(DOCKER_NAME):$(DOW)
docker push $(DOCKER_NAME):$(DOW)
docker-push-all: DATE_COMPILE := $(shell date +%Y%m%d-%H%M)
docker-push-all: NAME := force
docker-push-all: docker
docker push $(DOCKER_NAME):$(DOCKER_TAG)
@for d in Sun Mon Tue Wed Thu Fri Sat; do \
echo "Creating docker-image for $$d"; \
docker tag $(DOCKER_NAME):$(DOCKER_TAG) $(DOCKER_NAME):$$d; \
docker push $(DOCKER_NAME):$$d; \
done
docker-push-dbg: DATE_COMPILE := $(shell date +%Y%m%d-%H%M)
docker-push-dbg: NAME := dbg
docker-push-dbg: docker
docker tag $(DOCKER_NAME):$(DOCKER_TAG) $(DOCKER_NAME):$(NAME)
docker push $(DOCKER_NAME):$(NAME)
verify_latest: LATEST=$(DOCKER_NAME):$(DOCKER_TAG)
verify_latest: PREVIOUS=$(DOCKER_NAME):$(DATE_PREVIOUS)
verify_latest: docker
docker pull $(PREVIOUS)
./update_test.sh $(PREVIOUS) $(LATEST)