-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
patch.sh
executable file
·417 lines (389 loc) · 13.2 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
set -e
binary_name=xochitl
workdir=/home/rmhacks
patched="$workdir/$binary_name.patched"
if [ ! -d $workdir ]; then
mkdir -p $workdir
# migrate stuff and clean old patches
mv /home/root/xochitl.* $workdir 2> /dev/null || true
rm /home/root/patch_* 2> /dev/null || true
fi;
function checkspace(){
part=$1
needed=$2
available=$(df $part | tail -n1 | awk '{print $4}');
let available=$available/1024
if [ $available -lt $needed ];then
echo "Less than ${needed}MB free, ${available}MB"
return 1;
fi;
}
checkspace / 3 || (echo "Trying to free space..."; journalctl --vacuum-time=1m)
checkspace / 3 || (echo "Aborting..."; exit 10)
checkspace /home 10 || (echo "Not enough space on /home"; exit 10)
echo "Disk space seems to be enough."
trap onexit INT
function onexit(){
cleanup
auto_install
exit 0
}
function cleanup(){
echo "Cleaning up..."
rm /tmp/*crash* 2> /dev/null || true
rm -fr /home/root/.cache/remarkable/xochitl/qmlcache/*
}
function purge(){
if [ ! -f "$backup_file" ]; then
echo "The backup file is missing"
exit 1
fi
hash=$(sha1sum "$backup_file" | cut -c 1-40)
if [ "$expectedhash" != "$hash" ]; then
echo "The backup $backup_file is not the original file (was it replaced/ deleted? / wrong hash)"
echo "Expected hash: $expectedhash"
echo "Actual hash: $hash"
echo "cowardly aborting..."
exit 1
fi
systemctl stop xochitl
cleanup
cp "$backup_file" /usr/bin/xochitl
systemctl start xochitl
echo -n "Remove all traces [Y/n]? "
read yn
case $yn in
[Nn]* )
;;
* )
rm -fr "$workdir"
;;
esac
exit 0
}
function auto_install(){
if [ -z "$1" ]; then
echo -n "If everything worked, do you want to make it permanent [N/y]? "
read yn
else
yn=$1
fi
case $yn in
[Yy]* )
echo "Making it permanent, DON'T DELETE $backup_file !!!"
mv $patched /usr/bin/$binary_name
echo "IMPORTANT: Do not forget to disable 'Automatic updates' on your reMarkable to avoid losing the hack unintentionally."
echo "Starting the UI..."
systemctl start xochitl
return 0
;;
* )
echo "Use the $patched binary if you change your mind / provide it if it segfaulted."
echo "Starting the original..."
systemctl start xochitl
;;
esac
return 1
}
currentVersion="$(</etc/version)"
case $currentVersion in
"20221026103859" )
patch_name=${1:-patch_39.1.01}
version="21511189_rm1"
expectedhash="1c01bae469a2e29846c68758e2cae4a2b8b5055d"
echo "rM1 Version 2.15.1.1189 - $patch_name"
;;
"20221026104022" )
patch_name=${1:-patch_39.2.01}
version="21511189_rm2"
expectedhash="64e3cb3d05aec4a40624ebfc730e480358e1b184"
echo "rM2 Version 2.15.1.1189 - $patch_name"
;;
"20221003074737" )
patch_name=${1:-patch_38.1.03}
version="21501067_rm1"
expectedhash="a3ce408c8a717d48746e361336532924f5ff40f2"
echo "rM1 Version 2.15.0.1067 - $patch_name"
;;
"20221003075633" )
patch_name=${1:-patch_38.2.03}
version="21501067_rm2"
expectedhash="fcd3c84215c5457d455419831760304736f3b694"
echo "rM2 Version 2.15.0.1067 - $patch_name"
;;
"20220921102803" )
patch_name=${1:-patch_37.1.01}
version="21431047_rm1"
expectedhash="011742f027b70f37a0da293132daafcfc82b537d"
echo "rM1 Version 2.14.3.1047 - $patch_name"
;;
"20220921101206" )
patch_name=${1:-patch_37.2.01}
version="21431047_rm2"
expectedhash="47c3ad26651f604be5de901881a8a44f9124a79c"
echo "rM2 Version 2.14.3.1047 - $patch_name"
;;
"20220907142424" )
patch_name=${1:-patch_36.1.01}
version="21431005_rm1"
expectedhash="5b74a5d7bc7bd0926883c97d45af0d4015fb15f0"
echo "rM1 Version 2.14.3.1005 - $patch_name"
;;
"20220907143405" )
patch_name=${1:-patch_36.2.01}
version="21431005_rm2"
expectedhash="6ef873c5addef949cb56e636a8fbd682840afe17"
echo "rM2 Version 2.14.3.1005 - $patch_name"
;;
"20220825124750" )
patch_name=${1:-patch_36.2.01}
version="2143977_rm2"
expectedhash="470e88f8d5fb62f64939fe4ea3b89c515113f7e5"
echo "rM2 Version 2.14.3.977 - $patch_name"
;;
"20220825122914" )
patch_name=${1:-patch_36.1.01}
version="2143977_rm1"
expectedhash="a88faec812ae20960bfbab38be0aa49aafec902a"
echo "rM1 Version 2.14.3.977 - $patch_name"
;;
"20220617142418" )
patch_name=${1:-patch_35.1.01}
version="2141866_rm1"
expectedhash="a052dfbe587851d17146e586e4be65819f1360e3"
echo "rM1 Version 2.14.1.866 - $patch_name"
;;
"20220617143306" )
patch_name=${1:-patch_35.2.01}
version="2141866_rm2"
expectedhash="1d7f6f049e5a6b192caaf07cbf67ba7c2555e5f0"
echo "rM2 Version 2.14.1.866 - $patch_name"
;;
"20220615075543" )
patch_name=${1:-patch_34.1.01}
version="2140861_rm1"
expectedhash="a3da3cc4d393917703bcdc2ed3c280ebcc192e0f"
echo "rM1 Version 2.14.0.861 - $patch_name"
;;
"20220615074909" )
patch_name=${1:-patch_34.2.01}
version="2140861_rm2"
expectedhash="6376fb20bdf6952bb7b75838c0bda1c80f0e9191"
echo "rM2 Version 2.14.0.861 - $patch_name"
;;
"20220519120030" )
patch_name=${1:-patch_33.2.01}
version="2130758_rm2"
expectedhash="c77016e4608ccab1b1e619a6ef2769a205312025"
echo "rM2 Version 2.13.0.758 - $patch_name"
;;
"20220330140034" )
patch_name=${1:-patch_32.1.03}
version="2123606_rm1"
expectedhash="e6693c76ad588c7a223cf5be5a280214495a68e0"
echo "rM1 Version 2.12.3.606 - $patch_name"
;;
"20220330134519" )
patch_name=${1:-patch_32.2.02}
version="2123606_rm2"
expectedhash="b7d8f0ca786117cdf715e3f7b08b1eac3aed907a"
echo "rM2 Version 2.12.3.606 - $patch_name"
;;
"20220303120824" )
patch_name=${1:-patch_31.2.01}
version="2122573_rm2"
expectedhash="7105e311df4df7f4ccde457ce574da63f49d3a4e"
echo "rM2 Version 2.12.2.573 - $patch_name"
;;
"20220303122245" )
patch_name=${1:-patch_31.1.01}
version="2122573_rm1"
expectedhash="00b5095022a48e48cdbe435b8afff0e3dc736b96"
echo "rM1 Version 2.12.2.573 - $patch_name"
;;
"20220202133838" )
patch_name=${1:-patch_30.2.07}
version="2121527_rm2"
expectedhash="8728cf8a2677a1b458f8e1ed665f8c1358568f7f"
echo "rM2 Version 2.12.1.527 - $patch_name"
;;
"20220202133055" )
patch_name=${1:-patch_30.1.08}
version="2121527_rm1"
expectedhash="c542ee591b45cb18599dc852cc0d3ce82ec86b56"
echo "rM1 Version 2.12.1.527 - $patch_name"
;;
"20211208075454" )
patch_name=${1:-patch_29.2.02}
version="2110442_rm2"
expectedhash="ad88de508a3c7da7f1ff6a9d394806c5d987026d"
echo "rM2 Version 2.11.0.442 - $patch_name"
;;
"20211208080907" )
patch_name=${1:-patch_29.1.02}
version="2110442_rm1"
expectedhash="1f72eb42b0745d40196cb7fece6a8fee55f958c0"
echo "rM1 Version 2.11.0.442 - $patch_name"
;;
"20211102142308" )
patch_name=${1:-patch_28.1.02}
version="2103379_rm1"
expectedhash="1978c56c0bf9a53e74fb05b7212381543adb709e"
echo "rM1 Version 2.10.3.379 - $patch_name"
;;
"20211102143141" )
patch_name=${1:-patch_28.2.02}
version="2103379_rm2"
expectedhash="8510d6f4380b6155d630baecaccccfb0147263d0"
echo "rM2 Version 2.10.3.379 - $patch_name"
;;
"20211014151303" )
patch_name=${1:-patch_27.2.05}
version="2102356_rm2"
expectedhash="2cc077e0bc5eca53664d4692197d54b477fa02ba"
echo "rM2 Version 2.10.2.356 - $patch_name"
;;
"20211014150444" )
patch_name=${1:-patch_27.1.03}
version="2102356_rm1"
expectedhash="a76509107656c03e866ec169ad317da9111f71be"
echo "rM1 Version 2.10.2.356 - $patch_name"
;;
"20210929140057" )
patch_name=${1:-patch_26.2.02}
version="2101332_rm2"
expectedhash="44ed43a128c821988519c3ea92c4516f011edd7e"
echo "rM2 Version 2.10.1.332 - $patch_name"
;;
"20210923144714" )
patch_name=${1:-patch_25.2.01}
version="2100324_rm2"
expectedhash="0990b599d412a1c6368985d872383b29b47ffab6"
echo "rM2 Version 2.10.0.324 - $patch_name"
;;
"20210923152158" )
patch_name=${1:-patch_25.1.03}
version="2100324_rm1"
expectedhash="635917603b0d9349ddf5f6ead818701a42979945"
echo "rM1 Version 2.10.0.324 - $patch_name"
;;
"20210812195523" )
patch_name=${1:-patch_24.2.04}
version="291217_rm2"
expectedhash="ab37e201e819e4212fb4e2ce92cd747614499fbb"
echo "rM2 Version 2.9.1.217 - $patch_name"
;;
"20210820111232" )
patch_name=${1:-patch_24.1.02}
version="291236_rm1"
expectedhash="e5d3ce51e81a6e23bac0c66549b809e6dd4e35a0"
echo "rM1 Version 2.9.1.236 - $patch_name"
;;
"20210611153600" )
patch_name=${1:-patch_23.2.02}
version="28098_rm2"
expectedhash="02a851bc33231fcd253eee781eb127e3c942da69"
echo "rM2 Version 2.8.0.98 - $patch_name"
;;
"20210611154039" )
patch_name=${1:-patch_23.1.02}
version="28098_rm1"
expectedhash="b688b4afbd5c13347bada20f26b9108d82658f9a"
echo "rM1 Version 2.8.0.98 - $patch_name"
;;
"20210511153632" )
patch_name=${1:-patch_22.2.01}
version="27153_rm2"
expectedhash="f0846772da9b810aecc2a307ba5dae21c072674a"
echo "rM2 Version 2.7.1.53 - $patch_name"
;;
"20210504114631" )
patch_name=${1:-patch_21.2.05}
version="27051_rm2"
expectedhash="f0846772da9b810aecc2a307ba5dae21c072674a"
echo "rM2 Version 2.7.0.51 - $patch_name"
;;
"20210504114855" )
patch_name=${1:-patch_21.1.04}
version="27051_rm1"
expectedhash="123877bb7dd6133f4540e03d3912b1d4c4d76050"
echo "rM Version 2.7.0.51 - $patch_name"
;;
"20210322075357" )
patch_name=${1:-patch_20.2.03}
version="26275_rm2"
expectedhash="7b314d6fb03c8789396f0ed43a4b27a18c649d2d"
echo "rM2 Version 2.6.2.75 - $patch_name"
;;
"20210322075617" )
patch_name=${1:-patch_20.1.03}
version="26275_rm1"
expectedhash="50a44683ac1b8ce524e55e10f57b699e7c4ca409"
echo "rM Version 2.6.2.75 - $patch_name"
;;
"20210311194323" )
patch_name=${1:-patch_19.2.02}
version="26171_rm2"
expectedhash="fc434bf45f1ff927af799ddccc7b2b0449f516f7"
echo "rM2 Version 2.6.1.71 - $patch_name"
;;
"20210311193614" )
patch_name=${1:-patch_19.1.02}
version="26171_rm1"
expectedhash="2d31db3e7f1a7b98a493cc5a1351fe303f849cd3"
echo "rM1 Version 2.6.1.71 - $patch_name"
;;
* )
echo "The version the device is running is not supported, yet. $currentVersion"
exit 1
;;
esac
backup_file="$workdir/$binary_name.$version"
if [ $patch_name == "purge" ]; then
purge
exit 0
fi
if [ -z "$SKIP_DOWNLOAD" ]; then
wget "https://github.com/ddvk/remarkable-hacks/raw/master/patches/$version/$patch_name" -O "$workdir/$patch_name" || exit 1
# save this file locally for offline uninstall
wget "https://github.com/ddvk/remarkable-hacks/raw/master/patch.sh" -O "$workdir/patch.sh" || exit 1
chmod +x "$workdir/patch.sh"
fi
#make sure we keep the original, which is needed for additional patching or purge
if [ ! -f $backup_file ]; then
cp /usr/bin/$binary_name $backup_file
fi
hash=$(sha1sum $backup_file | cut -c 1-40)
if [ "$expectedhash" != "$hash" ]; then
echo "The backup $backup_file is not the original file (was it replaced/ deleted? / wrong hash)"
echo "Expected hash: $expectedhash"
echo "Actual hash: $hash"
echo "cowardly aborting..."
exit 1
fi
bspatch $backup_file $patched $workdir/$patch_name
chmod +x $patched
systemctl stop xochitl
systemctl reset-failed xochitl
#just to be sure, it goes into and endless reboot due to qml mismatch
systemctl stop remarkable-fail
# there can be only one (accessing the fb)
systemctl stop rm2fb || true
killall remarkable-shutdown || true
# oxide / remux / prevent multiple xochitl instances
killall xochitl || true
if [ -z "$MAKE_PERM" ]; then
cleanup
echo ""
echo "**********************************************"
echo "Trying to start the patched version..."
echo -e "\e[1mYou can play around, press \e[5m\e[31mCTRL-C \e[39m\e[25mwhen done!\e[0m"
echo "**********************************************"
echo ""
QT_LOGGING_RULES=*=false $patched -plugin evdevlamy || echo "Did it crash?"
cleanup
else
auto_install "y"
cleanup
exit
fi