diff --git a/.travis.yml b/.travis.yml index 1ae26b336..028702272 100644 --- a/.travis.yml +++ b/.travis.yml @@ -103,16 +103,22 @@ matrix: cache: directories: - /opt/build-windows/x86_64 - - stage: "macOS and AppImage" + - stage: "macOS, AppImage and Flatpak" os: osx osx_image: xcode7.3 env: JOB=build-osx - - stage: "macOS and AppImage" + - stage: "macOS, AppImage and Flatpak" os: linux env: JOB=APPIMAGE script: ./appimage/build-appimage.sh services: - docker + - stage: "macOS, AppImage and Flatpak" + os: linux + env: JOB=FLATPAK + script: ./flatpak/build-flatpak.sh + services: + - docker script: "./.travis/$JOB.sh" diff --git a/flatpak/build-flatpak.sh b/flatpak/build-flatpak.sh new file mode 100755 index 000000000..94697bff8 --- /dev/null +++ b/flatpak/build-flatpak.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: GPL-3.0+ +# +# Copyright © 2018 by The qTox Project Contributors +# +# This script should be run from the root of the repository + +if [ ! -f ./flatpak/build-flatpak.sh ]; then + echo "" + echo "You are attempting to run the build-flatpak.sh from a wrong directory." + echo "If you wish to run this script, you'll have to have" + echo "the repository root directory as the working directory." + echo "" + exit 1 +fi + +mkdir -p ./output + +docker run --rm --privileged \ + -v $PWD:/qtox \ + -v $PWD/output:/output \ + debian:stretch-slim \ + /bin/bash -c "/qtox/flatpak/build.sh" diff --git a/flatpak/build.sh b/flatpak/build.sh new file mode 100755 index 000000000..f5ad21199 --- /dev/null +++ b/flatpak/build.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: GPL-3.0+ +# +# Copyright © 2018 by The qTox Project Contributors + +# Fail out on error +set -exuo pipefail + +# directory paths +readonly QTOX_SRC_DIR="/qtox" +readonly OUTPUT_DIR="/output" +readonly BUILD_DIR="/build" +readonly QTOX_BUILD_DIR="$BUILD_DIR"/qtox +readonly FP_BUILD_DIR="$BUILD_DIR"/flatpak +readonly APT_FLAGS="-y --no-install-recommends" +# flatpak manifest file +readonly QTOX_MANIFEST="https://raw.githubusercontent.com/flathub/io.github.qtox.qTox/master/io.github.qtox.qTox.json" +# flatpak manifest download location +readonly MANIFEST_FILE="flatpak/io.github.qtox.qTox.json" +# directory containing necessary patches +readonly PATCH_DIR="flatpak/patches" +# use multiple cores when building +export MAKEFLAGS="-j$(nproc)" + +# add backports repo, needed for a recent enough flatpak +echo "deb http://ftp.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/stretch-backports.list + +# Get packages +apt-get update +apt-get install $APT_FLAGS ca-certificates git elfutils wget xz-utils patch + +# install recent flatpak packages +apt-get install $APT_FLAGS -t stretch-backports flatpak flatpak-builder + +# create build directory +mkdir -p "$BUILD_DIR" +cd "$BUILD_DIR" + +# copy qtox source +cp -r "$QTOX_SRC_DIR" "$QTOX_BUILD_DIR" +cd "$QTOX_BUILD_DIR" + +# download manifest file if not in repo, this allows an easy local override +if [ ! -f "$MANIFEST_FILE" ]; +then + wget -O "$MANIFEST_FILE" "$QTOX_MANIFEST" +fi + +# build from the local build directory instead of the git repo +patch "$MANIFEST_FILE" < "$PATCH_DIR"/build_directory.patch + +# this patch should contain all other patches needed +patch "$MANIFEST_FILE" < "$PATCH_DIR"/ci_fixes.patch + +# create flatpak build directory +mkdir -p "$FP_BUILD_DIR" +cd "$FP_BUILD_DIR" + +# Add 'https://flathub.org' remote: +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + +# Build the qTox flatpak +flatpak-builder --disable-rofiles-fuse --install-deps-from=flathub --force-clean --repo=tox-repo qTox-flatpak "$QTOX_BUILD_DIR"/flatpak/io.github.qtox.qTox.json + +# Create a bundle for distribution +flatpak build-bundle tox-repo "$OUTPUT_DIR"/qtox.flatpak io.github.qtox.qTox + +# Chmod since everything is root:root +chmod 755 -R "$OUTPUT_DIR" diff --git a/flatpak/patches/build_directory.patch b/flatpak/patches/build_directory.patch new file mode 100644 index 000000000..a921e8791 --- /dev/null +++ b/flatpak/patches/build_directory.patch @@ -0,0 +1,14 @@ +97,103c97,101 +< { +< "type": "git", +< "url": "https://github.com/qTox/qTox", +< "tag": "v1.15.0", +< "commit": "02d6c63acaac0ae95fa8be3a1b9301657e6a4a94" +< } +< ] +--- +> { +> "type": "dir", +> "path": "/build/qtox/" +> } +> ] diff --git a/flatpak/patches/ci_fixes.patch b/flatpak/patches/ci_fixes.patch new file mode 100644 index 000000000..0e2639028 --- /dev/null +++ b/flatpak/patches/ci_fixes.patch @@ -0,0 +1,3 @@ +8,9d7 +< "rename-desktop-file": "qtox.desktop", +< "rename-appdata-file": "qTox.appdata.xml",