forked from QiuSimons/YAOF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBPI-R4-Minimal-MTK-Bootloader-Test.yml
More file actions
183 lines (158 loc) · 7.16 KB
/
BPI-R4-Minimal-MTK-Bootloader-Test.yml
File metadata and controls
183 lines (158 loc) · 7.16 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
name: BPI-R4-Minimal-MTK-Bootloader-Test
run-name: Minimal BPI-R4 test · ${{ inputs.media }} · ${{ github.ref_name }}
on:
workflow_dispatch:
inputs:
media:
description: "Boot medium to validate (sd or emmc)"
required: false
type: string
default: "sd"
permissions:
contents: read
concurrency:
group: bpi-r4-minimal-${{ github.ref }}-${{ inputs.media }}
cancel-in-progress: false
jobs:
build:
runs-on: self-hosted
env:
seed: BPI-R4-MINIMAL
steps:
- name: Checkout
uses: actions/checkout@v4
with:
clean: false
- name: Cache OpenWrt build directories
uses: actions/cache@v4
with:
path: |
openwrt/dl
openwrt/staging_dir
openwrt/build_dir
# mtk-feed # disabled for now; upstream URL currently 404
bl-mt798x-dhcpd
key: ${{ runner.os }}-openwrt-minimal-${{ hashFiles('SCRIPTS/01_get_ready_minimal.sh', 'SCRIPTS/02_prepare_package_minimal.sh', 'SCRIPTS/BPI-R4/02_target_only_minimal.sh', 'SEED/BPI-R4-MINIMAL/config.seed') }}
restore-keys: |
${{ runner.os }}-openwrt-minimal-
- name: Build with Podman
id: compileopenwrt
continue-on-error: true
env:
INPUT_MEDIA: ${{ inputs.media || 'sd' }}
run: |
CURRENT_UID=$(id -u)
CURRENT_GID=$(id -g)
# Resolve GPT layout based on media
if [ "$INPUT_MEDIA" = "emmc" ]; then
GPT_LAYOUT="bpi-r4-emmc-8g-ab.json"
else
GPT_LAYOUT="bpi-r4-sd-ab.json"
fi
# Write build script to a file to avoid indentation issues
cat > build_script.sh <<'SCRIPT'
set -e
export DEBIAN_FRONTEND=noninteractive
if [ "$(id -u)" = "0" ]; then
export FORCE_UNSAFE_CONFIGURE=1
fi
# 1. Install dependencies
apt-get -o Acquire::Languages=none update -qq
apt-get install -y -qq --no-install-recommends \
asciidoc bash bin86 binutils bison bzip2 clang file flex g++ g++-multilib gawk \
gcc-multilib gettext git curl gzip help2man intltool jq libbpf-dev libelf-dev \
libncurses-dev libssl-dev libthread-queue-any-perl libusb-dev libxml-parser-perl \
make patch perl-modules pkg-config python3-dev python3-pip python3-pyelftools \
python3-setuptools rsync sharutils swig time unzip util-linux wget xsltproc \
xz-utils zlib1g-dev zip zstd dwarves dos2unix npm quilt bc llvm
npm install -g pnpm
pip3 install --user -U pylibfdt --break-system-packages
# 2. Execute scripts
chmod +x SCRIPTS/*.sh
chmod +x SCRIPTS/BPI-R4/*.sh
echo "=== Step 1: Get Ready ==="
bash SCRIPTS/01_get_ready_minimal.sh
echo "=== Step 2: Prepare Package ==="
cd openwrt
bash ../SCRIPTS/02_prepare_package_minimal.sh
bash ../SCRIPTS/BPI-R4/02_target_only_minimal.sh
echo "=== Step 3: Config ==="
cp -rf ../SEED/BPI-R4-MINIMAL/config.seed .config
echo "=== Step 4: Defconfig ==="
make defconfig
echo "=== Step 4b: Narrow bootloader variants for $INPUT_MEDIA ==="
sed -i \
-e '/^CONFIG_PACKAGE_trusted-firmware-a-mt7988-emmc-comb=/d' \
-e '/^CONFIG_PACKAGE_trusted-firmware-a-mt7988-sdmmc-comb=/d' \
-e '/^CONFIG_PACKAGE_trusted-firmware-a-mt7988-spim-nand-ubi-comb=/d' \
-e '/^CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-emmc=/d' \
-e '/^CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-sdmmc=/d' \
-e '/^CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-snand=/d' \
.config
case "$INPUT_MEDIA" in
emmc)
printf '%s\n' \
'# CONFIG_PACKAGE_trusted-firmware-a-mt7988-sdmmc-comb is not set' \
'# CONFIG_PACKAGE_trusted-firmware-a-mt7988-spim-nand-ubi-comb is not set' \
'# CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-sdmmc is not set' \
'# CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-snand is not set' \
'CONFIG_PACKAGE_trusted-firmware-a-mt7988-emmc-comb=y' \
'CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-emmc=y' >> .config
;;
sd|*)
printf '%s\n' \
'# CONFIG_PACKAGE_trusted-firmware-a-mt7988-emmc-comb is not set' \
'# CONFIG_PACKAGE_trusted-firmware-a-mt7988-spim-nand-ubi-comb is not set' \
'# CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-emmc is not set' \
'# CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-snand is not set' \
'CONFIG_PACKAGE_trusted-firmware-a-mt7988-sdmmc-comb=y' \
'CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-sdmmc=y' >> .config
;;
esac
echo "=== Step 4c: Final bootloader config ==="
grep -E '^(# )?CONFIG_PACKAGE_(trusted-firmware-a-mt7988|u-boot-mt7988_bananapi_bpi-r4)' .config || true
echo "=== Step 5: Download ==="
make download -j$(nproc)
echo "=== Step 6: Refresh host tar ==="
rm -rf build_dir/host/tar-* \
staging_dir/host/stamp/.tar_installed \
staging_dir/host/bin/tar \
staging_dir/host/share/man/man1/tar.1 \
staging_dir/host/man/man1/tar.1
make -j1 V=sc tools/tar/compile
echo "=== Step 7: Compile ==="
IGNORE_ERRORS=1 make -j$(nproc)
# 3. Fix permissions
echo "=== Fixing Permissions ==="
if [ "$(id -u)" = "0" ]; then
chown -R $CURRENT_UID:$CURRENT_GID /build || true
fi
SCRIPT
podman run --rm \
-v ${{ github.workspace }}:/build \
-w /build \
-e CURRENT_UID=$CURRENT_UID \
-e CURRENT_GID=$CURRENT_GID \
-e BPI_R4_GPT_LAYOUT=$GPT_LAYOUT \
ubuntu:24.04 \
bash build_script.sh
- name: If Error
if: ${{ always() && steps.compileopenwrt.outcome == 'failure' }}
run: |
podman run --rm \
-v ${{ github.workspace }}:/build \
-w /build/openwrt \
ubuntu:24.04 \
bash -lc '
cat ./.config
echo "================================================================"
echo "=== Verbose ATF rebuild ==="
make package/boot/arm-trusted-firmware-mediatek/clean
make package/boot/arm-trusted-firmware-mediatek/compile -j1 V=s || true
echo "================================================================"
echo "=== Verbose world rebuild ==="
make -j1 V=s || true
'
- name: Fail job if build failed
if: ${{ always() && steps.compileopenwrt.outcome == 'failure' }}
run: exit 1