-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch.sh
457 lines (370 loc) · 13 KB
/
patch.sh
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
#!/bin/bash -e
#
# Copyright (c) 2009-2024 Robert Nelson <robertcnelson@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Split out, so build_kernel.sh and build_deb.sh can share..
shopt -s nullglob
. ${DIR}/version.sh
if [ -f ${DIR}/system.sh ] ; then
. ${DIR}/system.sh
fi
git_bin=$(which git)
#git hard requirements:
#git: --no-edit
git="${git_bin} am"
#git_patchset=""
#git_opts
if [ "${RUN_BISECT}" ] ; then
git="${git_bin} apply"
fi
echo "Starting patch.sh"
git_add () {
${git_bin} add .
${git_bin} commit -a -m 'testing patchset'
}
start_cleanup () {
git="${git_bin} am --whitespace=fix"
}
cleanup () {
if [ "${number}" ] ; then
if [ "x${wdir}" = "x" ] ; then
${git_bin} format-patch -${number} -o ${DIR}/patches/
else
if [ ! -d ${DIR}/patches/${wdir}/ ] ; then
mkdir -p ${DIR}/patches/${wdir}/
fi
${git_bin} format-patch -${number} -o ${DIR}/patches/${wdir}/
unset wdir
fi
fi
exit 2
}
dir () {
wdir="$1"
if [ -d "${DIR}/patches/$wdir" ]; then
echo "dir: $wdir"
if [ "x${regenerate}" = "xenable" ] ; then
start_cleanup
fi
number=
for p in "${DIR}/patches/$wdir/"*.patch; do
${git} "$p"
number=$(( $number + 1 ))
done
if [ "x${regenerate}" = "xenable" ] ; then
cleanup
fi
fi
unset wdir
}
cherrypick () {
if [ ! -d ../patches/${cherrypick_dir} ] ; then
mkdir -p ../patches/${cherrypick_dir}
fi
${git_bin} format-patch -1 ${SHA} --start-number ${num} -o ../patches/${cherrypick_dir}
num=$(($num+1))
}
external_git () {
git_tag=""
echo "pulling: ${git_tag}"
${git_bin} pull --no-edit ${git_patchset} ${git_tag}
${git_bin} describe
}
rt_cleanup () {
echo "rt: needs fixup"
exit 2
}
rt () {
rt_patch="${KERNEL_REL}${kernel_rt}"
#${git_bin} revert --no-edit xyz
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
wget -c https://www.kernel.org/pub/linux/kernel/projects/rt/${KERNEL_REL}/older/patch-${rt_patch}.patch.xz
xzcat patch-${rt_patch}.patch.xz | patch -p1 || rt_cleanup
rm -f patch-${rt_patch}.patch.xz
rm -f localversion-rt
${git_bin} add .
${git_bin} commit -a -m 'merge: CONFIG_PREEMPT_RT Patch Set' -m "patch-${rt_patch}.patch.xz" -s
${git_bin} format-patch -1 -o ../patches/external/rt/
echo "RT: patch-${rt_patch}.patch.xz" > ../patches/external/git/RT
exit 2
fi
dir 'external/rt'
}
wireless_regdb () {
#https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ -d ./wireless-regdb ] ; then
rm -rf ./wireless-regdb || true
fi
${git_bin} clone https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git --depth=1
cd ./wireless-regdb
wireless_regdb_hash=$(git rev-parse HEAD)
cd -
cd ./KERNEL/
mkdir -p ./firmware/ || true
cp -v ../wireless-regdb/regulatory.db ./firmware/
cp -v ../wireless-regdb/regulatory.db.p7s ./firmware/
${git_bin} add -f ./firmware/regulatory.*
${git_bin} commit -a -m 'Add wireless-regdb regulatory database file' -m "https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/commit/?id=${wireless_regdb_hash}" -s
${git_bin} format-patch -1 -o ../patches/external/wireless_regdb/
echo "WIRELESS_REGDB: https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/commit/?id=${wireless_regdb_hash}" > ../patches/external/git/WIRELESS_REGDB
rm -rf ../wireless-regdb/ || true
${git_bin} reset --hard HEAD^
start_cleanup
${git} "${DIR}/patches/external/wireless_regdb/0001-Add-wireless-regdb-regulatory-database-file.patch"
wdir="external/wireless_regdb"
number=1
cleanup
fi
dir 'external/wireless_regdb'
}
ti_pm_firmware () {
#https://git.ti.com/gitweb?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=shortlog;h=refs/heads/ti-v4.1.y
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ -d ./ti-amx3-cm3-pm-firmware ] ; then
rm -rf ./ti-amx3-cm3-pm-firmware || true
fi
${git_bin} clone -b ti-v4.1.y git://git.ti.com/processor-firmware/ti-amx3-cm3-pm-firmware.git --depth=1
cd ./ti-amx3-cm3-pm-firmware
ti_amx3_cm3_hash=$(git rev-parse HEAD)
cd -
cd ./KERNEL/
mkdir -p ./firmware/ || true
cp -v ../ti-amx3-cm3-pm-firmware/bin/am* ./firmware/
${git_bin} add -f ./firmware/am*
${git_bin} commit -a -m 'Add AM335x CM3 Power Managment Firmware' -m "http://git.ti.com/gitweb/?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=commit;h=${ti_amx3_cm3_hash}" -s
${git_bin} format-patch -1 -o ../patches/drivers/ti/firmware/
echo "TI_AMX3_CM3: http://git.ti.com/gitweb/?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=commit;h=${ti_amx3_cm3_hash}" > ../patches/external/git/TI_AMX3_CM3
rm -rf ../ti-amx3-cm3-pm-firmware/ || true
${git_bin} reset --hard HEAD^
start_cleanup
${git} "${DIR}/patches/drivers/ti/firmware/0001-Add-AM335x-CM3-Power-Managment-Firmware.patch"
wdir="drivers/ti/firmware"
number=1
cleanup
fi
dir 'drivers/ti/firmware'
}
cleanup_dts_builds () {
rm -rf arch/arm/boot/dts/modules.order || true
rm -rf arch/arm/boot/dts/.*cmd || true
rm -rf arch/arm/boot/dts/.*tmp || true
rm -rf arch/arm/boot/dts/*dtb || true
rm -rf arch/arm/boot/dts/*dtbo || true
rm -rf arch/arm64/boot/dts/ti/modules.order || true
rm -rf arch/arm64/boot/dts/ti/.*cmd || true
rm -rf arch/arm64/boot/dts/ti/.*tmp || true
rm -rf arch/arm64/boot/dts/ti/*dtb || true
rm -rf arch/arm64/boot/dts/ti/*dtbo || true
}
omap_makefile_patch_of_overlays () {
cat arch/arm/boot/dts/ti/omap/Makefile | grep -v '#'> arch/arm/boot/dts/ti/omap/Makefile.bak
echo "# SPDX-License-Identifier: GPL-2.0" > arch/arm/boot/dts/ti/omap/Makefile
echo "" >> arch/arm/boot/dts/ti/omap/Makefile
echo "ifeq (\$(CONFIG_OF_OVERLAY),y)" >> arch/arm/boot/dts/ti/omap/Makefile
echo "DTC_FLAGS += -@" >> arch/arm/boot/dts/ti/omap/Makefile
echo "endif" >> arch/arm/boot/dts/ti/omap/Makefile
echo "" >> arch/arm/boot/dts/ti/omap/Makefile
cat arch/arm/boot/dts/ti/omap/Makefile.bak >> arch/arm/boot/dts/ti/omap/Makefile
rm -rf arch/arm/boot/dts/ti/omap/Makefile.bak
}
arm_dtb_makefile_append () {
sed -i -e 's:am335x-boneblack.dtb \\:am335x-boneblack.dtb \\\n\t'$device' \\:g' arch/arm/boot/dts/ti/omap/Makefile
}
arm_dtbo_makefile_append () {
sed -i -e 's:am335x-boneblack.dtb \\:am335x-boneblack.dtb \\\n\t'$device'.dtbo \\:g' arch/arm/boot/dts/ti/omap/Makefile
cp -v ../${work_dir}/src/arm/overlays/${device}.dts arch/arm/boot/dts/ti/omap/${device}.dtso
}
k3_dtb_makefile_append () {
echo "dtb-\$(CONFIG_ARCH_K3) += $device" >> arch/arm64/boot/dts/ti/Makefile
}
beagleboard_dtbs () {
branch="v6.7.x"
https_repo="https://openbeagle.org/beagleboard/BeagleBoard-DeviceTrees.git"
work_dir="BeagleBoard-DeviceTrees"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ -d ./${work_dir} ] ; then
rm -rf ./${work_dir} || true
fi
${git_bin} clone -b ${branch} ${https_repo} --depth=1
cd ./${work_dir}
git_hash=$(git rev-parse HEAD)
cd -
cd ./KERNEL/
cleanup_dts_builds
rm -rf arch/arm/boot/dts/ti/omap/overlays/ || true
rm -rf arch/arm64/boot/dts/ti/overlays/ || true
omap_makefile_patch_of_overlays
cp -v ../${work_dir}/src/arm/ti/omap/*.dts arch/arm/boot/dts/ti/omap/
cp -v ../${work_dir}/src/arm/ti/omap/*.dtsi arch/arm/boot/dts/ti/omap/
cp -v ../${work_dir}/src/arm64/ti/*.dts arch/arm64/boot/dts/ti/
cp -v ../${work_dir}/src/arm64/ti/*.dtsi arch/arm64/boot/dts/ti/
cp -v ../${work_dir}/src/arm64/ti/*.h arch/arm64/boot/dts/ti/
cp -vr ../${work_dir}/include/dt-bindings/* ./include/dt-bindings/
device="AM335X-PRU-UIO-00A0" ; arm_dtbo_makefile_append
device="AM57XX-PRU-UIO-00A0" ; arm_dtbo_makefile_append
device="BB-ADC-00A0" ; arm_dtbo_makefile_append
device="BB-BBBW-WL1835-00A0" ; arm_dtbo_makefile_append
device="BB-BBGG-WL1835-00A0" ; arm_dtbo_makefile_append
device="BB-BBGW-WL1835-00A0" ; arm_dtbo_makefile_append
device="BB-BONE-eMMC1-01-00A0" ; arm_dtbo_makefile_append
device="BBORG_COMMS-00A2" ; arm_dtbo_makefile_append
device="BBORG_FAN-A000" ; arm_dtbo_makefile_append
device="BONE-ADC" ; arm_dtbo_makefile_append
device="am335x-boneblack-uboot.dtb" ; arm_dtb_makefile_append
${git_bin} add -f arch/arm/boot/dts/
${git_bin} add -f arch/arm64/boot/dts/
${git_bin} add -f include/dt-bindings/
${git_bin} commit -a -m "Add BeagleBoard.org Device Tree Changes" -m "https://openbeagle.org/beagleboard/BeagleBoard-DeviceTrees/-/tree/${branch}" -m "https://openbeagle.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/${git_hash}" -s
${git_bin} format-patch -1 -o ../patches/external/bbb.io/
echo "BBDTBS: https://openbeagle.org/beagleboard/BeagleBoard-DeviceTrees/-/commit/${git_hash}" > ../patches/external/git/BBDTBS
rm -rf ../${work_dir}/ || true
${git_bin} reset --hard HEAD^
start_cleanup
${git} "${DIR}/patches/external/bbb.io/0001-Add-BeagleBoard.org-Device-Tree-Changes.patch"
wdir="external/bbb.io"
number=1
cleanup
fi
dir 'external/bbb.io'
}
local_patch () {
echo "dir: dir"
${git} "${DIR}/patches/dir/0001-patch.patch"
}
#external_git
#rt
wireless_regdb
ti_pm_firmware
beagleboard_dtbs
#local_patch
pre_backports () {
echo "dir: backports/${subsystem}"
cd ~/linux-src/
${git_bin} pull --no-edit https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master
${git_bin} pull --no-edit https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master --tags
${git_bin} pull --no-edit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master --tags
if [ ! "x${backport_tag}" = "x" ] ; then
echo "${git_bin} checkout ${backport_tag} -f"
${git_bin} checkout ${backport_tag} -f
fi
cd -
}
post_backports () {
if [ ! "x${backport_tag}" = "x" ] ; then
cd ~/linux-src/
${git_bin} checkout master -f
cd -
fi
${git_bin} add .
${git_bin} commit -a -m "backports: ${subsystem}: from: linux.git" -m "Reference: ${backport_tag}" -s
if [ ! -d ../patches/backports/${subsystem}/ ] ; then
mkdir -p ../patches/backports/${subsystem}/
fi
${git_bin} format-patch -1 -o ../patches/backports/${subsystem}/
}
pre_rpibackports () {
echo "dir: backports/${subsystem}"
cd ~/linux-rpi/
${git_bin} fetch --tags
if [ ! "x${backport_tag}" = "x" ] ; then
echo "${git_bin} checkout ${backport_tag} -f"
${git_bin} checkout ${backport_tag} -f
fi
cd -
}
post_rpibackports () {
if [ ! "x${backport_tag}" = "x" ] ; then
cd ~/linux-rpi/
${git_bin} checkout master -f
cd -
fi
${git_bin} add .
${git_bin} commit -a -m "backports: ${subsystem}: from: linux.git" -m "Reference: ${backport_tag}" -s
if [ ! -d ../patches/backports/${subsystem}/ ] ; then
mkdir -p ../patches/backports/${subsystem}/
fi
${git_bin} format-patch -1 -o ../patches/backports/${subsystem}/
}
patch_backports () {
echo "dir: backports/${subsystem}"
${git} "${DIR}/patches/backports/${subsystem}/0001-backports-${subsystem}-from-linux.git.patch"
}
backports () {
backport_tag="v5.10.209"
subsystem="uio"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
pre_backports
cp -v ~/linux-src/drivers/uio/uio_pruss.c ./drivers/uio/
post_backports
exit 2
else
patch_backports
dir 'drivers/ti/uio'
fi
backport_tag="rpi-6.7.y"
subsystem="edt-ft5x06"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
pre_rpibackports
cp -v ~/linux-rpi/drivers/input/touchscreen/edt-ft5x06.c ./drivers/input/touchscreen/
post_rpibackports
exit 2
else
patch_backports
fi
}
drivers () {
dir 'boris'
###FIXME: this driver needs to be rewritten to use gpiolib directly, instead of hacking and reverting gpiolib changes to make it steal access
dir 'drivers/ti/gpio'
}
###
backports
drivers
packaging () {
echo "Update: package scripts"
#do_backport="enable"
if [ "x${do_backport}" = "xenable" ] ; then
backport_tag="v6.7.4"
subsystem="bindeb-pkg"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
pre_backports
cp -v ~/linux-src/scripts/package/* ./scripts/package/
post_backports
exit 2
else
patch_backports
fi
fi
${git} "${DIR}/patches/backports/bindeb-pkg/0002-builddeb-Install-our-dtbs-under-boot-dtbs-version.patch"
}
packaging
echo "patch.sh ran successfully"
#