From 2e204a0abe2a327f20cdedd1807a2d1cee4d807a Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 14 Jun 2019 16:36:56 +0200 Subject: [PATCH] Cache the flapak state dir to speed the build. --- travis/compile_all.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/travis/compile_all.py b/travis/compile_all.py index 64e2b5e..02821a8 100755 --- a/travis/compile_all.py +++ b/travis/compile_all.py @@ -246,6 +246,14 @@ def make_deps_archive(target=None, name=None, full=False): print('.{}'.format(name), flush=True) tar.add(str(name), arcname=str(name.relative_to(relative_path))) +def make_flatpak_cache_archive(): + archive_name = "base_deps_{os}_{platform}.tar.xz".format( + os=TRAVIS_OS_NAME, + platform=PLATFORM) + cache = BASE_DIR/'.flatpak-builder' + with tarfile.open(str(BASE_EXPORT_DIR/archive_name), 'w:xz') as tar: + tar.add(str(cache), arcname=str(cache.relative_to(BASE_DIR))) + def update_flathub_git(): GIT_REPO_DIR = GIT_EXPORT_DIR/"org.kiwix.desktop" @@ -332,6 +340,19 @@ if PLATFORM != 'flatpak': else: run_kiwix_build('alldependencies', platform=PLATFORM) make_deps_archive(name=base_dep_archive_name, full=True) +else: + base_dep_archive_name = "base_deps_{os}_{platform}.tar.xz".format( + os=TRAVIS_OS_NAME, + platform=PLATFORM) + + print_message("Getting archive {}", base_dep_archive_name) + try: + local_filename = download_base_archive(base_dep_archive_name) + BASE_DIR.mkdir(parents=True) + with tarfile.open(local_filename) as f: + f.extractall(str(BASE_DIR)) + except URLError: + print_message("Cannot get archive. Move on") # A basic compilation to be sure everything is working (for a PR) @@ -369,6 +390,8 @@ if environ['TRAVIS_EVENT_TYPE'] != 'cron' and not make_release: make_archive('kiwix-tools', 'linux-armhf') elif PLATFORM == 'i586_static': make_archive('kiwix-tools', 'linux-i586') + elif PLATFORM == 'flatpak': + make_flatpak_cache_archive() sys.exit(0)