This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·65 lines (61 loc) · 2.72 KB
/
build.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
VERSIONCODE="80"
VERSIONNAME="6.4.0"
VERSIONSHA1="4a84001d584eeeff5f72480a0810de450e280446"
CURDIR=`pwd`
MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Script is in the" $MYDIR
BUILDTOOLDIR=$MYDIR/tool
#
# 77 -> 6.3.6 03145e09e79d72cf27ea00437f1c872cae858b78
# 78 -> 6.3.7 f20860ec42ef8e8fa0e80bdfebd07239acda52ba
# 79 -> 6.3.8 0d25c492cd7d12b59feb01331bdf437dc393e16c
#
# if stable use latest valid version
# else check update first if update available : use parser to generate so.patch and use previous version smali.patch if specified file not changed.
#
downloadRadiko(){
echo "Downloading radiko original apk"
DOWNLOADLINK=`curl -s https://apkpure.com/radiko-jp-for-android/jp.radiko.Player/download/$VERSIONCODE-APK |grep -oP "(?<=id=\"iframe_download\" src=\").*?(?=\")"`
if [ $DOWNLOADLINK ];then
wget -O $BUILDTOOLDIR/src-v$VERSIONNAME.apk $DOWNLOADLINK || exit 1
else
exit 1
fi
}
downloadApktool(){
echo "Downloading Apktool"
wget -O $BUILDTOOLDIR/apktool_2.3.2.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.3.2.jar || exit 1
}
echo "Using " $BUILDTOOLDIR " for apktool and radiko original android apk"
if [ ! -x "$BUILDTOOLDIR" ];then
mkdir $BUILDTOOLDIR
downloadRadiko
downloadApktool
else
if [[ ! -f $BUILDTOOLDIR/src-v$VERSIONNAME.apk ]] || [[ `md5sum $BUILDTOOLDIR/src-v$VERSIONNAME.apk |awk '{print $1}'` != $VERSIONSHA1 ]] ;then
downloadRadiko
fi
if [[ ! -f $BUILDTOOLDIR/apktool_2.3.2.jar ]] || [[ `md5sum $BUILDTOOLDIR/apktool_2.3.2.jar |awk '{print $1}'` != '953ed8a553becac4e713d1073912f15f' ]];then
downloadApktool
fi
fi
BUILDDIR=`mktemp -d`
echo "Create tmp build directory" $BUILDDIR
echo "Decompiling"
java -jar $BUILDTOOLDIR/apktool_2.3.2.jar d $BUILDTOOLDIR/src-v$VERSIONNAME.apk -f -o $BUILDDIR
cd $BUILDDIR
echo "Applying patch from " $MYDIR/patch/$VERSIONNAME/smali.patch
git apply --stat $MYDIR/patch/$VERSIONNAME/smali.patch
git apply $MYDIR/patch/$VERSIONNAME/smali.patch
#if debug , generate so.patch from parser.py
#
echo "Applying patch from " $MYDIR/patch/$VERSIONNAME/so.patch
git apply --stat $MYDIR/patch/$VERSIONNAME/so.patch
git apply $MYDIR/patch/$VERSIONNAME/so.patch
echo "Compiling && Packaging && Signing"
java -jar $BUILDTOOLDIR/apktool_2.3.2.jar b $BUILDDIR
cd $BUILDDIR/dist && keytool -genkey -keystore fake.jks -keyalg RSA -keysize 2048 -alias fake -storepass 123456 -dname "CN=fake" -keypass 123456 -validity 36500 && jarsigner -keystore fake.jks -digestalg SHA1 -sigalg SHA1withRSA -storepass 123456 -signedjar $MYDIR/radiko_kai_$VERSIONNAME.apk src-v$VERSIONNAME.apk fake
echo "Removing tmp directory" $BUILDDIR
rm -r $BUILDDIR
echo "Result is " $MYDIR/radiko_kai_$VERSIONNAME.apk
cd $CURDIR