Repository navigation
Expand file tree
/
Copy pathcheck_preload_symlinks
More file actions
executable file
·257 lines (195 loc) · 6.43 KB
/
Copy pathcheck_preload_symlinks
File metadata and controls
executable file
·257 lines (195 loc) · 6.43 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
############################################################################
#
# Copyright (c) 2013 - dsixda (dislam@rocketmail.com)
#
# 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 four mandatory arguments:
#
# $1 = base directory of the kitchen
# $2 = path to system folder under working directory
# $3 = path to img file
# $4 = name of img file (e.g. hidden.img or tomb.img.ext4)
#
base_dir=$1
system_dir=$2
hidden_dir=$3
img_file=$4
######################################################################
# Check for symlinks to /preload/symlink/system/app under /system/app
######################################################################
cd $system_dir/app
# First check for *.apk and *.odex with symlink to preload/symlink/system/app
# and delete them (this works for Linux / OS X)
preload_links=( `find . -type l -exec ls -l {} \; | grep /preload/symlink/system/app | sed 's/.* \/preload\/symlink\/system\/app\/\(.*\)/\1/g'` )
if [ "$preload_links" != "" ]
then
num_preload_links=${#preload_links[@]}
echo
echo -n "Under /system/app, removing <<$num_preload_links>> symlinks to APK and ODEX files in /preload/symlink/system/app "
for item in ${preload_links[@]}
do
echo -n "."
rm -f $item
done
use_hidden=1
else
# Check if the number of odex files outnumbers number of apks (this works for Cygwin)
num_odex_app=`find . | grep -c "\.odex$"`
num_apk_app=`find . | grep -c "\.apk$"`
if [ $num_odex_app -gt $num_apk_app ]
then
echo
echo "The /system/app folder is missing some APK (and maybe some ODEX) files."
use_hidden=1
elif [ `uname | grep CYGWIN` ]
then
# Check for versions higher than Gingerbread/ICS (this is a workaround for Cygwin)
cd $system_dir
if [ "`grep -c ro.build.version.release=2 build.prop`" == "0" ] && \
[ "`grep -c ro.build.version.release=4.0 build.prop`" == "0" ]
then
echo
echo "The /system/app folder is potentially missing some APK/ODEX files"
use_hidden=1
fi
fi
fi
cd $base_dir
if [ "$use_hidden" == "1" ]
then
echo
echo "These are probably found in $img_file"
if [ ! -e $hidden_dir/$img_file ]
then
echo
echo "--> Place $img_file under the '$hidden_dir' folder <--"
echo " (You can also ignore this step)"
echo
scripts/press_enter
if [ ! -e $hidden_dir/$img_file ]
then
echo "Skipping $img_file"
fi
fi
#
# $img_file unpacking
#
if [ -e $hidden_dir/$img_file ]
then
working_dir=$system_dir/..
hidden_dir2=$working_dir/hidden
mkdir $hidden_dir2
cd $hidden_dir2
hidden_dir2=`pwd`
cd $base_dir
echo
echo "Converting $img_file into a format for unpacking ..."
tools/samsung_files/simg2img_files/simg2img $hidden_dir/$img_file \
$hidden_dir2/ext4_hidden.img
if [ ! -e $hidden_dir2/ext4_hidden.img ]
then
echo "Unable to convert $img_file!"
exit 1
fi
if [ "$hidden_dir" != "original_update" ]
then
rm -f $hidden_dir/$img_file
fi
#
# Extract files from ext4_hidden.img
#
if [ `uname | grep CYGWIN` ]
then
scripts/show_ext2explore $hidden_dir2 ext4_hidden.img
else
scripts/extract_ext3_img $hidden_dir2 ext4_hidden.img
fi
rm -f $hidden_dir2/ext4_hidden.img 2>/dev/null
if [ "$?" == "1" ]
then
echo
echo "WARNING: ext4_hidden.img is in use. Remove file manually after application is closed."
echo
fi
echo
#
# Check if preload files are found in $img_file
#
if [ -d $hidden_dir2/symlink/system/app ]
then
num_preload_apk=`find $hidden_dir2/symlink/system/app | grep -c "\.apk$"`
num_preload_odex=`find $hidden_dir2/symlink/system/app | grep -c "\.odex$"`
num_preload_total=$(($num_preload_apk + $num_preload_odex))
if [ $num_preload_total -gt 0 ]
then
echo "Found <<$num_preload_total>> APK and ODEX files under $img_file"
mkdir -p $working_dir/preload/symlink/system
mv $hidden_dir2/symlink/system/app $working_dir/preload/symlink/system/
if [ "$num_preload_links" != "" ]
then
if [ $num_preload_links != $num_preload_total ]
then
echo "Warning: This number does not equal the number of symlinks found under /system/app earlier!"
else
echo "This number matches the number of symlinks found under /system/app earlier"
fi
fi
#
# Closing comments about /preload stuff
#
device_name=`scripts/get_samsung_variant`
if [ "$device_name" == "" ]
then
echo
echo "WARNING: Device name has not been defined under /tools/edify_defs!"
echo
else
preload_mnt=`scripts/get_edify_def_val $device_name preload_mnt`
if [ "$preload_mnt" != "UNKNOWN" ]
then
echo
preload_mnt=`echo $preload_mnt | sed -e 's/\\\\//g'`
echo "The mount point for /preload has already been defined for this"
echo "device as $preload_mnt under /tools/edify_defs/$device_name. "
echo "Good."
else
echo
echo "Warning: No /preload mount point ('preload_mnt') was defined under"
echo "tools/edify_defs/$device_name! Please ensure this is specified before"
echo "proceeding to next stage (press Enter when done or if you want to"
echo "skip this step)."
echo
scripts/press_enter
fi
fi
echo
echo "NOTE: If you wish to de-odex this ROM, you will need to move the APK"
echo "and ODEX files from the /preload apps folder to /system/app before you"
echo "de-odex them. The kitchen will automatically handle this."
echo
scripts/press_enter
else
echo "Warning: No APK/ODEX files found in $img_file!"
fi
else
echo "Warning: No /preload/symlink/system/app folder found in $img_file!"
fi
echo
echo
rm -rf $hidden_dir2
fi
elif [ -e $hidden_dir/$img_file ]
then
echo
echo "Ignoring $img_file"
if [ "$hidden_dir" != "original_update" ]
then
rm -f $hidden_dir/$img_file
fi
fi
cd $base_dir