aboutsummaryrefslogtreecommitdiff
path: root/scripts/build.sh
blob: 6b7ff67b60aa32fae13f57aa6b1bfcba87c7b991 (plain)
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
#!/bin/sh
# Rebuild the firmware package from the sources in this repository:
#   vendor/rockbox-822b9f5e.tar.xz   upstream YP3 Rockbox (jaydens-tasty-slop/rockbox)
#   patches/*.patch                  the audiobook changes
#   vendor/yp3-assets-1.tar.xz       themes and models the upstream build adds
# Downloaded: the Arm GNU toolchain (~150 MB), pinned by sha256 in the
# upstream tools/yp3/release.sh and cached in $YP3_CACHE; and rockslop's
# source at ROCKSLOP_COMMIT for its packager, packaging/mkpkg.py (or set
# MKPKG to a mkpkg.py you have).
#
#   scripts/build.sh [VERSION]       default VERSION: audiobook-dev
#
# Everything goes in build/ (not in git; safe to delete):
#   build/rockbox/   the patched source, a git repository
#   build/rockslop/  rockslop, for its mkpkg.py
#   build/out/       the package: rockbox-yp3-VERSION.tar.xz (+ .sha256)
# Copy the package to release/ when it has been tested on a player.
#
# Needs: sh, tar, xz, bzip2, zip, git, make, gcc (host tools), perl, python3, curl.
set -eu
die() { echo "build.sh: $*" >&2; exit 1; }

REPO=$(cd "$(dirname "$0")/.." && pwd)
VERSION=${1:-audiobook-dev}
UPSTREAM=822b9f5e999122bc25738fc9746bb7a17bb48fa6
# Upstream's commit time: the build's SOURCE_DATE_EPOCH base
UPSTREAM_DATE="2026-11-21T18:01:21-0700"
ROCKSLOP_URL=https://github.com/jaydens-tasty-slop/rockslop.git
ROCKSLOP_COMMIT=8715cfc99d392de62dd30ce06dc9703098e22c0f
W=$REPO/build                              # keep short: see below
CACHE=${YP3_CACHE:-$HOME/.cache/yp3-audiobook}

for t in tar xz bzip2 zip git make gcc perl python3 curl sha256sum; do
    command -v "$t" >/dev/null || die "needs $t"
done
(cd "$REPO/vendor" && sha256sum -c --quiet SHA256SUMS) || die "vendor/ checksums"

# The upstream build reaches the tree through a symlink and breaks
# ("Argument list too long") when it, or the output path, is long.
case ${#W} in [0-9]|[1-5][0-9]) ;; *)
    die "repository path too long for the build (${#W} chars in $W): clone it to a shorter path" ;;
esac

rm -rf "$W/rockbox" "$W/rockslop" "$W/out" "$W/s"
mkdir -p "$W/rockbox" "$W/rockslop" "$W/out"

# upstream tree as a git repository (the build reads versions from git),
# then the patches on top
tar -xJf "$REPO/vendor/rockbox-822b9f5e.tar.xz" -C "$W/rockbox"
(
    cd "$W/rockbox"
    export GIT_AUTHOR_NAME=upstream GIT_AUTHOR_EMAIL=upstream@localhost
    export GIT_COMMITTER_NAME=upstream GIT_COMMITTER_EMAIL=upstream@localhost
    export GIT_AUTHOR_DATE=$UPSTREAM_DATE GIT_COMMITTER_DATE=$UPSTREAM_DATE
    git init -q
    git add -A
    git commit -q -m "upstream jaydens-tasty-slop/rockbox $UPSTREAM"
    git am -q --committer-date-is-author-date "$REPO"/patches/*.patch
)
# rockslop's packager (its package format is the one the flasher reads)
if [ -z "${MKPKG:-}" ]; then
    git -C "$W/rockslop" init -q
    git -C "$W/rockslop" fetch -q --depth 1 "$ROCKSLOP_URL" "$ROCKSLOP_COMMIT" ||
        die "could not fetch rockslop $ROCKSLOP_COMMIT (or set MKPKG)"
    git -C "$W/rockslop" checkout -q FETCH_HEAD
    MKPKG=$W/rockslop/packaging/mkpkg.py
fi
[ -f "$MKPKG" ] || die "no mkpkg.py at $MKPKG"

echo "building $VERSION (log: $W/out/build.log)"
MKPKG=$(realpath "$MKPKG") \
YP3_ASSETS="file://$REPO/vendor/yp3-assets-1.tar.xz" \
YP3_ASSETS_SHA256=$(sed -n 's/  yp3-assets-1.tar.xz$//p' "$REPO/vendor/SHA256SUMS") \
YP3_SRC_LINK="$W/s" YP3_CACHE="$CACHE" \
    "$W/rockbox/tools/yp3/release.sh" "$VERSION" "$W/out"

echo
echo "package: $W/out/rockbox-yp3-$VERSION.tar.xz"
echo "check:   tools/rockslop-cli check $W/out/rockbox-yp3-$VERSION.tar.xz"