-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract-files.sh
executable file
·58 lines (51 loc) · 1.64 KB
/
extract-files.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
#!/bin/bash
export VENDOR=motorola
export DEVICE_VENDOR=moto
export DEVICE=shamu
# Check to see if the user passed a folder in to extract from rather than adb pull
if [ $# -eq 1 ]; then
COPY_FROM=$1
test ! -d "$COPY_FROM" && echo error reading dir "$COPY_FROM" && exit 1
fi
set -e
function extract() {
for FILE in `egrep -v '(^#|^$)' $1`; do
echo "Extracting /system/$FILE ..."
OLDIFS=$IFS IFS=":" PARSING_ARRAY=($FILE) IFS=$OLDIFS
FILE=`echo ${PARSING_ARRAY[0]} | sed -e "s/^-//g"`
DEST=${PARSING_ARRAY[1]}
if [ -z $DEST ]; then
DEST=$FILE
fi
DIR=`dirname $FILE`
if [ ! -d $2/$DIR ]; then
mkdir -p $2/$DIR
fi
if [ "$COPY_FROM" = "" ]; then
# Try destination target first
if [ -f /system/$DEST ]; then
adb pull /system/$DEST $2/$DEST
else
# if file does not exist try OEM target
if [ "$?" != "0" ]; then
adb pull /system/$FILE $2/$DEST
fi
fi
else
# Try destination target first
if [ -f $COPY_FROM/$DEST ]; then
cp $COPY_FROM/$DEST $2/$DEST
else
# if file does not exist try OEM target
if [ "$?" != "0" ]; then
cp $COPY_FROM/$FILE $2/$DEST
fi
fi
fi
done
}
DEVICE_BASE=../../../vendor/$VENDOR/$DEVICE/proprietary
rm -rf $DEVICE_BASE/*
# Extract the device specific files
extract ../../$DEVICE_VENDOR/$DEVICE/device-proprietary-files.txt $DEVICE_BASE
./setup-makefiles.sh