forked from CyanogenMod/android_device_huawei_kiwi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract-files.sh
executable file
·82 lines (77 loc) · 1.94 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#set -e
export DEVICE=kiwi
export VENDOR=huawei
if [ $# -eq 0 ]; then
SRC=adb
else
if [ $# -eq 2 ]; then
SRC=$1
RAMDISK=$2
SRC2=$1
RAMDISK2=$2
elif [ $# -eq 4 ]; then
SRC=$1
RAMDISK=$2
SRC2=$3
RAMDISK2=$4
else
echo "$0: bad number of arguments"
echo ""
echo "usage: $0 [PATH_TO_EXPANDED_ROM RAMDISK_TO_EXPAND_FROM [ALT_EXPANDED ALT_RAMDISK]]"
echo ""
echo "If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from"
echo "the device using adb pull."
exit 1
fi
fi
BASE=../../../vendor/$VENDOR/$DEVICE/proprietary
rm -rf $BASE/*
for FILE in `egrep -v '(^#|^$)' proprietary-files.txt`; do
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
if [ "${FILE:0:6}" = "/sbin/" ]; then
DIR_PREFIX=""
LOCAL_DIR=$RAMDISK
LOCAL_DIR2=$RAMDISK2
else
DIR_PREFIX=/system/
LOCAL_DIR=$SRC
LOCAL_DIR2=$SRC2
fi
DIR=`dirname $DEST`
if [ ! -d $BASE/$DIR ]; then
mkdir -p $BASE/$DIR
fi
# Try CM target first
if [ "$SRC" = "adb" ]; then
adb pull $DIR_PREFIX/$DEST $BASE/$DEST
# if file does not exist try OEM target
if [ "$?" != "0" ]; then
adb pull $DIR_PREFIX/$FILE $BASE/$DEST
if [ "$?" != "0" ]; then
echo "Failed to load: $FILE"
exit 1
fi
fi
else
if [ -r $LOCAL_DIR/$DIR_PREFIX/$DEST ]; then
cp $LOCAL_DIR/$DIR_PREFIX/$DEST $BASE/$DEST
elif [ -r $LOCAL_DIR/$DIR_PREFIX/$FILE ]; then
cp $LOCAL_DIR/$DIR_PREFIX/$FILE $BASE/$DEST
elif [ -r $LOCAL_DIR2/$DIR_PREFIX/$DEST ]; then
cp $LOCAL_DIR2/$DIR_PREFIX/$DEST $BASE/$DEST
elif [ -r $LOCAL_DIR2/$DIR_PREFIX/$FILE ]; then
cp $LOCAL_DIR2/$DIR_PREFIX/$FILE $BASE/$DEST
else
echo "error: missing file $FILE:$DEST"
exit 1
fi
fi
done
./setup-makefiles.sh