forked from darkdukey/Google-Play-Service-Lite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pack_gms.sh
executable file
·101 lines (81 loc) · 2.99 KB
/
pack_gms.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
#
# Pack Google Play Services >= 30 in one jar file
#
#
# Author: Jimmy Yin ([email protected])
#
#INSERT HERE YOUR ANDROID SDK PATH
ANDROID_SDK_ROOT=/Users/Astrovic/Dati/Applicazioni/android-sdk
PLAY_SERVICES_PATH=$ANDROID_SDK_ROOT/extras/google/m2repository/com/google/android/gms
PLAY_SERVICES_VERSION=10.0.1
PLAY_SERVICES_FILENAME="google-play-services.jar"
PLAY_SERVICES_TEMP_DIR="google-play-services-temp"
PLAY_SERVICES_STRIP_FILE="gms_lite.conf"
PLAY_SERVICES_NESTED_PATH="com/google/android/gms"
PLAY_SERVICES_OUTPUT_FILE="google-play-services-full.jar"
pack_gms() {
echo ""
echo "Packing google play services from " + $PLAY_SERVICES_PATH + "..."
echo ""
PLAY_SERVICES_STRIP_FILE=$1
PLAY_SERVICES_OUTPUT_FILE=$2
# Check if file exists in the same directory
if [ ! -d $PLAY_SERVICES_PATH ]; then
echo "\nPlease config $ANDROID_SDK_ROOT, then run it again\n\n"
exit -1
fi
# Preventive cleanup
rm -rf $PLAY_SERVICES_TEMP_DIR
# Create temporary work folder
mkdir $PLAY_SERVICES_TEMP_DIR
cd $PLAY_SERVICES_TEMP_DIR
# If the configuration file doesn't exist, create it
if [ ! -f ../$PLAY_SERVICES_STRIP_FILE ]; then
# Create the file
touch ../$PLAY_SERVICES_STRIP_FILE
FOLDERS=`ls $PLAY_SERVICES_PATH`
for index in $FOLDERS
do
echo "$index=true" >> ../$PLAY_SERVICES_STRIP_FILE
done
sed "1d" ../$PLAY_SERVICES_STRIP_FILE > ../$PLAY_SERVICES_STRIP_FILE.bak
sed "s/play-services-//g" ../$PLAY_SERVICES_STRIP_FILE.bak > ../$PLAY_SERVICES_STRIP_FILE
fi
# Read configuration from file
while read -r FOLDERS
do
CURRENT_FOLDER=$FOLDERS
CURRENT_FOLDER_NAME=`echo $CURRENT_FOLDER | awk -F'=' '{print $1}'`
CURRENT_FOLDER_ENABLED=`echo $CURRENT_FOLDER | awk -F'=' '{print $2}'`
if [ "$CURRENT_FOLDER_ENABLED" = true ]; then
ARR_FILE=$PLAY_SERVICES_PATH/play-services-$CURRENT_FOLDER_NAME/$PLAY_SERVICES_VERSION/play-services-$CURRENT_FOLDER_NAME-$PLAY_SERVICES_VERSION.aar
echo "Extracting " $CURRENT_FOLDER_NAME
if [ -f $ARR_FILE ]; then
unzip $ARR_FILE -d $CURRENT_FOLDER_NAME > /dev/null
fi
if [ -f $CURRENT_FOLDER_NAME/classes.jar ]; then
jar xvf $CURRENT_FOLDER_NAME/classes.jar > /dev/null
fi
echo "Extracting Done."
else
echo "Skip extracting " $CURRENT_FOLDER_NAME
fi
done < ../"$PLAY_SERVICES_STRIP_FILE"
# Create final stripped JAR
jar cf $PLAY_SERVICES_OUTPUT_FILE com/
cp $PLAY_SERVICES_OUTPUT_FILE ../
cd ..
# Clean up
echo "\nFolders removed, cleaning up.."
rm -rf $PLAY_SERVICES_TEMP_DIR
rm -fr $PLAY_SERVICES_STRIP_FILE.bak
}
main() {
pack_gms "gms_full.conf" "google-play-services-full.jar"
rm -fr "gms_full.conf"
pack_gms "gms_lite.conf" "google-play-services.jar"
echo "All done, exiting!"
exit 0
}
main