This repository has been archived by the owner on Jun 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
212 lines (193 loc) · 8.26 KB
/
build-kernel-modules.yml
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
name: Build Kernel Module
on:
push:
branches:
- main
paths:
- devices/**
- ci/*.py
- .github/workflows/build-kernel-modules.yml
pull_request:
paths:
- devices/**
- ci/*.py
- .github/workflows/build-kernel-modules.yml
workflow_dispatch:
env:
APT_DEPS: aria2
DOWNLOAD_FROM_TORRENT: false
jobs:
prepare-build:
runs-on: ubuntu-22.04
if: "!contains(github.event.head_commit.message, 'Bump version to ')"
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
version: ${{ steps.version.outputs.version }}
python: ${{ steps.tool-versions.outputs.python }}
steps:
- uses: actions/checkout@v3
- name: Read .tool-versions
uses: marocchino/tool-versions-action@v1
id: tool-versions
- uses: actions/setup-python@v4
with:
python-version: ${{ steps.tool-versions.outputs.python }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.tool-versions.outputs.python }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: 🏗️ Build matrix
id: matrix
run: poetry run python3 ci/generate_build_matrix.py
- name: 🏗️ Collect crosscompiler packages
id: crosscompilers
run: poetry run python3 ci/get_all_crosscompilers.py
- name: Get and cache apt dependencies
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: ${{ steps.crosscompilers.outputs.ALL_CROSSCOMPILERS }} ${{ env.APT_DEPS }}
version: 1.0
- name: Get version
id: version
run: echo "version=$(cat ./macvlan-unifios-version)" >> $GITHUB_OUTPUT
build-module:
runs-on: ubuntu-22.04
needs: prepare-build
strategy:
matrix: ${{ fromJSON(needs.prepare-build.outputs.matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ needs.prepare-build.outputs.python }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ needs.prepare-build.outputs.python }}-${{ hashFiles('**/poetry.lock') }}
- name: Extract device metadata
id: get-device-metadata
run: poetry run python3 ci/get_device_metadata.py ${{ matrix.device }}
- name: Extract firmware metadata
id: get-firmware-metadata
run: |
poetry run python3 ci/get_firmware_metadata.py ${{ matrix.device }} ${{ matrix.firmware }}
- name: Read archive info from file
id: archive-data
run: poetry run python3 ci/parse_archive_info.py ${{ fromJSON(steps.get-firmware-metadata.outputs.json).kernel-archive-path }}
- name: Restore cached apt dependencies
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: ${{ fromJSON(steps.get-device-metadata.outputs.json).cross-compiler-package }} ${{ env.APT_DEPS }}
version: 1.0
- name: Restore kernel archive from cache
id: cache-kernel-archive
uses: actions/cache@v3
with:
path: ./linux-unifios.tar.gz
key: ${{ fromJSON(steps.get-firmware-metadata.outputs.json).kernel-sha256sum }}
- name: Download kernel archive if required (http)
if: steps.cache-kernel-archive.outputs.cache-hit != 'true' && env.DOWNLOAD_FROM_TORRENT != 'true'
run: |
curl -Lo ./linux-unifios.tar.gz "${{ steps.archive-data.outputs.firmware-http-url }}"
- name: Download kernel archive if required (torrent)
if: steps.cache-kernel-archive.outputs.cache-hit != 'true' && env.DOWNLOAD_FROM_TORRENT == 'true'
run: |
wget -O archive.torrent "${{ steps.archive-data.outputs.archive-torrent-url }}"
FILE_INDEX="$(aria2c -d . -S archive.torrent \
| grep '${{ fromJSON(steps.get-firmware-metadata.outputs.json).kernel-archive-path }}$' \
| cut -d '|' -f1)"
aria2c -d . --seed-time=0 --select-file "${FILE_INDEX}" \
--bt-stop-timeout=10 --index-out="${FILE_INDEX}=./linux-unifios.tar.gz" \
archive.torrent || true
- name: Ensure kernel SHA matches
run: echo '${{ fromJSON(steps.get-firmware-metadata.outputs.json).kernel-sha256sum }} linux-unifios.tar.gz' | sha256sum -c
- name: Extract Kernel
run: |
mkdir linux-source
tar -xf ./linux-unifios.tar.gz --strip-components=1 -C linux-source
- name: Copy kernel config file into kernel directory
run: cp ${{ steps.get-firmware-metadata.outputs.firmware-directory }}/kernel-config linux-source/.config
- name: Update version placeholder in any patches
run: |
sed -i "s@%%VERSION%%@${{ needs.prepare-build.outputs.version }}@" ${{ steps.get-firmware-metadata.outputs.firmware-directory }}/patches/*.patch
- name: Apply firmware-specific patches
run: find ${{ steps.get-firmware-metadata.outputs.firmware-directory }}/patches -type f -name '*.patch' -print0 | sort -z | xargs -t -0 -n 1 patch -p0 -i
- name: Prepare for building
run: |
cd linux-source
make ARCH=${{ fromJSON(steps.get-device-metadata.outputs.json).architecture }} CROSS_COMPILE=${{ fromJSON(steps.get-device-metadata.outputs.json).cross-compiler }} olddefconfig prepare
- name: Build the module
run: |
cd linux-source
make ARCH=${{ fromJSON(steps.get-device-metadata.outputs.json).architecture }} CROSS_COMPILE=${{ fromJSON(steps.get-device-metadata.outputs.json).cross-compiler }} drivers/net/macvlan.ko
- name: Rename the artifact file
run: mv linux-source/drivers/net/macvlan.ko ./${{ matrix.device }}-${{ matrix.firmware }}_macvlan.ko
- name: Store the artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.device }}-${{ matrix.firmware }}_macvlan.ko
path: ./${{ matrix.device }}-${{ matrix.firmware }}_macvlan.ko
release:
if: github.ref == 'refs/heads/main' # if branch is main
runs-on: ubuntu-22.04
needs:
- build-module
- prepare-build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ needs.prepare-build.outputs.python }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ needs.prepare-build.outputs.python }}-${{ hashFiles('**/poetry.lock') }}
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2
id: download
with:
path: built_modules
- name: Generate release text files
run: |
poetry run python3 ci/build_release_text_files.py v${{ needs.prepare-build.outputs.version }} ${{steps.download.outputs.download-path}}
- name: Create release
uses: ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e # 1.12.0
with:
draft: true
allowUpdates: true
artifacts: ${{steps.download.outputs.download-path}}/*/*.ko,text_files_out/checksums.txt,text_files_out/setup_macvlan.sh
name: ${{ needs.prepare-build.outputs.version }}
tag: v${{ needs.prepare-build.outputs.version }}
bodyFile: text_files_out/release_notes.md