From 15636c3613a78c19b90e40df3376a95b1dedf2f9 Mon Sep 17 00:00:00 2001 From: Sebastian Sommer Date: Sun, 24 Nov 2024 07:26:04 +0100 Subject: [PATCH 1/4] Added Kodi image --- compose/apps/kodi.yml | 45 +++++++++++++++++++++++++ images/kodi/Dockerfile | 60 ++++++++++++++++++++++++++++++++++ images/kodi/scripts/startup.sh | 9 +++++ 3 files changed, 114 insertions(+) create mode 100644 compose/apps/kodi.yml create mode 100644 images/kodi/Dockerfile create mode 100644 images/kodi/scripts/startup.sh diff --git a/compose/apps/kodi.yml b/compose/apps/kodi.yml new file mode 100644 index 00000000..271a5c00 --- /dev/null +++ b/compose/apps/kodi.yml @@ -0,0 +1,45 @@ +######################### +# kodi.yml +######################### +# +# This container runs kodi + +services: + #################### + kodi: + build: + context: ./images/kodi + args: + BASE_IMAGE: ${BUILD_BASE_IMAGE} + BASE_APP_IMAGE: ${BUILD_BASE_APP_IMAGE} + runtime: ${DOCKER_RUNTIME} + privileged: true + network_mode: ${UDEVD_NETWORK} + volumes: + # Followings are needed in order to get joystick support + - /dev/input:/dev/input:ro + - udev:/run/udev/:ro + # Xorg socket in order to get the screen + - ${XORG_SOCKET}:/tmp/.X11-unix + # Pulse socket, audio + - ${PULSE_SOCKET_HOST}:${PULSE_SOCKET_GUEST} + # Home directory: + - ${LOCAL_STATE}/:/home:rw + # some emulators need more than 64 MB of shared memory - see https://github.com/libretro/dolphin/issues/222 + # TODO: why shm_size doesn't work ?????? + - type: tmpfs + target: /dev/shm + tmpfs: + size: ${SHM_SIZE} + ipc: ${SHARED_IPC} # Needed for MIT-SHM, removing this should cause a performance hit see https://github.com/jessfraz/dockerfiles/issues/359 + env_file: + - config/common.env + - config/xorg.env + # run-gow: gpu_env + + environment: + # Which devices does GoW need to be able to use? The docker user will be + # added to the groups that own these devices, to help with permissions + # issues + # These values are the defaults, but you can add others if needed + GOW_REQUIRED_DEVICES: /dev/uinput /dev/input/event* /dev/dri/* /dev/snd/* diff --git a/images/kodi/Dockerfile b/images/kodi/Dockerfile new file mode 100644 index 00000000..55393e95 --- /dev/null +++ b/images/kodi/Dockerfile @@ -0,0 +1,60 @@ +ARG BASE_APP_IMAGE + +# hadolint ignore=DL3006 +FROM ${BASE_APP_IMAGE} + +ARG DEBIAN_FRONTEND=noninteractive + +#TODO: Build this madness in a different Dockerfile and just copy the binary +ARG REQUIRED_PACKAGES=" \ + debhelper autoconf autoconf automake \ + autopoint gettext autotools-dev cmake \ + curl default-jre doxygen gawk gcc gdc \ + gperf libasound2-dev libass-dev \ + libavahi-client-dev libavahi-common-dev \ + libbluetooth-dev libbluray-dev libbz2-dev \ + libcdio-dev libp8-platform-dev libcrossguid-dev \ + libcurl4-openssl-dev libcwiid-dev libdbus-1-dev \ + libdrm-dev libegl1-mesa-dev libenca-dev \ + libexiv2-dev libflac-dev libfmt-dev \ + libfontconfig-dev libfreetype6-dev \ + libfribidi-dev libfstrcmp-dev \ + libgcrypt-dev libgif-dev libgles2-mesa-dev \ + libgl1-mesa-dev libglu1-mesa-dev libgnutls28-dev \ + libgpg-error-dev libgtest-dev libiso9660-dev \ + libjpeg-dev liblcms2-dev libltdl-dev liblzo2-dev \ + libmicrohttpd-dev libmysqlclient-dev libnfs-dev \ + libogg-dev libpcre2-dev libplist-dev libpng-dev \ + libpulse-dev libshairplay-dev libsmbclient-dev \ + libspdlog-dev libsqlite3-dev libssl-dev libtag1-dev \ + libtiff5-dev libtinyxml-dev libtinyxml2-dev libtool \ + libudev-dev libunistring-dev libva-dev libvdpau-dev \ + libvorbis-dev libxmu-dev libxrandr-dev libxslt1-dev \ + libxt-dev lsb-release meson nasm ninja-build \ + python3-dev python3-pil python3-pip rapidjson-dev \ + swig unzip uuid-dev zip zlib1g-dev git \ + libflatbuffers-dev libglew-dev libwayland-dev \ + libxkbcommon-dev waylandpp-dev wayland-protocols \ + " + +# Build Kodi from source +RUN apt-get update && \ + apt-get install -y $REQUIRED_PACKAGES && \ + git clone https://github.com/xbmc/xbmc kodi && \ + apt-get update && \ + mkdir kodi-build && \ + cd kodi-build && \ + cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=wayland -DAPP_RENDER_SYSTEM=gl && \ + cmake --build . -- VERBOSE=1 -j$(getconf _NPROCESSORS_ONLN) && \ + make install && \ + #clean up + cd .. && \ + rm -R kodi/ && \ + rm -R kodi-build/ + +COPY --chmod=777 scripts/startup.sh /opt/gow/startup-app.sh + +ENV XDG_RUNTIME_DIR=/tmp/.X11-unix + +ARG IMAGE_SOURCE +LABEL org.opencontainers.image.source=$IMAGE_SOURCE \ No newline at end of file diff --git a/images/kodi/scripts/startup.sh b/images/kodi/scripts/startup.sh new file mode 100644 index 00000000..43ccab3f --- /dev/null +++ b/images/kodi/scripts/startup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /opt/gow/bash-lib/utils.sh + +gow_log "Starting Kodi" + +source /opt/gow/launch-comp.sh +launcher kodi From 07f7c5b6605a9fea311df7551c303375ae753f08 Mon Sep 17 00:00:00 2001 From: Sebastian Sommer Date: Mon, 25 Nov 2024 02:04:42 +0100 Subject: [PATCH 2/4] fix: Controller now working --- images/kodi/Dockerfile | 17 ++++++-- images/kodi/configs/controller.xml | 40 +++++++++++++++++++ images/kodi/configs/settings.xml | 3 ++ images/kodi/scripts/startup-10-create-dirs.sh | 14 +++++++ images/kodi/scripts/startup.sh | 9 +++++ 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 images/kodi/configs/controller.xml create mode 100644 images/kodi/configs/settings.xml create mode 100644 images/kodi/scripts/startup-10-create-dirs.sh diff --git a/images/kodi/Dockerfile b/images/kodi/Dockerfile index 55393e95..0f9a7170 100644 --- a/images/kodi/Dockerfile +++ b/images/kodi/Dockerfile @@ -5,7 +5,9 @@ FROM ${BASE_APP_IMAGE} ARG DEBIAN_FRONTEND=noninteractive -#TODO: Build this madness in a different Dockerfile and just copy the binary +# TODO: Build this madness in a multi-step Dockerfile and just copy the needed binary +# Required packages are listed here: +# - https://github.com/xbmc/xbmc/blob/master/docs/README.Ubuntu.md#32-get-build-dependencies-manually ARG REQUIRED_PACKAGES=" \ debhelper autoconf autoconf automake \ autopoint gettext autotools-dev cmake \ @@ -46,13 +48,22 @@ RUN apt-get update && \ cd kodi-build && \ cmake ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=wayland -DAPP_RENDER_SYSTEM=gl && \ cmake --build . -- VERBOSE=1 -j$(getconf _NPROCESSORS_ONLN) && \ - make install && \ + make install + +# Build controller addon; !!! Add needed Addons HERE !!! +RUN cd kodi && \ + make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons PREFIX=/usr/local ADDONS="peripheral.joystick" && \ #clean up cd .. && \ rm -R kodi/ && \ - rm -R kodi-build/ + rm -R kodi-build/ && \ + apt-get autoremove -y --purge + COPY --chmod=777 scripts/startup.sh /opt/gow/startup-app.sh +COPY --chmod=777 scripts/startup-10-create-dirs.sh /opt/gow/startup.d/10-create-dirs.sh +COPY configs/controller.xml /opt/gow/controller.xml +COPY configs/settings.xml /opt/gow/settings.xml ENV XDG_RUNTIME_DIR=/tmp/.X11-unix diff --git a/images/kodi/configs/controller.xml b/images/kodi/configs/controller.xml new file mode 100644 index 00000000..f74360ea --- /dev/null +++ b/images/kodi/configs/controller.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/kodi/configs/settings.xml b/images/kodi/configs/settings.xml new file mode 100644 index 00000000..b3903cef --- /dev/null +++ b/images/kodi/configs/settings.xml @@ -0,0 +1,3 @@ + + 0 + diff --git a/images/kodi/scripts/startup-10-create-dirs.sh b/images/kodi/scripts/startup-10-create-dirs.sh new file mode 100644 index 00000000..aa26abe4 --- /dev/null +++ b/images/kodi/scripts/startup-10-create-dirs.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e + +gow_log "[start-create-dirs] Begin" + +# configure the controller. +if [ ! -d "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux" ] +then + gow_log "[start-create-dirs] Creating controller config file." + mkdir -p "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/" + cp "/opt/gow/controller.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Wolf_X-Box_One__virtual__pad_11b_8a.xml" + cp "/opt/gow/settings.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/settings.xml" +fi + +gow_log "[start-create-dirs] End" diff --git a/images/kodi/scripts/startup.sh b/images/kodi/scripts/startup.sh index 43ccab3f..71960750 100644 --- a/images/kodi/scripts/startup.sh +++ b/images/kodi/scripts/startup.sh @@ -3,7 +3,16 @@ set -e source /opt/gow/bash-lib/utils.sh +# Run additional startup scripts +for file in /opt/gow/startup.d/* ; do + if [ -f "$file" ] ; then + gow_log "[start] Sourcing $file" + source $file + fi +done + gow_log "Starting Kodi" source /opt/gow/launch-comp.sh launcher kodi +#launcher jstest-gtk \ No newline at end of file From 5dd493facf28c39e4bfeec72d0f6d721425c0783 Mon Sep 17 00:00:00 2001 From: Sebastian Sommer Date: Tue, 26 Nov 2024 23:13:10 +0100 Subject: [PATCH 3/4] Added Nintendo Switch Pro Controller support --- images/kodi/Dockerfile | 3 +- images/kodi/configs/Switch_controller.xml | 37 +++++++++++++++++++ .../{controller.xml => Xbox_controller.xml} | 0 images/kodi/scripts/startup-10-create-dirs.sh | 3 +- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 images/kodi/configs/Switch_controller.xml rename images/kodi/configs/{controller.xml => Xbox_controller.xml} (100%) diff --git a/images/kodi/Dockerfile b/images/kodi/Dockerfile index 0f9a7170..9f22c35c 100644 --- a/images/kodi/Dockerfile +++ b/images/kodi/Dockerfile @@ -62,7 +62,8 @@ RUN cd kodi && \ COPY --chmod=777 scripts/startup.sh /opt/gow/startup-app.sh COPY --chmod=777 scripts/startup-10-create-dirs.sh /opt/gow/startup.d/10-create-dirs.sh -COPY configs/controller.xml /opt/gow/controller.xml +COPY configs/Xbox_controller.xml /opt/gow/Xbox_controller.xml +COPY configs/Switch_controller.xml /opt/gow/Switch_controller.xml COPY configs/settings.xml /opt/gow/settings.xml ENV XDG_RUNTIME_DIR=/tmp/.X11-unix diff --git a/images/kodi/configs/Switch_controller.xml b/images/kodi/configs/Switch_controller.xml new file mode 100644 index 00000000..4bbbf51c --- /dev/null +++ b/images/kodi/configs/Switch_controller.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/kodi/configs/controller.xml b/images/kodi/configs/Xbox_controller.xml similarity index 100% rename from images/kodi/configs/controller.xml rename to images/kodi/configs/Xbox_controller.xml diff --git a/images/kodi/scripts/startup-10-create-dirs.sh b/images/kodi/scripts/startup-10-create-dirs.sh index aa26abe4..b218d2b2 100644 --- a/images/kodi/scripts/startup-10-create-dirs.sh +++ b/images/kodi/scripts/startup-10-create-dirs.sh @@ -7,7 +7,8 @@ if [ ! -d "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/butto then gow_log "[start-create-dirs] Creating controller config file." mkdir -p "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/" - cp "/opt/gow/controller.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Wolf_X-Box_One__virtual__pad_11b_8a.xml" + cp "/opt/gow/Xbox_controller.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Wolf_X-Box_One__virtual__pad_11b_8a.xml" + cp "/opt/gow/Switch_controller.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Wolf_Nintendo__virtual__pad_14b_6a.xml" cp "/opt/gow/settings.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/settings.xml" fi From 84cf018ff4b360750262997ad314f6fef86e8f1c Mon Sep 17 00:00:00 2001 From: Sebastian Sommer Date: Wed, 27 Nov 2024 00:50:08 +0100 Subject: [PATCH 4/4] Added Playstation controller support --- images/kodi/Dockerfile | 1 + images/kodi/configs/PS_controller.xml | 40 +++++++++++++++++++ images/kodi/scripts/startup-10-create-dirs.sh | 1 + 3 files changed, 42 insertions(+) create mode 100644 images/kodi/configs/PS_controller.xml diff --git a/images/kodi/Dockerfile b/images/kodi/Dockerfile index 9f22c35c..361bcb4c 100644 --- a/images/kodi/Dockerfile +++ b/images/kodi/Dockerfile @@ -64,6 +64,7 @@ COPY --chmod=777 scripts/startup.sh /opt/gow/startup-app.sh COPY --chmod=777 scripts/startup-10-create-dirs.sh /opt/gow/startup.d/10-create-dirs.sh COPY configs/Xbox_controller.xml /opt/gow/Xbox_controller.xml COPY configs/Switch_controller.xml /opt/gow/Switch_controller.xml +COPY configs/PS_controller.xml /opt/gow/PS_controller.xml COPY configs/settings.xml /opt/gow/settings.xml ENV XDG_RUNTIME_DIR=/tmp/.X11-unix diff --git a/images/kodi/configs/PS_controller.xml b/images/kodi/configs/PS_controller.xml new file mode 100644 index 00000000..4929d9a4 --- /dev/null +++ b/images/kodi/configs/PS_controller.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/kodi/scripts/startup-10-create-dirs.sh b/images/kodi/scripts/startup-10-create-dirs.sh index b218d2b2..97f70751 100644 --- a/images/kodi/scripts/startup-10-create-dirs.sh +++ b/images/kodi/scripts/startup-10-create-dirs.sh @@ -9,6 +9,7 @@ then mkdir -p "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/" cp "/opt/gow/Xbox_controller.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Wolf_X-Box_One__virtual__pad_11b_8a.xml" cp "/opt/gow/Switch_controller.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Wolf_Nintendo__virtual__pad_14b_6a.xml" + cp "/opt/gow/PS_controller.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Wolf_DualSense__virtual__pad_13b_8a.xml" cp "/opt/gow/settings.xml" "${HOME}/.kodi/userdata/addon_data/peripheral.joystick/settings.xml" fi