Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu Core support #59

Merged
merged 5 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
[![Retroarch Snap](https://snapcraft.io/retroarch/badge.svg)](https://snapcraft.io/retroarch)

# RetroArch Snap

This project creates a working snap of RetroArch.

## Current state
This package will include assets, database, cheats,joypad autoconfig, info cores, overlay and shaders.

This package will include assets, database, cheats, joypad autoconfig, info cores, overlay and shaders.

You will need to use the Online Updater to install cores.

## Daemon mode

[snap.retroarch.daemon.service](https://snapcraft.io/docs/services-and-daemons#defining-a-daemon) systemd unit will automatically enabled and started after installation on Ubuntu Core. On other versions of GNU/Linux to activate daemon run as root the following command:
> WARNING! For most desktop distributions this is not needed

```console
$ snap set ubuntu-frame daemon=true && snap start --enable retroarch.daemon
```
16 changes: 0 additions & 16 deletions daemon-start.sh

This file was deleted.

38 changes: 38 additions & 0 deletions scripts/bin/daemon-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
set -e

wait_for()
{
until
until
inotifywait --event create "$(dirname "$1")"&
inotify_pid=$!
[ -e "$1" ] || sleep 2 && [ -e "$1" ]
do
wait "${inotify_pid}"
done
kill "${inotify_pid}"
[ -O "$1" ]
do
sleep 1
done
}

if snapctl is-connected wayland
then
real_xdg_runtime_dir=$(dirname "${XDG_RUNTIME_DIR}")
export WAYLAND_DISPLAY="${real_xdg_runtime_dir}/${WAYLAND_DISPLAY:-wayland-0}"

# On core systems may need to wait for real XDG_RUNTIME_DIR
wait_for "${real_xdg_runtime_dir}"
wait_for "${WAYLAND_DISPLAY}"

mkdir -p "$XDG_RUNTIME_DIR" -m 700
elif [ -S $(dirname "${XDG_RUNTIME_DIR}")/${WAYLAND_DISPLAY:-wayland-0} ]
then
echo "WARNING: wayland interface not connected! Please run as superuser: snap connect retroarch:wayland"
fi

unset DISPLAY

exec "$@"
File renamed without changes.
20 changes: 20 additions & 0 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -euo pipefail

daemon=$(snapctl get daemon)
case "$daemon" in
true)
# start the daemon
if snapctl services "$SNAP_INSTANCE_NAME" | grep -q inactive; then
snapctl start --enable "$SNAP_INSTANCE_NAME" 2>&1 || true
fi
;;
false)
# stop the daemon
snapctl stop --disable "$SNAP_INSTANCE_NAME" 2>&1 || true
;;
*)
echo "ERROR: Set 'daemon' to one of true|false"
exit 1
;;
esac
18 changes: 18 additions & 0 deletions snap/hooks/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
set -eux

# we install with the daemon disabled, the configure hook
# will start and enable it if appropriate
snapctl stop --disable "$SNAP_INSTANCE_NAME.daemon"

daemon=$(snapctl get daemon)
if [ "$daemon" = "" ]
then
# By default, we run as a daemon on core, otherwise configure the daemon to stop
if grep -q -e snap_core= -e snapd_recovery_mode= /proc/cmdline
then
snapctl set daemon=true
else
snapctl set daemon=false
fi
fi
1 change: 1 addition & 0 deletions snap/hooks/post-refresh
76 changes: 24 additions & 52 deletions snapcraft.yaml → snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ layout:

apps:
retroarch:
#extensions:
# - kde-neon
# extensions:
# - kde-neon
command-chain:
- bin/desktop-launch
- bin/graphics-core22-wrapper
- usr/local/bin/retroarch.wrapper
- bin/retroarch.wrapper
command: usr/local/bin/retroarch
environment:
environment: &_environment
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pulseaudio:$SNAP/graphics/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR
plugs:
plugs: &_plugs
- network
- network-bind
- x11
Expand All @@ -74,38 +74,26 @@ apps:
- browser-support
- hardware-observe
- mount-observe
# daemon:
# command: $SNAP/usr/bin/snapcraft-preload $SNAP/usr/local/bin/daemon-start.sh $SNAP/usr/local/bin/retroarch.wrapper
# environment:
# LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/pulseaudio:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/dri:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/mesa:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/mesa-gl:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/xorg
# daemon: simple
# restart-condition: always
# plugs:
# - network
# - network-bind
# - opengl
# - home
# - alsa
# - audio-playback
# - bluez
# - joystick
# - raw-usb
# - removable-media
# - wayland
# - unity7
# - screen-inhibit-control
daemon:
command-chain:
- bin/daemon-start.sh
- bin/desktop-launch
- bin/graphics-core22-wrapper
- bin/retroarch.wrapper
command: usr/local/bin/retroarch -f -v
daemon: simple
restart-delay: 3s
restart-condition: always
environment: *_environment
plugs: *_plugs

parts:
retroarch-wrapper:
plugin: dump
after: [desktop-qt5]
source: .
organize:
retroarch.wrapper: usr/local/bin/retroarch.wrapper
# daemon-start.sh: usr/local/bin/daemon-start.sh
stage:
- usr/local/bin/retroarch.wrapper
# - usr/local/bin/daemon-start.sh
source: scripts
stage-packages:
- inotify-tools
retroarch:
plugin: autotools
# source-type: tar
Expand Down Expand Up @@ -231,9 +219,7 @@ parts:
ozone: .config/assets/ozone/
sounds: .config/assets/sounds/
menu_widgets: .config/assets/menu_widgets/
# filesets:
# assets: [.config/assets/menu_widgets/*, .config/assets/sounds/*, .config/assets/ozone/*, .config/assets/rgui/*, .config/assets/xmb/*, -.config/assets/xmb/*/src, .config/assets/glui/*.png, .config/assets/glui/*.ttf]
stage:
stage: &_assets
- -configure
- -Makefile
- .config/assets/menu_widgets/*
Expand All @@ -244,15 +230,7 @@ parts:
- -.config/assets/xmb/*/src
- .config/assets/glui/*.png
- .config/assets/glui/*.ttf]
prime:
- .config/assets/menu_widgets/*
- .config/assets/sounds/*
- .config/assets/ozone/*
- .config/assets/rgui/*
- .config/assets/xmb/*
- -.config/assets/xmb/*/src
- .config/assets/glui/*.png
- .config/assets/glui/*.ttf]
prime: *_assets
retroarch-autoconfig:
plugin: dump
after: [retroarch-assets]
Expand All @@ -263,18 +241,12 @@ parts:
linuxraw: .config/autoconfig/linuxraw/
hid: .config/autoconfig/hid/
x: .config/autoconfig/x/
# filesets:
# autoconfig: [ .config/autoconfig/udev, .config/autoconfig/linuxraw, .config/autoconfig/hid, .config/autoconfig/x]
stage:
- .config/autoconfig/udev
- .config/autoconfig/linuxraw
- .config/autoconfig/hid
- .config/autoconfig/x
prime:
stage: &_autoconfig
- .config/autoconfig/udev
- .config/autoconfig/linuxraw
- .config/autoconfig/hid
- .config/autoconfig/x
prime: *_autoconfig
retroarch-database:
plugin: dump
after: [retroarch-autoconfig]
Expand Down