From f16c90909080a73be1b64c991d6c2eb85c6199b9 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 18 Jul 2017 15:53:29 +0200 Subject: [PATCH] [CUSTOM_APP] Correctly set the version_name. The version_name need to be set a compilation time. By default the version_name is taken from json info file. But a user may want to change it. --- build_custom_app.py | 14 +++++++++++--- dependencies.py | 2 ++ travis/make_release.sh | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build_custom_app.py b/build_custom_app.py index f6ce3e8..a0fdd0e 100755 --- a/build_custom_app.py +++ b/build_custom_app.py @@ -51,6 +51,8 @@ def parse_args(): advance = parser.add_argument_group('advance', "Some advanced options.") advance.add_argument('--extra-code', type=int, default=0) + advance.add_argument('--version-name', default=None, + help="The version of the application (seen by user). Get from json info file by default.") advance.add_argument('--check-certificate', default=True) advance.add_argument('--zim-url', default=None) advance.add_argument('--no-android-upload', action='store_false', dest='android_upload') @@ -58,7 +60,6 @@ def parse_args(): # Hidden options parser.add_argument('--step', default='launch', choices=['launch', 'publish'], help=argparse.SUPPRESS) parser.add_argument('--apks-dir', help=argparse.SUPPRESS) - parser.add_argument('--version', default="0", help=argparse.SUPPRESS) parser.add_argument('--zim-path', default=None, help=argparse.SUPPRESS) parser.add_argument('--content-version-code', type=int) parser.add_argument('--package-name', default=None, help=argparse.SUPPRESS) @@ -66,11 +67,15 @@ def parse_args(): options = parser.parse_args() - if not options.package_name or not (options.zim_url or options.zim_path): + if (not options.package_name + or not (options.zim_url or options.zim_path) + or not options.version_name): if not options.package_name: print("Try to get package name from info.json file") if not options.zim_url: print("Try to get zim url from info.json file") + if not options.version_name: + print("Try to get version_name form info.json file") request_url = ('https://raw.githubusercontent.com/kiwix/kiwix-android-custom/master/{}/info.json' .format(options.custom_app)) json_request = requests.get(request_url) @@ -85,6 +90,9 @@ def parse_args(): if not options.zim_url: print("Found zim_url '{}'".format(json_data['zim_url'])) options.zim_url = json_data['zim_url'] + if not options.version_name: + print("Found version_name '{}'".format(json_data['version_name'])) + options.version_name = json_data['version_name'] options.base_version = "{}{}".format( datetime.date.today().strftime('%y%j'), @@ -179,7 +187,7 @@ def travis_launch_build(organisation, repository, options, zim_size): { 'ZIM_URL': options.zim_url}, { 'EXTRA_CODE': options.extra_code}, { 'CONTENT_VERSION_CODE': gen_version_code(0, options.base_version)}, - { 'VERSION': options.version}, + { 'VERSION_NAME': options.version_name}, # google_key { 'secure': ('VAgKBMx0KEIyJlSnpM4YrHKLALIbaibkhlsgiv19ITa6dODoEIqeYHz' 'wFTiL3mRHU6HwtXtdNb/JeMle9NfHJVFSV56ZgFzX7ev9zr0YG0qZQv' diff --git a/dependencies.py b/dependencies.py index 3acd526..cd40569 100644 --- a/dependencies.py +++ b/dependencies.py @@ -413,11 +413,13 @@ class KiwixCustomApp(Dependency): template = ("-i -P customDir={customDir}" " -P zim_file_size={zim_size}" " -P version_code={version_code}" + " -P version_name={version_name}" " -P content_version_code={content_version_code}") return template.format( customDir=pj(self.build_path, 'custom'), zim_size=self._get_zim_size(), version_code=os.environ['VERSION_CODE'], + version_name=os.environ['VERSION_NAME'], content_version_code=os.environ['CONTENT_VERSION_CODE']) @property diff --git a/travis/make_release.sh b/travis/make_release.sh index a7524ee..4f2e034 100755 --- a/travis/make_release.sh +++ b/travis/make_release.sh @@ -22,7 +22,6 @@ ${TRAVIS_BUILD_DIR}/build_custom_app.py \ --custom-app ${CUSTOM_APP} \ --package-name ${PACKAGE_NAME} \ --google-api-key ${GOOGLE_API_KEY} \ - --version ${VERSION} \ --zim-url ${ZIM_URL} \ --apks-dir ${HOME}/APKS \ --content-version-code ${CONTENT_VERSION_CODE}