Simplify a bit usage of make_archive.

This commit is contained in:
Matthieu Gautier 2018-03-15 17:06:13 +01:00
parent 579109ab79
commit 87d80928ee
1 changed files with 21 additions and 13 deletions

View File

@ -29,6 +29,16 @@ VERSIONS = {
'zimwriterfs': '1.0' 'zimwriterfs': '1.0'
} }
# We have build everything. Now create archives for public deployement.
BINARIES = {
'kiwix-tools': ('kiwix-install', 'kiwix-manage', 'kiwix-read', 'kiwix-search', 'kiwix-serve'),
'zim-tools': ('zimbench', 'zimdump', 'zimsearch', 'zimdiff', 'zimpatch', 'zimsplit'),
'zimwriterfs': ('zimwriterfs',)
}
_date = date.today().isoformat()
def write_manifest(manifest_file, archive_name, target, platform): def write_manifest(manifest_file, archive_name, target, platform):
with manifest_file.open(mode='w') as f: with manifest_file.open(mode='w') as f:
@ -58,12 +68,17 @@ def run_kiwix_build(target, platform, build_deps_only=False, make_release=False,
subprocess.check_call(command, cwd=str(home())) subprocess.check_call(command, cwd=str(home()))
def make_archive(project, platform, post_fix, file_to_archives): def make_archive(project, platform):
archive_name = "{}_{}-{}".format(project, platform, post_fix) file_to_archives = BINARIES[project]
if platform == "win32":
file_to_archives = ['{}.exe'.format(f) for f in file_to_archives]
if make_release: if make_release:
postfix = VERSIONS[project]
archive_dir = RELEASE_ARCHIVES_DIR archive_dir = RELEASE_ARCHIVES_DIR
else: else:
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) archive = archive_dir/'{}.tar.gz'.format(archive_name)
base_bin_dir = BASE_DIR/'INSTALL'/'bin' base_bin_dir = BASE_DIR/'INSTALL'/'bin'
with tarfile.open(str(archive), 'w:gz') as arch: with tarfile.open(str(archive), 'w:gz') as arch:
@ -144,11 +159,6 @@ for target in TARGETS:
# We have build everything. Now create archives for public deployement. # We have build everything. Now create archives for public deployement.
kiwix_tools_bins = ('kiwix-install', 'kiwix-manage', 'kiwix-read', 'kiwix-search', 'kiwix-serve')
zim_tools_bins = ('zimbench', 'zimdump', 'zimsearch', 'zimdiff', 'zimpatch', 'zimsplit')
zimwriterfs_bins = ('zimwriterfs',)
_date = date.today().isoformat()
kiwix_tools_postfix = VERSIONS['kiwix-tools'] if make_release else _date kiwix_tools_postfix = VERSIONS['kiwix-tools'] if make_release else _date
zim_tools_postfix = VERSIONS['zim-tools'] if make_release else _date zim_tools_postfix = VERSIONS['zim-tools'] if make_release else _date
zimwriterfs_postfix = VERSIONS['zimwriterfs'] if make_release else _date zimwriterfs_postfix = VERSIONS['zimwriterfs'] if make_release else _date
@ -164,14 +174,12 @@ if make_release and PLATFORM == 'native_dyn':
shutil.copy(str(BASE_DIR/target/'meson-dist'/'{}-{}.tar.xz'.format(target, VERSIONS[target])), shutil.copy(str(BASE_DIR/target/'meson-dist'/'{}-{}.tar.xz'.format(target, VERSIONS[target])),
str(out_dir)) str(out_dir))
elif PLATFORM == 'native_static': elif PLATFORM == 'native_static':
make_archive('kiwix-tools', 'linux64', kiwix_tools_postfix, kiwix_tools_bins) for target in ('kiwix-tools', 'zim-tools', 'zimwriterfs'):
make_archive('zim-tools', 'linux64', zim_tools_postfix, zim_tools_bins) make_archive(target, 'linux64')
make_archive('zimwriterfs', 'linux64', zimwriterfs_postfix, zimwriterfs_bins)
elif PLATFORM == 'win32_static': elif PLATFORM == 'win32_static':
make_archive('kiwix-tools', 'win32', kiwix_tools_postfix, make_archive('kiwix-tools', 'win32')
('{}.exe'.format(b) for b in kiwix_tools_bins))
elif PLATFORM == 'armhf_static': elif PLATFORM == 'armhf_static':
make_archive('kiwix-tools', 'armhf', kiwix_tools_postfix, kiwix_tools_bins) make_archive('kiwix-tools', 'armhf')
elif PLATFORM.startswith('android_') and 'kiwix-android' in TARGETS: elif PLATFORM.startswith('android_') and 'kiwix-android' in TARGETS:
APK_NAME = "kiwix-{}".format(PLATFORM) APK_NAME = "kiwix-{}".format(PLATFORM)
source_debug_dir = BASE_DIR/'kiwix-android'/'app'/'build'/'outputs'/'apk'/'kiwix'/'debug' source_debug_dir = BASE_DIR/'kiwix-android'/'app'/'build'/'outputs'/'apk'/'kiwix'/'debug'