mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 15:11:05 +00:00
Flatpak support (#4383)
* Initial flatpak support * Fix compatibility list directory * Hard-code SSH mount location * Add workaround documentation * Change SSH repo directory * Change SSH repo directory (again) * Fix variable name * Remove temporary testing branch placeholder * Use a flatpak-specific docker image * Enable network access during the flatpak build so we can download compatibility list the right way * Fix flatpak tag support * Fix typo * Use cloned git for the build * Change SSH repo location * Disable shallow git cloning, needed for tagged building
This commit is contained in:
parent
1444d60109
commit
81cbc3fa15
4
.gitignore
vendored
4
.gitignore
vendored
@ -33,3 +33,7 @@ Thumbs.db
|
||||
|
||||
# Python files
|
||||
*.pyc
|
||||
|
||||
# Flatpak generated files
|
||||
.flatpak-builder/
|
||||
repo/
|
||||
|
12
.travis.yml
12
.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
|
||||
|
4
.travis/linux-flatpak/build.sh
Executable file
4
.travis/linux-flatpak/build.sh
Executable file
@ -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
|
4
.travis/linux-flatpak/deps.sh
Executable file
4
.travis/linux-flatpak/deps.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh -ex
|
||||
|
||||
# Download the docker image that contains flatpak build dependencies
|
||||
docker pull citraemu/build-environments:linux-flatpak
|
35
.travis/linux-flatpak/docker.sh
Executable file
35
.travis/linux-flatpak/docker.sh
Executable file
@ -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"
|
9
.travis/linux-flatpak/finish.sh
Executable file
9
.travis/linux-flatpak/finish.sh
Executable file
@ -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/*"
|
142
.travis/linux-flatpak/generate-data.sh
Normal file
142
.travis/linux-flatpak/generate-data.sh
Normal file
@ -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 <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<application>
|
||||
<id type="desktop">org.citra.$REPO_NAME.desktop</id>
|
||||
<name>$REPO_NAME_FRIENDLY</name>
|
||||
<summary>Nintendo 3DS emulator</summary>
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>GPL-2.0</project_license>
|
||||
<description>
|
||||
<p>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.</p>
|
||||
<p>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.)</p>
|
||||
</description>
|
||||
<url type="homepage">https://citra-emu.org/</url>
|
||||
<url type="donation">https://citra-emu.org/donate/</url>
|
||||
<url type="bugtracker">https://github.com/citra-emu/citra/issues</url>
|
||||
<url type="faq">https://citra-emu.org/wiki/faq/</url>
|
||||
<url type="help">https://citra-emu.org/wiki/home/</url>
|
||||
<screenshot>https://raw.githubusercontent.com/citra-emu/citra-web/master/site/static/images/screenshots/01-Super%20Mario%203D%20Land.jpg</screenshot>
|
||||
<screenshot>https://raw.githubusercontent.com/citra-emu/citra-web/master/site/static/images/screenshots/02-Mario%20Kart%207.jpg</screenshot>
|
||||
<screenshot>https://raw.githubusercontent.com/citra-emu/citra-web/master/site/static/images/screenshots/28-The%20Legend%20of%20Zelda%20Ocarina%20of%20Time%203D.jpg</screenshot>
|
||||
<screenshot>https://raw.githubusercontent.com/citra-emu/citra-web/master/site/static/images/screenshots/35-Pok%C3%A9mon%20ORAS.png</screenshot>
|
||||
<categories>
|
||||
<category>Games</category>
|
||||
<category>Emulator</category>
|
||||
</categories>
|
||||
</application>
|
||||
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 <<EOF
|
||||
{
|
||||
"app-id": "org.citra.$REPO_NAME",
|
||||
"runtime": "org.kde.Platform",
|
||||
"runtime-version": "5.11",
|
||||
"sdk": "org.kde.Sdk",
|
||||
"command": "citra-qt",
|
||||
"rename-desktop-file": "citra.desktop",
|
||||
"rename-icon": "citra",
|
||||
"rename-appdata-file": "org.citra.$REPO_NAME.appdata.xml",
|
||||
"sdk-extensions": [
|
||||
"org.freedesktop.Sdk.Extension.gcc7"
|
||||
],
|
||||
"build-options": {
|
||||
"build-args": [
|
||||
"--share=network"
|
||||
],
|
||||
"env": {
|
||||
"CC": "/usr/lib/sdk/gcc7/bin/gcc",
|
||||
"CXX": "/usr/lib/sdk/gcc7/bin/g++",
|
||||
"CI": "$CI",
|
||||
"TRAVIS": "$TRAVIS",
|
||||
"CONTINUOUS_INTEGRATION": "$CONTINUOUS_INTEGRATION",
|
||||
"TRAVIS_BRANCH": "$TRAVIS_BRANCH",
|
||||
"TRAVIS_BUILD_ID": "$TRAVIS_BUILD_ID",
|
||||
"TRAVIS_BUILD_NUMBER": "$TRAVIS_BUILD_NUMBER",
|
||||
"TRAVIS_COMMIT": "$TRAVIS_COMMIT",
|
||||
"TRAVIS_JOB_ID": "$TRAVIS_JOB_ID",
|
||||
"TRAVIS_JOB_NUMBER": "$TRAVIS_JOB_NUMBER",
|
||||
"TRAVIS_REPO_SLUG": "$TRAVIS_REPO_SLUG",
|
||||
"TRAVIS_TAG": "$TRAVIS_TAG"
|
||||
}
|
||||
},
|
||||
"finish-args": [
|
||||
"--device=all",
|
||||
"--socket=x11",
|
||||
"--socket=pulseaudio",
|
||||
"--share=network",
|
||||
"--share=ipc",
|
||||
"--filesystem=xdg-config/citra-emu:create",
|
||||
"--filesystem=xdg-data/citra-emu:create",
|
||||
"--filesystem=host:ro"
|
||||
],
|
||||
"modules": [
|
||||
{
|
||||
"name": "cmake",
|
||||
"buildsystem": "cmake-ninja",
|
||||
"cleanup": ["*"],
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://cmake.org/files/v3.12/cmake-3.12.3.tar.gz",
|
||||
"sha256": "acbf13af31a741794106b76e5d22448b004a66485fc99f6d7df4d22e99da164a"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "citra",
|
||||
"buildsystem": "cmake-ninja",
|
||||
"builddir": true,
|
||||
"config-opts": [
|
||||
"-DCMAKE_BUILD_TYPE=Release",
|
||||
"-DENABLE_QT_TRANSLATION=ON",
|
||||
"-DCITRA_ENABLE_COMPATIBILITY_REPORTING=ON",
|
||||
"-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON"
|
||||
],
|
||||
"cleanup": [
|
||||
"/bin/citra",
|
||||
"/share/man",
|
||||
"/share/pixmaps"
|
||||
],
|
||||
"post-install": [
|
||||
"install -Dm644 ../appdata.xml /app/share/appdata/org.citra.$REPO_NAME.appdata.xml",
|
||||
"desktop-file-install --dir=/app/share/applications ../dist/citra.desktop",
|
||||
"sed -i 's/Name=Citra/Name=$REPO_NAME_FRIENDLY/g' /app/share/applications/citra.desktop",
|
||||
"echo 'StartupWMClass=citra-qt' >> /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
|
9
.travis/linux-flatpak/travis-ci-flatpak.env
Normal file
9
.travis/linux-flatpak/travis-ci-flatpak.env
Normal file
@ -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
|
BIN
keys.tar.enc
Normal file
BIN
keys.tar.enc
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user