forked from dsixda/Android-Kitchen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_apps2sd
More file actions
executable file
·224 lines (177 loc) · 5.11 KB
/
add_apps2sd
File metadata and controls
executable file
·224 lines (177 loc) · 5.11 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
############################################################################
#
# Copyright (c) 2012 - 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.
#
############################################################################
scripts/check_galaxies
if [ "$?" == "1" ]
then
clear
echo
echo "Feature not supported by kitchen for this ROM"
exit 0
fi
if [ "$1" == "" ]
then
clear
elif [ "$1" == "show_help" ]
then
clear
echo
echo "-----------------------------------------------------------------"
echo
echo "Apps2SD is a feature that will allow all your apps to be"
echo "installed onto the SD card to save storage space on your device."
echo
echo "NOTE: It is meant for devices with SMALL internal storage space,"
echo "so if your device has large internal memory (such as on the Nexus"
echo "S) then Apps2SD is not required and MAY NOT BE COMPATIBLE EITHER!"
echo
echo "This kitchen uses the Darktremor Apps2SD method. Ensure you have"
echo "a fast memory card (e.g. Class 6), and that it is partitioned"
echo "with an appropriate filesystem, preferably EXT3. A swap"
echo "partition is usually not necessary."
echo
echo "-----------------------------------------------------------------"
echo
fi
device_name=`scripts/get_device_name`
change_mnt=`scripts/get_edify_def_val $device_name change_mnt`
change_mnt_dell=`scripts/get_edify_def_val $device_name change_mnt_dell`
if [ -e tools/edify_defs/$device_name ]
then
if [ "$change_mnt" != "UNKNOWN" ] || [ "$change_mnt_dell" != "UNKNOWN" ]
then
echo "WARNING: This device ($device_name) most likely will NOT support Apps2SD!"
echo
fi
fi
echo -n "Proceed with installing Apps2SD (y/n)? (default: y): "
read do_apps2sd
if [ "$do_apps2sd" == "n" ]
then
exit 0
fi
echo
if [ -d WORKING_* ]
then
cd WORKING_*
if [ ! -e META-INF/com/google/android/update-script ]
then
echo "Error: update-script not found!"
cd ..
exit 0
fi
su_path=`find . -name su`
if [ "$su_path" == "" ]
then
echo "'su' binary not found under working folder!"
echo "You must root your ROM first."
cd ..
exit 0
else
echo
echo "Found $su_path"
cd ..
scripts/a2sd_exists
if [ "$?" == "1" ]
then
echo
echo "a2sd is already installed!"
scripts/add_cachesd_to_update_script
exit 0
fi
fi
else
echo
echo Working folder not found, you will need to create one!
exit 0
fi
scripts/ensure_boot_extracted
if [ -d BOOT-EXTRACTED ]
then
if [ -d WORKING_* ]
then
echo
else
exit 0
fi
else
exit 0
fi
if [ -d BOOT-EXTRACTED/boot.img-ramdisk ]
then
cd BOOT-EXTRACTED/boot.img-ramdisk
else
echo "Error: BOOT-EXTRACTED/boot.img-ramdisk folder not found!"
exit 0
fi
test_property=`grep -c "on property:cm.filesystem.ready=1" init.rc`
test_start_a2sd=`grep -c "start a2sd" init.rc`
test_sysinit=`grep -c "start sysinit" init.rc`
test_cm_sysinit=`grep -c "exec /system/bin/sysinit" init.rc`
if [[ "$test_property" != "0" && "$test_start_a2sd" != "0" ]] || \
[[ "$test_property" != "0" && "$test_sysinit" != "0" ]] || \
[[ "$test_property" != "0" && "$test_cm_sysinit" != "0" ]]
then
echo "init.rc already has content to start a2sd!"
cd ../..
echo
echo "Removing BOOT-EXTRACTED folder ..."
rm -rf BOOT-EXTRACTED
else
echo
echo Modifying init.rc in ramdisk to enable Apps2SD ...
if [ "$test_sysinit" != "0" ]
then
sed -i -e 's/start sysinit/start sysinit\n on property:cm.filesystem.ready=1/' init.rc
elif [ "$test_start_a2sd" != "0" ] && [ "$test_property" == "0" ]
then
sed -i -e 's/start a2sd/start a2sd\n on property:cm.filesystem.ready=1/' init.rc
elif [ "$test_start_a2sd" == "0" ] && [ "$test_property" == "0" ]
then
sed -i -e 's/class_start default/start a2sd\n on property:cm.filesystem.ready=1\n\n class_start default/' init.rc
elif [ "$test_start_a2sd" == "0" ] && [ "$test_property" != "0" ]
then
sed -i -e 's/on property:cm.filesystem.ready=1/start a2sd\n on property:cm.filesystem.ready=1/' init.rc
fi
test_service_a2sd=`grep -c "service a2sd" init.rc`
test_service_sysinit=`grep -c "service sysinit" init.rc`
if [ "$test_service_a2sd" == "0" ] && [ "$test_service_sysinit" == "0" ]
then
sed -i -e 's/service media /service a2sd \/system\/bin\/logwrapper \/system\/bin\/sh \/system\/bin\/a2sd\n disabled\n oneshot\n\nservice media /' init.rc
fi
cd ../..
scripts/build_boot_img
fi
scripts/add_apps2sd_files
scripts/add_apps2sd_to_update_script
res=$?
if [ "$res" == "0" ]
then
#
# apps2sd may have included Bash binary
#
find_cmd=`find tools/apps2sd_files -name bash`
if [ "$find_cmd" != "" ]
then
scripts/add_bash_to_update_script
fi
#
# Prompt for busybox run-parts method
#
if [ "$test_sysinit" == "0" ]
then
scripts/add_busybox_run_parts for_apps2sd
fi
#
# Dalvik-cache to SD
#
scripts/add_cachesd_to_update_script
echo
echo Finished
fi