~hristoast/mgba-appimage

e68c33ba5883b0a7382085e6e5182b8dcad670f4 — Hristos N. Triantafillou 1 year, 8 months ago
Initial commit

mGBA works as expected, with the exception that shaders packed with it
aren't findable (the current build does not pack them).
6 files changed, 131 insertions(+), 0 deletions(-)

A .gitignore
A Dockerfile
A LICENSE
A Makefile
A README.md
A make-appimage.sh
A  => .gitignore +1 -0
@@ 1,1 @@
out/

A  => Dockerfile +38 -0
@@ 1,38 @@
FROM docker.io/library/ubuntu:bionic-20220801
# "bionic" is 18.04

# System stuff
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
    apt-get upgrade -y && \
	apt-get install -y \
    cmake curl fuse g++ git make \
    libavcodec-dev libavfilter-dev libavformat-dev libavresample-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev \
    libedit-dev libelf-dev libepoxy-dev libminizip-dev libpng-dev libsdl2-dev libsqlite3-dev libzip-dev \
    libqt5multimedia5-plugins qt5-default qtbase5-dev qtmultimedia5-dev

# Cleanup
RUN apt-get clean autoclean && \
    apt-get autoremove --yes && \
    rm -rf /var/lib/apt /var/lib/cache /var/lib/log

# AppImage tooling
RUN curl -sLO https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
RUN curl -sLO https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
RUN chmod +x linuxdeploy*.AppImage

# Build mgba
ENV mgba_version=0.9.3
WORKDIR /
RUN git clone https://github.com/mgba-emu/mgba /src
WORKDIR /src
RUN git checkout $mgba_version
RUN mkdir /src/build
WORKDIR /src/build
RUN cmake ..
RUN make -j $(nproc)
WORKDIR /

# Make the appimage
COPY make-appimage.sh /
CMD [ "/make-appimage.sh" ]

A  => LICENSE +21 -0
@@ 1,21 @@
MIT License

Copyright (c) 2022 Hristos N. Triantafillou

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

A  => Makefile +12 -0
@@ 1,12 @@
.DEFAULT_GOAL: all

all: build run

build:
	docker build -t mgbaappimage:0 .

run:
	docker run --cap-add SYS_ADMIN --device /dev/fuse -it --rm -v $$(pwd)/out:/mnt mgbaappimage:0

bash sh:
	docker run --cap-add SYS_ADMIN --device /dev/fuse -it --rm -v $$(pwd)/out:/mnt mgbaappimage:0 bash

A  => README.md +33 -0
@@ 1,33 @@
# mgba-appimage

Build an AppImage for the mGBA emulator

## Requirements

* docker
* FUSE
* GNU make (optional)

## Usage

To build:

```sh
git clone https://git.sr.ht/~hristoast/mgba-appimage
cd mgba-appimage
make # Read the Makefile to skip make and properly call docker directly
```

A file called `mgba-$version-x86_64.AppImage` will be placed into an `out` directory in the root of this repo. At present, `$version` is hardcoded in the dockerfile.

To get a shell inside the container (useful for developing):

```sh
git clone https://git.sr.ht/~hristoast/mgba-appimage
cd mgba-appimage
make sh # Read the Makefile to skip make and properly call docker directly
```

## Caveats

As of right now, shaders bundled into the AppImage aren't accessible. To work around this, shaders must be downloaded and selected separately.

A  => make-appimage.sh +26 -0
@@ 1,26 @@
#!/usr/bin/env bash
set -ex
export VERSION="${mgba_version}"

# Now create the AppImage
mkdir -p /AppDir/usr/{bin,lib,share}
mkdir -p /AppDir/usr/share/mgba

# Assemble the AppDir
cp /src/build/qt/mgba-qt /AppDir/usr/bin/
cp /src/build/libmgba.so* /AppDir/usr/lib/
cp /src/res/mgba-64.png /src/res/mgba.png
cp /src/res/nointro.dat /AppDir/usr/share/mgba/
#TODO: how to make packed shaders visible?
# cp -r /src/res/shaders /AppDir/usr/share/mgba/

# Make it
/linuxdeploy-x86_64.AppImage \
    --appdir=/AppDir --output=appimage \
    --desktop-file=/src/res/mgba-qt.desktop \
    --deploy-deps-only=/AppDir/usr/bin \
    --icon-file=/src/res/mgba.png \
    --plugin=qt > linuxdeploy.log

# Copy stuff to the expected out dir
cp  -r /src/res/shaders mGBA-${mgba_version}-x86_64.AppImage linuxdeploy.log /mnt/