win 下对 apk 批量签名
Paste_Image.pngtarget 要签名路径
out 产出
build 临时
make.py 执行签名
# -*- coding: utf-8 -*-
import os
import shutil
import os.path
import re
print(' 重签 start')
BASE_DIR = os.path.dirname(__file__)
out = os.path.exists('out')
if(out):
shutil.rmtree('out')
os.mkdir('out')
else:
os.mkdir('out')
_build = os.path.exists('build')
if(_build):
shutil.rmtree('build')
os.mkdir('build')
else:
os.mkdir('build')
keystore = 'game_2015_12_22_13_26_29_7M.keystore'
keypass = '******'
keyalias = '******'
BASE_DIR = os.path.dirname(__file__)
outDir = os.path.join(BASE_DIR, "out")
buildDir = os.path.join(BASE_DIR, "build")
targetDir = os.path.join(BASE_DIR, "target")
list = os.listdir(os.path.join(BASE_DIR, "target"))
for file in list:
print(file)
signedFile = os.path.join(buildDir, file + "signed.apk")
outFile = os.path.join(outDir, file)
f = os.path.join(targetDir, file)
signcmd = 'jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore "%s" -storepass "%s" -signedjar "%s" "%s" "%s"' % (keystore, keypass, signedFile, f, keyalias)
'jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore keystore -storepass keypass -signedjar signedFile file keyalias'
os.system(signcmd)
aligncmd = 'zipalign -f 4 "%s" "%s"' % (signedFile, outFile)
os.system(aligncmd)
print(file + " 完成")
网友评论