v1签名

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
#! /bin/sh
function signApk
{
echo "=========Start sign apk ### $1 ### with keystore. "
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore keystore文件路径 -storepass 密码 $1 签名证书别名
echo "=========Start zipalign apk ."
zipalign -f -v 4 $1 ./release/$2_realease.apk
}
# get this script path
# filepath=$(cd "$(dirname "$0")"; pwd)
# go into the script folder
cd `dirname $0`
# check command jarsigner exsit
command -v jarsigner >/dev/null 2>&1 || { echo >&2 "I require jarsigner but it's not found. Aborting."; exit 1; }
# make a folder to storage apk after sign and zipalign
mkdir ./release
for entry in ./*
do
echo "$entry"
file=$entry
# echo “filename: ${file%.*}
extension=${file##*.}
echo "$extension"
if [ "$extension" = "apk" ]; then
echo "is a APK"
fileName=${file%.*}
isRelease=${fileName#./FILE_NAME*_}
if [ "$isRelease" = "release" ]; then
echo "is a release version ,so ignore"
else
echo "not a release version,start sign..."
signApk $file $fileName;
fi

else
echo "not a apk file, ignore"
fi
done
echo "sign all apk file successfully!"

v2签名

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
#! /bin/sh
function signApk
{
echo "=========Start sign apk ### $1 ### with keystore. "
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore -keystore keystore文件路径 -storepass 密码 $1 签名证书别名
echo "=========Start zipalign apk ."
zipalign -f -v 4 $1 ./release/$2_realease.apk
echo "=========Start v2 sign apk ### $2_realease.apk ### with keystore. "
apksigner sign -v --ks keystore文件路径 --ks-key-alias 签名证书别名 --ks-pass pass:密码 --key-pass pass:密码 --out ./release_v2/$2_realease_v2.apk ./release/$2_realease.apk
}
# get this script path
# filepath=$(cd "$(dirname "$0")"; pwd)
# go into the script folder
cd `dirname $0`
# check command jarsigner exsit
command -v jarsigner >/dev/null 2>&1 || { echo >&2 "I require jarsigner but it's not found. Aborting."; exit 1; }
# make a folder to storage apk after sign and zipalign
mkdir ./release
mkdir ./release_v2
for entry in ./*
do
echo "$entry"
file=$entry
# echo “filename: ${file%.*}
extension=${file##*.}
echo "$extension"
if [ "$extension" = "apk" ]; then
echo "is a APK"
fileName=${file%.*}
isRelease=${fileName#./FILE_NAME*_}
if [ "$isRelease" = "release" ]; then
echo "is a release version ,so ignore"
else
echo "not a release version,start sign..."
signApk $file $fileName;
fi

else
echo "not a apk file, ignore"
fi
done
echo "sign all apk file successfully!"