From 086361b4327eca97b64060a8a4da9c1fa33ddfc3 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 27 Nov 2018 10:04:36 +0100 Subject: [PATCH] Build the flatpak in travis. Use docker to have the last version of ubuntu (and flatpak) --- .travis.yml | 13 ++++++-- travis/Dockerfile_flatpak | 63 +++++++++++++++++++++++++++++++++++++++ travis/compile_all.py | 27 +++++++++++------ 3 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 travis/Dockerfile_flatpak diff --git a/.travis.yml b/.travis.yml index 9938aec..39a5ffe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,8 +32,13 @@ script: - | if [[ $TRAVIS_OS_NAME = "linux" && $DESKTOP_ONLY == 1 ]] then - docker build -t kiwix/build -f travis/Dockerfile . - docker run -e PLATFORM -e NIGHTLY_DATE -e TRAVIS_EVENT_TYPE -e TRAVIS_BUILD_DIR -e DESKTOP_ONLY -e TRAVIS_TAG --device /dev/fuse --cap-add SYS_ADMIN kiwix/build + if [[ $PLATFORM = "flatpak" ]] + then + docker build -t kiwix/build -f travis/Dockerfile_flatpak . + else + docker build -t kiwix/build -f travis/Dockerfile . + fi + docker run -e PLATFORM -e NIGHTLY_DATE -e TRAVIS_EVENT_TYPE -e TRAVIS_BUILD_DIR -e DESKTOP_ONLY -e TRAVIS_TAG --device /dev/fuse --cap-add ALL kiwix/build else travis/compile_all.py fi @@ -83,6 +88,10 @@ matrix: addons: apt: packages: [] + - env: PLATFORM="flatpak" DESKTOP_ONLY=1 + addons: + apt: + packages: [] - env: PLATFORM="native_static" addons: apt: diff --git a/travis/Dockerfile_flatpak b/travis/Dockerfile_flatpak new file mode 100644 index 0000000..8518e8c --- /dev/null +++ b/travis/Dockerfile_flatpak @@ -0,0 +1,63 @@ +FROM ubuntu:bionic + +ENV LANG C.UTF-8 + +RUN \ + apt update -q; \ + apt full-upgrade --purge -q -y; \ + apt install -q -y --no-install-recommends \ +# Base build tools + build-essential \ + automake \ + libtool \ + cmake \ + ccache \ + pkg-config \ + autopoint \ + patch \ + python \ + python3 \ + python3-pip \ + python3-setuptools \ + git \ + subversion \ + wget \ + unzip \ + sudo \ +# Flatpak tools + elfutils \ + flatpak \ + flatpak-builder \ +# Some helper tools + vim \ + less \ + grep \ + openssh-client \ + ; \ + apt-get clean -y; \ + rm -rf \ + /usr/share/doc/* \ + /var/cache/debconf/* + +RUN useradd --create-home travis -G sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +USER travis + +WORKDIR /home/travis + +RUN \ + mkdir -p /home/travis/.local/bin ;\ + wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip ;\ + unzip ninja-linux.zip ninja ;\ + mv ninja /home/travis/.local/bin ;\ + rm ninja-linux.zip +ENV PATH="/home/travis/.local/bin:${PATH}" + +COPY . kiwix-build/ +RUN sudo chown -R travis:travis /home/travis/kiwix-build +RUN pip3 install --user -e kiwix-build + +ENV TRAVISCI_SSH_KEY /home/travis/kiwix-build/travis/travisci_builder_id_key +ENV TRAVIS_OS_NAME linux_artful + +CMD kiwix-build/travis/compile_all.py && kiwix-build/travis/deploy.sh diff --git a/travis/compile_all.py b/travis/compile_all.py index 6606edb..1301ead 100755 --- a/travis/compile_all.py +++ b/travis/compile_all.py @@ -96,7 +96,7 @@ def run_kiwix_build(target, platform, subprocess.check_call(command, cwd=str(HOME)) -def create_app_image(): +def create_desktop_image(): if make_release: postfix = main_project_versions['kiwix-desktop'] extra_postfix = release_versions.get('kiwix-desktop') @@ -112,19 +112,24 @@ def create_app_image(): 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)) + if PLATFORM == 'flatpak': + build_path = BASE_DIR/'BUILD_flatpak'/'org.kiwix.Client.flatpak' + app_name = 'org.kiwix.Client.{}.flatpak'.format(postfix) + else: + build_path = HOME/'Kiwix-x86_64.AppImage' + app_name = "kiwix-desktop_x86_64_{}.appimage".format(postfix) + 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)) + print_message("Copy Build to {}".format(archive_dir/app_name)) + shutil.copy(str(build_path), str(archive_dir/app_name)) def make_archive(project, platform): @@ -291,6 +296,8 @@ if environ['TRAVIS_EVENT_TYPE'] != 'cron' and not make_release: TARGETS = ('kiwix-desktop', ) else: TARGETS = ('kiwix-tools', 'zim-tools', 'zimwriterfs') + elif PLATFORM == 'flatpak': + TARGETS = ('kiwix-desktop', ) else: TARGETS = ('kiwix-tools', ) @@ -319,6 +326,8 @@ elif PLATFORM.startswith('native_'): TARGETS = ('kiwix-desktop', ) else: TARGETS = ('libzim', 'zimwriterfs', 'zim-tools', 'kiwix-lib', 'kiwix-tools') +elif PLATFORM == 'flatpak': + TARGETS = ('kiwix-desktop', ) else: TARGETS = ('libzim', 'zim-tools', 'kiwix-lib', 'kiwix-tools') @@ -334,7 +343,7 @@ for target in TARGETS: platform=PLATFORM, make_release=make_release) if target == 'kiwix-desktop': - create_app_image() + create_desktop_image() if make_release and PLATFORM == 'native_dyn' and release_versions.get(target) == 0: run_kiwix_build(target, platform=PLATFORM,