-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.dist.yaml
More file actions
284 lines (263 loc) · 7.97 KB
/
Taskfile.dist.yaml
File metadata and controls
284 lines (263 loc) · 7.97 KB
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#
# main.yaml
#
version: '3'
includes:
dev: task/dev
env:
LC_COLLATE: en_US.utf8
vars:
PKGS:
- go-task
- gomplate
- go-template-cli
tasks:
signing-key-create:
run: once
desc: Prepare signing keys
status:
- test -s signing-key/private-key.pem
- test -s signing-key/public-key.pem
preconditions:
- sh: test -x openwrt-sdk/staging_dir/host/bin/openssl
msg: openssl utility not found
cmds:
- cmd: mkdir -p signing-key
- cmd: >-
openwrt-sdk/staging_dir/host/bin/openssl ecparam
-name prime256v1
-genkey
-noout
-out signing-key/private-key.pem
- cmd: >-
openwrt-sdk/staging_dir/host/bin/openssl ec
-in signing-key/private-key.pem
-pubout > signing-key/public-key.pem
signing-key-copy:
desc: Copy signing keys to OpenWRT SDK directory
status:
- test -s openwrt-sdk/private-key.pem
- test -s openwrt-sdk/public-key.pem
preconditions:
- sh: test -d openwrt-sdk
msg: OpenWRT SDK not installed
deps:
- signing-key-create
cmds:
- cmd: cp signing-key/private-key.pem openwrt-sdk
- cmd: cp signing-key/public-key.pem openwrt-sdk
signing-key-init:
internal: true
cmds:
- task: signing-key-create
- task: signing-key-copy
signing-key-publish:
desc: Publish signing key
preconditions:
- sh: test -s signing-key/public-key.pem
msg: Signing key not found
- sh: test -d feeds
msg: Fedds directory does not exitst
cmds:
- mkdir -p feeds/signing-key
- cp signing-key/public-key.pem feeds/signing-key/gomplate.pem
feeds-configure:
desc: Configure feeds
dir: openwrt-sdk
status:
- test -s feeds.conf
cmds:
- cp feeds.conf.default feeds.conf
- echo 'src-link gomplate {{joinPath .ROOT_DIR "packages"}}' >> feeds.conf
feeds-install:
desc: Install and/or update feeds
dir: openwrt-sdk
cmds:
- ./scripts/feeds update -a
- ./scripts/feeds install -a
- ./scripts/feeds install {{.PKGS | join " "}}
feeds-init:
internal: true
cmds:
- task: feeds-configure
- task: feeds-install
sdk-configure:
desc: Configure OpenWRT SDK
dir: openwrt-sdk
status:
- test -s .config
cmds:
- cp {{joinPath .ROOT_DIR "openwrt" "diffconfig" | relPath .TASK_DIR | shellQuote}} .config
- make defconfig
package-compile:
desc: Compile packages
dir: openwrt-sdk
cmds:
- for: { var: PKGS }
cmd: make package/{{.ITEM}}/compile {{.CLI_ARGS}}
package-clean:
desc: Clean-up packages
dir: openwrt-sdk
cmds:
- cmd: make -j{{numCPU}} {{range .PKGS}}package/{{.}}/clean {{end}}
package-index:
desc: Index packages
dir: openwrt-sdk
cmds:
- make package/index
copy-pkgs-*:
internal: true
label: copy-pkgs-{{index .MATCH 0 | dir | base}}
vars:
ARCH: '{{index .MATCH 0 | dir | base}}'
PKG_DIR: '{{index .MATCH 0 | joinPath "openwrt-sdk" "bin" "packages"}}'
DST_DIR: '{{joinPath "feeds" .ARCH}}'
cmds:
- mkdir -p {{.DST_DIR}}
- cp -a {{.PKG_DIR}} {{.DST_DIR}}
- touch -cr {{dir .PKG_DIR}} {{.DST_DIR}}
package-copy-to-feeds:
desc: Copy packages to feeds
vars:
PKG_DIRS:
sh: |
for p in openwrt-sdk/bin/packages/*/gomplate; do
echo ${p#openwrt-sdk/bin/packages/}
done
cmds:
- cmd: mkdir -p feeds
- for:
var: PKG_DIRS
task: copy-pkgs-{{.ITEM}}
create-index:
desc: Create index.html
internal: true
dir: feeds
silent: true
requires:
vars: ['DIR', 'TIMESTAMP']
vars:
SDIR: '{{.DIR | default "."}}'
DOC_DIR: '{{joinPath "/" .DIR}}'
INDEX_HTML: '{{joinPath .SDIR "index.html"}}'
HTML_HEADER: >-
<!DOCTYPE html>
<html lang="en">
<head>
<title>Directory listing of {{.DOC_DIR}}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<style>
table { width: 95%; border-collapse: collapse; margin-left: auto; margin-right: auto}
table tbody, tbody td { border: 1px solid }
tbody th { border: 2px solid }
tbody th, tbody td { padding: .3ex }
thead th, thead td { padding-bottom: .5em }
tr.updir td { font-size: larger; font-weight: bold }
tr.feed td { font-weight: bold }
tr.folder td { font-weight: bold }
tr.script td { font-family: monospace; }
tr.file td { font-size: smaller; font-family: system-ui }
tr td.name { text-align: left }
tr td.fsize { text-align: right }
footer { text-align: center; padding-top: 1em }
</style>
</head>
<body>
<h1>Directory Listing: <em>{{.DOC_DIR}}</em></h1>
<table>
HTML_DIR_UP: >-
{{if ne .SDIR "."}}
<thead>
<tr class="updir"><td colspan="2">
<a href="..">··</a>
</td></tr>
</thead>
{{end}}
TABLE_BODY: >-
<tbody>
<tr>
<th class="fname">Name</th>
<th class="fsize">Size</th>
</tr>
HTML_LIST:
sh: |
ls -1 --group-directories-first "{{.SDIR}}" --ignore=index.html --ignore=tmp | while read file; do
ehref="$file"
if [ -d "{{.SDIR}}/${file}" ]; then
if [ -d "{{.SDIR}}/${file}/gomplate" ]; then
eclass=feed
else
eclass=folder
fi
elif [ "${file##*.}" = "apk" ]; then
fsize=$(stat -c%s "{{.SDIR}}/${file}")
hfsize=$(numfmt --to=iec ${fsize})
eclass=apk
echo "<tr class=\"${eclass}\"><td><a href=\"${file}\">${file}</a></td><td class=\"fsize\">${hfsize}</td></tr>"
continue
elif [ "${file##*.}" = "sh" ]; then
eclass=script
else
eclass=file
fi
echo "<tr class=\"${eclass}\"><td colspan=\"2\"><a href=\"${file}\">${file}</a></td></tr>"
done
HTML_FOOTER: >-
</tbody></table>
<footer>Generated on <code>{{html .TIMESTAMP}}</code>.
{{if env "GIT_COMMIT"}}<br>Commit: <a href="https://github.com/RoEdAl/task-feed/commit/{{env "GIT_COMMIT"}}" target="_blank" rel="noopener noreferrer">{{env "GIT_COMMIT" | substr 0 7 | html}}</a>.{{end}}
</footer>
</body></html>
cmds:
- cmd: "echo 'Generating index: {{.INDEX_HTML}}'"
- cmd: |
cat << EOF > "{{.INDEX_HTML}}"
{{.HTML_HEADER}}
{{trim .HTML_DIR_UP}}
{{.TABLE_BODY}}
{{.HTML_LIST}}
{{.HTML_FOOTER}}
EOF
directory-listing:
internal: true
dir: feeds
requires:
vars:
- TIMESTAMP
vars:
DIRS:
sh: find . -type d -not -path '*/[@.]*' -not -path '*/tmp' -printf '%P\n'
cmds:
- for: { var: DIRS, split: "\n" }
task: create-index
vars:
DIR: '{{.ITEM}}'
TIMESTAMP: '{{.TIMESTAMP}}'
feeds-prepare:
desc: Prepare feeds directory
dir: feeds
vars:
TIMESTAMP: '{{date "2006-01-02T15:04:05Z07:00" now}}'
cmds:
- cmd: touch -d "{{.TIMESTAMP}}" .nojekyll
- cmd: cp ../openwrt/task-feed.sh .
- task: signing-key-publish
- task: directory-listing
vars:
TIMESTAMP: '{{.TIMESTAMP}}'
default:
aliases:
- build
desc: Build packages
deps:
- signing-key-init
- feeds-init
cmds:
- task: sdk-configure
- task: package-clean
- task: package-compile
- task: package-index