Skip to content

Instantly share code, notes, and snippets.

@msdx
Created January 23, 2019 10:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msdx/bb4c891ede89a81988773debaa94bea7 to your computer and use it in GitHub Desktop.
Save msdx/bb4c891ede89a81988773debaa94bea7 to your computer and use it in GitHub Desktop.
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