blob: 1e74beb1eca792aa6be4240957f71059905bd1b6 (
plain) (
blame)
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
#!/usr/bin/env bash
cd "$DOTFILES/sh/templates/" || exit 1
mkdir -p "$DOTFILES/cron/generated/"
for job in report-summary annex backup copy-box-backups repo-update mbox-archive mr-remotes-backup; do
sed "s/__JOB__/$job/" cronjob-with-email.sh > "$HOME/dev/libre/dotfiles/cron/generated/$job-job.sh"
chmod +x "$HOME/dev/libre/dotfiles/cron/$job.sh"
chmod +x "$HOME/dev/libre/dotfiles/cron/generated/$job-job.sh"
done
mkdir -p "$HOME/annex/bin/cron/generated/"
# shellcheck disable=2043
for job in pacheco; do
prefix="$HOME/annex/bin/cron"
sed "s/__JOB__-job/$job-job/" cronjob-with-email.sh | sed "s|.*__JOB__.*|$prefix/$job.sh|" > "$HOME/annex/bin/cron/$job-job.sh"
chmod +x "$HOME/annex/bin/cron/$job.sh"
chmod +x "$HOME/annex/bin/cron/generated/$job-job.sh"
done
mkdir -p ~/archive/torrent/
find ~/dev/libre/website/ -type f -name '*.torrent' -exec cp {} ~/archive/torrent/ \;
DEFAULT_TLD_SCRIPT='s/@TLD@/euandreh.xyz/g'
sed -e "$DEFAULT_TLD_SCRIPT" < build-aux/ci/git-pre-push.sh.in > build-aux/ci/git-pre-push.sh
normalize_name() {
if [ -n "$RENAME_TO" ]; then
echo "$RENAME_TO"
elif [[ "$1" = ..* ]]; then
echo "${1:1}"
else
echo "$1"
fi
}
cp_all() {
for f in "$@"; do
OUT="$PREFIX/$(normalize_name "$f")"
mkdir -p "$(dirname "$OUT")"
cp "$f" "$OUT"
done
}
cp_if_not() {
for f in "$@"; do
OUT="$PREFIX/$(normalize_name "$f")"
if [ ! -f "$OUT" ]; then
cp_all "$f"
fi
done
}
envsubst_all() {
for f in "$@"; do
OUT="$PREFIX/$(normalize_name "$f")"
mkdir -p "$(dirname "$OUT")"
envsubst < "$f" > "$OUT"
if [ -n "$EXECUTABLE" ]; then
chmod +x "$OUT"
fi
done
}
envsubst_if_not() {
for f in "$@"; do
OUT="$PREFIX/$(normalize_name "$f")"
if [ ! -f "$OUT" ]; then
envsubst_all "$f"
fi
done
}
sed_all() {
for f in "$@"; do
OUT="$PREFIX/$(normalize_name "$f")"
mkdir -p "$(dirname "$OUT")"
if [ -n "$ENABLE_CI" ]; then
ENABLE_CI_SCRIPT='s/__ENABLE_CI__ //g'
if [ -n "$ENABLE_AUTOTOOLS" ]; then
TLD_SCRIPT=''
else
TLD_SCRIPT="$DEFAULT_TLD_SCRIPT"
fi
else
ENABLE_CI_SCRIPT='/__ENABLE_CI__ /d'
TLD_SCRIPT="$DEFAULT_TLD_SCRIPT"
fi
sed "$f" \
-e "s/__PROJECT_UC__/$PROJECT_UC/g" \
-e "s/__PROJECT__/$PROJECT/g" \
-e "s/__MAILING_LIST__/$MAILING_LIST/g" \
-e "$TLD_SCRIPT" \
-e "$ENABLE_CI_SCRIPT" \
-e "$ENABLE_AUTOTOOLS_SCRIPT" \
> "$OUT"
if [ -n "$EXECUTABLE" ]; then
chmod +x "$OUT"
fi
done
}
sed_if_not() {
for f in "$@"; do
OUT="$PREFIX/$(normalize_name "$f")"
if [ ! -f "$OUT" ]; then
sed_all "$f"
fi
done
}
ln_env() {
export PROJECT="$1"
export PREFIX="${PREFIX_FOR_PROJECT[$PROJECT]:-$HOME/dev/libre/$PROJECT}"
export MAILING_LIST="${ML_FOR_PROJECT[$PROJECT]:-public-inbox}"
export PROJECT_UC="${PROJECT_NAMES[$PROJECT]:-$PROJECT}"
if [ -f "$PREFIX/Makefile.am" ]; then
export ENABLE_AUTOTOOLS=1
else
export ENABLE_AUTOTOOLS=
fi
if [ -f "$PREFIX/Makefile" ] || [ -f "$PREFIX/Makefile.am" ]; then
export ENABLE_CI=1
else
export ENABLE_CI=
fi
if [ -n "${GUILE_PROJECTS[$PROJECT]}" ]; then
ENABLE_GUILE=1
else
ENABLE_GUILE=
fi
if [ -n "${RUST_PROJECT[$PROJECT]}" ]; then
ENABLE_RUST=1
else
ENABLE_RUST=
fi
if [ -f "$PREFIX/guix/pinned-channels.scm" ] &&
[ "$(wc -l < "$PREFIX/guix/pinned-channels.scm")" = 11 ]; then
ENABLE_OVERWRITE_PINNED_CHANNELS=1
else
ENABLE_OVERWRITE_PINNED_CHANNELS=
fi
if [ -n "${GUIX_PROJECT_NO_CHANNEL[$PROJECT]}" ]; then
ENABLE_GUIX_PROJECT_CHANNEL=
else
ENABLE_GUIX_PROJECT_CHANNEL=1
fi
if [ -f "$PREFIX/README.md" ]; then
ENABLE_README_SH=1
else
ENABLE_README_SH=
fi
}
ln_init() {
if ! grep -q "$PROJECT" ~/annex/bin/misc/git/mrconfig.ini; then
red "$(printf '%s missing from mrconfig.ini!\n' "$PROJECT")"
fi
if [ ! -d "$PREFIX" ]; then
git init "$PREFIX"
fi
}
ln_autotools() {
chmod +w "$PREFIX/INSTALL" 2> /dev/null ||:
cp_all AUTHORS \
bootstrap \
ChangeLog \
build-aux/dev-checks.am \
build-aux/default-extra-dist.am \
m4/links.m4 \
m4/programmer-mode.m4 \
build-aux/html-files-from-sources.am
# dev-cheks.am: test maintainer mode
# https://www.gnu.org/software/automake/manual/html_node/maintainer_002dmode.html
cp_if_not description
# assumes:
# - ln_workflow for .gitignore
# - ln_git_notes_release for Makefile.am
# - ln_guix_files for Makefile.am
envsubst_if_not ..gitignore README.in
sed_if_not configure.ac Makefile.am
}
ln_build_aux() {
cp_all build-aux/assert-todos.sh \
build-aux/assert-shellcheck.sh \
build-aux/workflow/TODOs.sh \
build-aux/workflow/style.css \
build-aux/workflow/preamble.md
if [ "$ENABLE_README_SH" ]; then
cp_all build-aux/workflow/README.sh
fi
cp_if_not TODOs.md
}
ln_agpl() {
cp_all COPYING
}
ln_guix_files() {
cp_all build-aux/with-container.sh \
build-aux/assert-shellcheck.sh
cp_if_not guix/manifest.scm
if [ -n "$ENABLE_GUIX_PROJECT_CHANNEL" ]; then
cp_all .guix-channel \
.guix-authorizations \
guix/channel/euandreh.key
if [ ! -f "$PREFIX/guix/channel/xyz/euandreh/$PROJECT/channel.scm" ]; then
RENAME_TO="guix/channel/xyz/euandreh/$PROJECT/channel.scm.in" cp_if_not rename/basic-channel.scm.in
fi
fi
if [ -n "$ENABLE_OVERWRITE_PINNED_CHANNELS" ]; then
cp_all guix/pinned-channels.scm
else
cp_if_not guix/pinned-channels.scm
fi
}
ln_ci() {
if [ -n "$ENABLE_CI" ]; then
if [ -n "$ENABLE_AUTOTOOLS" ]; then
sed_all build-aux/ci/git-pre-push.sh.in
else
EXECUTABLE=1 sed_all build-aux/ci/git-pre-push.sh
fi
cp_all build-aux/assert-shellcheck.sh \
build-aux/ci/ci-build.sh \
build-aux/ci/git-post-receive.sh
rm "$PREFIX/.git/hooks/pre-push"
ln -s "$PREFIX/build-aux/ci/git-pre-push.sh" "$PREFIX/.git/hooks/pre-push"
else
EXECUTABLE=1 sed_all ..git/hooks/pre-push
fi
}
ln_git_notes_release() {
cp_all build-aux/git-notes-release.am build-aux/git-notes-release.sh
cp_if_not NEWS
}
ln_dicts() {
cp_if_not doc/dictionaries/international.txt doc/dictionaries/en.txt
}
ln_pandoc_index() {
cp_all build-aux/compile-readme.sh
}
ln_web_assets_file() {
mkdir -p "$PREFIX/build-aux/"
cp "build-aux/$1-build-web-assets.sh" "$PREFIX/build-aux/build-web-assets.sh"
}
ln_scribble() {
ln_dicts
}
ln_antora() {
ln_dicts
}
ln_base_autotools_guix_project() {
ln_env "$1"
ln_init
ln_build_aux
ln_guix_files
ln_git_notes_release
ln_autotools
ln_generated_readme
ln_pandoc_index
ln_agpl
ln_ci
ln_dicts
if [ -n "$ENABLE_GUILE" ]; then
cp_all build-aux/guile.am m4/guile.m4
fi
if [ -n "$ENABLE_RUST" ]; then
cp_all build-aux/rust.am
fi
}
ln_texinfo_autotools_guix_project() {
ln_base_autotools_guix_project "$1"
RENAME_TO="doc/$PROJECT.texi" envsubst_if_not rename/empty-texinfo.texi
ln_web_assets_file texinfo
cp_all build-aux/docbook-xsl.tar.gz
}
ln_sphinx_autotools_guix_project() {
ln_base_autotools_guix_project "$1"
cp_all build-aux/assert-docs-spelling.sh doc/_templates/footer.html doc/favicon.ico
envsubst_all doc/conf.py.in doc/_templates/layout.html
envsubst_if_not doc/index.rst
# EXECUTABLE=1 sed_all build-aux/build-sphinx.sh
cp_if_not doc/i18n-pagenames.json doc/Makefile
}
ln_scribble_autotools_guix_project() {
ln_base_autotools_guix_project "$1"
ln_scribble
}
ln_antora_autotools_guix_project() {
ln_base_autotools_guix_project "$1"
ln_antora
}
ln_simple_makefile() {
envsubst_if_not Makefile
}
ln_generated_readme() {
if [ ! -f "$PREFIX/README" ]; then
cat <(printf "%s\n\n" "$PROJECT_UC") \
<(fold < "$PREFIX/description") \
<(printf "\nSee: https://%s.euandreh.xyz\n" "$PROJECT") \
> "$PREFIX/README"
fi
}
ln_makefile_only_guix_project() {
ln_env "$1"
ln_agpl
ln_build_aux
ln_guix_files
ln_ci
ln_simple_makefile
}
ln_bare_project() {
ln_env "$1"
ln_agpl
ln_ci
}
ln_description_foreign_project() {
ln_env "$1"
# Foreign projects may have Makefiles and alike, and I don't want
# to have CI files copied to the repository
ENABLE_CI=
ln_ci
}
declare -A PROJECT_NAMES=(
[vps]=VPS
[cement]=Cement
[parsecc]=ParsecC
[songbooks]=Songbooks
[mediator]=Mediator
[byopds]=BYOPDS
[pires]=Pires
)
declare -A ML_FOR_PROJECT=(
[cement]=byopds
[byopds]=byopds
[guile-pds]=byopds
[parsecc]=mediator
[parseclj]=mediator
[x-bindgen]=mediator
[mediator]=mediator
[libedn]=mediator
[eq]=mediator
[songbooks]=songbooks
[guile-clap]=songbooks
[pires]=pires
)
declare -A PREFIX_FOR_PROJECT=(
[guix]="$HOME/dev/guix/guix"
)
declare -A GUILE_PROJECTS=(
[guile-quickcheck]=1
[guile-pds]=1
[guile-clap]=1
[songbooks]=1
)
declare -A RUST_PROJECT=(
[spalc]=1
[libedn]=1
[x-bindgen]=1
)
declare -A GUIX_PROJECT_NO_CHANNEL=(
[vps]=1
[website]=1
)
ln_all() {
LN_FN="$1"
shift
for f in "$@"; do
"$LN_FN" "$f"
done
}
ln_all ln_texinfo_autotools_guix_project guile-quickcheck guile-pds guile-clap cement songbooks
ln_all ln_sphinx_autotools_guix_project libedn x-bindgen eq mediator
# ln_all ln_scribble_autotools_guix_project
ln_all ln_antora_autotools_guix_project byopds spalc
ln_all ln_makefile_only_guix_project vps pires remembering website
ln_all ln_description_foreign_project guix parsecc
ln_all ln_bare_project parseclj \
boneco \
brinquedoteca \
casa-do-caminho \
dotfiles \
euandreh-guix-channel \
music \
pdfs-da-d-maria \
swift2nix \
swift2nix-demo \
cargo2nix \
cargo2nix-demo
cd - > /dev/null || exit 1
|