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..361bcb4c --- /dev/null +++ b/images/kodi/Dockerfile @@ -0,0 +1,73 @@ +ARG BASE_APP_IMAGE + +# hadolint ignore=DL3006 +FROM ${BASE_APP_IMAGE} + +ARG DEBIAN_FRONTEND=noninteractive + +# 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 \ + 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 + +# 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/ && \ + 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/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 + +ARG IMAGE_SOURCE +LABEL org.opencontainers.image.source=$IMAGE_SOURCE \ No newline at end of file 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/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/Xbox_controller.xml b/images/kodi/configs/Xbox_controller.xml new file mode 100644 index 00000000..f74360ea --- /dev/null +++ b/images/kodi/configs/Xbox_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..97f70751 --- /dev/null +++ b/images/kodi/scripts/startup-10-create-dirs.sh @@ -0,0 +1,16 @@ +#!/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/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 + +gow_log "[start-create-dirs] End" diff --git a/images/kodi/scripts/startup.sh b/images/kodi/scripts/startup.sh new file mode 100644 index 00000000..71960750 --- /dev/null +++ b/images/kodi/scripts/startup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +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