Skip to content

Commit

Permalink
Merge pull request #477 from flathub/lwbt-patch-1
Browse files Browse the repository at this point in the history
Update Makefile, intel-mediasdk, add stub scripts
  • Loading branch information
lwbt authored Nov 22, 2024
2 parents 8908013 + 9408a0e commit 06cd6b9
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 83 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repos:
- id: end-of-file-fixer
exclude: |
(?x)^(
data/intel-mediasdk-gcc13\.patch|
npm-generated-sources\.json|
nuget-generated-sources-arm64\.json|
nuget-generated-sources-x64\.json
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LLVM_VER=19
NODE_VER=22
RUNTIME_VER=24.08
BUILD_DATE := $(shell date -I)
GH_ACCOUNT := $(gh auth status --active | grep "Logged in to github.com account" | cut -d " " -f 9)
GH_ACCOUNT := $(shell gh auth status --active | grep "Logged in to github.com account" | cut -d " " -f 9)

.PHONY: all clean remove-sources reset setup-sdk prepare pkg pkg-x64 pkg-arm64 run bundle bundle-x64 bundle-arm64 lint check-meta release generate-sources refresh-sources workflow-check

Expand Down
11 changes: 11 additions & 0 deletions data/intel-mediasdk-gcc13.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff -up MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp.gcc13 MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp
--- MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp.gcc13 2022-11-18 09:02:59.000000000 +0100
+++ MediaSDK-intel-mediasdk-22.6.4/api/mfx_dispatch/linux/mfxparser.cpp 2023-01-17 21:26:56.794562323 +0100
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>

+#include <cstdint>
#include <list>

#include "mfxloader.h"
15 changes: 8 additions & 7 deletions data/jellyfin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# $TS_USE_MAGIC_DNS have been set by the user.
[[ -n "${TS_SELF_DNS_NAME}" && "${TS_USE_MAGIC_DNS}" == "true" ]] && JF_URL="https://${TS_SELF_DNS_NAME}:${JF_PORT_HTTPS}"

# Start with 1 (250mc) instead of 0, this is typically closer to what is reported
# Start with 1 (250ms) instead of 0, this is typically closer to what is reported
# in the log.
WAIT_COUNTER=1
TS_CERT_CRT="/var/config/jellyfin/${TS_SELF_DNS_NAME}.crt"
Expand All @@ -19,25 +19,26 @@ TS_CERT_PFX="/var/config/jellyfin/ts-web-certificate.pfx"

check_health() {
# These curl parameters have been taken from Jellyfin build scripts and
# turned into their respective long forms to improve readabilility.
# turned into their respective long forms to improve readability.
curl --location --insecure --fail --silent "${JF_HEALTHCHECK_URL}"
}

[[ "$1" == "backup" ]] && {
"jf-backup.sh"
# A few shortcuts.
[[ "$1" =~ ^("backup"|"updater"|"service-setup")$ ]] && {
"jf-${1}.sh"
exit
}

if [[ -n "${TS_SELF_DNS_NAME}" && -f "${TS_CERT_CRT}" && -f "${TS_CERT_KEY}" ]]; then
# TODO: Notify how long certificate is valid.
echo "Found Tailscale certficates."
echo "Found Tailscale certificates."
openssl pkcs12 \
-export \
-out "${TS_CERT_PFX}" \
-inkey "${TS_CERT_KEY}" \
-in "${TS_CERT_CRT}" \
-passout pass: \
&& echo "Converted Tailscale certficates."
&& echo "Converted Tailscale certificates."
fi

if ! check_health; then
Expand Down Expand Up @@ -71,7 +72,7 @@ if ! check_health; then
[[ ! "$*" =~ ("--service") ]] && xdg-open "${JF_URL}"
fi
else
notify-send 2> /dev/null "Jellyfin" "Another instance is already runnng."
notify-send 2> /dev/null "Jellyfin" "Another instance is already running."

# Attempt to open the dashboard with direct access to restart and shutdown
# options.
Expand Down
23 changes: 11 additions & 12 deletions data/jf-backup.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/bin/bash

echo "# This is just a simple script for now."
echo "# The command below cannot be executed by the app itself from within the sandbox."
echo "# Please run the command to backup your data before a release upgrade."
echo "# Remove the data when you are confident that the migration was successful to free up storage space."
echo -e "# ---\n"
cat << 'EOF'
# This is just a simple script for now.
# The command below cannot be executed by the app itself from within the sandbox.
# Please run the command to backup your data before a release upgrade.
# Remove the data when you are confident that the migration was successful to free up storage space.
# ---
# shellcheck disable=SC2016
echo -e \
'cp -a \\\n' \
' "${HOME}/.var/app/org.jellyfin.JellyfinServer/" \\\n' \
' "${HOME}/.var/app/org.jellyfin.JellyfinServer_bak_$(date -I)"'
# shellcheck disable=SC2016
echo 'du -hs "${HOME}/.var/app/org.jellyfin.JellyfinServer"*'
cp -a \
"${HOME}/.var/app/org.jellyfin.JellyfinServer/" \
"${HOME}/.var/app/org.jellyfin.JellyfinServer_bak_$(date -I)"
du -hs "${HOME}/.var/app/org.jellyfin.JellyfinServer"*
EOF
23 changes: 23 additions & 0 deletions data/jf-service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

cat << 'EOF'
# The command below cannot be executed by the app itself from within the sandbox.
# Please copy the script below and execute it to configure automatic updates of ALL Flatpaks on your system.
# ---
# https://wiki.archlinux.org/title/Systemd/User#Automatic_start-up_of_systemd_user_instances
loginctl list-users
loginctl enable-linger $USER
loginctl list-users
unit="jellyfin.service"
cp -v "$(flatpak info --show-location org.jellyfin.JellyfinServer)/files/share/templates/${unit}" \
"${HOME}/.local/share/systemd/user/${unit}"
# # Override defaults, like starting the app in --user scope.
# mkdir -pv "${HOME}/.local/share/systemd/user/${unit}.d/"
# echo -e "[Service]\nEnvironment=FLATPAK_SCOPE=--user" > "${HOME}/.local/share/systemd/user/${unit}.d/override.conf"
systemctl --user daemon-reload
systemctl --user --no-pager enable "${unit}" --now
sleep 1
systemctl --user --no-pager --full status "${unit}"
EOF
30 changes: 30 additions & 0 deletions data/jf-updater.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

cat << 'EOF'
# NOTE: Please check the capabilities of your desktop environment before proceeding with this solution.
#
# The command below cannot be executed by the app itself from within the sandbox.
# Please copy the script below and execute it to configure automatic updates of ALL Flatpaks on your system.
# ---
unit_selection=(
flatpak-update.service
flatpak-update.timer
flatpak-update-onactive.service
flatpak-update-onactive.timer
)
# https://wiki.archlinux.org/title/Systemd/User#Automatic_start-up_of_systemd_user_instances
loginctl list-users
loginctl enable-linger $USER
loginctl list-users
for unit in "${unit_selection[@]}"; do
cp -v "$(flatpak info --show-location org.jellyfin.JellyfinServer)/files/share/templates/${unit}" \
"${HOME}/.local/share/systemd/user/${unit}"
systemctl --user daemon-reload
systemctl --user --no-pager enable "${unit}" --now
sleep 1
systemctl --user --no-pager --full status "${unit}"
done
EOF
13 changes: 13 additions & 0 deletions data/systemd/flatpak-update-onactive.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Flatpak update
Requires=flatpak-update.service

[Timer]
OnBootSec=5min
#OnActiveSec=15min
OnUnitActiveSec=15min
Persistent=true
#RandomizedDelaySec=10min

[Install]
WantedBy=timers.target
15 changes: 15 additions & 0 deletions data/systemd/flatpak-update.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# NOTE: This service does not run inside the Flatpak.
[Unit]
Description=Daily flatpak update activities
Documentation=man:flatpak(1)
#ConditionACPower=true

[Service]
Type=oneshot
ExecStartPre=/usr/bin/notify-send 'Flatpak' 'Flatpak daily update started'
ExecStart=/usr/bin/flatpak update --noninteractive --assumeyes
ExecStartPost=/usr/bin/flatpak remove --unused --noninteractive --assumeyes
ExecStopPost=/usr/bin/notify-send 'Flatpak' 'Flatpak daily update started'

[Install]
WantedBy=default.target
14 changes: 14 additions & 0 deletions data/systemd/flatpak-update.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Daily flatpak update activities
Requires=flatpak-update.service

[Timer]
OnBootSec=5m
#OnUnitActiveSec=6h
OnCalendar=*-*-* 6/12:00
#RandomizedDelaySec=30m
RandomizedDelaySec=5m
Persistent=true

[Install]
WantedBy=timers.target
19 changes: 19 additions & 0 deletions data/systemd/jellyfin.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Jellyfin Media Server (Flatpak)
Documentation=https://github.com/flathub/org.jellyfin.JellyfinServer/wiki
# This target does not exist in user scope?
#After = network-online.target

[Service]
Type=simple
Environment=FLATPAK_SCOPE=--system
ExecStart=/usr/bin/flatpak run $FLATPAK_SCOPE --command=jellyfin org.jellyfin.JellyfinServer --service
ExecStop=/usr/bin/flatpak kill org.jellyfin.JellyfinServer
Restart=on-failure
TimeoutSec=15
SuccessExitStatus=0 143

[Install]
# Modified for user scope.
#WantedBy = multi-user.target
WantedBy=default.target
95 changes: 32 additions & 63 deletions org.jellyfin.JellyfinServer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,6 @@ modules:
x-checker-data:
type: git
tag-pattern: ^v([\d.]+)$
#sources:
# - type: archive
# url: https://deb.debian.org/debian/pool/main/o/ocl-icd/ocl-icd_2.3.1.orig.tar.gz
# sha256: a32b67c2d52ffbaf490be9fc18b46428ab807ab11eff7664d7ff75e06cfafd6d
# x-checker-data:
# type: html
# url: https://packages.debian.org/source/bookworm/ocl-icd
# version-pattern: ocl-icd \((\d+\.\d+\.\d+)
# url-template: https://deb.debian.org/debian/pool/main/o/ocl-icd/ocl-icd_$version.orig.tar.gz
# - type: archive
# url: https://deb.debian.org/debian/pool/main/o/ocl-icd/ocl-icd_2.3.1-1.debian.tar.xz
# sha256: eed9c271ebf0c7045a00f4d11f960529cd3c4860300daf5fb806a7af3c228ee7
# dest: debs
# x-checker-data:
# type: html
# url: https://packages.debian.org/source/bookworm/ocl-icd
# version-pattern: ocl-icd \(([^\)]+)\)
# url-template: https://deb.debian.org/debian/pool/main/o/ocl-icd/ocl-icd_$version.debian.tar.xz
# - type: shell
# commands:
# - for p in $(cat debs/patches/series); do if [[ $p != "#"* ]]; then patch
# -Np1 -i "debs/patches/$p" -d .; fi; done
modules:
- name: khronos-opencl-headers
buildsystem: cmake-ninja
Expand All @@ -100,58 +78,30 @@ modules:
x-checker-data:
type: git
tag-pattern: ^v([\d.]+)$
#- type: archive
# url: https://deb.debian.org/debian/pool/main/k/khronos-opencl-headers/khronos-opencl-headers_3.0~2023.02.06.orig.tar.gz
# sha256: 464d1b04a5e185739065b2d86e4cebf02c154c416d63e6067a5060d7c053c79a
# x-checker-data:
# type: html
# url: https://packages.debian.org/source/bookworm/khronos-opencl-headers
# version-pattern: khronos-opencl-headers \((\d+\.\d+~\d+\.\d+\.\d+)
# url-template: https://deb.debian.org/debian/pool/main/k/khronos-opencl-headers/khronos-opencl-headers_$version.orig.tar.gz
#- type: archive
# url: https://deb.debian.org/debian/pool/main/k/khronos-opencl-headers/khronos-opencl-headers_3.0~2023.02.06-1.debian.tar.xz
# sha256: 3b935732ae4e17ac27512d97a1be287ba245b3ba0840d6a1a66e2ba4a7b2532c
# dest: debs
# x-checker-data:
# type: html
# url: https://packages.debian.org/source/bookworm/khronos-opencl-headers
# version-pattern: khronos-opencl-headers \(([^\)]+)\)
# url-template: https://deb.debian.org/debian/pool/main/k/khronos-opencl-headers/khronos-opencl-headers_$version.debian.tar.xz
#- type: shell
# commands:
# - for p in $(cat debs/patches/series); do if [[ $p != "#"* ]]; then patch
# -Np1 -i "debs/patches/$p" -d .; fi; done

- name: intel-mediasdk
only-arches:
- x86_64
buildsystem: cmake-ninja
config-opts:
- -DBUILD_SAMPLES=OFF
- -DBUILD_TESTS=OFF
- -DBUILD_TUTORIALS=OFF
- -DCMAKE_BUILD_TYPE=Release
- -DENABLE_X11=OFF
sources:
- type: archive
url: https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/intel-mediasdk/22.5.4-1ubuntu1/intel-mediasdk_22.5.4.orig.tar.gz
sha256: 0eb04409a226da6e752576d60c46a3ec969ddfe03042897088367392207c7ab3
x-checker-data:
type: html
url: https://launchpad.net/ubuntu/+source/intel-mediasdk
version-pattern: intel-mediasdk \((\d+\.\d+\.\d+)
url-template: https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/intel-mediasdk/$version-1ubuntu1/intel-mediasdk_$version.orig.tar.gz
- type: archive
url: https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/intel-mediasdk/22.5.4-1ubuntu1/intel-mediasdk_22.5.4-1ubuntu1.debian.tar.xz
sha256: 3f414418cc382efd6b2e5304f60ee91b7a9d45c3e98f0fb3d56fb9801ce2e054
dest: debs
- type: git
url: https://github.com/Intel-Media-SDK/MediaSDK.git
commit: 73c6ca577f83b1c451e28517e6bd41045c2f9097
tag: intel-mediasdk-22.6.5
x-checker-data:
type: html
url: https://launchpad.net/ubuntu/+source/intel-mediasdk
version-pattern: intel-mediasdk \(([^\)]+)\)
url-template: https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/intel-mediasdk/$version-1ubuntu1/intel-mediasdk_$version-1ubuntu1.debian.tar.xz
- type: shell
commands:
- for p in $(cat debs/patches/series); do if [[ $p != "#"* ]]; then patch
-Np1 -i "debs/patches/$p" -d .; fi; done
type: git
tag-pattern: ^intel-mediasdk-([\d.]+)$
# Version from https://github.com/flathub/fr.handbrake.ghb.Plugin.IntelMediaSDK
versions:
=: 22.6.5
- type: patch
path: data/intel-mediasdk-gcc13.patch

- name: onevpl
only-arches:
Expand Down Expand Up @@ -782,6 +732,13 @@ modules:
build-commands:
- install -D jellyfin.sh $FLATPAK_DEST/bin/jellyfin.sh
- install -D jf-backup.sh $FLATPAK_DEST/bin/jf-backup.sh
- install -D jf-updater.sh $FLATPAK_DEST/bin/jf-updater.sh
- install -D jf-service-setup.sh $FLATPAK_DEST/bin/jf-service-setup.sh
- install -D -m 644 flatpak-update.service $FLATPAK_DEST/share/templates/flatpak-update.service
- install -D -m 644 flatpak-update.service $FLATPAK_DEST/share/templates/flatpak-update-onactive.service
- install -D -m 644 flatpak-update.timer $FLATPAK_DEST/share/templates/flatpak-update.timer
- install -D -m 644 flatpak-update-onactive.timer $FLATPAK_DEST/share/templates/flatpak-update-onactive.timer
- install -D -m 644 jellyfin.service $FLATPAK_DEST/share/templates/jellyfin.service
- install -D $FLATPAK_ID.metainfo.xml $FLATPAK_DEST/share/metainfo/$FLATPAK_ID.metainfo.xml
- install -D $FLATPAK_ID.desktop $FLATPAK_DEST/share/applications/$FLATPAK_ID.desktop
# Required, otherwise fails the build with: "non-png-icon-in-hicolor-size-folder"
Expand Down Expand Up @@ -814,3 +771,15 @@ modules:
path: data/jellyfin.sh
- type: file
path: data/jf-backup.sh
- type: file
path: data/jf-updater.sh
- type: file
path: data/systemd/flatpak-update.service
- type: file
path: data/systemd/flatpak-update.timer
- type: file
path: data/systemd/flatpak-update-onactive.timer
- type: file
path: data/jf-service-setup.sh
- type: file
path: data/systemd/jellyfin.service

0 comments on commit 06cd6b9

Please sign in to comment.