diff --git a/.gitignore b/.gitignore index 9e11b5d754..37591363a2 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,7 @@ Thumbs.db # Python files *.pyc + +# Flatpak generated files +.flatpak-builder/ +repo/ diff --git a/.travis.yml b/.travis.yml index 54b7a90919..402c9538eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,6 +61,18 @@ matrix: script: "./.travis/linux-mingw/build.sh" after_success: "./.travis/linux-mingw/upload.sh" cache: ccache + - if: repo =~ ^.*\/(citra-canary|citra-nightly)$ AND tag IS present + git: + depth: false + os: linux + env: NAME="flatpak build" + sudo: required + dist: trusty + services: docker + cache: ccache + install: "./.travis/linux-flatpak/deps.sh" + script: "./.travis/linux-flatpak/build.sh" + after_script: "./.travis/linux-flatpak/finish.sh" deploy: provider: releases diff --git a/.travis/linux-flatpak/build.sh b/.travis/linux-flatpak/build.sh new file mode 100755 index 0000000000..91fba01aac --- /dev/null +++ b/.travis/linux-flatpak/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash -ex +mkdir -p "$HOME/.ccache" +# Configure docker and call the script that generates application data and build scripts +docker run --env-file .travis/common/travis-ci.env --env-file .travis/linux-flatpak/travis-ci-flatpak.env -v $(pwd):/citra -v "$HOME/.ccache":/root/.ccache -v "$HOME/.ssh":/root/.ssh --privileged citraemu/build-environments:linux-flatpak /bin/bash -ex /citra/.travis/linux-flatpak/generate-data.sh diff --git a/.travis/linux-flatpak/deps.sh b/.travis/linux-flatpak/deps.sh new file mode 100755 index 0000000000..b8fd4974cf --- /dev/null +++ b/.travis/linux-flatpak/deps.sh @@ -0,0 +1,4 @@ +#!/bin/sh -ex + +# Download the docker image that contains flatpak build dependencies +docker pull citraemu/build-environments:linux-flatpak diff --git a/.travis/linux-flatpak/docker.sh b/.travis/linux-flatpak/docker.sh new file mode 100755 index 0000000000..31e2bb777a --- /dev/null +++ b/.travis/linux-flatpak/docker.sh @@ -0,0 +1,35 @@ +#!/bin/bash -ex + +# Converts "citra-emu/citra-nightly" to "citra-nightly" +REPO_NAME=$(echo $TRAVIS_REPO_SLUG | cut -d'/' -f 2) +CITRA_SRC_DIR="/citra" +BUILD_DIR="$CITRA_SRC_DIR/build" +REPO_DIR="$CITRA_SRC_DIR/repo" +STATE_DIR="$CITRA_SRC_DIR/.flatpak-builder" +KEYS_ARCHIVE="/tmp/keys.tar" +SSH_DIR="/upload" +SSH_KEY="/tmp/ssh.key" +GPG_KEY="/tmp/gpg.key" + +# Extract keys +openssl aes-256-cbc -K $FLATPAK_ENC_K -iv $FLATPAK_ENC_IV -in "$CITRA_SRC_DIR/keys.tar.enc" -out "$KEYS_ARCHIVE" -d +tar -C /tmp -xvf $KEYS_ARCHIVE + +# Configure SSH keys +eval "$(ssh-agent -s)" +chmod -R 600 "$HOME/.ssh" +chown -R root "$HOME/.ssh" +chmod 600 "$SSH_KEY" +ssh-add "$SSH_KEY" +echo "[$FLATPAK_SSH_HOSTNAME]:$FLATPAK_SSH_PORT,[$(dig +short $FLATPAK_SSH_HOSTNAME)]:$FLATPAK_SSH_PORT $FLATPAK_SSH_PUBLIC_KEY" > ~/.ssh/known_hosts + +# Configure GPG keys +gpg2 --import "$GPG_KEY" + +# Mount our flatpak repository +mkdir -p "$REPO_DIR" +sshfs "$FLATPAK_SSH_USER@$FLATPAK_SSH_HOSTNAME:$SSH_DIR" "$REPO_DIR" -C -p "$FLATPAK_SSH_PORT" -o IdentityFile="$SSH_KEY" + +# Build the citra flatpak +flatpak-builder -v --jobs=4 --ccache --force-clean --state-dir="$STATE_DIR" --gpg-sign="$FLATPAK_GPG_PUBLIC_KEY" --repo="$REPO_DIR" "$BUILD_DIR" "/tmp/org.citra.$REPO_NAME.json" +flatpak build-update-repo "$REPO_DIR" -v --generate-static-deltas --gpg-sign="$FLATPAK_GPG_PUBLIC_KEY" diff --git a/.travis/linux-flatpak/finish.sh b/.travis/linux-flatpak/finish.sh new file mode 100755 index 0000000000..c9f0c07311 --- /dev/null +++ b/.travis/linux-flatpak/finish.sh @@ -0,0 +1,9 @@ +#!/bin/bash -ex + +CITRA_SRC_DIR="/citra" +REPO_DIR="$CITRA_SRC_DIR/repo" + +# When the script finishes, unmount the repository and delete sensitive files, +# regardless of whether the build passes or fails +umount "$REPO_DIR" +rm -rf "$REPO_DIR" "/tmp/*" diff --git a/.travis/linux-flatpak/generate-data.sh b/.travis/linux-flatpak/generate-data.sh new file mode 100644 index 0000000000..d8ca90aab5 --- /dev/null +++ b/.travis/linux-flatpak/generate-data.sh @@ -0,0 +1,142 @@ +#!/bin/bash -ex +# This script generates the appdata.xml and org.citra.$REPO_NAME.json files +# needed to define application metadata and build citra depending on what version +# of citra we're building (nightly or canary) + +# Converts "citra-emu/citra-nightly" to "citra-nightly" +REPO_NAME=$(echo $TRAVIS_REPO_SLUG | cut -d'/' -f 2) +# Converts "citra-nightly" to "Citra Nightly" +REPO_NAME_FRIENDLY=$(echo $REPO_NAME | sed -e 's/-/ /g' -e 's/\b\(.\)/\u\1/g') + +# Generate the correct appdata.xml for the version of Citra we're building +cat > /tmp/appdata.xml < + + org.citra.$REPO_NAME.desktop + $REPO_NAME_FRIENDLY + Nintendo 3DS emulator + CC0-1.0 + GPL-2.0 + +

