forked from LineageOS/android_device_sony_common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract-files.sh
executable file
·61 lines (54 loc) · 1.36 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
#!/bin/bash
PROPRIETARY_FILES=${PROPRIETARY_FILES:-proprietary-files*.txt}
BASE=../../../vendor/$VENDOR/$DEVICE/proprietary
while getopts ":nhsd:" options
do
case $options in
n ) NC=1 ;;
d ) LDIR=$OPTARG ;;
s ) SETUP=1 ;;
h ) echo "Usage: `basename $0` [OPTIONS] "
echo " -n No cleanup"
echo " -d Fetch blob from filesystem"
echo " -s Setup only, no extraction"
echo " -h Show this help"
exit ;;
* ) ;;
esac
done
if [ "x$NC" != "x1" ]; then
rm -rf $BASE/*
fi
for FILE in `cat ../$DEVICE/$PROPRIETARY_FILES | grep -v ^# | grep -v ^$ | sort`
do
# Split the file from the destination (format is "file[:destination]")
OLDIFS=$IFS IFS=":" PARSING_ARRAY=($FILE) IFS=$OLDIFS
FILE=${PARSING_ARRAY[0]}
DEST=${PARSING_ARRAY[1]}
if [[ "$FILE" =~ ^-.* ]]; then
FILE=`echo $FILE | sed s/^-//`
fi
if [ -z "$DEST" ]; then
DEST=$FILE
fi
DIR=`dirname $DEST`
if [ ! -d $BASE/$DIR ]; then
mkdir -p $BASE/$DIR
fi
if [ "x$SETUP" != "x1" ]; then
if [ -z $LDIR ]; then
adb pull /system/$FILE $BASE/$DEST
else
cp $LDIR/system/$FILE $BASE/$DEST
fi
# if file dot not exist try destination
if [ "$?" != "0" ]; then
if [ -z $LDIR ]; then
adb pull /system/$DEST $BASE/$DEST
else
cp $LDIR/system/$DEST $BASE/$DEST
fi
fi
fi
done
exit 0