Merge pull request #137 from kiwix/zip_extension

[TRAVIS] Zip archive must have ".zip" extension.
This commit is contained in:
Matthieu Gautier 2018-03-21 19:44:49 +01:00 committed by GitHub
commit 56e3bfe442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 5 deletions

View File

@ -73,8 +73,8 @@ def run_kiwix_build(target, platform, build_deps_only=False, make_release=False,
def make_archive(project, platform): def make_archive(project, platform):
file_to_archives = BINARIES[project] file_to_archives = BINARIES[project]
if platform == "win32": base_bin_dir = BASE_DIR/'INSTALL'/'bin'
file_to_archives = ['{}.exe'.format(f) for f in file_to_archives]
if make_release: if make_release:
postfix = dependency_versions.main_project_versions[project] postfix = dependency_versions.main_project_versions[project]
if project in ('kiwix-lib', 'kiwix-tools'): if project in ('kiwix-lib', 'kiwix-tools'):
@ -84,19 +84,26 @@ def make_archive(project, platform):
else: else:
postfix = _date postfix = _date
archive_dir = NIGHTLY_ARCHIVES_DIR archive_dir = NIGHTLY_ARCHIVES_DIR
archive_name = "{}_{}-{}".format(project, platform, postfix)
archive = archive_dir/'{}.tar.gz'.format(archive_name)
try: try:
archive_dir.mkdir(parents=True) archive_dir.mkdir(parents=True)
except FileExistsError: except FileExistsError:
pass pass
base_bin_dir = BASE_DIR/'INSTALL'/'bin'
archive_name = "{}_{}-{}".format(project, platform, postfix)
if platform == "win32": if platform == "win32":
file_to_archives = ['{}.exe'.format(f) for f in file_to_archives]
open_archive = lambda a : zipfile.ZipFile(str(a), 'w', compression=zipfile.ZIP_LZMA) open_archive = lambda a : zipfile.ZipFile(str(a), 'w', compression=zipfile.ZIP_LZMA)
archive_add = lambda a, f : a.write(str(base_bin_dir/f), arcname=str(f)) archive_add = lambda a, f : a.write(str(base_bin_dir/f), arcname=str(f))
archive_ext = ".zip"
else: else:
open_archive = lambda a : tarfile.open(str(a), 'w:gz') open_archive = lambda a : tarfile.open(str(a), 'w:gz')
archive_add = lambda a, f : a.add(str(base_bin_dir/f), arcname="{}/{}".format(archive_name, str(f))) archive_add = lambda a, f : a.add(str(base_bin_dir/f), arcname="{}/{}".format(archive_name, str(f)))
archive_ext = ".tar.gz"
archive = archive_dir/'{}{}'.format(archive_name, archive_ext)
with open_archive(archive) as arch: with open_archive(archive) as arch:
for f in file_to_archives: for f in file_to_archives:
archive_add(arch, f) archive_add(arch, f)