def create_app_image(): if make_release: postfix = main_project_versions['kiwix-desktop'] extra_postfix = release_versions.get('kiwix-desktop') if extra_postfix is None: # We should not make archives for release not wanted return if extra_postfix: postfix = "{}-{}".format(postfix, extra_postfix) archive_dir = RELEASE_KIWIX_ARCHIVES_DIR / 'kiwix-desktop' src_dir = SOURCE_DIR / 'kiwix-desktop_release' else: postfix = _date archive_dir = NIGHTLY_KIWIX_ARCHIVES_DIR src_dir = SOURCE_DIR / 'kiwix-desktop' command = [ 'kiwix-build/scripts/create_kiwix-desktop_appImage.sh', str(BASE_DIR / 'INSTALL'), str(src_dir), str(HOME / 'AppDir') ] print_message("Build AppImage of kiwix-desktop") subprocess.check_call(command, cwd=str(HOME)) try: archive_dir.mkdir(parents=True) except FileExistsError: pass app_name = "kiwix-desktop_x86_64_{}.appimage".format(postfix) print_message("Copy AppImage to {}".format(archive_dir / app_name)) shutil.copy(str(HOME / 'Kiwix-x86_64.AppImage'), str(archive_dir / app_name))
def make_archive(project, platform): base_dir, export_files = EXPORT_FILES[project] if make_release: postfix = main_project_versions[project] extra_postfix = release_versions.get(project) if extra_postfix is None: # We should not make archives for release not wanted return if extra_postfix: postfix = "{}-{}".format(postfix, extra_postfix) if project in ('kiwix-lib', 'kiwix-tools'): archive_dir = RELEASE_KIWIX_ARCHIVES_DIR / project else: archive_dir = RELEASE_ZIM_ARCHIVES_DIR / project else: postfix = _date if project in ('kiwix-lib', 'kiwix-tools'): archive_dir = NIGHTLY_KIWIX_ARCHIVES_DIR else: archive_dir = NIGHTLY_ZIM_ARCHIVES_DIR try: archive_dir.mkdir(parents=True) except FileExistsError: pass archive_name = "{}_{}-{}".format(project, platform, postfix) files_to_archive = [] for export_file in export_files: files_to_archive.extend(base_dir.glob(export_file)) if platform == "win-i686": open_archive = lambda a: zipfile.ZipFile( str(a), 'w', compression=zipfile.ZIP_DEFLATED) archive_add = lambda a, f: a.write( str(f), arcname=str(f.relative_to(base_dir))) archive_ext = ".zip" else: open_archive = lambda a: tarfile.open(str(a), 'w:gz') archive_add = lambda a, f: a.add( str(f), arcname="{}/{}".format(archive_name, str(f.relative_to(base_dir)))) archive_ext = ".tar.gz" archive = archive_dir / '{}{}'.format(archive_name, archive_ext) print_message("create archive {} with {}", archive, files_to_archive) with open_archive(archive) as arch: for f in files_to_archive: archive_add(arch, f)
def make_archive(project, platform): file_to_archives = BINARIES[project] base_bin_dir = BASE_DIR / 'INSTALL' / 'bin' if make_release: postfix = main_project_versions[project] extra_postfix = release_versions.get(project) if extra_postfix is None: # We should not make archives for release not wanted return if extra_postfix: postfix = "{}-{}".format(postfix, extra_postfix) if project in ('kiwix-lib', 'kiwix-tools'): archive_dir = RELEASE_KIWIX_ARCHIVES_DIR / project else: archive_dir = RELEASE_ZIM_ARCHIVES_DIR / project else: postfix = _date if project in ('kiwix-lib', 'kiwix-tools'): archive_dir = NIGHTLY_KIWIX_ARCHIVES_DIR else: archive_dir = NIGHTLY_ZIM_ARCHIVES_DIR try: archive_dir.mkdir(parents=True) except FileExistsError: pass archive_name = "{}_{}-{}".format(project, platform, postfix) if platform == "win-i686": file_to_archives = ['{}.exe'.format(f) for f in file_to_archives] open_archive = lambda a: zipfile.ZipFile( str(a), 'w', compression=zipfile.ZIP_DEFLATED) archive_add = lambda a, f: a.write(str(base_bin_dir / f), arcname=str(f)) archive_ext = ".zip" else: 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_ext = ".tar.gz" archive = archive_dir / '{}{}'.format(archive_name, archive_ext) with open_archive(archive) as arch: for f in file_to_archives: archive_add(arch, f)
def create_desktop_image(): print_message("creating desktop image") if make_release: postfix = main_project_versions['kiwix-desktop'] extra_postfix = release_versions.get('kiwix-desktop') if extra_postfix is None: # We should not make archives for release not wanted return if extra_postfix: postfix = "{}-{}".format(postfix, extra_postfix) archive_dir = RELEASE_KIWIX_ARCHIVES_DIR / 'kiwix-desktop' src_dir = SOURCE_DIR / 'kiwix-desktop_release' else: postfix = _date archive_dir = NIGHTLY_KIWIX_ARCHIVES_DIR src_dir = SOURCE_DIR / 'kiwix-desktop' if PLATFORM == 'flatpak': build_path = BASE_DIR / 'org.kiwix.desktop.flatpak' app_name = 'org.kiwix.desktop.{}.flatpak'.format(postfix) print_message("archive is ", build_path) else: build_path = HOME / 'Kiwix-{}-x86_64.AppImage'.format(postfix) app_name = "kiwix-desktop_x86_64_{}.appimage".format(postfix) command = [ 'kiwix-build/scripts/create_kiwix-desktop_appImage.sh', str(INSTALL_DIR), str(src_dir), str(HOME / 'AppDir') ] env = dict(os.environ) env['VERSION'] = postfix print_message("Build AppImage of kiwix-desktop") subprocess.check_call(command, cwd=str(HOME), env=env) try: archive_dir.mkdir(parents=True) except FileExistsError: pass print_message("Copy Build to {}".format(archive_dir / app_name)) shutil.copy(str(build_path), str(archive_dir / app_name))
elif PLATFORM == 'flatpak': TARGETS = ('kiwix-desktop', ) else: TARGETS = ('libzim', 'zim-tools', 'kiwix-lib', 'kiwix-tools') for target in TARGETS: if environ['TRAVIS_EVENT_TYPE'] == 'cron' and PLATFORM not in ('android', 'flatpak'): run_kiwix_build(target, platform=PLATFORM, build_deps_only=True) archive = make_deps_archive(target) scp(archive, '[email protected]:/data/tmp/ci/') run_kiwix_build(target, platform=PLATFORM, make_release=make_release) if target == 'kiwix-desktop': create_desktop_image() if make_release and PLATFORM == 'native_dyn' and release_versions.get( target) == 0: run_kiwix_build(target, platform=PLATFORM, make_release=True, make_dist=True) # We have build everything. Now create archives for public deployement. if make_release and PLATFORM == 'native_dyn': for target in TARGETS: if release_versions.get(target) != 0: # Do not release project not in release_versions continue if target in ('kiwix-lib', 'kiwix-tools', 'kiwix-desktop'): out_dir = DIST_KIWIX_ARCHIVES_DIR else: out_dir = DIST_ZIM_ARCHIVES_DIR
'kiwix-tools') elif PLATFORM == 'flatpak': TARGETS = ('kiwix-desktop', ) else: TARGETS = ('libzim', 'zim-tools', 'kiwix-lib', 'kiwix-tools') for target in TARGETS: if environ['TRAVIS_EVENT_TYPE'] == 'cron' and PLATFORM not in ('android', 'flatpak'): run_kiwix_build(target, platform=PLATFORM, build_deps_only=True) make_deps_archive(target=target) run_kiwix_build(target, platform=PLATFORM, make_release=make_release) if target == 'kiwix-desktop': create_desktop_image() if make_release and PLATFORM == 'native_dyn' and release_versions.get( target) == 0: run_kiwix_build(target, platform=PLATFORM, make_release=True, make_dist=True) # We have build everything. Now create archives for public deployement. if make_release and PLATFORM == 'native_dyn': for target in TARGETS: if release_versions.get(target) != 0: # Do not release project not in release_versions continue if target in ('kiwix-lib', 'kiwix-tools', 'kiwix-desktop'): out_dir = DIST_KIWIX_ARCHIVES_DIR else: out_dir = DIST_ZIM_ARCHIVES_DIR
def get_postfix(project): postfix = main_project_versions[project] extra = release_versions.get(project) if extra: postfix = "{}-{}".format(postfix, extra) return postfix