Repository navigation
150 lines (139 loc) · 6.98 KB
/
Copy pathuboot-master-patch.yml
File metadata and controls
150 lines (139 loc) · 6.98 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
# Regenerate the squashed U-Boot patches that buildroot applies on top of the
# pinned upstream release.
#
# thingino builds the upstream U-Boot *release* tarball (BR2_TARGET_UBOOT_VERSION)
# and, via the global patch dir (BR2_GLOBAL_PATCH_DIR =
# package/all-patches), applies package/all-patches/uboot/<version>/*.patch to it
# with `patch -p1`. The fork branch (gtxaspec/u-boot ingenic-t-series) is
# maintained by merging upstream u-boot into itself, so a single diff from the
# release tag to the fork branch carries upstream churn plus our T-series port.
#
# This workflow regenerates that as two patches, split at the most recent
# upstream merge into the fork branch, so "release tree + upstream patch +
# thingino patch" reproduces our exact fork tree and the thingino patch stays
# small and reviewable:
# 0001-from-<version>-to-u-boot-head.patch upstream churn
# 0002-from-u-boot-head-to-thingino.patch thingino changes
#
# Manual trigger only. Binary files (binman self-test blobs) are excluded: GNU
# patch cannot apply git binary hunks, and the firmware build never touches them.
name: Regenerate U-Boot master patch
on:
workflow_dispatch:
inputs:
fork_repo:
description: "U-Boot fork repository (HTTPS URL)"
required: true
default: "https://github.com/gtxaspec/u-boot.git"
fork_ref:
description: "Fork branch or tag to diff against"
required: true
default: "ingenic-t-series"
base_tag:
description: "Upstream release tag to diff from (matches BR2_TARGET_UBOOT_VERSION)"
required: true
default: "v2026.07"
permissions:
contents: write
concurrency: uboot-master-patch
jobs:
regenerate:
runs-on: ubuntu-latest
steps:
- name: Checkout thingino-firmware
uses: actions/checkout@v5
- name: Fetch upstream release + fork branch
run: |
set -euxo pipefail
git init uboot
git -C uboot remote add upstream https://github.com/u-boot/u-boot.git
git -C uboot remote add fork "${{ inputs.fork_repo }}"
# The two diffs only need each tip's complete snapshot, but finding
# the split point needs the fork branch history back to the most
# recent upstream merge, so fetch a generous window.
git -C uboot fetch --depth=1 upstream \
"refs/tags/${{ inputs.base_tag }}:refs/tags/${{ inputs.base_tag }}"
git -C uboot fetch --depth=4000 fork \
"${{ inputs.fork_ref }}:refs/heads/fork-ref"
- name: Generate the patches (text-only, patch -p1 compatible)
run: |
set -euxo pipefail
base="${{ inputs.base_tag }}"
# Most recent merge in the fork branch's first-parent history: the
# last upstream merge the thingino work sits on top of.
split="$(git -C uboot log --first-parent --merges -1 --format=%H fork-ref)"
[ -n "$split" ] || { echo "error: no merge found in fork branch; cannot split" >&2; exit 1; }
echo "split point: $split"
# GNU patch (buildroot's tool) cannot apply git binary hunks; drop any
# binary files from each diff. --no-renames keeps these paths plain.
gen_patch() {
from="$1"
to="$2"
out="$3"
mapfile -t bins < <(git -C uboot diff --no-renames --numstat "$from" "$to" \
| awk '$1=="-" || $2=="-" { print $3 }')
excludes=()
for f in "${bins[@]}"; do excludes+=(":(exclude)$f"); done
if [ "${#bins[@]}" -gt 0 ]; then
printf 'Excluding binary file: %s\n' "${bins[@]}"
fi
# --no-renames so renames become delete+add full hunks (GNU patch has no
# rename support); default a/ b/ prefixes => applied with -p1.
git -C uboot -c core.quotepath=false diff --no-renames --no-color \
"$from" "$to" -- . "${excludes[@]}" > "$out"
}
gen_patch "$base" "$split" uboot-upstream.patch
gen_patch "$split" fork-ref uboot-thingino.patch
ls -l uboot-upstream.patch uboot-thingino.patch
# Belt-and-suspenders: no git binary hunks may remain.
! grep -qE '^Binary files|GIT binary patch' uboot-upstream.patch uboot-thingino.patch
- name: Verify they apply to a pristine release tree (buildroot's patch cmd)
run: |
set -euxo pipefail
base="${{ inputs.base_tag }}"
rm -rf verify && mkdir verify
git -C uboot archive "$base" | tar -x -C verify
# Exactly buildroot/support/scripts/apply-patches.sh, applied in order.
# Apply for real (not --dry-run): the second patch needs the first
# patch's result, so both are exercised against the same tree.
patch -F0 -g0 -p1 --no-backup-if-mismatch -d verify -t -N \
< uboot-upstream.patch
patch -F0 -g0 -p1 --no-backup-if-mismatch -d verify -t -N \
< uboot-thingino.patch
# Then the carry patches that buildroot applies after ours (skip the
# committed 0001/0002, which the two above replace). A carry patch the
# fork has since absorbed is refused as "previously applied" and would
# break every build of this U-Boot version: fail instead of pushing.
shopt -s nullglob
for p in "package/all-patches/uboot/${base#v}"/*.patch; do
case "${p##*/}" in 0001-* | 0002-*) continue ;; esac
patch -F0 -g0 -p1 --no-backup-if-mismatch -d verify -t -N < "$p" || {
echo "::error::${p##*/} does not apply on top of the regenerated patches; drop or refresh it in the same commit"
exit 1
}
done
- name: Place patches and commit if changed
run: |
set -euxo pipefail
ver="${{ inputs.base_tag }}"; ver="${ver#v}" # v2026.04 -> 2026.04
dest_dir="package/all-patches/uboot/${ver}"
upstream_dest="${dest_dir}/0001-from-${ver}-to-u-boot-head.patch"
thingino_dest="${dest_dir}/0002-from-u-boot-head-to-thingino.patch"
mkdir -p "$dest_dir"
mv uboot-upstream.patch "$upstream_dest"
mv uboot-thingino.patch "$thingino_dest"
# Drop the old combined baseline patch if this is the first split run.
rm -f "${dest_dir}/0001-uboot-master.patch"
git add "$dest_dir"
# Use the staged diff: a brand-new (untracked) patch must count as a
# change. Plain `git diff` ignores untracked files, so it would report
# "no change" on the very first run and skip the commit.
if git diff --cached --quiet -- "$dest_dir"; then
echo "No change to $dest_dir"
exit 0
fi
sha="$(git -C uboot rev-parse fork-ref)"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "uboot: regenerate ${ver} patches (${{ inputs.fork_ref }} @ ${sha:0:12})"
git push