-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·211 lines (191 loc) · 6.37 KB
/
build.sh
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
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
## Hello!
## This is a bash script which builds rio, repeatr, and the other components of the Timeless Stack,
## and assembles an omnibus tarball containing all those lovely things.
##
## It's both how we release, and a pretty good demo of using repeatr :)
##
## Identical results should be produced by using the 'module.tl' file
## via the `reach emerge` command in this directory.
## We're keeping both build paths around because this one is a neat demo
## of how to use the APIs!
##
## You need repeatr and rio on your $PATH in order to run this script.
## Download one of the omnibus tarballs to bootstrap.
## (You can also build them from source individually if you like;
## their individual build instructions are in their respective git repos.)
##
## Note: we're currently only building for linux-amd64, sorry :( PRs welcome!!
## Todo: also bundle r2k8s... etc...
##
set -euo pipefail
mkdir -p .memo
export REPEATR_MEMODIR=".memo"
BASE_IMG_HASH="tar:6q7G4hWr283FpTa5Lf8heVqw9t97b5VoMU6AGszuBYAz9EzQdeHVFAou7c4W9vFcQ6"
BASE_IMG_URL="ca+https://repeatr.s3.amazonaws.com/warehouse/"
GO_COMPILER_HASH="tar:3SbM6Wy1SpEKxAsEGrdTBLx8L3jHWUsLfASWAjHaT1Tc8294ok3fKnobgYKdVaHs6c"
GO_COMPILER_URL="https://storage.googleapis.com/golang/go1.11.linux-amd64.tar.gz"
RIO_SRC_HASH="git:4fef789ffc851aaf3ac291a91c21e477e6367811"
RIO_SRC_URL="https://github.com/polydawn/rio"
REPEATR_PLUGIN_RUNC_HASH="tar:9ZaF8VyS4kiVThF3gxFGKVpb3df7wE4vqgTdWFXG5KnQJdYScbjtDsCfxNvQbw6JiB"
REPEATR_PLUGIN_RUNC_URL="ca+https://repeatr.s3.amazonaws.com/warehouse/"
REPEATR_SRC_HASH="git:18d413f517f943680aa4fa899dc79bf40cd13ff2"
REPEATR_SRC_URL="https://github.com/polydawn/repeatr"
REACH_SRC_HASH="git:8fa531a46588d0c84cfc62b8e6d4a584485c6112"
REACH_SRC_URL="https://github.com/polydawn/reach"
REFMT_SRC_HASH="git:01bf1e26dd14f9b71f26b7005a2b1ef514d5f9a4"
REFMT_SRC_URL="https://github.com/polydawn/refmt"
### Build Rio.
rr="$(repeatr run <(refmt yaml=json << EOF
formula:
inputs:
"/": "$BASE_IMG_HASH"
"/app/go": "$GO_COMPILER_HASH"
"/task": "$RIO_SRC_HASH"
action:
exec:
- "/bin/bash"
- "-c"
- |
export PATH=\$PATH:/app/go/go/bin
export GOPATH=\$PWD/.gopath
export GOBIN=\$PWD/bin
CGO_ENABLED=0 go install --ldflags '-extldflags "-static"' ./cmd/*
outputs:
"/task/bin": {packtype: "tar"}
context:
fetchUrls:
"/": ["$BASE_IMG_URL"]
"/app/go": ["$GO_COMPILER_URL"]
"/task": ["$RIO_SRC_URL"]
saveUrls:
"/task/bin": "ca+file://./warehouse/"
EOF
))"
echo "$rr"
RIO_LINUXAMD64_HASH="$(echo "$rr" | jq -r '.results["/task/bin"]')"
### Build Repeatr.
rr="$(repeatr run <(refmt yaml=json << EOF
formula:
inputs:
"/": "$BASE_IMG_HASH"
"/app/go": "$GO_COMPILER_HASH"
"/task": "$REPEATR_SRC_HASH"
action:
exec:
- "/bin/bash"
- "-c"
- |
export PATH=\$PATH:/app/go/go/bin
export GOPATH=\$PWD/.gopath
export GOBIN=\$PWD/bin
CGO_ENABLED=0 go install --ldflags '-extldflags "-static"' ./cmd/*
outputs:
"/task/bin": {packtype: "tar"}
context:
fetchUrls:
"/": ["$BASE_IMG_URL"]
"/app/go": ["$GO_COMPILER_URL"]
"/task": ["$REPEATR_SRC_URL"]
saveUrls:
"/task/bin": "ca+file://./warehouse/"
EOF
))"
echo "$rr"
REPEATR_LINUXAMD64_HASH="$(echo "$rr" | jq -r '.results["/task/bin"]')"
### Build Reach
rr="$(repeatr run <(refmt yaml=json << EOF
formula:
inputs:
"/": "$BASE_IMG_HASH"
"/app/go": "$GO_COMPILER_HASH"
"/task": "$REACH_SRC_HASH"
action:
exec:
- "/bin/bash"
- "-c"
- |
export PATH=\$PATH:/app/go/go/bin
export GOPATH=\$PWD/.gopath
export GOBIN=\$PWD/bin
CGO_ENABLED=0 go install --ldflags '-extldflags "-static"' ./cmd/*
outputs:
"/task/bin": {packtype: "tar"}
context:
fetchUrls:
"/": ["$BASE_IMG_URL"]
"/app/go": ["$GO_COMPILER_URL"]
"/task": ["$REACH_SRC_URL"]
saveUrls:
"/task/bin": "ca+file://./warehouse/"
EOF
))"
echo "$rr"
REACH_LINUXAMD64_HASH="$(echo "$rr" | jq -r '.results["/task/bin"]')"
### Build Refmt.
rr="$(repeatr run <(refmt yaml=json << EOF
formula:
inputs:
"/": "$BASE_IMG_HASH"
"/app/go": "$GO_COMPILER_HASH"
"/task": "$REFMT_SRC_HASH"
action:
exec:
- "/bin/bash"
- "-c"
- |
export PATH=\$PATH:/app/go/go/bin
export GOPATH=\$PWD/.gopath
export GOBIN=\$PWD/bin
CGO_ENABLED=0 go install --ldflags '-extldflags "-static"' ./cmd/*
outputs:
"/task/bin": {packtype: "tar"}
context:
fetchUrls:
"/": ["$BASE_IMG_URL"]
"/app/go": ["$GO_COMPILER_URL"]
"/task": ["$REFMT_SRC_URL"]
saveUrls:
"/task/bin": "ca+file://./warehouse/"
EOF
))"
echo "$rr"
REFMT_LINUXAMD64_HASH="$(echo "$rr" | jq -r '.results["/task/bin"]')"
### Build final assembly at the end that takes all the intermediate wares
### and stitches them together into one easy-to-download omnibus tar!
rr="$(repeatr run <(refmt yaml=json << EOF
formula:
inputs:
"/": "$BASE_IMG_HASH"
"/task/parts/rio": "$RIO_LINUXAMD64_HASH"
"/task/parts/repeatr": "$REPEATR_LINUXAMD64_HASH"
"/task/parts/runc": "$REPEATR_PLUGIN_RUNC_HASH"
"/task/parts/reach": "$REACH_LINUXAMD64_HASH"
"/task/parts/refmt": "$REFMT_LINUXAMD64_HASH"
action:
exec:
- "/bin/bash"
- "-c"
- |
mkdir out
mkdir out/bin
mv parts/{rio,repeatr,reach,refmt}/* out/bin
mkdir out/bin/plugins
mv parts/runc/runc out/bin/plugins/repeatr-plugin-runc
outputs:
"/task/out": {packtype: "tar"}
context:
fetchUrls:
"/": ["$BASE_IMG_URL"]
"/task/parts/rio": ["ca+file://./warehouse/"]
"/task/parts/repeatr": ["ca+file://./warehouse/"]
"/task/parts/runc": ["$REPEATR_PLUGIN_RUNC_URL"]
"/task/parts/hitch": ["ca+file://./warehouse/"]
"/task/parts/reach": ["ca+file://./warehouse/"]
"/task/parts/refmt": ["ca+file://./warehouse/"]
saveUrls:
"/task/out": "ca+file://./warehouse/"
EOF
))"
echo "$rr"
OMNIBUS_LINUXAMD64_HASH="$(echo "$rr" | jq -r '.results["/task/bin"]')"