Citra is an experimental open-source Nintendo 3DS emulator/debugger written in C++. It is written with portability in mind, with builds actively maintained for Windows, Linux and macOS.

+

Citra emulates a subset of 3DS hardware and therefore is useful for running/debugging homebrew applications, and it is also able to run many commercial games! Some of these do not run at a playable state, but we are working every day to advance the project forward. (Playable here means compatibility of at least "Okay" on our game compatibility list.)

+
+ https://citra-emu.org/ + https://citra-emu.org/donate/ + https://github.com/citra-emu/citra/issues + https://citra-emu.org/wiki/faq/ + https://citra-emu.org/wiki/home/ + https://raw.githubusercontent.com/citra-emu/citra-web/master/site/static/images/screenshots/01-Super%20Mario%203D%20Land.jpg + https://raw.githubusercontent.com/citra-emu/citra-web/master/site/static/images/screenshots/02-Mario%20Kart%207.jpg + https://raw.githubusercontent.com/citra-emu/citra-web/master/site/static/images/screenshots/28-The%20Legend%20of%20Zelda%20Ocarina%20of%20Time%203D.jpg + https://raw.githubusercontent.com/citra-emu/citra-web/master/site/static/images/screenshots/35-Pok%C3%A9mon%20ORAS.png + + Games + Emulator + +
+EOF + +# Generate the citra flatpak manifest, appending certain variables depending on +# whether we're building nightly or canary. +cat > /tmp/org.citra.$REPO_NAME.json <> /app/share/applications/citra.desktop", + "install -Dm644 ../dist/citra.svg /app/share/icons/hicolor/scalable/apps/citra.svg", + "install -Dm644 ../dist/icon.png /app/share/icons/hicolor/512x512/apps/citra.png", + "mv /app/share/mime/packages/citra.xml /app/share/mime/packages/org.citra.$REPO_NAME.xml", + "sed 's/citra/org.citra.citra-nightly/g' -i /app/share/mime/packages/org.citra.$REPO_NAME.xml", + "install -m644 --target-directory=/app/lib /usr/lib/sdk/gcc7/lib/libstdc++.so*" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/citra-emu/$REPO_NAME.git", + "branch": "$TRAVIS_BRANCH", + "disable-shallow-clone": true + }, + { + "type": "file", + "path": "/tmp/appdata.xml" + } + ] + } + ] +} +EOF + +# Call the script to build citra +/bin/bash -ex /citra/.travis/linux-flatpak/docker.sh diff --git a/.travis/linux-flatpak/travis-ci-flatpak.env b/.travis/linux-flatpak/travis-ci-flatpak.env new file mode 100644 index 0000000000..0823d91c83 --- /dev/null +++ b/.travis/linux-flatpak/travis-ci-flatpak.env @@ -0,0 +1,9 @@ +# Flatpak specific environment variables +FLATPAK_ENC_IV +FLATPAK_ENC_K +FLATPAK_GPG_PUBLIC_KEY +FLATPAK_SSH_HOSTNAME +FLATPAK_SSH_LOCATION +FLATPAK_SSH_PORT +FLATPAK_SSH_PUBLIC_KEY +FLATPAK_SSH_USER diff --git a/keys.tar.enc b/keys.tar.enc new file mode 100644 index 0000000000..6a8c1484e5 Binary files /dev/null and b/keys.tar.enc differ