-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.sh
More file actions
540 lines (434 loc) · 14 KB
/
patch.sh
File metadata and controls
540 lines (434 loc) · 14 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
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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
#!/bin/bash -e
#
# Copyright (c) 2009-2019 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
}
aufs_fail () {
echo "aufs failed"
exit 2
}
aufs () {
echo "dir: aufs"
aufs_prefix="aufs4-"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
KERNEL_REL=4.19.17+
wget https://raw.githubusercontent.com/sfjro/${aufs_prefix}standalone/aufs${KERNEL_REL}/${aufs_prefix}kbuild.patch
patch -p1 < ${aufs_prefix}kbuild.patch || aufs_fail
rm -rf ${aufs_prefix}kbuild.patch
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs-kbuild' -s
wget https://raw.githubusercontent.com/sfjro/${aufs_prefix}standalone/aufs${KERNEL_REL}/${aufs_prefix}base.patch
patch -p1 < ${aufs_prefix}base.patch || aufs_fail
rm -rf ${aufs_prefix}base.patch
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs-base' -s
wget https://raw.githubusercontent.com/sfjro/${aufs_prefix}standalone/aufs${KERNEL_REL}/${aufs_prefix}mmap.patch
patch -p1 < ${aufs_prefix}mmap.patch || aufs_fail
rm -rf ${aufs_prefix}mmap.patch
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs-mmap' -s
wget https://raw.githubusercontent.com/sfjro/${aufs_prefix}standalone/aufs${KERNEL_REL}/${aufs_prefix}standalone.patch
patch -p1 < ${aufs_prefix}standalone.patch || aufs_fail
rm -rf ${aufs_prefix}standalone.patch
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs-standalone' -s
${git_bin} format-patch -4 -o ../patches/aufs/
cd ../
if [ ! -d ./${aufs_prefix}standalone ] ; then
${git_bin} clone -b aufs${KERNEL_REL} https://github.com/sfjro/${aufs_prefix}standalone --depth=1
else
rm -rf ./${aufs_prefix}standalone || true
${git_bin} clone -b aufs${KERNEL_REL} https://github.com/sfjro/${aufs_prefix}standalone --depth=1
fi
cd ./KERNEL/
KERNEL_REL=4.19
cp -v ../${aufs_prefix}standalone/Documentation/ABI/testing/*aufs ./Documentation/ABI/testing/
mkdir -p ./Documentation/filesystems/aufs/
cp -rv ../${aufs_prefix}standalone/Documentation/filesystems/aufs/* ./Documentation/filesystems/aufs/
mkdir -p ./fs/aufs/
cp -v ../${aufs_prefix}standalone/fs/aufs/* ./fs/aufs/
cp -v ../${aufs_prefix}standalone/include/uapi/linux/aufs_type.h ./include/uapi/linux/
${git_bin} add .
${git_bin} commit -a -m 'merge: aufs' -s
${git_bin} format-patch -5 -o ../patches/aufs/
rm -rf ../${aufs_prefix}standalone/ || true
${git_bin} reset --hard HEAD~5
start_cleanup
${git} "${DIR}/patches/aufs/0001-merge-aufs-kbuild.patch"
${git} "${DIR}/patches/aufs/0002-merge-aufs-base.patch"
${git} "${DIR}/patches/aufs/0003-merge-aufs-mmap.patch"
${git} "${DIR}/patches/aufs/0004-merge-aufs-standalone.patch"
${git} "${DIR}/patches/aufs/0005-merge-aufs.patch"
wdir="aufs"
number=5
cleanup
fi
${git} "${DIR}/patches/aufs/0001-merge-aufs-kbuild.patch"
${git} "${DIR}/patches/aufs/0002-merge-aufs-base.patch"
${git} "${DIR}/patches/aufs/0003-merge-aufs-mmap.patch"
${git} "${DIR}/patches/aufs/0004-merge-aufs-standalone.patch"
${git} "${DIR}/patches/aufs/0005-merge-aufs.patch"
}
can_isotp () {
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./can-isotp ] ; then
${git_bin} clone https://github.com/hartkopp/can-isotp --depth=1
else
rm -rf ./can-isotp || true
${git_bin} clone https://github.com/hartkopp/can-isotp --depth=1
fi
cd ./KERNEL/
cp -v ../can-isotp/include/uapi/linux/can/isotp.h include/uapi/linux/can/
cp -v ../can-isotp/net/can/isotp.c net/can/
${git_bin} add .
${git_bin} commit -a -m 'merge: can-isotp: https://github.com/hartkopp/can-isotp' -s
${git_bin} format-patch -1 -o ../patches/can_isotp/
rm -rf ../can-isotp/ || true
${git_bin} reset --hard HEAD~1
start_cleanup
${git} "${DIR}/patches/can_isotp/0001-merge-can-isotp-https-github.com-hartkopp-can-isotp.patch"
wdir="can_isotp"
number=1
cleanup
exit 2
fi
dir 'can_isotp'
}
rt_cleanup () {
echo "rt: needs fixup"
exit 2
}
rt () {
echo "dir: rt"
rt_patch="${KERNEL_REL}${kernel_rt}"
#v4.19.x
#${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}/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' -s
${git_bin} format-patch -1 -o ../patches/rt/
exit 2
fi
${git} "${DIR}/patches/rt/0001-merge-CONFIG_PREEMPT_RT-Patch-Set.patch"
}
wireguard_fail () {
echo "WireGuard failed"
exit 2
}
wireguard () {
echo "dir: WireGuard"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./WireGuard ] ; then
${git_bin} clone https://git.zx2c4.com/WireGuard --depth=1
else
rm -rf ./WireGuard || true
${git_bin} clone https://git.zx2c4.com/WireGuard --depth=1
fi
cd ./KERNEL/
../WireGuard/contrib/kernel-tree/create-patch.sh | patch -p1 || wireguard_fail
${git_bin} add .
${git_bin} commit -a -m 'merge: WireGuard' -s
${git_bin} format-patch -1 -o ../patches/WireGuard/
rm -rf ../WireGuard/ || true
${git_bin} reset --hard HEAD^
start_cleanup
${git} "${DIR}/patches/WireGuard/0001-merge-WireGuard.patch"
wdir="WireGuard"
number=1
cleanup
fi
${git} "${DIR}/patches/WireGuard/0001-merge-WireGuard.patch"
}
ti_pm_firmware () {
#http://git.ti.com/gitweb/?p=processor-firmware/ti-amx3-cm3-pm-firmware.git;a=shortlog;h=refs/heads/ti-v4.1.y-next
echo "dir: drivers/ti/firmware"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cd ../
if [ ! -d ./ti-amx3-cm3-pm-firmware ] ; then
${git_bin} clone -b ti-v4.1.y-next git://git.ti.com/processor-firmware/ti-amx3-cm3-pm-firmware.git --depth=1
else
rm -rf ./ti-amx3-cm3-pm-firmware || true
${git_bin} clone -b ti-v4.1.y-next git://git.ti.com/processor-firmware/ti-amx3-cm3-pm-firmware.git --depth=1
fi
cd ./KERNEL/
cp -v ../ti-amx3-cm3-pm-firmware/bin/am* ./firmware/
${git_bin} add -f ./firmware/am*
${git_bin} commit -a -m 'add am33x firmware' -s
${git_bin} format-patch -1 -o ../patches/drivers/ti/firmware/
rm -rf ../ti-amx3-cm3-pm-firmware/ || true
${git_bin} reset --hard HEAD^
start_cleanup
${git} "${DIR}/patches/drivers/ti/firmware/0001-add-am33x-firmware.patch"
wdir="drivers/ti/firmware"
number=1
cleanup
fi
${git} "${DIR}/patches/drivers/ti/firmware/0001-add-am33x-firmware.patch"
}
local_patch () {
echo "dir: dir"
${git} "${DIR}/patches/dir/0001-patch.patch"
}
#external_git
aufs
can_isotp
#rt
wireguard
ti_pm_firmware
#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
${git_bin} checkout ${backport_tag} -b tmp
fi
cd -
}
post_backports () {
if [ ! "x${backport_tag}" = "x" ] ; then
cd ~/linux-src/
${git_bin} checkout master -f ; ${git_bin} branch -D tmp
cd -
fi
${git_bin} add .
${git_bin} commit -a -m "backports: ${subsystem}: from: linux.git" -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="v4.20.17"
subsystem="remoteproc"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
pre_backports
cp -rv ~/linux-src/drivers/remoteproc/* ./drivers/remoteproc/
cp -v ~/linux-src/include/linux/remoteproc.h ./include/linux/remoteproc.h
post_backports
exit 2
else
patch_backports
fi
}
reverts () {
echo "dir: reverts"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
start_cleanup
fi
## notes
##git revert --no-edit xyz -s
#${git} "${DIR}/patches/reverts/0001-Revert-xyz.patch"
if [ "x${regenerate}" = "xenable" ] ; then
wdir="reverts"
number=1
cleanup
fi
}
drivers () {
dir 'drivers/ar1021_i2c'
dir 'drivers/btrfs'
dir 'drivers/pwm'
dir 'drivers/spi'
dir 'drivers/ssd1306'
dir 'drivers/tps65217'
dir 'drivers/opp'
dir 'drivers/wiznet'
dir 'drivers/ti/overlays'
dir 'drivers/ti/cpsw'
dir 'drivers/ti/etnaviv'
dir 'drivers/ti/eqep'
dir 'drivers/ti/rpmsg'
dir 'drivers/ti/serial'
dir 'drivers/ti/spi'
dir 'drivers/ti/tsc'
dir 'drivers/ti/gpio'
${git} "${DIR}/patches/drivers/ti/uio_pruss/0001-uio-pruss-cleanups-and-pruss-v2-pru-icss-support.patch"
${git} "${DIR}/patches/drivers/ti/uio_pruss/0003-ARM-omap2-support-deasserting-reset-from-dts.patch"
#[PATCH v3 1/4] mfd: stmpe: Move ADC related defines to header of mfd
dir 'drivers/iio/stmpe'
}
soc () {
# dir 'soc/imx/udoo'
# dir 'soc/imx/wandboard'
# dir 'soc/imx/imx6'
# dir 'soc/imx/imx7'
# dir 'soc/ti/omap3'
# dir 'soc/ti/omap4'
dir 'soc/ti/am335x'
dir 'soc/ti/blue'
dir 'soc/ti/abbbi'
dir 'soc/ti/pocketbeagle'
dir 'soc/ti/beaglebone_capes'
dir 'soc/ti/uboot'
dir 'soc/ti/spi_symlink'
}
dtb_makefile_append () {
sed -i -e 's:am335x-boneblack.dtb \\:am335x-boneblack.dtb \\\n\t'$device' \\:g' arch/arm/boot/dts/Makefile
}
beaglebone () {
#This has to be last...
echo "dir: beaglebone/dtbs"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
patch -p1 < "${DIR}/patches/beaglebone/dtbs/0001-sync-am335x-peripheral-pinmux.patch"
exit 2
fi
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
start_cleanup
fi
${git} "${DIR}/patches/beaglebone/dtbs/0001-sync-am335x-peripheral-pinmux.patch"
if [ "x${regenerate}" = "xenable" ] ; then
number=1
cleanup
fi
####
#dtb makefile
echo "dir: beaglebone/generated"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
device="am335x-boneblack-uboot.dtb" ; dtb_makefile_append
# device="am335x-boneblack-roboticscape.dtb" ; dtb_makefile_append
# device="am335x-boneblack-wireless-roboticscape.dtb" ; dtb_makefile_append
device="am335x-abbbi.dtb" ; dtb_makefile_append
device="am335x-boneblack-wl1835mod.dtb" ; dtb_makefile_append
device="am335x-boneblack-bbbmini.dtb" ; dtb_makefile_append
device="am335x-boneblack-bbb-exp-c.dtb" ; dtb_makefile_append
device="am335x-boneblack-bbb-exp-r.dtb" ; dtb_makefile_append
device="am335x-boneblack-audio.dtb" ; dtb_makefile_append
device="am335x-bone-uboot-univ.dtb" ; dtb_makefile_append
device="am335x-boneblack-uboot-univ.dtb" ; dtb_makefile_append
device="am335x-bonegreen-wireless-uboot-univ.dtb" ; dtb_makefile_append
git commit -a -m 'auto generated: capes: add dtbs to makefile' -s
git format-patch -1 -o ../patches/beaglebone/generated/
exit 2
else
${git} "${DIR}/patches/beaglebone/generated/0001-auto-generated-capes-add-dtbs-to-makefile.patch"
fi
}
###
backports
#reverts
drivers
soc
beaglebone
packaging () {
echo "dir: packaging"
#regenerate="enable"
if [ "x${regenerate}" = "xenable" ] ; then
cp -v "${DIR}/3rdparty/packaging/Makefile" "${DIR}/KERNEL/scripts/package"
cp -v "${DIR}/3rdparty/packaging/builddeb" "${DIR}/KERNEL/scripts/package"
cp -v "${DIR}/3rdparty/packaging/mkdebian" "${DIR}/KERNEL/scripts/package"
${git_bin} commit -a -m 'packaging: sync builddeb changes' -s
${git_bin} format-patch -1 -o "${DIR}/patches/packaging"
exit 2
else
${git} "${DIR}/patches/packaging/0001-packaging-sync-builddeb-changes.patch"
fi
}
packaging
echo "patch.sh ran successfully"