优化打包脚本
diff --git a/Makefile b/Makefile
index 83637bb..12ce435 100644
--- a/Makefile
+++ b/Makefile
@@ -2,20 +2,32 @@
APPPATH=./app/build/outputs/apk/release
BUILDAPK=app-release.apk
-SIGNAPK=app_sign.apk
+SIGNAPK=posa711dali.apk
+GRADLE=./gradlew
+ZIP=zip
+SALT_KEY=.sign_salt
+SIGN_FILE=hash256.sign
+
+OS=$(shell uname)
+
+ifneq (,$(findstring MINGW,$(OS)))
+GRADLE=gradlew.bat
+else
+GRADLE=./gradlew
+endif
+
+VERSION=$(shell git describe --abbrev=4 --dirty --always --tags)
apk:
@echo "build app apk!"
- gradlew app:assembleRelease
+ $(GRADLE) app:assembleRelease
@echo "build android sign apk"
- java -jar signapk.jar platform.x509.pem platform.pk8 $(APPPATH)/$(BUILDAPK) $(APPPATH)/$(SIGNAPK)
- @echo "build upgrade zip"
- python upgrade.py $(APPPATH)/$(SIGNAPK)
+ java -jar signapk.jar platform.x509.pem platform.pk8 $(APPPATH)/$(BUILDAPK) $(APPPATH)/$(SIGNAPK)
+ @echo "build upgrade app zip"
+ cat $(APPPATH)/$(SIGNAPK) $(SALT_KEY) | sha256sum - | cut -d' ' -f 1 | tr -d '\n' > $(APPPATH)/$(SIGN_FILE)
+ cd $(APPPATH) && $(ZIP) posa711-$(VERSION).zip $(SIGN_FILE) $(SIGNAPK)
+
clean:
@echo "remove build cache apk!"
- rm -rf $(APPPATH)/$(BUILDAPK)
- rm -rf $(APPPATH)/$(SIGNAPK)
- rm -rf $(APPPATH)/hash256.sign
- rm -rf $(APPPATH)/output.json
+ cd $(APPPATH) && rm -rf *.apk *.json *.sign
@echo "remove build cache file success"
-
diff --git a/upgrade.py b/upgrade.py
deleted file mode 100644
index 957fed9..0000000
--- a/upgrade.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#coding=utf-8
-#使用python做升级文件打包
-
-import hashlib
-import sys
-import zipfile
-from os import path
-import subprocess
-
-hashFileName = 'hash256.sign'
-
-
-def sha256_checknum(apk):
- hash256 = hashlib.sha256()
- srcFile = open(apk,'rb')
- with srcFile as f:
- for block in iter(lambda:f.read(4096),b''):
- hash256.update(block);
- srcFile.close()
- hash256.update(b'nzoqPYMIu91VViA/mEIG5FtJXi8=')
-
- hashFile = path.dirname(apk)+'/'+hashFileName
- print('hashFile = '+hashFile)
- destFile = open(hashFile,'w+')
- destFile.write(hash256.hexdigest())
- destFile.close()
-
-def zip_file(apk):
- fileDir = path.dirname(apk)
- version = subprocess.check_output(['git', 'describe', '--abbrev=4','--dirty','--always','--tags']).strip().decode('utf-8')
- zipFile = fileDir+'/posa711dali'+'-'+version+'.zip'
- print('zipFile = '+zipFile)
-
- zf = zipfile.ZipFile(zipFile,'w',zipfile.ZIP_DEFLATED)
- zf.write(fileDir+'/'+hashFileName,hashFileName)
- zf.write(apk,'posa711dali.apk')
- zf.close()
-
-if __name__ == '__main__':
- if len(sys.argv) < 2:
- print('miss parameter:app path!!!')
- exit(1)
- appFile = sys.argv[1]
- print('appFile = ' + appFile)
-
- if not path.exists(appFile):
- print(appFile +' is not exist')
- exit()
- sha256_checknum(appFile)
- zip_file(appFile)
- print('build upgrade zip success!')
\ No newline at end of file