update
This commit is contained in:
parent
937d6d56d8
commit
f649403571
@ -4,11 +4,11 @@ import os
|
|||||||
import stat
|
import stat
|
||||||
import shutil
|
import shutil
|
||||||
import json
|
import json
|
||||||
|
|
||||||
print(os.path.abspath(__name__))
|
print(os.path.abspath(__name__))
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
RD, WD, XD = 4, 2, 1
|
RD, WD, XD = 4, 2, 1
|
||||||
BNS = [RD, WD, XD]
|
BNS = [RD, WD, XD]
|
||||||
MDS = [
|
MDS = [
|
||||||
@ -17,6 +17,7 @@ MDS = [
|
|||||||
[stat.S_IXUSR, stat.S_IXGRP, stat.S_IXOTH]
|
[stat.S_IXUSR, stat.S_IXGRP, stat.S_IXOTH]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def chmod(path, mode):
|
def chmod(path, mode):
|
||||||
if isinstance(mode, int):
|
if isinstance(mode, int):
|
||||||
mode = str(mode)
|
mode = str(mode)
|
||||||
@ -30,18 +31,20 @@ def chmod(path, mode):
|
|||||||
mode_num += MDS[bnidx][midx]
|
mode_num += MDS[bnidx][midx]
|
||||||
# os.chmod(path, mode_num)
|
# os.chmod(path, mode_num)
|
||||||
|
|
||||||
#遍历res下的所有文件
|
|
||||||
def isFindApk (parent):
|
# 遍历res下的所有文件
|
||||||
for i in os.listdir(parent) :
|
def isFindApk(parent):
|
||||||
if i.endswith('.apk') :
|
for i in os.listdir(parent):
|
||||||
print ('find apk file-===%s' %i)
|
if i.endswith('.apk'):
|
||||||
|
print('find apk file-===%s' % i)
|
||||||
return i;
|
return i;
|
||||||
print ('no apk file=====')
|
print('no apk file=====')
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def readChannelfile(filename):
|
def readChannelfile(filename):
|
||||||
try:
|
try:
|
||||||
print (filename)
|
print(filename)
|
||||||
f = open(filename)
|
f = open(filename)
|
||||||
global channelList
|
global channelList
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -49,104 +52,108 @@ def readChannelfile(filename):
|
|||||||
exit(0)
|
exit(0)
|
||||||
channelList = json.load(f)
|
channelList = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
def backUpManifest():
|
def backUpManifest():
|
||||||
if os.path.exists('./AndroidManifest.xml'):
|
if os.path.exists('./AndroidManifest.xml'):
|
||||||
os.remove('./AndroidManifest.xml')
|
os.remove('./AndroidManifest.xml')
|
||||||
manifestPath = './temp/AndroidManifest.xml'
|
manifestPath = './temp/AndroidManifest.xml'
|
||||||
shutil.copyfile(manifestPath, './AndroidManifest.xml')
|
shutil.copyfile(manifestPath, './AndroidManifest.xml')
|
||||||
print ('manifest info--%s' %manifestPath)
|
print('manifest info--%s' % manifestPath)
|
||||||
|
|
||||||
|
|
||||||
def modifyChannel(value):
|
def modifyChannel(value):
|
||||||
tempXML = ''
|
tempXML = ''
|
||||||
f = open('./AndroidManifest.xml')
|
f = open('./AndroidManifest.xml')
|
||||||
for line in f :
|
for line in f:
|
||||||
if line.find('leguChannel') > 0 and easyName != '' :
|
if line.find('leguChannel') > 0 and easyName != '':
|
||||||
if easyNameSuffix == "1" :
|
if easyNameSuffix == "1":
|
||||||
if value < 10 :
|
if value < 10:
|
||||||
line = '<meta-data android:name="leguChannel" android:value="%s_0%d"/>' % (easyName, value)
|
line = '<meta-data android:name="leguChannel" android:value="%s_0%d"/>' % (easyName, value)
|
||||||
else :
|
else:
|
||||||
line = '<meta-data android:name="leguChannel" android:value="%s_%d"/>' % (easyName, value)
|
line = '<meta-data android:name="leguChannel" android:value="%s_%d"/>' % (easyName, value)
|
||||||
else :
|
else:
|
||||||
line = '<meta-data android:name="leguChannel" android:value="%s"/>' % (easyName)
|
line = '<meta-data android:name="leguChannel" android:value="%s"/>' % (easyName)
|
||||||
elif line.find('owner') > 0 and owner != '' :
|
elif line.find('owner') > 0 and owner != '':
|
||||||
print ('owner====%s' %line)
|
print('owner====%s' % line)
|
||||||
line = '<meta-data android:name="owner" android:value="%s"/>' % (owner)
|
line = '<meta-data android:name="owner" android:value="%s"/>' % (owner)
|
||||||
elif line.find('package') > 0 and packageId != '' :
|
elif line.find('package') > 0 and packageId != '':
|
||||||
print ('package====%s' %line)
|
print('package====%s' % line)
|
||||||
line = '<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="30" android:compileSdkVersionCodename="11" android:installLocation="auto" package="%s" platformBuildVersionCode="30" platformBuildVersionName="11">' % (packageId)
|
line = '<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="30" android:compileSdkVersionCodename="11" android:installLocation="auto" package="%s" platformBuildVersionCode="30" platformBuildVersionName="11">' % (
|
||||||
elif line.find('appid') > 0 and appid != '' :
|
packageId)
|
||||||
print ('appid====%s' %line)
|
elif line.find('appid') > 0 and appid != '':
|
||||||
line = '<meta-data android:name="appid" android:value="%s"/>' % (appid)
|
print('appid====%s' % line)
|
||||||
elif line.find('gism_id') > 0 and gism_id != '' :
|
line = '<meta-data android:name="appid" android:value="%s"/>' % (appid)
|
||||||
print ('gism_id====%s' %line)
|
elif line.find('gism_id') > 0 and gism_id != '':
|
||||||
line = '<meta-data android:name="gism_id" android:value="%s"/>' % (gism_id)
|
print('gism_id====%s' % line)
|
||||||
elif line.find('gism_name') > 0 and gism_name != '' :
|
line = '<meta-data android:name="gism_id" android:value="%s"/>' % (gism_id)
|
||||||
print ('gism_name====%s' %line)
|
elif line.find('gism_name') > 0 and gism_name != '':
|
||||||
line = '<meta-data android:name="gism_name" android:value="%s"/>' % (gism_name)
|
print('gism_name====%s' % line)
|
||||||
elif line.find('gism_channel') > 0 and gism_channel != '' :
|
line = '<meta-data android:name="gism_name" android:value="%s"/>' % (gism_name)
|
||||||
print ('gism_channel====%s' %line)
|
elif line.find('gism_channel') > 0 and gism_channel != '':
|
||||||
line = '<meta-data android:name="gism_channel" android:value="%s"/>' % (gism_channel)
|
print('gism_channel====%s' % line)
|
||||||
elif line.find('lg_ad_id') > 0 and lg_ad_id != '' :
|
line = '<meta-data android:name="gism_channel" android:value="%s"/>' % (gism_channel)
|
||||||
print ('lg_ad_id====%s' %line)
|
elif line.find('lg_ad_id') > 0 and lg_ad_id != '':
|
||||||
line = '<meta-data android:name="lg_ad_id" android:value="%s"/>' % (lg_ad_id)
|
print('lg_ad_id====%s' % line)
|
||||||
elif line.find('lg_ad_name') > 0 and lg_ad_name != '' :
|
line = '<meta-data android:name="lg_ad_id" android:value="%s"/>' % (lg_ad_id)
|
||||||
print ('lg_ad_name====%s' %line)
|
elif line.find('lg_ad_name') > 0 and lg_ad_name != '':
|
||||||
line = '<meta-data android:name="lg_ad_name" android:value="%s"/>' % (lg_ad_name)
|
print('lg_ad_name====%s' % line)
|
||||||
elif line.find('gactionId') > 0 and gactionId != '' :
|
line = '<meta-data android:name="lg_ad_name" android:value="%s"/>' % (lg_ad_name)
|
||||||
print ('gactionId====%s' %line)
|
elif line.find('gactionId') > 0 and gactionId != '':
|
||||||
line = '<meta-data android:name="gactionId" android:value="%s"/>' % (gactionId)
|
print('gactionId====%s' % line)
|
||||||
elif line.find('gappSecretKey') > 0 and gappSecretKey != '' :
|
line = '<meta-data android:name="gactionId" android:value="%s"/>' % (gactionId)
|
||||||
print ('gappSecretKey====%s' %line)
|
elif line.find('gappSecretKey') > 0 and gappSecretKey != '':
|
||||||
line = '<meta-data android:name="gappSecretKey" android:value="%s"/>' % (gappSecretKey)
|
print('gappSecretKey====%s' % line)
|
||||||
elif line.find('baiduId') > 0 and baiduId != '' :
|
line = '<meta-data android:name="gappSecretKey" android:value="%s"/>' % (gappSecretKey)
|
||||||
print ('baiduId====%s' %line)
|
elif line.find('baiduId') > 0 and baiduId != '':
|
||||||
line = '<meta-data android:name="baiduId" android:value="%s"/>' % (baiduId)
|
print('baiduId====%s' % line)
|
||||||
elif line.find('baiduSecretKey') > 0 and baiduSecretKey != '' :
|
line = '<meta-data android:name="baiduId" android:value="%s"/>' % (baiduId)
|
||||||
print ('baiduSecretKey====%s' %line)
|
elif line.find('baiduSecretKey') > 0 and baiduSecretKey != '':
|
||||||
line = '<meta-data android:name="baiduSecretKey" android:value="%s"/>' % (baiduSecretKey)
|
print('baiduSecretKey====%s' % line)
|
||||||
elif line.find('lg_reyun_game_appkey') > 0 and lg_reyun_game_appkey != '' :
|
line = '<meta-data android:name="baiduSecretKey" android:value="%s"/>' % (baiduSecretKey)
|
||||||
print ('lg_reyun_game_appkey====%s' %line)
|
elif line.find('lg_reyun_game_appkey') > 0 and lg_reyun_game_appkey != '':
|
||||||
line = '<meta-data android:name="lg_reyun_game_appkey" android:value="%s"/>' % (lg_reyun_game_appkey)
|
print('lg_reyun_game_appkey====%s' % line)
|
||||||
elif line.find('lg_reyun_game_channelId') > 0 and lg_reyun_game_channelId != '' :
|
line = '<meta-data android:name="lg_reyun_game_appkey" android:value="%s"/>' % (lg_reyun_game_appkey)
|
||||||
print ('lg_reyun_game_channelId====%s' %line)
|
elif line.find('lg_reyun_game_channelId') > 0 and lg_reyun_game_channelId != '':
|
||||||
line = '<meta-data android:name="lg_reyun_game_channelId" android:value="%s"/>' % (lg_reyun_game_channelId)
|
print('lg_reyun_game_channelId====%s' % line)
|
||||||
elif line.find('lg_reyun_io_appkey') > 0 and lg_reyun_io_appkey != '' :
|
line = '<meta-data android:name="lg_reyun_game_channelId" android:value="%s"/>' % (lg_reyun_game_channelId)
|
||||||
print ('lg_reyun_io_appkey====%s' %line)
|
elif line.find('lg_reyun_io_appkey') > 0 and lg_reyun_io_appkey != '':
|
||||||
line = '<meta-data android:name="lg_reyun_io_appkey" android:value="%s"/>' % (lg_reyun_io_appkey)
|
print('lg_reyun_io_appkey====%s' % line)
|
||||||
elif line.find('lg_reyun_io_channelId') > 0 and lg_reyun_io_channelId != 0 :
|
line = '<meta-data android:name="lg_reyun_io_appkey" android:value="%s"/>' % (lg_reyun_io_appkey)
|
||||||
print ('lg_reyun_io_channelId====%s' %line)
|
elif line.find('lg_reyun_io_channelId') > 0 and lg_reyun_io_channelId != 0:
|
||||||
line = '<meta-data android:name="lg_reyun_io_channelId" android:value="%s"/>' % (lg_reyun_io_channelId)
|
print('lg_reyun_io_channelId====%s' % line)
|
||||||
elif line.find('eventType') > 0 and eventType != '' :
|
line = '<meta-data android:name="lg_reyun_io_channelId" android:value="%s"/>' % (lg_reyun_io_channelId)
|
||||||
print ('eventType====%s' %line)
|
elif line.find('eventType') > 0 and eventType != '':
|
||||||
line = '<meta-data android:name="eventType" android:value="%s"/>' % (eventType)
|
print('eventType====%s' % line)
|
||||||
|
line = '<meta-data android:name="eventType" android:value="%s"/>' % (eventType)
|
||||||
tempXML += line
|
tempXML += line
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
output = open('./temp/AndroidManifest.xml', 'w')
|
output = open('./temp/AndroidManifest.xml', 'w')
|
||||||
output.write(tempXML)
|
output.write(tempXML)
|
||||||
output.close()
|
output.close()
|
||||||
if value < 10 :
|
if value < 10:
|
||||||
unsignApk = r'./bin/%s_0%d_unsigned.apk'% (easyName, value)
|
unsignApk = r'./bin/%s_0%d_unsigned.apk' % (easyName, value)
|
||||||
#chmod(unsignApk, "777")
|
# chmod(unsignApk, "777")
|
||||||
else :
|
else:
|
||||||
unsignApk = r'./bin/%s_%d_unsigned.apk'% (easyName, value)
|
unsignApk = r'./bin/%s_%d_unsigned.apk' % (easyName, value)
|
||||||
chmod(unsignApk, "777")
|
chmod(unsignApk, "777")
|
||||||
|
|
||||||
cmdPack = r'java -jar apktool.jar b temp -o %s'% (unsignApk)
|
cmdPack = r'java -jar apktool.jar b temp -o %s' % (unsignApk)
|
||||||
os.system(cmdPack)
|
os.system(cmdPack)
|
||||||
|
|
||||||
if value < 10 :
|
if value < 10:
|
||||||
signedjar = r'./bin/%s_0%d.apk'% (easyName, value)
|
signedjar = r'./bin/%s_0%d.apk' % (easyName, value)
|
||||||
unsignedjar = r'./bin/%s_0%d_unsigned.apk'% (easyName, value)
|
unsignedjar = r'./bin/%s_0%d_unsigned.apk' % (easyName, value)
|
||||||
chmod(signedjar, "777")
|
chmod(signedjar, "777")
|
||||||
chmod(unsignedjar, "777")
|
chmod(unsignedjar, "777")
|
||||||
else :
|
else:
|
||||||
signedjar = r'./bin/%s_%d.apk'% (easyName, value)
|
signedjar = r'./bin/%s_%d.apk' % (easyName, value)
|
||||||
unsignedjar = r'./bin/%s_%d_unsigned.apk'% (easyName, value)
|
unsignedjar = r'./bin/%s_%d_unsigned.apk' % (easyName, value)
|
||||||
chmod(signedjar, "777")
|
chmod(signedjar, "777")
|
||||||
chmod(unsignedjar, "777")
|
chmod(unsignedjar, "777")
|
||||||
|
|
||||||
cmd_sign = r'jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA -keystore %s -storepass %s -keypass %s -signedjar %s %s %s'% (keystore, storepass, keypass, signedjar, unsignedjar, alianame)
|
cmd_sign = r'jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA -keystore %s -storepass %s -keypass %s -signedjar %s %s %s' % (
|
||||||
|
keystore, storepass, keypass, signedjar, unsignedjar, alianame)
|
||||||
os.system(cmd_sign)
|
os.system(cmd_sign)
|
||||||
os.remove(unsignedjar);
|
os.remove(unsignedjar);
|
||||||
|
|
||||||
@ -154,7 +161,7 @@ def modifyChannel(value):
|
|||||||
channelList = {}
|
channelList = {}
|
||||||
#
|
#
|
||||||
os.system('java -jar apkool.jar empty-framework-dir --force')
|
os.system('java -jar apkool.jar empty-framework-dir --force')
|
||||||
readChannelfile('./channel')
|
readChannelfile('channel.json')
|
||||||
|
|
||||||
apkName = ""
|
apkName = ""
|
||||||
apkNameSuffix = "0"
|
apkNameSuffix = "0"
|
||||||
@ -165,17 +172,17 @@ packageIdSuffix = "0"
|
|||||||
easyName = ""
|
easyName = ""
|
||||||
easyNameSuffix = "0"
|
easyNameSuffix = "0"
|
||||||
|
|
||||||
keystore = ''
|
keystore = ''
|
||||||
storepass = ''
|
storepass = ''
|
||||||
alianame = ''
|
alianame = ''
|
||||||
keypass = ''
|
keypass = ''
|
||||||
|
|
||||||
owner = ''
|
owner = ''
|
||||||
|
|
||||||
packNum = 0
|
packNum = 0
|
||||||
start = 0
|
start = 0
|
||||||
|
|
||||||
#----------------------- third qudao start----------------------
|
# ----------------------- third qudao start----------------------
|
||||||
appid = ''
|
appid = ''
|
||||||
gism_id = ''
|
gism_id = ''
|
||||||
gism_name = ''
|
gism_name = ''
|
||||||
@ -185,203 +192,197 @@ lg_ad_name = ''
|
|||||||
gactionId = ''
|
gactionId = ''
|
||||||
gappSecretKey = ''
|
gappSecretKey = ''
|
||||||
baiduId = ''
|
baiduId = ''
|
||||||
baiduSecretKey = ''
|
baiduSecretKey = ''
|
||||||
lg_reyun_game_appkey = ''
|
lg_reyun_game_appkey = ''
|
||||||
lg_reyun_game_channelId = ''
|
lg_reyun_game_channelId = ''
|
||||||
lg_reyun_io_appkey = ''
|
lg_reyun_io_appkey = ''
|
||||||
lg_reyun_io_channelId = ''
|
lg_reyun_io_channelId = ''
|
||||||
eventType = ''
|
eventType = ''
|
||||||
|
|
||||||
|
# ----------------------- third qudao end------------------------
|
||||||
|
|
||||||
#----------------------- third qudao end------------------------
|
print('-------------------- your channel.json values --------------------')
|
||||||
|
# print 'channel.json list: ', channelList
|
||||||
|
|
||||||
print ('-------------------- your channel values --------------------')
|
if 'apkname' in channelList:
|
||||||
#print 'channel list: ', channelList
|
print('apkname==%s' % channelList['apkname'])
|
||||||
|
print('apkname value==%s' % channelList['apkname']['value'])
|
||||||
|
print('apkname suffix==%s' % channelList['apkname']['suffix'])
|
||||||
|
apkName = channelList['apkname']['value']
|
||||||
|
apkNameSuffix = channelList['apkname']['suffix']
|
||||||
|
else:
|
||||||
|
apkName = isFindApk('./')
|
||||||
|
|
||||||
if 'apkname' in channelList :
|
if 'packageId' in channelList:
|
||||||
print ('apkname==%s' %channelList['apkname'])
|
print('packageId==%s' % channelList['packageId'])
|
||||||
print ('apkname value==%s' %channelList['apkname']['value'])
|
print('packageId value==%s' % channelList['packageId']['value'])
|
||||||
print ('apkname suffix==%s' %channelList['apkname']['suffix'])
|
print('packageId suffix==%s' % channelList['packageId']['suffix'])
|
||||||
apkName = channelList['apkname']['value']
|
packageId = channelList['packageId']['value']
|
||||||
apkNameSuffix = channelList['apkname']['suffix']
|
packageIdSuffix = channelList['packageId']['suffix']
|
||||||
else :
|
else:
|
||||||
apkName = isFindApk('./')
|
print("no key packageId")
|
||||||
|
|
||||||
|
if 'leguChannel' in channelList:
|
||||||
|
print('leguchannel==%s' % channelList['leguChannel'])
|
||||||
|
print('leguchannel value==%s' % channelList['leguChannel']['value'])
|
||||||
|
print('leguchannel suffix==%s' % channelList['leguChannel']['suffix'])
|
||||||
|
easyName = channelList['leguChannel']['value']
|
||||||
|
easyNameSuffix = channelList['leguChannel']['suffix']
|
||||||
|
else:
|
||||||
|
print("no key leguChannel")
|
||||||
|
|
||||||
if 'packageId' in channelList :
|
if 'keystore' in channelList:
|
||||||
print ('packageId==%s' %channelList['packageId'])
|
print('keystore==%s' % channelList['keystore'])
|
||||||
print ('packageId value==%s' %channelList['packageId']['value'])
|
print('keystore filename==%s' % channelList['keystore']['filename'])
|
||||||
print ('packageId suffix==%s' %channelList['packageId']['suffix'])
|
print('keystore storepass==%s' % channelList['keystore']['storepass'])
|
||||||
packageId = channelList['packageId']['value']
|
print('keystore alianame==%s' % channelList['keystore']['alianame'])
|
||||||
packageIdSuffix = channelList['packageId']['suffix']
|
print('keystore keypass==%s' % channelList['keystore']['keypass'])
|
||||||
else :
|
keystore = channelList['keystore']['filename']
|
||||||
print ("no key packageId")
|
storepass = channelList['keystore']['storepass']
|
||||||
|
alianame = channelList['keystore']['alianame']
|
||||||
|
keypass = channelList['keystore']['keypass']
|
||||||
|
else:
|
||||||
|
print("no key keystore")
|
||||||
|
|
||||||
if 'leguChannel' in channelList :
|
if 'owner' in channelList:
|
||||||
print ('leguchannel==%s' %channelList['leguChannel'])
|
print('owner==%s' % channelList['owner'])
|
||||||
print ('leguchannel value==%s' %channelList['leguChannel']['value'])
|
print('owner value==%s' % channelList['owner']['value'])
|
||||||
print ('leguchannel suffix==%s' %channelList['leguChannel']['suffix'])
|
owner = channelList['owner']['value']
|
||||||
easyName = channelList['leguChannel']['value']
|
else:
|
||||||
easyNameSuffix = channelList['leguChannel']['suffix']
|
print("no key owner")
|
||||||
else :
|
|
||||||
print ("no key leguChannel")
|
|
||||||
|
|
||||||
if 'keystore' in channelList :
|
if 'num' in channelList:
|
||||||
print ('keystore==%s' %channelList['keystore'])
|
print('num==%s' % channelList['num'])
|
||||||
print ('keystore filename==%s' %channelList['keystore']['filename'])
|
print('num value==%s' % channelList['num']['value'])
|
||||||
print ('keystore storepass==%s' %channelList['keystore']['storepass'])
|
print('num start==%s' % channelList['num']['start'])
|
||||||
print ('keystore alianame==%s' %channelList['keystore']['alianame'])
|
packNum = int(channelList['num']['value']) + 1
|
||||||
print ('keystore keypass==%s' %channelList['keystore']['keypass'])
|
start = int(channelList['num']['start'])
|
||||||
keystore = channelList['keystore']['filename']
|
else:
|
||||||
storepass = channelList['keystore']['storepass']
|
print("no key num")
|
||||||
alianame = channelList['keystore']['alianame']
|
|
||||||
keypass = channelList['keystore']['keypass']
|
|
||||||
else :
|
|
||||||
print ("no key keystore")
|
|
||||||
|
|
||||||
if 'owner' in channelList :
|
if 'appid' in channelList:
|
||||||
print ('owner==%s' %channelList['owner'])
|
print('appid==%s' % channelList['appid'])
|
||||||
print ('owner value==%s' %channelList['owner']['value'])
|
print('appid value==%s' % channelList['appid']['value'])
|
||||||
owner = channelList['owner']['value']
|
gism_id = channelList['appid']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key owner")
|
print("no key appid")
|
||||||
|
|
||||||
if 'num' in channelList :
|
if 'gism_id' in channelList:
|
||||||
print ('num==%s' %channelList['num'])
|
print('gism_id==%s' % channelList['gism_id'])
|
||||||
print ('num value==%s' %channelList['num']['value'])
|
print('gism_id value==%s' % channelList['gism_id']['value'])
|
||||||
print ('num start==%s' %channelList['num']['start'])
|
gism_id = channelList['gism_id']['value']
|
||||||
packNum = int(channelList['num']['value']) + 1
|
else:
|
||||||
start = int(channelList['num']['start'])
|
print("no key gism_id")
|
||||||
else :
|
|
||||||
print ("no key num")
|
|
||||||
|
|
||||||
|
if 'gism_name' in channelList:
|
||||||
|
print('gism_name==%s' % channelList['gism_name'])
|
||||||
|
print('gism_name value==%s' % channelList['gism_name']['value'])
|
||||||
|
gism_name = channelList['gism_name']['value']
|
||||||
|
else:
|
||||||
|
print("no key gism_name")
|
||||||
|
|
||||||
if 'appid' in channelList :
|
if 'gism_channel' in channelList:
|
||||||
print ('appid==%s' %channelList['appid'])
|
print('gism_channel==%s' % channelList['gism_channel'])
|
||||||
print ('appid value==%s' %channelList['appid']['value'])
|
print('gism_channel value==%s' % channelList['gism_channel']['value'])
|
||||||
gism_id = channelList['appid']['value']
|
gism_channel = channelList['gism_channel']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key appid")
|
print("no key gism_channel")
|
||||||
|
|
||||||
if 'gism_id' in channelList :
|
if 'lg_ad_id' in channelList:
|
||||||
print ('gism_id==%s' %channelList['gism_id'])
|
print('lg_ad_id==%s' % channelList['lg_ad_id'])
|
||||||
print ('gism_id value==%s' %channelList['gism_id']['value'])
|
print('lg_ad_id value==%s' % channelList['lg_ad_id']['value'])
|
||||||
gism_id = channelList['gism_id']['value']
|
lg_ad_id = channelList['lg_ad_id']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key gism_id")
|
print("no key lg_ad_id")
|
||||||
|
|
||||||
if 'gism_name' in channelList :
|
if 'lg_ad_name' in channelList:
|
||||||
print ('gism_name==%s' %channelList['gism_name'])
|
print('lg_ad_name==%s' % channelList['lg_ad_name'])
|
||||||
print ('gism_name value==%s' %channelList['gism_name']['value'])
|
print('lg_ad_name value==%s' % channelList['lg_ad_name']['value'])
|
||||||
gism_name = channelList['gism_name']['value']
|
lg_ad_name = channelList['lg_ad_name']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key gism_name")
|
print("no key lg_ad_name")
|
||||||
|
|
||||||
if 'gism_channel' in channelList :
|
if 'gactionId' in channelList:
|
||||||
print ('gism_channel==%s' %channelList['gism_channel'])
|
print('gactionId==%s' % channelList['gactionId'])
|
||||||
print ('gism_channel value==%s' %channelList['gism_channel']['value'])
|
print('gactionId value==%s' % channelList['gactionId']['value'])
|
||||||
gism_channel = channelList['gism_channel']['value']
|
gactionId = channelList['gactionId']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key gism_channel")
|
print("no key gactionId")
|
||||||
|
|
||||||
if 'lg_ad_id' in channelList :
|
if 'gappSecretKey' in channelList:
|
||||||
print ('lg_ad_id==%s' %channelList['lg_ad_id'])
|
print('gappSecretKey==%s' % channelList['gappSecretKey'])
|
||||||
print ('lg_ad_id value==%s' %channelList['lg_ad_id']['value'])
|
print('gappSecretKey value==%s' % channelList['gappSecretKey']['value'])
|
||||||
lg_ad_id = channelList['lg_ad_id']['value']
|
gism_id = channelList['gappSecretKey']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key lg_ad_id")
|
print("no key gappSecretKey")
|
||||||
|
|
||||||
if 'lg_ad_name' in channelList :
|
if 'baiduId' in channelList:
|
||||||
print ('lg_ad_name==%s' %channelList['lg_ad_name'])
|
print('baiduId ==%s' % channelList['baiduId'])
|
||||||
print ('lg_ad_name value==%s' %channelList['lg_ad_name']['value'])
|
print('baiduId value==%s' % channelList['baiduId']['value'])
|
||||||
lg_ad_name = channelList['lg_ad_name']['value']
|
gism_id = channelList['baiduId']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key lg_ad_name")
|
print("no key baiduId")
|
||||||
|
|
||||||
if 'gactionId' in channelList :
|
if 'baiduSecretKey' in channelList:
|
||||||
print ('gactionId==%s' %channelList['gactionId'])
|
# print 'baiduSecretKey==', channelList['baiduSecretKey']
|
||||||
print ('gactionId value==%s' %channelList['gactionId']['value'])
|
# print 'baiduSecretKey value==', channelList['baiduSecretKey']['value']
|
||||||
gactionId = channelList['gactionId']['value']
|
gism_id = channelList['baiduSecretKey']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key gactionId")
|
print("no key baiduSecretKey")
|
||||||
|
|
||||||
if 'gappSecretKey' in channelList :
|
if 'lg_reyun_game_appkey' in channelList:
|
||||||
print ('gappSecretKey==%s' %channelList['gappSecretKey'])
|
# print 'lg_reyun_game_appkey==', channelList['lg_reyun_game_appkey']
|
||||||
print ('gappSecretKey value==%s' %channelList['gappSecretKey']['value'])
|
# print 'lg_reyun_game_appkey value==', channelList['lg_reyun_game_appkey']['value']
|
||||||
gism_id = channelList['gappSecretKey']['value']
|
gism_id = channelList['lg_reyun_game_appkey']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key gappSecretKey")
|
print("no key lg_reyun_game_appkey")
|
||||||
|
|
||||||
if 'baiduId' in channelList :
|
if 'lg_reyun_game_channelId' in channelList:
|
||||||
print ('baiduId ==%s' %channelList['baiduId'])
|
# print 'lg_reyun_game_channelId==', channelList['lg_reyun_game_channelId']
|
||||||
print ('baiduId value==%s' %channelList['baiduId']['value'])
|
# print 'lg_reyun_game_channelId value==', channelList['lg_reyun_game_channelId']['value']
|
||||||
gism_id = channelList['baiduId']['value']
|
gism_id = channelList['lg_reyun_game_channelId']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key baiduId")
|
print("no key lg_reyun_game_channelId")
|
||||||
|
|
||||||
if 'baiduSecretKey' in channelList :
|
if 'lg_reyun_io_appkey' in channelList:
|
||||||
#print 'baiduSecretKey==', channelList['baiduSecretKey']
|
# print 'lg_reyun_io_appkey==', channelList['lg_reyun_io_appkey']
|
||||||
#print 'baiduSecretKey value==', channelList['baiduSecretKey']['value']
|
# print 'lg_reyun_io_appkey value==', channelList['lg_reyun_io_appkey']['value']
|
||||||
gism_id = channelList['baiduSecretKey']['value']
|
gism_id = channelList['lg_reyun_io_appkey']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key baiduSecretKey")
|
print("no key lg_reyun_io_appkey")
|
||||||
|
|
||||||
if 'lg_reyun_game_appkey' in channelList :
|
if 'lg_reyun_io_channelId' in channelList:
|
||||||
#print 'lg_reyun_game_appkey==', channelList['lg_reyun_game_appkey']
|
# print 'lg_reyun_io_channelId==', channelList['lg_reyun_io_channelId']
|
||||||
#print 'lg_reyun_game_appkey value==', channelList['lg_reyun_game_appkey']['value']
|
# print 'lg_reyun_io_channelId value==', channelList['lg_reyun_io_channelId']['value']
|
||||||
gism_id = channelList['lg_reyun_game_appkey']['value']
|
gism_id = channelList['lg_reyun_io_channelId']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key lg_reyun_game_appkey")
|
print("no key lg_reyun_io_channelId")
|
||||||
|
|
||||||
if 'lg_reyun_game_channelId' in channelList :
|
if 'eventType' in channelList:
|
||||||
#print 'lg_reyun_game_channelId==', channelList['lg_reyun_game_channelId']
|
# print 'eventType==', channelList['eventType']
|
||||||
#print 'lg_reyun_game_channelId value==', channelList['lg_reyun_game_channelId']['value']
|
# print 'eventType value==', channelList['eventType']['value']
|
||||||
gism_id = channelList['lg_reyun_game_channelId']['value']
|
gism_id = channelList['eventType']['value']
|
||||||
else :
|
else:
|
||||||
print ("no key lg_reyun_game_channelId")
|
print("no key eventType")
|
||||||
|
|
||||||
if 'lg_reyun_io_appkey' in channelList :
|
output_apk_dir = "./bin"
|
||||||
#print 'lg_reyun_io_appkey==', channelList['lg_reyun_io_appkey']
|
|
||||||
#print 'lg_reyun_io_appkey value==', channelList['lg_reyun_io_appkey']['value']
|
|
||||||
gism_id = channelList['lg_reyun_io_appkey']['value']
|
|
||||||
else :
|
|
||||||
print ("no key lg_reyun_io_appkey")
|
|
||||||
|
|
||||||
if 'lg_reyun_io_channelId' in channelList :
|
|
||||||
#print 'lg_reyun_io_channelId==', channelList['lg_reyun_io_channelId']
|
|
||||||
#print 'lg_reyun_io_channelId value==', channelList['lg_reyun_io_channelId']['value']
|
|
||||||
gism_id = channelList['lg_reyun_io_channelId']['value']
|
|
||||||
else :
|
|
||||||
print ("no key lg_reyun_io_channelId")
|
|
||||||
|
|
||||||
if 'eventType' in channelList :
|
|
||||||
#print 'eventType==', channelList['eventType']
|
|
||||||
#print 'eventType value==', channelList['eventType']['value']
|
|
||||||
gism_id = channelList['eventType']['value']
|
|
||||||
else :
|
|
||||||
print ("no key eventType")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output_apk_dir="./bin"
|
|
||||||
if os.path.exists(output_apk_dir):
|
if os.path.exists(output_apk_dir):
|
||||||
shutil.rmtree(output_apk_dir)
|
shutil.rmtree(output_apk_dir)
|
||||||
|
|
||||||
print ('apkname--==%s' %apkName)
|
print('apkname--==%s' % apkName)
|
||||||
if apkName == '' :
|
if apkName == '':
|
||||||
print ('apkName no, stop ...')
|
print('apkName no, stop ...')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
else :
|
else:
|
||||||
cmdExtract = r'java -jar apktool.jar d -f -s %s -o temp'% (apkName)
|
cmdExtract = r'java -jar apktool.jar d -f -s %s -o temp' % (apkName)
|
||||||
os.system(cmdExtract)
|
os.system(cmdExtract)
|
||||||
backUpManifest()
|
backUpManifest()
|
||||||
|
|
||||||
for channel in range(start, packNum) :
|
for channel in range(start, packNum):
|
||||||
modifyChannel(channel)
|
modifyChannel(channel)
|
||||||
|
|
||||||
if os.path.exists('./temp'):
|
if os.path.exists('./temp'):
|
||||||
shutil.rmtree('./temp')
|
shutil.rmtree('./temp')
|
||||||
if os.path.exists('./AndroidManifest.xml'):
|
if os.path.exists('./AndroidManifest.xml'):
|
||||||
os.remove('./AndroidManifest.xml')
|
os.remove('./AndroidManifest.xml')
|
||||||
print ('Done')
|
print('Done')
|
||||||
|
@ -1 +0,0 @@
|
|||||||
{"leguChannel": {"value": "test7", "suffix": "1"}, "num": {"value": "1", "start": "1"}, "keystore": {"filename": "/www/wwwroot/legusdk/app/Components/SDK/ApkTool/keystore/legu729.keystore", "storepass": "123456", "alianame": "legu", "keypass": "123456"}}
|
|
17
ApkTool/channel.json
Normal file
17
ApkTool/channel.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"apkname":{"value":"/data/bale_apk/ApkTool/gmswz_TT_gy_01.apk"},
|
||||||
|
"leguChannel": {
|
||||||
|
"value": "test7",
|
||||||
|
"suffix": "1"
|
||||||
|
},
|
||||||
|
"num": {
|
||||||
|
"value": "1",
|
||||||
|
"start": "1"
|
||||||
|
},
|
||||||
|
"keystore": {
|
||||||
|
"filename": "/www/wwwroot/legusdk/app/Components/SDK/ApkTool/keystore/legu729.keystore",
|
||||||
|
"storepass": "123456",
|
||||||
|
"alianame": "legu",
|
||||||
|
"keypass": "123456"
|
||||||
|
}
|
||||||
|
}
|
@ -13,13 +13,13 @@ router = APIRouter()
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# @router.post("/channel")
|
# @router.post("/channel.json")
|
||||||
# async def channel(
|
# async def channel.json(
|
||||||
# data_in: schemas.BaleCreate
|
# data_in: schemas.BaleCreate
|
||||||
# ) -> schemas.Msg:
|
# ) -> schemas.Msg:
|
||||||
# file = os.path.join(settings.ROOT_DIR, 'ApkTool/channel')
|
# file = os.path.join(settings.ROOT_DIR, 'ApkTool/channel.json')
|
||||||
# with open(file, 'w') as f:
|
# with open(file, 'w') as f:
|
||||||
# json.dump(data_in.channel, f)
|
# json.dump(data_in.channel.json, f)
|
||||||
#
|
#
|
||||||
# resp = schemas.Msg(
|
# resp = schemas.Msg(
|
||||||
# code=0,
|
# code=0,
|
||||||
@ -130,7 +130,7 @@ async def run(
|
|||||||
)
|
)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
file = os.path.join(settings.ROOT_DIR, 'ApkTool/channel')
|
file = os.path.join(settings.ROOT_DIR, 'ApkTool/channel.json')
|
||||||
with open(file, 'w') as f:
|
with open(file, 'w') as f:
|
||||||
json.dump(data_in.channel, f)
|
json.dump(data_in.channel, f)
|
||||||
|
|
||||||
|
9
test.py
9
test.py
@ -1,3 +1,8 @@
|
|||||||
from utils import bale
|
import os
|
||||||
|
|
||||||
bale.run_bale_apk('aa',334)
|
from utils import MakeTool
|
||||||
|
from core.config import settings
|
||||||
|
|
||||||
|
make_tool = MakeTool(os.path.join(settings.ROOT_DIR, 'ApkTool/channel.json'))
|
||||||
|
a, b = make_tool.run()
|
||||||
|
print(a, b)
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
# coding:utf-8
|
# coding:utf-8
|
||||||
from .bale import bale
|
from .bale import bale
|
||||||
|
from .make_tool import MakeTool
|
||||||
|
@ -5,6 +5,7 @@ import os
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from core.config import settings
|
from core.config import settings
|
||||||
|
from .make_tool import MakeTool
|
||||||
from .put_file import put_file
|
from .put_file import put_file
|
||||||
|
|
||||||
|
|
||||||
@ -15,13 +16,25 @@ class Bale:
|
|||||||
def run_bale_apk(cls, dir_, id_):
|
def run_bale_apk(cls, dir_, id_):
|
||||||
try:
|
try:
|
||||||
pkg_num = 0
|
pkg_num = 0
|
||||||
with open(os.path.join(settings.ROOT_DIR, 'ApkTool/channel'), 'r') as f:
|
with open(os.path.join(settings.ROOT_DIR, 'ApkTool/channel.json'), 'r') as f:
|
||||||
props = json.load(f)
|
props = json.load(f)
|
||||||
pkg_num = int(props.get('num', {}).get('value', 0))
|
pkg_num = int(props.get('num', {}).get('value', 0))
|
||||||
|
|
||||||
cls.status = 'busy'
|
cls.status = 'busy'
|
||||||
cmd = os.path.join(settings.ROOT_DIR, 'ApkTool/run.sh')
|
make_tool = MakeTool(os.path.join(settings.ROOT_DIR, 'ApkTool/channel.json'))
|
||||||
os.system(cmd)
|
a, b = make_tool.run()
|
||||||
|
if not a:
|
||||||
|
data = {
|
||||||
|
'id': id_,
|
||||||
|
'url': '',
|
||||||
|
'apkname': '',
|
||||||
|
'total_pkg': pkg_num,
|
||||||
|
'current_pkg': 0,
|
||||||
|
'done': 0,
|
||||||
|
'code': -1,
|
||||||
|
'msg': b
|
||||||
|
}
|
||||||
|
requests.post('http://gamesdk.legu.cc/api/subpackageRecord/getRecord', data=data)
|
||||||
|
|
||||||
path = os.path.join(settings.ROOT_DIR, 'ApkTool/bin')
|
path = os.path.join(settings.ROOT_DIR, 'ApkTool/bin')
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
@ -36,14 +49,27 @@ class Bale:
|
|||||||
is_ok, msg = put_file(f'{dir_}/{item}', os.path.join(path, item))
|
is_ok, msg = put_file(f'{dir_}/{item}', os.path.join(path, item))
|
||||||
os.remove(os.path.join(path, item))
|
os.remove(os.path.join(path, item))
|
||||||
if not is_ok:
|
if not is_ok:
|
||||||
continue
|
data = {
|
||||||
|
'id': id_,
|
||||||
|
'url': msg,
|
||||||
|
'apkname': item,
|
||||||
|
'total_pkg': pkg_num,
|
||||||
|
'current_pkg': count,
|
||||||
|
'done': int(count >= pkg_num),
|
||||||
|
'code': -1,
|
||||||
|
'msg': msg
|
||||||
|
}
|
||||||
|
requests.post('http://gamesdk.legu.cc/api/subpackageRecord/getRecord', data=data)
|
||||||
data = {
|
data = {
|
||||||
'id': id_,
|
'id': id_,
|
||||||
'url': msg,
|
'url': msg,
|
||||||
'apkname': item,
|
'apkname': item,
|
||||||
'done': int(count >= pkg_num)
|
'total_pkg': pkg_num,
|
||||||
|
'current_pkg': count,
|
||||||
|
'done': int(count >= pkg_num),
|
||||||
|
'code': 0
|
||||||
}
|
}
|
||||||
resp = requests.post('http://gamesdk.legu.cc/api/subpackageRecord/getRecord', data=data)
|
requests.post('http://gamesdk.legu.cc/api/subpackageRecord/getRecord', data=data)
|
||||||
print(f'上传:{item} 完成')
|
print(f'上传:{item} 完成')
|
||||||
|
|
||||||
|
|
||||||
|
230
utils/make_tool.py
Normal file
230
utils/make_tool.py
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
# coding:utf-8
|
||||||
|
import json
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
from core.config import settings
|
||||||
|
|
||||||
|
|
||||||
|
class MakeTool:
|
||||||
|
MakeDir = os.path.join(settings.ROOT_DIR, 'ApkTool')
|
||||||
|
|
||||||
|
def __init__(self, channel_path):
|
||||||
|
self.channel_path = channel_path
|
||||||
|
self.apkName = ''
|
||||||
|
self.apkNameSuffix = '0'
|
||||||
|
self.easyName = ''
|
||||||
|
self.easyNameSuffix = '0'
|
||||||
|
self.packageId = ''
|
||||||
|
self.packageIdSuffix = '0'
|
||||||
|
self.keystore = ''
|
||||||
|
self.storepass = ''
|
||||||
|
self.alianame = ''
|
||||||
|
self.keypass = ''
|
||||||
|
self.owner = ''
|
||||||
|
self.packNum = 0
|
||||||
|
self.start = 0
|
||||||
|
self.appid = ''
|
||||||
|
self.gism_id = ''
|
||||||
|
self.gism_name = ''
|
||||||
|
self.gism_channel = ''
|
||||||
|
self.lg_ad_id = ''
|
||||||
|
self.lg_ad_name = ''
|
||||||
|
self.gactionId = ''
|
||||||
|
self.gappSecretKey = ''
|
||||||
|
self.baiduId = ''
|
||||||
|
self.baiduSecretKey = ''
|
||||||
|
self.lg_reyun_game_appkey = ''
|
||||||
|
self.lg_reyun_game_channelId = ''
|
||||||
|
self.lg_reyun_io_appkey = ''
|
||||||
|
self.lg_reyun_io_channelId = ''
|
||||||
|
self.eventType = ''
|
||||||
|
|
||||||
|
def _init_props(self):
|
||||||
|
# 提取参数
|
||||||
|
props = dict()
|
||||||
|
with open(self.channel_path, 'r') as f:
|
||||||
|
props = json.load(f)
|
||||||
|
# 母包路径
|
||||||
|
self.apkName = props.get('apkname', {}).get('value') or self.apkName
|
||||||
|
self.apkNameSuffix = props.get('apkname', {}).get('suffix') or self.apkNameSuffix
|
||||||
|
|
||||||
|
self.easyName = props.get('leguChannel', {}).get('value') or self.easyName
|
||||||
|
self.easyNameSuffix = props.get('leguChannel', {}).get('suffix') or self.easyNameSuffix
|
||||||
|
|
||||||
|
self.packageId = props.get('packageId', {}).get('value') or self.packageId
|
||||||
|
self.packageIdSuffix = props.get('packageId', {}).get('suffix') or self.packageIdSuffix
|
||||||
|
|
||||||
|
self.keystore = props.get('keystore', {}).get('filename') or self.keystore
|
||||||
|
self.storepass = props.get('keystore', {}).get('storepass') or self.storepass
|
||||||
|
self.alianame = props.get('keystore', {}).get('alianame') or self.alianame
|
||||||
|
self.keypass = props.get('keystore', {}).get('keypass') or self.keypass
|
||||||
|
|
||||||
|
self.owner = props.get('owner', {}).get('value') or self.owner
|
||||||
|
|
||||||
|
self.packNum = props.get('num', {}).get('value') or self.packNum
|
||||||
|
self.start = props.get('num', {}).get('start') or self.start
|
||||||
|
self.start = int(self.start)
|
||||||
|
self.packNum = int(self.packNum) + 1
|
||||||
|
|
||||||
|
self.appid = props.get('appid', {}).get('value') or self.appid
|
||||||
|
self.gism_id = props.get('gism_id', {}).get('value') or self.gism_id
|
||||||
|
self.gism_name = props.get('gism_name', {}).get('value') or self.gism_name
|
||||||
|
self.gism_channel = props.get('gism_channel', {}).get('value') or self.gism_channel
|
||||||
|
self.lg_ad_id = props.get('lg_ad_id', {}).get('value') or self.lg_ad_id
|
||||||
|
self.lg_ad_name = props.get('lg_ad_name', {}).get('value') or self.lg_ad_name
|
||||||
|
self.gactionId = props.get('gactionId', {}).get('value') or self.gactionId
|
||||||
|
self.gappSecretKey = props.get('gappSecretKey', {}).get('value') or self.gappSecretKey
|
||||||
|
self.baiduId = props.get('baiduId', {}).get('value') or self.baiduId
|
||||||
|
self.baiduSecretKey = props.get('baiduSecretKey', {}).get('value') or self.baiduSecretKey
|
||||||
|
self.lg_reyun_game_appkey = props.get('lg_reyun_game_appkey', {}).get('value') or self.lg_reyun_game_appkey
|
||||||
|
self.lg_reyun_game_channelId = props.get('lg_reyun_game_channelId', {}).get(
|
||||||
|
'value') or self.lg_reyun_game_channelId
|
||||||
|
self.lg_reyun_io_appkey = props.get('lg_reyun_io_appkey', {}).get('value') or self.lg_reyun_io_appkey
|
||||||
|
self.lg_reyun_io_channelId = props.get('lg_reyun_io_channelId', {}).get('value') or self.lg_reyun_io_channelId
|
||||||
|
self.eventType = props.get('eventType', {}).get('value') or self.eventType
|
||||||
|
|
||||||
|
def _init_path(self):
|
||||||
|
bin_dir = os.path.join(self.MakeDir, 'bin')
|
||||||
|
if os.path.exists(bin_dir):
|
||||||
|
shutil.rmtree(bin_dir)
|
||||||
|
os.makedirs(bin_dir)
|
||||||
|
|
||||||
|
def check_props(self):
|
||||||
|
if not os.path.exists(self.apkName):
|
||||||
|
return False, '缺少apkName路径'
|
||||||
|
return True, 'ok'
|
||||||
|
|
||||||
|
def modify_channel(self, value):
|
||||||
|
tempXML = ''
|
||||||
|
with open(os.path.join(self.MakeDir, 'AndroidManifest.xml')) as f:
|
||||||
|
for line in f:
|
||||||
|
if line.find('leguChannel') > 0 and self.easyName != '':
|
||||||
|
if self.easyNameSuffix == "1":
|
||||||
|
if value < 10:
|
||||||
|
line = '<meta-data android:name="leguChannel" android:value="%s_0%d"/>' % (
|
||||||
|
self.easyName, value)
|
||||||
|
else:
|
||||||
|
line = '<meta-data android:name="leguChannel" android:value="%s_%d"/>' % (
|
||||||
|
self.easyName, value)
|
||||||
|
else:
|
||||||
|
line = '<meta-data android:name="leguChannel" android:value="%s"/>' % (self.easyName)
|
||||||
|
elif line.find('owner') > 0 and self.owner != '':
|
||||||
|
print('owner====%s' % line)
|
||||||
|
line = '<meta-data android:name="owner" android:value="%s"/>' % (self.owner)
|
||||||
|
elif line.find('package') > 0 and self.packageId != '':
|
||||||
|
print('package====%s' % line)
|
||||||
|
line = '<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="30" android:compileSdkVersionCodename="11" android:installLocation="auto" package="%s" platformBuildVersionCode="30" platformBuildVersionName="11">' % (
|
||||||
|
self.packageId)
|
||||||
|
elif line.find('appid') > 0 and self.appid != '':
|
||||||
|
print('appid====%s' % line)
|
||||||
|
line = '<meta-data android:name="appid" android:value="%s"/>' % (self.appid)
|
||||||
|
elif line.find('gism_id') > 0 and self.gism_id != '':
|
||||||
|
print('gism_id====%s' % line)
|
||||||
|
line = '<meta-data android:name="gism_id" android:value="%s"/>' % (self.gism_id)
|
||||||
|
elif line.find('gism_name') > 0 and self.gism_name != '':
|
||||||
|
print('gism_name====%s' % line)
|
||||||
|
line = '<meta-data android:name="gism_name" android:value="%s"/>' % (self.gism_name)
|
||||||
|
elif line.find('gism_channel') > 0 and self.gism_channel != '':
|
||||||
|
print('gism_channel====%s' % line)
|
||||||
|
line = '<meta-data android:name="gism_channel" android:value="%s"/>' % (self.gism_channel)
|
||||||
|
elif line.find('lg_ad_id') > 0 and self.lg_ad_id != '':
|
||||||
|
print('lg_ad_id====%s' % line)
|
||||||
|
line = '<meta-data android:name="lg_ad_id" android:value="%s"/>' % (self.lg_ad_id)
|
||||||
|
elif line.find('lg_ad_name') > 0 and self.lg_ad_name != '':
|
||||||
|
print('lg_ad_name====%s' % line)
|
||||||
|
line = '<meta-data android:name="lg_ad_name" android:value="%s"/>' % (self.lg_ad_name)
|
||||||
|
elif line.find('gactionId') > 0 and self.gactionId != '':
|
||||||
|
print('gactionId====%s' % line)
|
||||||
|
line = '<meta-data android:name="gactionId" android:value="%s"/>' % (self.gactionId)
|
||||||
|
elif line.find('gappSecretKey') > 0 and self.gappSecretKey != '':
|
||||||
|
print('gappSecretKey====%s' % line)
|
||||||
|
line = '<meta-data android:name="gappSecretKey" android:value="%s"/>' % (self.gappSecretKey)
|
||||||
|
elif line.find('baiduId') > 0 and self.baiduId != '':
|
||||||
|
print('baiduId====%s' % line)
|
||||||
|
line = '<meta-data android:name="baiduId" android:value="%s"/>' % (self.baiduId)
|
||||||
|
elif line.find('baiduSecretKey') > 0 and self.baiduSecretKey != '':
|
||||||
|
print('baiduSecretKey====%s' % line)
|
||||||
|
line = '<meta-data android:name="baiduSecretKey" android:value="%s"/>' % (self.baiduSecretKey)
|
||||||
|
elif line.find('lg_reyun_game_appkey') > 0 and self.lg_reyun_game_appkey != '':
|
||||||
|
print('lg_reyun_game_appkey====%s' % line)
|
||||||
|
line = '<meta-data android:name="lg_reyun_game_appkey" android:value="%s"/>' % (
|
||||||
|
self.lg_reyun_game_appkey)
|
||||||
|
elif line.find('lg_reyun_game_channelId') > 0 and self.lg_reyun_game_channelId != '':
|
||||||
|
print('lg_reyun_game_channelId====%s' % line)
|
||||||
|
line = '<meta-data android:name="lg_reyun_game_channelId" android:value="%s"/>' % (
|
||||||
|
self.lg_reyun_game_channelId)
|
||||||
|
elif line.find('lg_reyun_io_appkey') > 0 and self.lg_reyun_io_appkey != '':
|
||||||
|
print('lg_reyun_io_appkey====%s' % line)
|
||||||
|
line = '<meta-data android:name="lg_reyun_io_appkey" android:value="%s"/>' % (
|
||||||
|
self.lg_reyun_io_appkey)
|
||||||
|
elif line.find('lg_reyun_io_channelId') > 0 and self.lg_reyun_io_channelId != 0:
|
||||||
|
print('lg_reyun_io_channelId====%s' % line)
|
||||||
|
line = '<meta-data android:name="lg_reyun_io_channelId" android:value="%s"/>' % (
|
||||||
|
self.lg_reyun_io_channelId)
|
||||||
|
elif line.find('eventType') > 0 and self.eventType != '':
|
||||||
|
print('eventType====%s' % line)
|
||||||
|
line = '<meta-data android:name="eventType" android:value="%s"/>' % (self.eventType)
|
||||||
|
tempXML += line
|
||||||
|
|
||||||
|
with open(os.path.join(self.MakeDir, 'temp/AndroidManifest.xml'), 'w') as f:
|
||||||
|
f.write(tempXML)
|
||||||
|
|
||||||
|
unsignApk = os.path.join(self.MakeDir, f'bin/{self.easyName}_{value}_unsigned.apk')
|
||||||
|
|
||||||
|
cmdPack = f'cd {self.MakeDir} && java -jar apktool.jar b temp -o {unsignApk}'
|
||||||
|
os.system(cmdPack)
|
||||||
|
|
||||||
|
signedjar = os.path.join(self.MakeDir, f'bin/{self.easyName}_{value}.apk')
|
||||||
|
unsignedjar = os.path.join(self.MakeDir, f'bin/{self.easyName}_{value}_unsigned.apk')
|
||||||
|
|
||||||
|
cmd_sign = f'cd {self.MakeDir} && jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA -keystore {self.keystore} -storepass {self.storepass} -keypass {self.keypass} -signedjar {signedjar} {unsignedjar} {self.alianame}'
|
||||||
|
os.system(cmd_sign)
|
||||||
|
os.remove(unsignedjar)
|
||||||
|
|
||||||
|
def _unpack(self, pack_name):
|
||||||
|
"""
|
||||||
|
解包
|
||||||
|
:param pack_name:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
cmd = f'cd {self.MakeDir} && java -jar apktool.jar d -f -s {self.apkName} -o temp'
|
||||||
|
os.system(cmd)
|
||||||
|
androidmanifest_path = os.path.join(self.MakeDir, 'AndroidManifest.xml')
|
||||||
|
if os.path.exists(androidmanifest_path):
|
||||||
|
os.remove(androidmanifest_path)
|
||||||
|
new_androidmanifest_path = os.path.join(self.MakeDir, 'temp/AndroidManifest.xml')
|
||||||
|
shutil.copyfile(new_androidmanifest_path, androidmanifest_path)
|
||||||
|
|
||||||
|
def _clear(self):
|
||||||
|
path = os.path.join(self.MakeDir, 'temp')
|
||||||
|
if os.path.exists(path):
|
||||||
|
shutil.rmtree(path)
|
||||||
|
path = os.path.join(self.MakeDir, 'AndroidManifest.xml')
|
||||||
|
if os.path.exists(path):
|
||||||
|
os.remove(path)
|
||||||
|
|
||||||
|
def _make(self):
|
||||||
|
"""
|
||||||
|
重新编译包
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
for i in range(self.start, self.packNum):
|
||||||
|
self.modify_channel(i)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
self._init_props()
|
||||||
|
self._init_path()
|
||||||
|
is_ok, msg = self.check_props()
|
||||||
|
if not is_ok:
|
||||||
|
return False, msg
|
||||||
|
self._unpack(self.apkName)
|
||||||
|
self._make()
|
||||||
|
self._clear()
|
||||||
|
except Exception as e:
|
||||||
|
return False, str(e)
|
||||||
|
else:
|
||||||
|
return True, 'ok'
|
Loading…
Reference in New Issue
Block a user