forked from dsixda/Android-Kitchen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_update_script
More file actions
executable file
·862 lines (657 loc) · 20 KB
/
convert_update_script
File metadata and controls
executable file
·862 lines (657 loc) · 20 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
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
############################################################################
#
# Copyright (c) 2013 - dsixda ([email protected])
#
# Android Kitchen is 100% free. This script file is intended for personal
# and/or educational use only. It may not be duplicated for monetary
# benefit or any other purpose without the permission of the developer.
#
############################################################################
#
# This script has two optional arguments:
#
# $1 = "for_zip" - use this option after update.zip created
# $2 = yes/no (express build mode) - relies on $1 being present
#
if [ "$1" == "" ]
then
clear
fi
echo
if [ -d WORKING_* ]
then
cd WORKING_*
cd META-INF/com/google/android
else
echo
echo Working folder not found, you will need to create one!
exit 0
fi
if [ "$1" == "" ]
then
echo "Conversion Tool: update-script (Amend) to updater-script (Edify)"
echo "--------------------------------------------------------------------------"
echo
echo "This script will convert your update-script into an updater-script"
echo "and will also add the update-binary file."
echo
echo "This option will also be given when you build your ROM, so it is"
echo "not necessary to convert your update-script now. The kitchen is NOT"
echo "compatible with updater-scripts, so only a few options can be used "
echo "afterwards if you have an updater-script."
echo
echo "Ensure you have an update-script under META-INF/com/google/android"
echo "of your working folder."
echo
echo -n "Proceed with conversion (y/n)? (default: y): "
read proceed_now
echo
if [ "$proceed_now" == "n" ]
then
cd ../../../../..
exit 0
fi
echo "--------------------------------------------------------------------------"
echo
fi
if [ -e update-script ]
then
if [ -e updater-script ]
then
if [ "$2" == "yes" ]
then
remove_it=y
else
echo "Error: Although you have an update-script, you also have an updater-script"
echo " in the same folder. Remove one of them."
echo
echo -n "Remove updater-script and continue conversion (y/n)? (default: y): "
read remove_it
echo
fi
if [ "$remove_it" != "n" ]
then
rm -vf updater-script
echo
else
cd ../../../../..
exit 0
fi
fi
else
echo "Error: update-script not found!"
cd ../../../../..
exit 0
fi
cd ../../../../..
if [ "$1" != "for_zip" ]
then
echo "Checking for final modifications to update-script before conversion ..."
scripts/fix_pre_build
fi
cd WORKING_*
cd META-INF/com/google/android
echo
echo "--------------------------------------------------------------------------"
echo
echo "Converting to updater-script, please wait ..."
echo
cp update-script updater-script
orig_list=( DATA SYSTEM PRELOAD CACHE SDEXT BOOT SDCARD )
new_list=( userdata system preload cache sdext boot sdcard )
new_list_str="0 1 2 3 4 5 6"
echo "- Initial formatting ..."
#
# In Samsung Galaxy S2 and equivalent, convert 'format' back to delete_recursive,
# which was changed earlier
#
cd ../../../../..
scripts/check_galaxy_s_and_s2
ss2=$?
scripts/check_galaxy_s2x
s2x=$?
scripts/check_galaxy_s3_common
s3_common=$?
scripts/check_galaxy_s4_common
s4_common=$?
cd WORKING_*
cd META-INF/com/google/android
if [ "$ss2" == "1" ] || [ "$s2x" == "1" ] || [ "$s3_common" == "1" ] || [ "$s4_common" == "1" ]
then
sed -i -e 's/format /delete_recursive /g' updater-script
fi
# 3rd line: remove leading and trailing whitespace on each line
sed -i \
-e ':a;N;$!ba;s/,\n//g' \
-e 's/assert[^\n]*[\n]*//g' \
updater-script
#
# Remove leading/trailing whitespace and tabs
# Not sure why this requires a separate statement from the above, to work!
#
sed -i -e 's/^[ \t]*//;s/[ \t]*$//g' updater-script
#
# Remove lines with comments
#
sed -i -e '/^#/d' updater-script
#
# boot.img / radio.img / bootloader.img
#
img_list=( boot radio bootloader )
for (( i = 0 ; i < ${#img_list[@]} ; i++ ))
do
img_name=${img_list[${i}]}
str="write_raw_image PACKAGE:$img_name.img"
#
# Check to see if image file is written in a different manner;
# e.g. in CyanogenMod for Galaxy S they use run_program instead of
# write_raw_image for the boot.img in the updater-script.
#
line_num=`sed -n -e '/'"$str"'/{=;q}' updater-script`
if [ "$line_num" != "" ]
then
str2="package_extract_file PACKAGE:$img_name.img TMP:$img_name.img"
str3="delete TMP:$img_name.img"
line_num3=`sed -n -e '/'"$str3"'/{=;q}' updater-script`
if [ "$line_num3" != "" ]
then
line_num_temp2=$(($line_num3-2))
str_temp=`sed -n -e ''"$line_num_temp2"'p' updater-script`
if [ "$str_temp" == "$str2" ] && [ $line_num3 -lt $line_num ]
then
sed -i -e ''"$line_num"'d' updater-script
continue
fi
fi
fi
sed -i -e 's/'"$str"'.*$/assert(package_extract_file("'"$img_name"'.img", "\/tmp\/'"$img_name"'.img"),\n write_raw_image("\/tmp\/'"$img_name"'.img", "'"$img_name"'"),\n delete("\/tmp\/'"$img_name"'.img"));/g' updater-script
done
#
# radio.img
#
if [ `grep -c write_radio_image updater-script` -gt 0 ]
then
echo "- Sorry, ignoring 'write_radio_image' - unable to convert ..."
sed -i -e 's/write_radio_image PACKAGE:radio.img//g' updater-script
fi
#
# hboot.img
#
if [ `grep -c write_hboot_image updater-script` -gt 0 ]
then
echo "- Sorry, ignoring 'write_hboot_image' - unable to convert ..."
sed -i -e 's/write_hboot_image PACKAGE:hboot.img//g' updater-script
fi
#
# copy_dir
#
echo "- copy_dir ..."
sed -i \
-e 's/copy_dir \(.*\)/package_extract_dir(\"\1\");/g' \
-e 's/\(package_extract_dir.*\) \(.*\)/\1", "\2/g' \
-e 's/\(package_extract_dir.*\)PACKAGE:/\1/g' \
-e 's/\(package_extract_dir.*\)SYSTEM:\([^)]*\))/\1\/system\/\2)/g' \
-e 's/\(package_extract_dir.*\)PRELOAD:\([^)]*\))/\1\/preload\/\2)/g' \
-e 's/\(package_extract_dir.*\)DATA:\([^)]*\))/\1\/data\/\2)/g' \
-e 's/\(package_extract_dir.*\)TMP:\([^)]*\))/\1\/tmp\/\2)/g' \
-e 's/\(package_extract_dir.*\)SDCARD:\([^)]*\))/\1\/sdcard\/\2)/g' \
-e 's/\(package_extract_dir.*\)BOOT:\([^)]*\))/\1\/boot\/\2)/g' \
-e 's/\(package_extract_dir.*\)CACHE:\([^)]*\))/\1\/cache\/\2)/g' \
updater-script
#
# set_perm_recursive
#
echo "- set_perm_recursive ..."
sed -i \
-e 's/set_perm_recursive \(.*\)/set_perm_recursive(\1);/g' \
-e 's/\(set_perm_recursive.*[0-9]*\) \([0-9]*\) \([0-9]*\) \([0-9]*\) /\1, \2, \3, \4, /g' \
-e 's/\(set_perm_recursive.*\)SYSTEM:)/\1\"\/system\")/g' \
-e 's/\(set_perm_recursive.*\)SYSTEM:\([^)]*\))/\1\"\/system\/\2\")/g' \
-e 's/\(set_perm_recursive.*\)DATA:\([^)]*\))/\1\"\/data\/\2\")/g' \
-e 's/\(set_perm_recursive.*\)TMP:\([^)]*\))/\1\"\/tmp\/\2\")/g' \
-e 's/\(set_perm_recursive.*\)CACHE:\([^)]*\))/\1\"\/cache\/\2\")/g' \
-e 's/\(set_perm_recursive.*\) \/\(.*\)\([^)]*\))/\1\ "\/\2\3\")/g' \
updater-script
#
# set_perm
#
echo "- set_perm ..."
sed -i \
-e 's/set_perm \(.*\)/set_perm(\1);/g' \
-e 's/\(set_perm.*[0-9]*\) \([0-9]*\) \([0-9]*\) /\1, \2, \3, /g' \
-e 's/\(set_perm.*\)SYSTEM:\([^)]*\))/\1\"\/system\/\2\")/g' \
-e 's/\(set_perm.*\)DATA:\([^)]*\))/\1\"\/data\/\2\")/g' \
-e 's/\(set_perm.*\)TMP:\([^)]*\))/\1\"\/tmp\/\2\")/g' \
-e 's/\(set_perm.*\)CACHE:\([^)]*\))/\1\"\/cache\/\2\")/g' \
-e 's/\(set_perm.*\) \/\(.*\)\([^)]*\))/\1\ "\/\2\3\")/g' \
updater-script
#
# run_program
#
echo "- run_program ..."
line_num=`sed -n -e '/run_program /{=;q}' updater-script`
while [ "$line_num" != "" ]
do
sed -i \
-e ''$line_num' s/run_program \(.*\)/run_program(\"\1\");/g' \
-e ''$line_num' s/ /", "/g' \
-e ''$line_num' s/PACKAGE:/\//g' \
-e ''$line_num' s/TMP:/\/tmp\//g' \
-e ''$line_num' s/BOOT:/\/boot\//g' \
-e ''$line_num' s/SYSTEM:/\/system\//g' \
-e ''$line_num' s/DATA:/\/data\//g' \
updater-script
# Check for scripts that are at the root of the ROM; move them to /tmp;
# otherwise they won't run!! Set permissions before you run them from /tmp.
sed -i \
-e ''$line_num' s/run_program("\/\([^\/^\"]*\)"\(.*\)/package_extract_file("\1", "\/tmp\/\1");\nrun_program("\/tmp\/\1"\2/g' \
updater-script
# First check if permission already exists before adding it
prog_name=`sed -n -e ''$line_num' s/package_extract_file("[^\"]*",[ ]*"\([^\"]*\)");/\1/p' updater-script`
if [ "$prog_name" != "" ]
then
sed -i \
-e ''$line_num' s/package_extract_file("\([^\"]*\)",[ ]*"\([^\"]*\)");/package_extract_file("\1", "\2");\nset_perm(0, 0, 0777, "\2");/g' \
updater-script
fi
line_num=`sed -n -e '/run_program /{=;q}' updater-script`
done
#
# package_extract_file
#
echo "- package_extract_file ..."
sed -i \
-e 's/package_extract_file PACKAGE:/package_extract_file /g' \
-e 's/package_extract_file \(.*\)/package_extract_file(\"\1\");/g' \
-e 's/\(package_extract_file[^,]*\) \(.*\)/\1", "\2/g' \
-e 's/\(package_extract_file.*\)(\"SYSTEM:\([^)]*\))/\1(\"system\/\2)/g' \
-e 's/\(package_extract_file.*\)(\"DATA:\([^)]*\))/\1(\"data\/\2)/g' \
-e 's/\(package_extract_file.*\)(\"TMP:\([^)]*\))/\1(\"tmp\/\2)/g' \
-e 's/\(package_extract_file.*\)SYSTEM:\([^)]*\))/\1\/system\/\2)/g' \
-e 's/\(package_extract_file.*\)DATA:\([^)]*\))/\1\/data\/\2)/g' \
-e 's/\(package_extract_file.*\)TMP:\([^)]*\))/\1\/tmp\/\2)/g' \
-e 's/\(package_extract_file.*\)CACHE:\([^)]*\))/\1\/cache\/\2)/g' \
updater-script
#
# show_progress
#
echo "- show_progress ..."
sed -i \
-e 's/show_progress \(.*\)/show_progress(\1);/g' \
-e 's/\(show_progress.*\) \(.*\)/\1, \2/g' \
updater-script
#
# set_progress
#
echo "- set_progress ..."
sed -i \
-e 's/set_progress \(.*\)/set_progress(\1);/g' \
updater-script
#
# sleep
#
echo "- sleep ..."
sed -i \
-e 's/sleep \(.*\)/sleep(\1);/g' \
updater-script
#
# delete / delete_recursive
#
echo "- delete/delete_recursive ..."
sed -i \
-e 's/delete \(.*\)/delete(\"\1\");/g' \
-e 's/delete_recursive \(.*\)/delete_recursive(\"\1\");/g' \
-e 's/\(delete.*\)SYSTEM:/\1\/system\//g' \
-e 's/\(delete.*\)PRELOAD:/\1\/preload\//g' \
-e 's/\(delete.*\)DATA:/\1\/data\//g' \
-e 's/\(delete.*\)SDCARD:/\1\/sdcard\//g' \
-e 's/\(delete.*\)CACHE:/\1\/cache\//g' \
-e 's/\(delete.*\)TMP:\([^)]*\))/\1\/tmp\/\2)/g' \
-e 's/\(delete.*\)TMP:/\1\/tmp\//g' \
-e 's/\(delete.*\)SDEXT:/\1\/sdext\//g' \
updater-script
#
# symlink
#
echo "- symlink ..."
sed -i \
-e 's/symlink \(.*\)/symlink(\"\1\");/g' \
-e 's/\(symlink("[^\ ]*\)[ ]*\([^\"]*");\)/\1", "\2/g' \
-e 's/\(symlink.*\)SYSTEM:\(.*\)/\1\/system\/\2/g' \
-e 's/\(symlink.*\)DATA:\(.*\)/\1\/data\/\2/g' \
updater-script
#
# write_raw_image
#
echo "- write_raw_image ..."
sed -i \
-e 's/write_raw_image \(.*\)/write_raw_image(\"\1\");/g' \
-e 's/\(write_raw_image.*"[^,]*\) \(.*\)/\1", "\2/g' \
-e 's/\(write_raw_image.*\)PACKAGE:/\1/g' \
-e 's/\(write_raw_image.*\)BOOT:/\1boot/g' \
-e 's/\(write_raw_image.*\)TMP:\([^)]*\))/\1\/tmp\/\2)/g' \
-e 's/\(write_raw_image.*\)CACHE:\([^)]*\))/\1\/cache\/\2)/g' \
updater-script
#
# format, mount
#
echo "- format and mount ..."
# Add 'mount' before package_extract_dir and delete.*
for new in ${new_list[@]}
do
if [ "$new" == "userdata" ]
then
new2=data
else
if [ "$new" == "sdcard" ]
then
continue
fi
new2=$new
fi
# Find which ones comes first
line_num_del=`sed -n -e '/delete.*("\/'"$new2"'.*")/{=;q}' updater-script`
line_num_pkg=`sed -n -e '/package_extract_dir([^,]*, "\/'"$new2"'.*")/{=;q}' updater-script`
use_pkg=0
use_del=0
if [ "$line_num_del" == "" ] && [ "$line_num_pkg" == "" ]
then
continue
fi
if [ "$line_num_del" == "" ]
then
use_pkg=1
else
if [ "$line_num_pkg" == "" ]
then
use_del=1
else
if [ "$line_num_del" -lt "$line_num_pkg" ]
then
use_del=1
else
use_pkg=1
fi
fi
fi
# Replace only the first occurrence
if [ $use_del == 1 ]
then
sed -i \
-e '0,/\(delete.*\)("\/'"$new2"'\(.*\)")/s//mount("MTD", "'"$new"'", "\/'"$new2"'");\n\1("\/'"$new2"'\2")/' \
updater-script
else
sed -i \
-e '0,/package_extract_dir(\([^,]*\), "\/'"$new2"'\(.*\)")/s//mount("MTD", "'"$new"'", "\/'"$new2"'");\npackage_extract_dir(\1, "\/'"$new2"'\2")/' \
updater-script
fi
done
for i in $new_list_str
do
orig=${orig_list[${i}]}
new=${new_list[${i}]}
new2=$new
if [ "$new" == "userdata" ]
then
new2=data
fi
#
# Convert the 'format' line
#
sed -i -e 's/format '"$orig"':/format("MTD", "'"$new"'");/g' updater-script
sed -i -e 's/format \(.*\) '"$orig"':/format("\1", "MTD", "'"$new"'");\nmount("\1", "MTD", "'"$new"'", "\/'"$new2"'");/g' updater-script
#
# We don't want to move/remove the mount command for the boot partition, due to
# the boot.img commands we used previously... unless we have a NAND ROM!
#
if [ "$new" == "boot" ]
then
if [ -e ../../../../boot/initrd.gz ] && [ -e ../../../../boot/zImage ]
then
sed -i -e 's/\(format(.*"\/boot");\)/\1\nmount("MTD", "boot", "\/boot");/g' updater-script
grep_mnt=`grep "mount(.* \"/boot\");" updater-script`
if [ "$grep_mnt" == "" ]
then
sed -i -e 's/\(mount.*"\/system");\)/\1\nmount("MTD", "boot", "\/boot");/g' updater-script
fi
fi
continue
fi
grep_mnt=`grep "mount(\"MTD\", \"$new\", \"/$new2\");" updater-script`
#
# If a special mount is found, then remove the regular mount
#
grep_fmt2=`grep "format(\"[A-Za-z0-9]*\", \"MTD\", \"$new\");" updater-script`
if [ "$grep_fmt2" != "" ]
then
grep_mnt2=`grep "mount(\"[A-Za-z0-9]*\", \"MTD\", \"$new\", \"/$new2\");" updater-script`
if [ "$grep_mnt" != "" ] && [ "$grep_mnt2" != "" ]
then
sed -i -e '/mount("MTD", "'"$new"'", "\/'"$new2"'");/d' updater-script
fi
fi
#
# Move the associated 'mount' line (if it exists), so that it goes directly below the 'format' line
#
grep_fmt=`grep "format(\"MTD\", \"$new\");" updater-script`
if [ "$grep_fmt" != "" ]
then
if [ "$grep_mnt" != "" ]
then
# Delete the line
sed -i -e '/mount("MTD", "'"$new"'", "\/'"$new2"'");/d' updater-script
# Add it after the format
sed -i -e 's/format("MTD", "'"$new"'");/format("MTD", "'"$new"'");\nmount("MTD", "'"$new"'", "\/'"$new2"'");/g' updater-script
fi
fi
done
#
# Look for any other 'format' commands that were not covered above
#
line_num=`sed -n -e '/format /{=;q}' updater-script`
while [ "$line_num" != "" ]
do
sed -i \
-e ''$line_num' s/format \(.*\)/format(\"\1\");/g' \
-e ''$line_num' s/ /", "/g' \
-e ''$line_num' s/format\(.*\));/format\1);\nmount\1, "???");/g' \
updater-script
line_num=`sed -n -e '/format /{=;q}' updater-script`
done
#
# Fix any incomplete ("???") mounts, using the updater-script.orig file
#
if [ -e updater-script.orig ]
then
line_num=`sed -n -e '/^mount(.*???/{=;q}' updater-script`
while [ "$line_num" != "" ]
do
partial_str=`grep "^mount(" updater-script | grep -m 1 ??? | \
sed \
-e 's/"???");//g' \
-e 's/"/\\\"/g' `
# Get the string we want, from the original file, but replace special characters
# such as the forward slash to prevent formatting issues
orig_str=`grep -m 1 "$partial_str" updater-script.orig | sed -e 's/\//fwdslash/g'`
if [ "$orig_str" != "" ]
then
sed -i \
-e ''$line_num' s/.*/'"$orig_str"'/g' \
-e ''$line_num' s/fwdslash/\//g' \
updater-script
else
# We don't want to be stuck in an infinite loop
break
fi
line_num=`sed -n -e '/^mount(.*???/{=;q}' updater-script`
done
fi
#
# unmount
#
echo "- unmount ..."
for new in ${new_list[@]}
do
if [ "$new" == "userdata" ]
then
new2=data
else
new2=$new
fi
grep_mnt=`grep "mount(.* \"/$new\");" updater-script`
if [ "$grep_mnt" != "" ]
then
echo "unmount(\"/$new2\");" >> updater-script
fi
done
#
# Fix for systems with different mounts, e.g. ext3 types
# e.g. 'userdata' was replaced by /dev/block/whatever
#
grep_mnt=`grep "mount(.* \"/data\");" updater-script`
if [ "$grep_mnt" != "" ]
then
echo "unmount(\"/data\");" >> updater-script
fi
echo "- Final formatting ..."
sed -i \
-e 's/SYSTEM:/\/system\//g' \
-e 's/TMP:/\/tmp\//g' \
-e 's/DATA:/\/data\//g' \
-e 's/SDCARD:/\/sdcard\//g' \
-e 's/CACHE:/\/cache\//g' \
-e 's/SDEXT:/\/sdext\//g' \
-e 's/BOOT:/\/boot\//g' \
updater-script
#
# Fix up run_program parameters that contain special characters
#
sed -i \
-e 's/\[sp\]/ /g' \
-e 's/\[cr\]/\n/g' \
-e 's/\[sc\]/;/g' \
-e 's/\[co\]/,/g' \
updater-script
#
# Check if shell script had already unmounted the partition
#
if [ `grep -c "run_program.*umount" updater-script` ]
then
for new in ${new_list[@]}
do
if [ "$new" == "userdata" ]
then
new=data
fi
grep_mnt=`grep "mount(.* \"/$new\");" updater-script`
grep_umnt=`grep -c "umount /$new" updater-script`
if [ $grep_umnt -gt 0 ] && [ "$grep_mnt" != "" ]
then
sed -i -e '/unmount("\/'"$new"'");/d' updater-script
fi
done
fi
#
# Other commands
#
sed -i \
-e 's/add_upgrade_property/add_upgrade_property();/g' \
-e 's/install_modem_package/install_modem_package();/g' \
updater-script
sed -i -e 's/write_blob_raw_image PACKAGE:blob/assert(package_extract_file("blob", "\/tmp\/blob"),\n write_blob_raw_image("\/tmp\/blob", "staging"),\n delete("\/tmp\/blob"));/g' updater-script
#
# Clean up any mess left by my script
#
sed -i \
-e 's/\/");/");/g' \
-e 's/; $/;/g' \
updater-script
#
# Remove blank lines
#
sed -i -e '/^$/d' updater-script
#
# Cool solution from the web :-)
#
# Delete duplicate, consecutive lines from a file (emulates "uniq").
# First line in a set of duplicate lines is kept, rest are deleted.
#
sed -i -e '$!N; /^\(.*\)\n\1$/!P; D' updater-script
#
# Device-specific mount points
#
cd ../../../../..
scripts/adjust_mnt updater-script
cd WORKING_*
cd META-INF/com/google/android
sed -i -e '/^$/d' updater-script
test_mnt=`grep "^mount(" updater-script`
test_mnt2=`grep "sbin/mount\", \"" updater-script`
test_mnt3=`grep "boot.img\"" updater-script | grep dev`
if [ "$test_mnt" != "" ] || [ "$test_mnt2" != "" ] || [ "$test_mnt3" != "" ]
then
echo
echo
echo "Please ensure these device mount statements are correct:"
echo "--------------------------------------------------------------------------"
if [ "$test_mnt" != "" ]
then
echo $test_mnt
fi
if [ "$test_mnt2" != "" ]
then
echo $test_mnt2
fi
if [ "$test_mnt3" != "" ]
then
echo $test_mnt3
fi
echo "--------------------------------------------------------------------------"
fi
if [ -e updater-script ]
then
cd ../../../../..
scripts/check_which_update_binary
cd WORKING_*
cd META-INF/com/google/android
echo
echo "--------------------------------------------------------------------------"
echo
if [ "$2" != "yes" ]
then
echo "An updater-script has been created under META-INF/com/google/android of"
echo "your working folder. Please review it and make any necessary changes. An"
echo "update-binary has also been added."
echo ""
fi
if [ "$1" != "for_zip" ]
then
mv -f update-script update-script.orig
echo "The original update-script has been renamed to update-script.orig - it"
echo "will not be included in your completed ROM's ZIP file."
else
if [ "$2" == "no" ]
then
echo "DO NOT delete any of the files under META-INF/com/google/android."
echo
fi
fi
grep_fmt=`grep -n "^format(" updater-script`
grep_mount=`grep -n "^mount(" updater-script`
grep_huh=`grep -n "???" updater-script`
if [ "$grep_huh" != "" ]
then
echo
echo "--------------------------------------------------------------------------"
echo
echo "NOTE: Ensure you fix the unknown reference(s) at the line number(s) below."
echo " Compare with the original version of the updater-script, if you have"
echo " one."
echo
echo $grep_huh | sed -e 's/;[ ]*/;\n/g'
echo
fi
else
echo "Error: updater-script not created!"
fi
cd ../../../../..