-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpatch_rom
More file actions
executable file
·496 lines (407 loc) · 11.6 KB
/
Copy pathpatch_rom
File metadata and controls
executable file
·496 lines (407 loc) · 11.6 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
#!/bin/bash
# SPDX-FileCopyrightText: 2024 Edrick Sinsuan
# SPDX-License-Identifier: Apache-2.0
script_dir=$(dirname $0)
if ! check_file "$script_dir/setup_env"; then
decho "setup_env must be present in $script_dir!"
exit_timestamp 1
fi
source $script_dir/setup_env
if ! check_file "build/envsetup.sh"; then
decho "Call this script in the ROM's root directory!"
exit_timestamp 1
fi
readonly ROM_ROOT="$(pwd)"
readonly white_list_default=(
"$ROM_ROOT"
)
readonly black_list_default=(
)
white_list=(${white_list_default[@]})
black_list=(${black_list_default[@]})
is_skipped() {
local white_list_tmp=(${white_list[@]})
local black_list_tmp=(${black_list[@]})
# Reset the lists after patch
white_list=(${white_list_default[@]})
black_list=(${black_list_default[@]})
for rom in ${black_list_tmp[@]}; do
if [[ ! -z $(echo $ROM_ROOT | grep -i $rom) ]]; then
return 0
fi
done
if [[ ! -z $target_patch ]]; then
if [[ $target_patch != $patch_id ]]; then
return 0
else
return 1
fi
fi
for rom in ${white_list_tmp[@]}; do
if [[ ! -z $(echo $ROM_ROOT | grep -i $rom) ]]; then
return 1
fi
done
return 0
}
patch_banner() {
border
echo "Patch ID: $patch_id"
echo "Dir: $dir"
border
}
patch_git() {
local giturl=$1
local sha1=$2
local sha2=$3
local commit_sha
local commit_cnt
local __revert=$revert
revert=n
dir="$ROM_ROOT/$dir"
if is_skipped; then
return
fi
patch_banner
if check_dir "$dir" && cd "$dir"; then
git fetch $giturl
if [[ -z $sha2 ]]; then
commit_sha="$sha1"
commit_cnt="-n 1"
else
local conn='^..'
commit_sha="$sha1$conn$sha2"
fi
decho "$(git log $commit_cnt --pretty=oneline $commit_sha)"
if [[ $list_patches == "y" ]]; then
return
fi
if [[ $__revert == "y" ]]; then
decho "Reverting patches $commit_sha"
git revert $commit_sha
else
git cherry-pick $commit_sha
fi
if [[ ! -z $sha2 ]]; then
for ((i=0 ; i < ($(git rev-list --count $commit_sha) - 1) ; i++));
do
pause_script
if [[ $__revert == "y" ]]; then
git revert --skip
else
git cherry-pick --skip
fi
done
else
pause_script
fi
if [[ $__revert == "y" ]]; then
git revert --abort &> /dev/null
else
git cherry-pick --abort &> /dev/null
fi
fi
}
patch_single_curl() {
local patchurl=$1
dir="$ROM_ROOT/$dir"
if is_skipped; then
return
fi
patch_banner
if check_dir "$dir" && cd "$dir"; then
decho $patchurl
if [[ $list_patches == "y" ]]; then
return
fi
curl $patchurl | git am -3
pause_script
git am --abort &> /dev/null
fi
}
patch_single_local() {
local patchfile=$1
dir="$ROM_ROOT/$dir"
if is_skipped; then
return
fi
patch_banner
if check_dir "$dir" && cd "$dir"; then
decho $patchfile
if [[ $list_patches == "y" ]]; then
return
fi
git am -3 $patchfile
pause_script
git am --abort &> /dev/null
fi
}
param_func() {
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--skip-pause)
nopause=y
;;
-p|--patch-id)
if check_valid "$2"; then
target_patch="$2"
shift
fi
;;
-a|--all)
all_patches=y
;;
-l|--list)
list_patches=y
;;
-r|--revert)
revert=y
;;
esac
shift
done
}
#
# Patches
#
#
# 4.14 necessary patches
#
patch_qcomcaf() {
patch_id="qcomcaf"
dir=hardware/qcom-caf/common
# Patch qcom-caf for 4.14
patch_git "https://github.com/ederevx/android_hardware_qcom-caf_common a15" \
"468cd2bae94cdf01a826ea78c53469beb2427046"
}
patch_displayintf() {
patch_id="displayintf"
dir=vendor/qcom/opensource/commonsys-intf/display
# Patch display-commonsys-intf for 4.14
patch_git "https://github.com/ederevx/android_vendor_qcom_opensource_display-commonsys-intf lineage-22.1-msm8998-4-14" \
"385d238cc4ec9b7802b941131ef99742e530c659" \
"f235461d3cd0fe015e86a9c6136e2d3cf7c392ea"
}
patch_sepolicylegacy() {
patch_id="sepolicylegacy"
dir=device/qcom/sepolicy-legacy-um
# Patch sepolicy-legacy-um for 4.14
patch_git "https://github.com/ederevx/android_device_qcom_sepolicy a15" \
"bd3086d857f6c9f9f2c3461f6bead0e75f119886" \
"492418bf7ac1336d3c42db326ffa40c8d3ecc20d"
}
#
# Various build fixes
#
patch_buildmake() {
patch_id="buildmake"
dir=build/make
# Define fake out directories
patch_git "https://github.com/LineageOS/android_build lineage-21.0" \
"ea73f271e00847ea25b1dc232416685e1a21cb1e"
}
patch_bison() {
patch_id="bison"
dir=build/soong
black_list=(
"yaap"
)
# Allow bison - lineage
#patch_git "https://github.com/ederevx/android_build_soong a14" \
# "6a4996614768c719b9559956289a11c91369e958"
patch_git "https://github.com/ederevx/android_build_soong a15-derp" \
"7f817717bffec902a4397a3fee79005bcf536015"
dir=build/soong
white_list=(
"yaap"
)
# Allow bison - yaap
patch_git "https://github.com/ederevx/android_build_soong a15-yaap" \
"75cdf0768d969b63fa37dd03d36a76bc0632c19"
}
patch_revertbionic() {
patch_id="revertbionic"
revert=y
dir=bionic
white_list=(
"infinity"
)
# Revert workaround for sched_param
patch_git "https://github.com/ProjectInfinity-X/bionic 16" \
"4bf50c190d3d5e0ad48540bd16a10fdcb76761be"
}
patch_volumepanel() {
patch_id="volumepanel"
dir=frameworks/base
white_list=(
"derp"
)
# Allow overriding volume panel is left
patch_git "https://github.com/ederevx/derp_frameworks_base a14-derp" \
"b09631bbaa88de1543056044e689d333dd2b2706"
}
patch_tsgestures() {
patch_id="tsgestures"
dir=packages/apps/LineageParts
black_list=(
# "derp"
"$ROM_ROOT"
)
# Remove touchscreen gestures in LineageParts
patch_git "https://github.com/ederevx/android_packages_apps_LineageParts a14" \
"d0ccc35c0bd117e8841b0d414643c24ebc20a106"
dir=packages/apps/Settings
black_list=(
"$ROM_ROOT"
)
# Remove touchscreen gestures in Settings
patch_git "https://github.com/ederevx/android_packages_apps_Settings a14" \
"31187a64c9a5c49495651d11926edc5424a9473f"
}
patch_sepolicybinder() {
patch_id="sepolicybinder"
dir=system/sepolicy
white_list=(
"yaap"
)
# Fix binder denials
patch_git "https://github.com/ederevx/rising_android_system_sepolicy a15-yaap" \
"e31d7c8e856c1ec009db3de418c695cbe8d7a8d1"
}
patch_sepolicydrm() {
patch_id="sepolicydrm"
dir=system/sepolicy
white_list=(
"yaap"
)
# Allow hal_drm and hal_widevine for vendor access
patch_git "https://github.com/ederevx/android_system_sepolicy a16-yaap" \
"8235f2a15dd68d7c3ec5f7dd651caac83a1a173a"
}
patch_retrodyn() {
patch_id="retrodyn"
dir=system/sepolicy
white_list=(
"yaap"
)
# Resolve neverallow in retrofit devices
patch_git "https://github.com/ederevx/android_system_sepolicy a15-yaap" \
"a74949e75273cfe2d0b2a94eba51daa2cfb02c52"
dir=system/core
white_list=(
"yaap"
)
# fixup! liblp: Allow to flash on bigger block device
patch_git "https://github.com/LineageOS/android_system_core lineage-21.0" \
"abe5928776475c98f57175492ccf80957602910c"
dir=bootable/deprecated-ota
white_list=(
"yaap"
)
# updater: Support loading dynamic partition metadata from OTA - added in source
#patch_git "https://github.com/ederevx/android_bootable_deprecated-ota a15-yaap" \
# "86938568e3917a084c03d916771c9e7cbe735793"
dir=build/tools
white_list=(
"yaap"
)
# releasetools: Pass non-sparse super_empty.img to update_dynamic_partitions()
# https://github.com/LineageOS/android_build/commit/8124d9428ef269148f06c262f636d29e566d92d4
patch_git "git@github.com:ederevx/android_build_tools.git a15-yaap" \
"6b2f2725a0a6e00e4a8943488c16fe5b1cb5f8bf"
dir=build/tools
white_list=(
"yaap"
)
# Allow override of device asserts, including multi-device support
# https://github.com/LineageOS/android_build/commit/2f71c5fcdf3786692c6d2ec5433e1ccf51132047
patch_git "git@github.com:ederevx/android_build_tools.git a15-yaap" \
"5725f3d83f2e362c8e1d7c433c1cc0ca65829617"
dir=build/tools
white_list=(
"yaap"
)
# build: ota: Support for install tools in /tmp/install
# https://github.com/P-404/android_build/commit/deb9184d52445d1c390e89f3aaa6cbb0d83d1ed0
patch_git "git@github.com:ederevx/android_build_tools.git a15-yaap" \
"5e8f81226c5e74d9abcf9fc65258ebfe9dbe6c51"
}
patch_hardwarepixel() {
patch_id="hardwarepixel"
dir=hardware/google/pixel
white_list=(
"yaap"
)
# Prevent build error with YAAP vendor
patch_git "https://github.com/LineageOS/android_hardware_google_pixel lineage-21.0" \
"5723b06faf36c6a2c7c27a35ac43e30e51d8eb23"
}
patch_sepolicylegacyxtra() {
patch_id="sepolicylegacyxtra"
dir=device/qcom/sepolicy-legacy-um
white_list=(
"yaap"
)
# Remove xtra_control_prop
patch_git "https://github.com/ederevx/android_device_qcom_sepolicy a15-yaap" \
"50b4265bb4472f360730b32c09598ef96ad79240"
}
patch_lineagesepolicyfsck() {
patch_id="lineagesepolicyfsck"
dir=device/lineage/sepolicy
white_list=(
"yaap"
)
# Remove fsck prop
patch_git "https://github.com/ederevx/android_device_lineage_sepolicy a15-yaap" \
"4779acca48776a62a9ec708ba63ec6482b30c0bb"
}
patch_notifled() {
patch_id="notifled"
dir=framework/base
# Patch framework/base for notification LED fix
patch_git "https://github.com/LineageOS/android_frameworks_base lineage-21.0" \
"f9c33143b3906d07aebb782f214775a623ead94a"
}
patch_norecoveryover() {
patch_id="norecoveryover"
dir=bootable/deprecated-ota
white_list=(
"yaap"
)
# Allow us to not override the recovery
patch_git "https://github.com/ederevx/android_bootable_deprecated-ota a15-yaap" \
"93059ed1aca99828deeeda911351ec2bb90579d6"
}
patch_settings() {
patch_id="settings"
dir=packages/apps/Settings
# Patch settings app for theming a15
patch_git "https://github.com/ederevx/packages_apps_Settings a15-pixelage" \
"c0f973969d28a0b36e6d7c1c4db705f5e632c934"
}
decho "This only needs to be called once if done cleanly and after a repo start!"
param_func "$@"
# 4.14 necessary patches
patch_qcomcaf
patch_displayintf
patch_sepolicylegacy
if [[ $all_patches == "y" ]] || [[ ! -z $target_patch ]]; then
# Various build fixes
patch_buildmake
#patch_bison
#patch_volumepanel
#patch_tsgestures
#patch_sepolicybinder
patch_revertbionic
patch_sepolicydrm
patch_retrodyn
patch_hardwarepixel
patch_sepolicylegacyxtra
patch_lineagesepolicyfsck
patch_notifled
patch_norecoveryover
fi
exit_timestamp 0