Instantly share code, notes, and snippets.

@msdx msdx/jiagu.sh
Created Jan 23, 2019

Embed
What would you like to do?
360加固
#!/bin/bash
cd `dirname $0`/../
projectDir=`pwd`
buildDir="$projectDir/build"
# release Official apk
cd $buildDir
touch timestampFile
echo "Build release official apk"
cd $projectDir
# invoke gradlew to build the official apk
./gradlew releaseOfficial || exit 1
# find the target apk
targetApk=`find $projectDir/release -name "*.apk" -newer $buildDir/timestampFile`
if [ ! -n "$targetApk" ]; then
echo "Apk is not changed. Exit"
exit 0
fi
# download the program
cd ~/
jgCacheDir=".android/jiagu"
jgVersion="1.0"
jgFolder=360-jiagu-$jgVersion
jgZipName=$jgFolder.zip
if [ ! -d "$jgCacheDir" ]; then
mkdir $jgCacheDir
fi
cd $jgCacheDir
if test -e "$jgZipName"; then
zflag=" -z $jgZipName"
else
zflag=""
fi
# origin url https://github.com/msdx/360-jiagu/archive/$jgVersion.zip
curl -L -e ";auto" -o $jgZipName $zflag https://github.com/msdx/360-jiagu/archive/$jgVersion.zip #这里应改为你的cdn地址
# extract
cd $buildDir
echo "Extract jiagu.zip"
unzip -oq ~/$jgCacheDir/$jgFolder -d .
if [ ! -d "jiagu" ]; then
mv $jgFolder jiagu
else
cp -rf $jgFolder/* jiagu/
fi
cd jiagu && ./init.sh || exit 1
cd $buildDir/jiagu
# login
if [ ! -n "$1" ] || [ ! -n "$2" ]; then
username=$JIAGU_USERNAME
password=$JIAGU_PASSWORD
else
username=$1
password=$2
fi
java -jar jiagu.jar -login $username $password
# remove unnecessary service config
java -jar jiagu.jar -config -
# process
for file in `find output -name "*.apk"`; do
rm $file;
done
echo "Start process $targetApk"
java -jar jiagu.jar -jiagu $targetApk output || exit 1
enhancedApk=`find output -name "*.apk"`
# sign
echo "Sign $enhancedApk"
$projectDir/buildsystem/signIOP.sh $enhancedApk
# cp the archives to folder
if [ ! -d "archives" ]; then
mkdir archives
else
rm archives/*
fi
cp $enhancedApk archives/
for file in `find $projectDir/release -type f -newer $buildDir/timestampFile`; do
cp $file archives/
done
git log -n 1 > archives/git-info.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment