Repository navigation
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·849 lines (754 loc) · 35.8 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·849 lines (754 loc) · 35.8 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
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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
#!/bin/sh
# Build the current commit on the build server and publish it as the rolling
# `latest` release, plus the Windows simulator as `Simulator`, the extra
# themes as `Themes`, the voice files as `Voices` and the bootloader installer
# as `Bootloader`.
#
# There are no version tags. Every run replaces all five releases and moves
# their tags to the commit that was built, so the release page always shows the
# current build and nothing else.
#
# Five releases rather than one page of assets: the firmware zips unpack onto
# a player, the simulator zips unpack onto a PC, the theme and voice zips are
# optional extras and the bootloader is installed once from a PC, and a page
# that offers them all side by side invites unpacking the wrong one.
#
# Only `latest` is marked Latest. GitHub features that release and the
# repository's front page links to it, so the other four are created with
# --latest=false: what a visitor is offered first has to be the firmware.
#
# The build server is not recorded here -- see PODBOX_BUILD_SERVER below.
#
# The zips are built from a clean `git archive` of the commit being released,
# extracted into its own directory on the server -- deliberately NOT from the
# dev tree, so the zips provably match the tag rather than whatever happened to
# be lying around in it.
#
# The archive is taken with core.autocrlf/core.eol forced off. `git archive`
# otherwise honours this checkout's autocrlf=true and produces CRLF, which
# lands `#!/bin/sh^M` on the server and fails the first build with "bad
# interpreter". Forcing them off ships true blob content, which also means no
# `sed 's/\r$//'` pass is needed -- and that matters, because such a pass
# applied to a binary (the 4bpp theme font) silently eats any 0x0D that happens
# to precede a 0x0A.
#
# Nothing reaches GitHub until both targets have built and both zips have been
# checked, so a failed build leaves the previous release standing.
#
# Usage: ./release.sh [options]
#
# --server U@H build server. Defaults to $PODBOX_BUILD_SERVER; required.
# --root PATH build directory on the server, relative to its home
# directory. Defaults to $PODBOX_BUILD_ROOT or podbox-release.
# -y don't ask for confirmation before publishing
# --draft create the releases as drafts
# --dry-run build and verify, then stop -- the existing releases stand.
# Required on any branch but master.
# --no-sim skip the simulator; leave the Simulator release as it is
# --no-voices skip the voice files; leave the Voices release as it is
# --no-arcade leave the Arcade's build action, game template and IDE
# page as they are (release-arcade.sh publishes them)
#
# Requires: ssh to the build server (key-based, non-interactive), and `gh`
# installed and authenticated THERE -- see the --repo note further down, and
# mingw-w64 for the bootloader installer's tools. The simulator also needs the
# SDL2 mingw wrapper on the server; --no-sim is the way past a box without it.
# The voices need Piper there (see build-voices.sh); --no-voices is the way
# past a box without it. A first voice run takes about an hour.
set -eu
# The build server is deliberately not baked in: this script is committed to a
# public repo and the box is someone's private machine. Supply it per-user via
# the environment (export PODBOX_BUILD_SERVER=user@host in your shell profile)
# or per-run with --server.
SERVER=${PODBOX_BUILD_SERVER:-}
# Kept relative so it resolves against the remote account's home directory and
# no username is written down here either.
REMOTE_ROOT=${PODBOX_BUILD_ROOT:-podbox-release}
TARGETS="ipod6g ipodvideo"
# The four releases, reused forever. Their tags are moved to each commit built.
RELEASE=latest
SIM_RELEASE=Simulator
THEMES_RELEASE=Themes
VOICES_RELEASE=Voices
BOOT_RELEASE=Bootloader
# What build-bootloader.sh makes, under the name it is published as.
BOOT_ASSET=podbox-bootloader.zip
# The themes published as their own download. Scrim is not among them: it is
# the theme the firmware ships with, and bundle-theme.sh puts it in the build.
# Named rather than globbed, for the same reason bundle-theme.sh names its one
# -- a `git merge rockbox/master` must not start publishing stock themes that
# were never converted.
EXTRA_THEMES="themify_2 obsede_2 bony iclassic_square jive"
# Published asset names. The build directory's own name means nothing to
# somebody choosing a download.
asset_name() {
case "$1" in
ipod6g) echo "rockbox-ipod6g.zip" ;;
ipodvideo) echo "rockbox-ipodvideo-5g.zip" ;;
esac
}
# The same zip without .rockbox/tools/, for anyone whose browser, network or
# antivirus will not let a zip holding Windows executables through.
notools_asset_name() {
case "$1" in
ipod6g) echo "rockbox-ipod6g-no-tools.zip" ;;
ipodvideo) echo "rockbox-ipodvideo-5g-no-tools.zip" ;;
esac
}
# Each build's link map rides with the release rather than in the zip, which
# is synced onto the player. A panic address resolves only against the build
# that crashed, and this is the one copy of it kept. Named to sort after the
# zips, which must be what a visitor sees first.
map_name() {
case "$1" in
ipod6g) echo "symbols-ipod6g.map" ;;
ipodvideo) echo "symbols-ipodvideo-5g.map" ;;
esac
}
sim_asset_name() {
case "$1" in
ipod6g) echo "simulator-ipod6g.zip" ;;
ipodvideo) echo "simulator-ipodvideo-5g.zip" ;;
esac
}
theme_asset_name() { echo "$1.zip"; }
# A voice file is made for one build and will not load on the other player
voices_asset_name() {
case "$1" in
ipod6g) echo "voices-ipod6g.zip" ;;
ipodvideo) echo "voices-ipodvideo-5g.zip" ;;
esac
}
# Every extra theme in one download, beside the single ones.
ALL_THEMES_ASSET=all-themes.zip
cd "$(dirname "$0")"
die() { echo "release: $*" >&2; exit 1; }
say() { echo; echo "==> $*"; }
ASSUME_YES=
DRAFT=
DRY_RUN=
WITH_SIM=1
WITH_VOICES=1
WITH_ARCADE=1
while [ $# -gt 0 ]; do
case "$1" in
-y|--yes) ASSUME_YES=1 ;;
--draft) DRAFT=--draft ;;
--dry-run) DRY_RUN=1 ;;
--no-sim) WITH_SIM= ;;
--no-voices) WITH_VOICES= ;;
--no-arcade) WITH_ARCADE= ;;
--server) [ $# -ge 2 ] || die "--server needs user@host"
SERVER=$2; shift ;;
--root) [ $# -ge 2 ] || die "--root needs a path"
REMOTE_ROOT=$2; shift ;;
# Print the header block, however long it grows -- a fixed line range
# silently truncates the moment an option is added.
-h|--help) awk 'NR>1 { if (!/^#/) exit; sub(/^# ?/, ""); print }' "$0"
exit 0 ;;
-*) die "unknown option '$1'" ;;
*) die "unexpected argument '$1' -- this script takes no
version; it always publishes the current commit as '$RELEASE'" ;;
esac
shift
done
[ -n "$SERVER" ] || die "no build server. Either
export PODBOX_BUILD_SERVER=user@host
in your shell profile, or pass --server user@host. It is not stored in
the repo on purpose."
# ---------------------------------------------------------------- preflight --
say "Checking the tree"
[ -z "$(git status --porcelain)" ] ||
die "working tree is not clean -- commit or stash first, so the zips match the tag"
# The settings and the two documents that describe them, which nothing else
# runs. A mismatch ships a setting whose Explain entry is empty or a guide
# describing a player that no longer exists -- neither of which shows up in a
# build, a zip check or on the device. Here rather than in build-hw.sh: a
# half-written feature has every right to be undocumented while it is being
# written, and a release has none.
sh tools/check-settings-docs.sh ||
die "settings and their documents disagree -- see the lines above"
# A rehearsal tags nothing, and builds from git archive, so it needs nothing
# pushed: unpushed work can be rehearsed before it goes out.
if [ -z "$DRY_RUN" ]; then
UPSTREAM=$(git rev-parse --abbrev-ref '@{u}' 2>/dev/null) ||
die "this branch has no upstream; push it before releasing"
[ "$(git rev-parse HEAD)" = "$(git rev-parse '@{u}')" ] ||
die "HEAD differs from $UPSTREAM -- push first, so the tag names a published commit"
fi
# The release belongs to whatever origin points at here. Derived rather than
# hardcoded so a renamed fork doesn't silently publish to the wrong place.
SLUG=$(git remote get-url origin | sed -e 's#^.*github\.com[:/]##' -e 's#\.git$##')
case "$SLUG" in
*/*) ;;
*) die "can't work out the GitHub repo from origin ($SLUG)" ;;
esac
BRANCH=$(git rev-parse --abbrev-ref HEAD)
COMMIT=$(git rev-parse --short HEAD)
# `latest` is what every player installs, so it is published from master
# only. A feature branch can still rehearse a release with --dry-run.
[ "$BRANCH" = master ] || [ -n "$DRY_RUN" ] ||
die "on branch $BRANCH -- releases come from master (--dry-run is allowed)"
say "Checking the build server"
ssh -o BatchMode=yes -o ConnectTimeout=10 "$SERVER" true 2>/dev/null ||
die "can't reach $SERVER"
ssh -o BatchMode=yes "$SERVER" 'command -v arm-elf-eabi-gcc >/dev/null' ||
die "no arm-elf-eabi-gcc on $SERVER"
# build-sim.sh checks this too, but only after configure has wiped and
# recreated the build directory -- and finding out here costs two firmware
# builds less.
ssh -o BatchMode=yes "$SERVER" 'command -v x86_64-w64-mingw32-gcc >/dev/null' ||
die "no x86_64-w64-mingw32-gcc on $SERVER -- the bootloader installer's tools need it"
if [ -n "$WITH_SIM" ]; then
ssh -o BatchMode=yes "$SERVER" \
'PATH=$HOME/bin:$PATH command -v x86_64-w64-mingw32-sdl2-config >/dev/null' ||
die "no x86_64-w64-mingw32-sdl2-config on $SERVER (\$HOME/bin holds the
wrapper; the SDL2 mingw package it points at is not packaged and has to
be staged). Pass --no-sim to skip the simulator."
fi
ssh -o BatchMode=yes "$SERVER" 'command -v gh >/dev/null' ||
die "gh is not installed on $SERVER"
ssh -o BatchMode=yes "$SERVER" 'gh auth status >/dev/null 2>&1' ||
die "gh on $SERVER is not authenticated (run: ssh $SERVER gh auth login)"
# ------------------------------------------------------------------- notes --
# Everything since the last release, which is wherever the `$RELEASE` tag
# currently points. That tag is asked of origin rather than looked up locally:
# nothing here creates it, gh does, on the server.
#
# It is also the only tag worth asking about. This tree mirrors upstream
# Rockbox, so upstream's tags (v3.x, v4.0-final) ARE ancestors of HEAD and the
# fork has none of its own in that history: `git describe` walks straight into
# upstream's changelog. `$RELEASE` always names a commit this script itself
# published, so no override for the start point is needed.
say "Working out what has changed"
REMOTE_TAG=$(git ls-remote --tags origin "refs/tags/$RELEASE" 2>/dev/null || true)
# An annotated tag lists two lines, the tag object and a `...^{}` line naming
# the commit. Prefer the dereferenced one; a lightweight tag has only the first.
PREV=$(printf '%s\n' "$REMOTE_TAG" | sed -n 's/^\([0-9a-f]\{7,\}\).*\^{}$/\1/p')
[ -n "$PREV" ] ||
PREV=$(printf '%s\n' "$REMOTE_TAG" | sed -n 's/^\([0-9a-f]\{7,\}\).*/\1/p')
# A release published from some other checkout can name a commit this one has
# never seen. Listing the whole history beats dying at the last step.
if [ -n "$PREV" ] && ! git cat-file -e "$PREV^{commit}" 2>/dev/null; then
echo " the $RELEASE release names $PREV, which isn't in this checkout --"
echo " listing the full history instead"
PREV=
fi
if [ -n "$PREV" ]; then
HEADING="Changes since the last release"
CHANGES=$(git log --no-merges --pretty='- %s' "$PREV..HEAD")
else
HEADING="Changes"
CHANGES=$(git log --no-merges --pretty='- %s')
fi
# Empty means HEAD is already what the release names -- a rebuild, not a
# mistake, so say so rather than publishing an empty heading.
[ -n "$CHANGES" ] || CHANGES="- Rebuilt from the same commit."
echo " $(printf '%s\n' "$CHANGES" | wc -l | tr -d ' ') commits to list"
UPGRADE_NOTES=docs/podbox/upgrade-notes.md
NOTES=$(mktemp)
SIM_NOTES=$(mktemp)
THEMES_NOTES=$(mktemp)
BOOT_NOTES=$(mktemp)
VOICES_NOTES=$(mktemp)
trap 'rm -f "$NOTES" "$SIM_NOTES" "$THEMES_NOTES" "$BOOT_NOTES" "$VOICES_NOTES"' EXIT
{
printf 'Built from `%s` on `%s`.\n\n' "$(git rev-parse HEAD)" "$BRANCH"
printf '| file | player |\n| --- | --- |\n'
printf '| `%s` | iPod Classic 6G/7G |\n' "$(asset_name ipod6g)"
printf '| `%s` | iPod Video 5G/5.5G |\n\n' "$(asset_name ipodvideo)"
printf 'Unzip onto the root of the player. The `.map` files resolve a\n'
printf 'crash address from this build and are not installed.\n\n'
printf 'If your browser or antivirus will not download those, take\n'
printf '`%s` or `%s` instead: the same\n' \
"$(notools_asset_name ipod6g)" "$(notools_asset_name ipodvideo)"
printf 'firmware without the Windows desktop tools in `.rockbox/tools/`.\n\n'
printf '**Update your themes too.** If you use any theme from the\n'
printf '[%s release](https://github.com/%s/releases/tag/%s), download it\n' \
"$THEMES_RELEASE" "$SLUG" "$THEMES_RELEASE"
printf 'again with this build: the themes there are made for this firmware.\n'
printf 'Scrim ships inside the firmware zip and needs nothing.\n\n'
# What an owner should know before updating, written by hand and emptied
# once it has gone out
if grep -q '[^[:space:]]' "$UPGRADE_NOTES" 2>/dev/null; then
printf '### Before you update\n\n'
cat "$UPGRADE_NOTES"
printf '\n'
fi
printf '### %s\n\n' "$HEADING"
printf '%s\n' "$CHANGES"
} > "$NOTES"
{
printf 'The same build, running on Windows. From `%s` on `%s`.\n\n' \
"$(git rev-parse HEAD)" "$BRANCH"
printf '| file | player it simulates |\n| --- | --- |\n'
printf '| `%s` | iPod Classic 6G/7G |\n' "$(sim_asset_name ipod6g)"
printf '| `%s` | iPod Video 5G/5.5G |\n\n' "$(sim_asset_name ipodvideo)"
printf 'Unzip anywhere and run `rockboxui.exe`, keeping `simdisk\\` beside\n'
printf 'it: that directory is the player'"'"'s storage, and `simdisk\\.rockbox`\n'
printf 'is this build. Drop music into `simdisk\\` and the database will\n'
printf 'find it. SDL is linked statically, so there are no DLLs to install.\n\n'
printf 'Run it with `--debugwps` to trace skin parsing; F5 writes a\n'
printf 'screendump into `simdisk\\`.\n\n'
printf '### %s\n\n' "$HEADING"
printf '%s\n' "$CHANGES"
} > "$SIM_NOTES"
# The themes are files in the tree rather than something built, so these notes
# carry no commit list: nothing here changes with most commits, and a changelog
# of firmware work would only mislead somebody after a theme.
{
printf 'Extra themes for PodBox, each modified to support dynamic colours\n'
printf 'and art in lists. Scrim is not here: it ships with the firmware.\n\n'
printf '| file | theme |\n| --- | --- |\n'
printf '| `%s` | every theme below, in one download |\n' "$ALL_THEMES_ASSET"
for theme in $EXTRA_THEMES; do
printf '| `%s` | [%s](https://github.com/%s/blob/%s/themes/%s/README.md) |\n' \
"$(theme_asset_name "$theme")" "$theme" "$SLUG" "$BRANCH" "$theme"
done
printf '\nUnzip onto the root of the player, so the `.rockbox` folder lands\n'
printf 'on top of the one already there, then pick it under\n'
printf 'Settings > Load Theme.\n\n'
printf 'Each zip carries the fonts its theme needs, so they can be\n'
printf 'installed in any order and on their own.\n'
} > "$THEMES_NOTES"
# The voices are made for this build, so the notes say which commit; no
# commit list, since a voice changes only with the menus' words.
{
printf 'Recorded voices for the menus, made for the PodBox build from\n'
printf '`%s`, in twelve languages: English, English (US),\n' \
"$(git rev-parse HEAD)"
printf 'Deutsch, Français, Español, Italiano, Nederlands, Português\n'
printf '(Brasil), Polski, Svenska, 日本語 and 简体中文.\n\n'
printf '| file | player |\n| --- | --- |\n'
printf '| `%s` | iPod Classic 6G/7G |\n' "$(voices_asset_name ipod6g)"
printf '| `%s` | iPod Video 5G/5.5G |\n\n' "$(voices_asset_name ipodvideo)"
printf 'Unzip onto the root of the player, so the `.rockbox` folder lands\n'
printf 'on top of the one already there. The voice for the language chosen\n'
printf 'in Settings > System > Language & Text > Language is the one used.\n\n'
printf 'They are optional: without them the built-in voice speaks the\n'
printf 'menus, in English. A voice file belongs to one build, so take these\n'
printf 'again with each new firmware -- an old one is refused and the\n'
printf 'built-in voice takes over.\n'
} > "$VOICES_NOTES"
# No commit list here either: the bootloader changes rarely, and is installed
# once rather than with every build.
{
printf 'The PodBox bootloader for both players, with the Windows tools that\n'
printf 'install it. From `%s`.\n\n' "$(git rev-parse HEAD)"
printf 'With it the player starts PodBox even when the hold switch is on.\n'
printf 'Hold Menu while it starts for Apple'"'"'s firmware.\n\n'
printf 'Unzip `%s` anywhere and follow its `README.txt`:\n' "$BOOT_ASSET"
printf 'run `install-5g.cmd` for an iPod Video 5G/5.5G, or\n'
printf '`install-6g.cmd` for an iPod Classic 6G/7G. It is installed once;\n'
printf 'updating PodBox does not replace it.\n'
} > "$BOOT_NOTES"
# ------------------------------------------------------------------- plan ---
cat <<PLAN
releases $THEMES_RELEASE,${WITH_SIM:+ $SIM_RELEASE,}${WITH_VOICES:+ $VOICES_RELEASE,} $BOOT_RELEASE, then $RELEASE${DRAFT:+ (draft)}
commit $COMMIT on $BRANCH
repo $SLUG
targets $TARGETS${WITH_SIM:+ (firmware and Windows simulator)}
themes $EXTRA_THEMES
build in $SERVER:$REMOTE_ROOT/$RELEASE
release notes
-------------
PLAN
cat "$NOTES"
echo
if [ -n "$WITH_SIM" ]; then
echo "simulator release notes"
echo "-----------------------"
cat "$SIM_NOTES"
echo
fi
echo "themes release notes"
echo "--------------------"
cat "$THEMES_NOTES"
echo
if [ -n "$WITH_VOICES" ]; then
echo "voices release notes"
echo "--------------------"
cat "$VOICES_NOTES"
echo
fi
echo "bootloader release notes"
echo "------------------------"
cat "$BOOT_NOTES"
echo
if [ -n "$DRY_RUN" ]; then
echo "(--dry-run: will build and verify, then stop before publishing)"
elif [ -z "$ASSUME_YES" ]; then
printf 'Build this and replace the %s releases? [y/N] ' \
"$THEMES_RELEASE,${WITH_SIM:+ $SIM_RELEASE,}${WITH_VOICES:+ $VOICES_RELEASE,} $BOOT_RELEASE, $RELEASE"
read -r reply
case "$reply" in
y|Y|yes|YES) ;;
*) die "aborted" ;;
esac
fi
# ------------------------------------------------------------------ build ---
REMOTE_DIR=$REMOTE_ROOT/$RELEASE
say "Shipping the tree to $SERVER"
ssh "$SERVER" "rm -rf '$REMOTE_DIR' && mkdir -p '$REMOTE_DIR'"
git -c core.autocrlf=false -c core.eol=lf archive --format=tar HEAD | gzip -1 |
ssh "$SERVER" "tar xzf - -C '$REMOTE_DIR'"
for target in $TARGETS; do
say "Building $target"
ssh "$SERVER" "cd '$REMOTE_DIR' && ./build-hw.sh $target"
done
# Empty under --no-sim, so every simulator loop below folds away to nothing.
SIM_TARGETS=
[ -z "$WITH_SIM" ] || SIM_TARGETS=$TARGETS
# $HOME/bin holds the x86_64-w64-mingw32-sdl2-config wrapper. configure looks
# for that cross-prefixed name before the plain one, and without it a Windows
# build links against whatever SDL the server has for itself.
for target in $SIM_TARGETS; do
say "Building the $target simulator"
ssh "$SERVER" "cd '$REMOTE_DIR' && PATH=\$HOME/bin:\$PATH ./build-sim.sh $target win"
done
# The desktop tool links against the Windows simulator, which is built after
# the firmware -- so bundle-tools.sh inside build-hw.sh had no simulator to
# build it from and shipped nothing. Added here instead, into zips that
# already exist, which is what every bundle script does anyway.
#
# Under --no-sim there is no simulator and so no tool, and the check below
# stops asking for one rather than failing a release that was never going to
# have it.
TOOL_WANT=
for target in $SIM_TARGETS; do
say "Adding the desktop tools to $target"
ssh "$SERVER" "cd '$REMOTE_DIR' && ./bundle-tools.sh build-hw-$target"
TOOL_WANT=".rockbox/tools/soundscan.exe .rockbox/tools/database_pb.exe .rockbox/tools/artcache_pb.exe"
done
# Made inside each firmware build, whose language strings number them. The
# clip pool outlives the release directory, so only words that changed since
# the last release are synthesised again.
VOICE_TARGETS=
[ -z "$WITH_VOICES" ] || VOICE_TARGETS=$TARGETS
for target in $VOICE_TARGETS; do
say "Making the $target voices"
ssh "$SERVER" "cd '$REMOTE_DIR' && ./build-voices.sh build-hw-$target && \
cp build-hw-$target/voices.zip $(voices_asset_name "$target")"
done
# The script checks its own zip's contents.
say "Building the bootloader installer"
ssh "$SERVER" "cd '$REMOTE_DIR' && ./build-bootloader.sh"
# ----------------------------------------------------------------- verify ---
# A themeless zip installs happily and leaves the player looking broken, so each
# entry below is a file only a bundle script writes -- one that silently did
# nothing is caught. settings-help.txt matters most: without it every Explain
# menu entry shows nothing and nothing else looks wrong. Scrim is named by its
# .cfg, its .sbs and a bitmap, because a half-copied theme still passes a
# .cfg-only check. A font licence is named too: those texts are how the OFL
# notice reaches the player, and bundle-theme.sh only picks them up because it
# copies the whole theme directory.
say "Checking the zips"
for target in $TARGETS; do
zip=$REMOTE_DIR/build-hw-$target/rockbox.zip
ssh "$SERVER" "
set -e
[ -f '$zip' ] || { echo 'missing: $zip' >&2; exit 1; }
[ -s '$REMOTE_DIR/build-hw-$target/rockbox.map' ] ||
{ echo 'missing: $target rockbox.map' >&2; exit 1; }
for want in .rockbox/themes/scrim.cfg \
.rockbox/wps/scrim.sbs .rockbox/wps/scrim/volband.bmp \
.rockbox/docs/settings-help.txt \
.rockbox/trim.config \
.rockbox/speech/cmudict.bin \
.rockbox/games/font.bin \
.rockbox/games/spike.pbg \
.rockbox/games/musicquiz.pbg \
.rockbox/games/brickmania.pbg \
.rockbox/langs/english.vstrings \
.rockbox/fonts/LICENSE-Noto.txt \
$TOOL_WANT \
.rockbox/rockbox.ipod; do
unzip -l '$zip' | grep -q \"\$want\" ||
{ echo \"$target zip is missing \$want\" >&2; exit 1; }
done
printf ' %-10s ok (%s)\n' '$target' \"\$(du -h '$zip' | cut -f1)\"
"
done
# Every language, or the release would quietly ship without one -- Japanese
# needs the newer Piper, and is the one left out on a box without it.
for target in $VOICE_TARGETS; do
asset=$(voices_asset_name "$target")
n=$(ssh "$SERVER" "unzip -Z1 '$REMOTE_DIR/$asset'" | grep -c '[.]voice$' || true)
[ "$n" -eq 12 ] || die "$asset has $n voices, not 12 -- see build-voices.sh"
printf ' %-10s ok (%s voices)\n' "$target" "$n"
done
# Cut from the zip just checked, so the two differ by .rockbox/tools/ and
# nothing else. Under --no-sim there are no tools, and the copy is the same zip.
say "Packing the zips without the desktop tools"
for target in $TARGETS; do
asset=$(notools_asset_name "$target")
ssh "$SERVER" "
set -e
cd '$REMOTE_DIR'
cp build-hw-$target/rockbox.zip '$asset'
if unzip -Z1 '$asset' | grep -q '^\.rockbox/tools/'; then
zip -dq '$asset' '.rockbox/tools/*'
fi
if unzip -Z1 '$asset' | grep -qiE '\.(exe|dll)\$|^\.rockbox/tools/'; then
echo '$asset still carries the desktop tools' >&2; exit 1
fi
unzip -l '$asset' | grep -q .rockbox/rockbox.ipod ||
{ echo '$asset is missing .rockbox/rockbox.ipod' >&2; exit 1; }
printf ' %-10s ok (%s)\n' '$target' \"\$(du -h '$asset' | cut -f1)\"
"
done
# Packed from the extracted archive, like everything else here -- not zipped
# from the dev tree, whose checkout is CRLF and would ship skins the player
# reads with a stray carriage return on every line.
#
# Each theme's README goes in as .rockbox/docs, because the fonts it names
# are licensed under the OFL and the notice has to travel with them. They no
# longer travel in the firmware zip: that one carries Scrim's fonts only.
say "Packing the themes"
for theme in $EXTRA_THEMES; do
asset=$(theme_asset_name "$theme")
ssh "$SERVER" "
set -e
cd '$REMOTE_DIR'
[ -d 'themes/$theme/.rockbox' ] ||
{ echo 'themes/$theme/.rockbox is missing' >&2; exit 1; }
out=\$(pwd)/'$asset'
stage=\$(mktemp -d)
trap 'rm -rf \"\$stage\"' EXIT
cp -R 'themes/$theme/.rockbox' \"\$stage/\"
mkdir -p \"\$stage/.rockbox/docs\"
cp 'themes/$theme/README.md' \"\$stage/.rockbox/docs/$theme.md\"
rm -f \"\$out\"
(cd \"\$stage\" && zip -qr \"\$out\" .rockbox)
for want in .rockbox/themes/$theme.cfg .rockbox/wps/$theme.sbs \
.rockbox/wps/$theme.wps .rockbox/docs/$theme.md; do
unzip -l \"\$out\" | grep -q \"\$want\" ||
{ echo \"$theme zip is missing \$want\" >&2; exit 1; }
done
unzip -l \"\$out\" | grep -q '\.rockbox/fonts/.*\.fnt' ||
{ echo '$theme zip carries no fonts' >&2; exit 1; }
unzip -l \"\$out\" | grep -q '\.rockbox/fonts/LICENSE-' ||
{ echo '$theme zip carries fonts with no licence' >&2; exit 1; }
printf ' %-14s ok (%s)\n' '$theme' \"\$(du -h \"\$out\" | cut -f1)\"
"
done
# Unpacked from the single zips just made rather than staged again, so it
# cannot differ from them. Fonts several themes share are the same file, and
# land once.
ssh "$SERVER" "
set -e
cd '$REMOTE_DIR'
out=\$(pwd)/'$ALL_THEMES_ASSET'
stage=\$(mktemp -d)
trap 'rm -rf \"\$stage\"' EXIT
for zip in $(for t in $EXTRA_THEMES; do printf '%s ' "$(theme_asset_name "$t")"; done); do
unzip -qo \"\$zip\" -d \"\$stage\"
done
rm -f \"\$out\"
(cd \"\$stage\" && zip -qr \"\$out\" .rockbox)
for theme in $EXTRA_THEMES; do
unzip -l \"\$out\" | grep -q \".rockbox/themes/\$theme.cfg\" ||
{ echo \"$ALL_THEMES_ASSET is missing \$theme\" >&2; exit 1; }
done
printf ' %-14s ok (%s)\n' 'all themes' \"\$(du -h \"\$out\" | cut -f1)\"
"
# The simulator ships as one file holding both halves: the exe, and the
# simdisk/ beside it that build-sim.sh has already unpacked this build into.
# Separating them would let somebody run last month's exe against this month's
# .rockbox. Packed here rather than at publish time so --dry-run exercises it.
[ -z "$SIM_TARGETS" ] || say "Packing the simulators"
for target in $SIM_TARGETS; do
asset=$(sim_asset_name "$target")
ssh "$SERVER" "
set -e
cd '$REMOTE_DIR/build-sim-$target-win32'
[ -f rockboxui.exe ] || { echo 'missing: $target rockboxui.exe' >&2; exit 1; }
[ -f simdisk/.rockbox/themes/scrim.cfg ] ||
{ echo '$target simulator has no theme in simdisk' >&2; exit 1; }
rm -f '../$asset'
zip -qr '../$asset' rockboxui.exe simdisk
printf ' %-14s ok (%s)\n' '$target sim' \"\$(du -h '../$asset' | cut -f1)\"
"
done
say "Fetching copies to dist/"
mkdir -p dist
scp "$SERVER:$REMOTE_DIR/build-hw-ipod6g/rockbox.zip" \
"dist/$(asset_name ipod6g)"
scp "$SERVER:$REMOTE_DIR/build-hw-ipodvideo/rockbox.zip" \
"dist/$(asset_name ipodvideo)"
for target in $TARGETS; do
scp "$SERVER:$REMOTE_DIR/build-hw-$target/rockbox.map" \
"dist/$(map_name "$target")"
asset=$(notools_asset_name "$target")
scp "$SERVER:$REMOTE_DIR/$asset" "dist/$asset"
done
for target in $SIM_TARGETS; do
asset=$(sim_asset_name "$target")
scp "$SERVER:$REMOTE_DIR/$asset" "dist/$asset"
done
for theme in $EXTRA_THEMES; do
asset=$(theme_asset_name "$theme")
scp "$SERVER:$REMOTE_DIR/$asset" "dist/$asset"
done
scp "$SERVER:$REMOTE_DIR/$ALL_THEMES_ASSET" "dist/$ALL_THEMES_ASSET"
scp "$SERVER:$REMOTE_DIR/$BOOT_ASSET" "dist/$BOOT_ASSET"
if [ -n "$DRY_RUN" ]; then
# the Arcade's repositories made and checked from this build, as they
# would be published
[ -z "$WITH_ARCADE" ] || ./release-arcade.sh --server "$SERVER" \
--remote-dir "$REMOTE_DIR" --commit "$(git rev-parse HEAD)" --dry-run
say "Dry run: built and verified, nothing published"
echo " zips in dist/"
exit 0
fi
# ---------------------------------------------------------------- publish ---
# Everything below this line is visible outside, and is deliberately last.
#
# The order is themes, then simulator, then bootloader, then firmware. Only
# the firmware is marked Latest, the release the repository's front page
# offers; the others pass --latest=false, because GitHub otherwise moves the
# badge to each release as it is created. A visitor must land on the build,
# not on a theme, the simulator or the bootloader.
#
# A failure in the last step leaves fresh Themes, Simulator and Bootloader
# releases beside a stale `latest`. Everything is built and verified before
# any of this runs, so what remains is a network or gh failure; re-running
# the script republishes all four.
SHA=$(git rev-parse HEAD)
# --repo is REQUIRED on every gh call here and must not be dropped. gh infers
# the repo from the origin of the checkout it runs in, and the server's origin
# is upstream Rockbox, not this fork -- so an inferred release would target the
# wrong repo. (CLAUDE.md's "no --repo" note describes running gh on the local
# machine, where origin *is* the fork. It does not apply on the server.)
#
# Each release deletes its old self and its tag before the new one takes the
# tag. `gh release create` reuses an existing tag rather than moving it, so a
# leftover tag would publish these zips against an older commit. The second
# delete covers a tag left behind by a run that died between the two; it goes
# through gh rather than
# `git push --delete` because this script may itself be running on the server,
# where the fork is an https remote with no credentials -- a push there fails
# silently and leaves the stale tag for `gh release create` to reuse.
#
# --target names the commit each new tag is created at, on GitHub. Nothing tags
# locally: a rolling tag left in the dev checkout only goes stale.
say "Replacing the $THEMES_RELEASE release"
ssh "$SERVER" "gh release delete '$THEMES_RELEASE' --repo '$SLUG' --yes \
--cleanup-tag || true"
ssh "$SERVER" "gh api --method DELETE --silent \
'repos/$SLUG/git/refs/tags/$THEMES_RELEASE' 2>/dev/null || true"
scp -q "$THEMES_NOTES" "$SERVER:$REMOTE_DIR/themes-notes.md"
# The zips were named in the packing step, so there is nothing to rename here
# -- unlike the firmware, whose two builds both make rockbox.zip.
ssh "$SERVER" "cd '$REMOTE_DIR' && \
gh release create '$THEMES_RELEASE' \
--repo '$SLUG' \
--target '$SHA' \
--title 'Extra themes' \
--notes-file themes-notes.md \
--latest=false \
$DRAFT \
$ALL_THEMES_ASSET \
$(for t in $EXTRA_THEMES; do printf '%s ' "$(theme_asset_name "$t")"; done)"
say "Published $COMMIT as $THEMES_RELEASE"
echo " https://github.com/$SLUG/releases/tag/$THEMES_RELEASE"
if [ -n "$SIM_TARGETS" ]; then
say "Replacing the $SIM_RELEASE release"
ssh "$SERVER" "gh release delete '$SIM_RELEASE' --repo '$SLUG' --yes \
--cleanup-tag || true"
ssh "$SERVER" "gh api --method DELETE --silent \
'repos/$SLUG/git/refs/tags/$SIM_RELEASE' 2>/dev/null || true"
scp -q "$SIM_NOTES" "$SERVER:$REMOTE_DIR/simulator-notes.md"
ssh "$SERVER" "cd '$REMOTE_DIR' && \
gh release create '$SIM_RELEASE' \
--repo '$SLUG' \
--target '$SHA' \
--title 'Windows simulator' \
--notes-file simulator-notes.md \
--latest=false \
$DRAFT \
$(sim_asset_name ipod6g) $(sim_asset_name ipodvideo)"
say "Published $COMMIT as $SIM_RELEASE"
echo " https://github.com/$SLUG/releases/tag/$SIM_RELEASE"
fi
if [ -n "$VOICE_TARGETS" ]; then
say "Replacing the $VOICES_RELEASE release"
ssh "$SERVER" "gh release delete '$VOICES_RELEASE' --repo '$SLUG' --yes \
--cleanup-tag || true"
ssh "$SERVER" "gh api --method DELETE --silent \
'repos/$SLUG/git/refs/tags/$VOICES_RELEASE' 2>/dev/null || true"
scp -q "$VOICES_NOTES" "$SERVER:$REMOTE_DIR/voices-notes.md"
ssh "$SERVER" "cd '$REMOTE_DIR' && \
gh release create '$VOICES_RELEASE' \
--repo '$SLUG' \
--target '$SHA' \
--title 'Voices' \
--notes-file voices-notes.md \
--latest=false \
$DRAFT \
$(voices_asset_name ipod6g) $(voices_asset_name ipodvideo)"
say "Published $COMMIT as $VOICES_RELEASE"
echo " https://github.com/$SLUG/releases/tag/$VOICES_RELEASE"
fi
say "Replacing the $BOOT_RELEASE release"
ssh "$SERVER" "gh release delete '$BOOT_RELEASE' --repo '$SLUG' --yes \
--cleanup-tag || true"
ssh "$SERVER" "gh api --method DELETE --silent \
'repos/$SLUG/git/refs/tags/$BOOT_RELEASE' 2>/dev/null || true"
scp -q "$BOOT_NOTES" "$SERVER:$REMOTE_DIR/bootloader-notes.md"
ssh "$SERVER" "cd '$REMOTE_DIR' && \
gh release create '$BOOT_RELEASE' \
--repo '$SLUG' \
--target '$SHA' \
--title 'Bootloader installer' \
--notes-file bootloader-notes.md \
--latest=false \
$DRAFT \
$BOOT_ASSET"
say "Published $COMMIT as $BOOT_RELEASE"
echo " https://github.com/$SLUG/releases/tag/$BOOT_RELEASE"
# The firmware is uploaded as a draft under $STAGING_TAG while the old release
# still stands, so a failed upload leaves the old `latest` and its tag -- and
# the tag keeps the next run's notes to what is new. A draft has no tag until
# it is published, so the swap deletes the old release and tag, then renames
# and publishes the draft. A failure inside the swap leaves the build as the
# draft; publish it by hand with
# gh release edit latest-next --repo <slug> --tag latest --draft=false --latest
STAGING_TAG=$RELEASE-next
PUBLISH='--draft=false --latest'
[ -z "$DRAFT" ] || PUBLISH=
say "Uploading the $RELEASE release as a draft"
ssh "$SERVER" "gh release delete '$STAGING_TAG' --repo '$SLUG' --yes || true"
scp -q "$NOTES" "$SERVER:$REMOTE_DIR/release-notes.md"
# Both targets produce a file called rockbox.zip, so they must be renamed
# BEFORE upload. gh's `file#text` syntax does not do this -- it sets a display
# label and leaves the asset name as the filename, so uploading that way sends
# two assets both named rockbox.zip and the second one collides.
ssh "$SERVER" "cd '$REMOTE_DIR' && \
cp build-hw-ipod6g/rockbox.zip $(asset_name ipod6g) && \
cp build-hw-ipodvideo/rockbox.zip $(asset_name ipodvideo) && \
cp build-hw-ipod6g/rockbox.map $(map_name ipod6g) && \
cp build-hw-ipodvideo/rockbox.map $(map_name ipodvideo) && \
gh release create '$STAGING_TAG' \
--repo '$SLUG' \
--target '$SHA' \
--title 'Latest build' \
--notes-file release-notes.md \
--draft \
$(asset_name ipod6g) $(asset_name ipodvideo) \
$(notools_asset_name ipod6g) $(notools_asset_name ipodvideo) \
$(map_name ipod6g) $(map_name ipodvideo)"
say "Replacing the $RELEASE release"
ssh "$SERVER" "gh release delete '$RELEASE' --repo '$SLUG' --yes --cleanup-tag \
|| true"
ssh "$SERVER" "gh api --method DELETE --silent \
'repos/$SLUG/git/refs/tags/$RELEASE' 2>/dev/null || true"
ssh "$SERVER" "gh release edit '$STAGING_TAG' --repo '$SLUG' \
--tag '$RELEASE' $PUBLISH"
say "Published $COMMIT as $RELEASE"
echo " https://github.com/$SLUG/releases/tag/$RELEASE"
echo " local copies in dist/"
# The Arcade's side, from the same commit: published after the firmware,
# so @latest never builds for a firmware not yet out
[ -z "$WITH_ARCADE" ] || ./release-arcade.sh --server "$SERVER" \
--remote-dir "$REMOTE_DIR" --commit "$SHA"