Add RPM package spec

Signed-off-by: Thomas Büttner <thomas@tartaros.tech>
pull/702/head
Thomas Büttner 6 years ago
parent d3b0ba978c
commit a2c1ec0de3

@ -0,0 +1,3 @@
*.rpm
*.zip
*.tar.gz

@ -0,0 +1,44 @@
# unoffical jellyfin RPM
<a href="https://copr.fedorainfracloud.org/coprs/wuerfelbecher/jellyfin/package/jellyfin/"><img src="https://copr.fedorainfracloud.org/coprs/wuerfelbecher/jellyfin/package/jellyfin/status_image/last_build.png" /></a>
## ffmpeg
The RPM package for Fedora/CentOS requires some additional repos as ffmpeg is not in the main repositories.
```shell
# ffmpeg from RPMfusion free
# Fedora
$ sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
# CentOS 7
$ sudo yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
```
## In-App service control
A sample sudoers-policy is located at `/usr/share/jellyfin/jellyfin-sudoers` which you need to review and copy to `/etc/sudoers.d`.
Use `install -D -m 0600 -o root -g root /usr/share/jellyfin/jellyfin-sudoers /etc/sudoers.d/jellyfin-sudoers` for the right permissions.
Finally uncomment JELLYFIN_RESTART_OPT in /etc/sysconfig/jellyfin and restart the service.
## Database patching
To fix the paths in the emby database for a migration to jellyfin run the script:
```shell
/usr/share/jellyfin/update-db-paths.sh <path-to-library.db> <path-to-emby-data> <path-to-jellyfin-data>
```
PS: Please **backup your emby database beforehand**.
## Building with dotnet
Jellyfin is build with `--self-contained` so no dotnet required for runtime.
```shell
# dotnet required for building the RPM
# Fedora
$ sudo dnf copr enable @dotnet-sig/dotnet
# CentOS
$ sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
```
## TODO
- [ ] OpenSUSE

@ -0,0 +1,27 @@
# Jellyfin default configuration options
# Use this file to override the default configurations; add additional
# options with JELLYFIN_ADD_OPTS.
# To override the user or this config file's location, use
# /etc/systemd/system/jellyfin.service.d/override.conf
#
# This is a POSIX shell fragment
#
#
# General options
#
# Tell jellyfin wich ffmpeg/ffprobe to use
# JELLYFIN_FFMPEG="-ffmpeg /usr/bin/ffmpeg -ffprobe /usr/bin/ffprobe"
# Data directory
JELLYFIN_DATA="/var/lib/jellyfin"
# To enable In-App service control uncomment JELLYFIN_RESTART_OPT
# and install the sample sudo policy to Allow jellyfin group to start, stop and restart itself.
# /usr/share/jellyfin/jellyfin-sudoers to /etc/sudoers.d/
# JELLYFIN_RESTART_OPT="-restartpath /usr/libexec/jellyfin/restart.sh"
# Additional options for the binary
JELLYFIN_ADD_OPTS=""

@ -0,0 +1,15 @@
[Unit]
After=network.target
Description=Jellyfin is a free software media system that puts you in control of managing and streaming your media.
[Service]
EnvironmentFile=/etc/sysconfig/jellyfin
WorkingDirectory=/var/lib/jellyfin
ExecStart=/usr/bin/jellyfin -programdata ${JELLYFIN_DATA} ${JELLYFIN_RESTART_OPT} ${JELLYFIN_ADD_OPTS} ${JELLYFIN_FFMPEG}
TimeoutSec=15
Restart=on-failure
User=jellyfin
Group=jellyfin
[Install]
WantedBy=multi-user.target

@ -0,0 +1,135 @@
%global debug_package %{nil}
# jellyfin commit to package
%global commit f8a720d3d8adbdb1f092a42e592dae37ba3f25bb
%global gittag v3.5.2-5
%global shortcommit %(c=%{commit}; echo ${c:0:7})
# Taglib-sharp commit of the submodule since github archive doesn't include submodules
%global taglib_commit ee5ab21742b71fd1b87ee24895582327e9e04776
%global taglib_shortcommit %(c=%{taglib_commit}; echo ${c:0:7})
Name: jellyfin
Version: 3.5.2.git%{shortcommit}
Release: 3%{?dist}
Summary: The Free Software Media Browser.
License: GPLv2
URL: https://jellyfin.media
Source0: https://github.com/%{name}/%{name}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
Source1: jellyfin.service
Source2: jellyfin.env
Source3: jellyfin.sudoers
Source4: restart.sh
Source5: https://github.com/mono/taglib-sharp/archive/%{taglib_commit}/taglib-sharp-%{taglib_shortcommit}.tar.gz
Source6: update-db.sh
%{?systemd_requires}
BuildRequires: systemd
Requires(pre): shadow-utils
BuildRequires: libcurl-devel, fontconfig-devel, freetype-devel, openssl-devel, glibc-devel, libicu-devel
Requires: libcurl, fontconfig, freetype, openssl, glibc libicu
# Requirements not packaged in main repos
# COPR @dotnet-sig/dotnet
BuildRequires: dotnet-sdk-2.2
# RPMfusion free
Requires: ffmpeg
# For the update-db-paths.sh script to fix emby paths to jellyfin
Recommends: sqlite
# Fedora has openssl1.1 which is incompatible with dotnet
%{?fedora:Requires: compat-openssl10}
# Disable Automatic Dependency Processing for Centos
%{?el7:AutoReqProv: no}
%description
Jellyfin is a free software media system that puts you in control of managing and streaming your media.
%prep
%autosetup -n %{name}-%{commit}
pushd ThirdParty
tar xf %{S:5}
rm -rf taglib-sharp
mv taglib-sharp-%{taglib_commit} taglib-sharp
popd
%build
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
dotnet build --runtime linux-x64
%install
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
dotnet publish --configuration Release --output='%{buildroot}%{_libdir}/jellyfin' --self-contained --runtime linux-x64
%{__install} -D -m 0644 LICENSE %{buildroot}%{_datadir}/licenses/%{name}/LICENSE
%{__install} -D -m 0644 debian/conf/jellyfin.service.conf %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d/override.conf
%{__mkdir} -p %{buildroot}%{_bindir}
tee %{buildroot}%{_bindir}/jellyfin << EOF
#!/bin/sh
exec %{_libdir}/%{name}/%{name} \${@}
EOF
%{__mkdir} -p %{buildroot}%{_sharedstatedir}/jellyfin
%{__install} -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
%{__install} -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
%{__install} -D -m 0600 %{SOURCE3} %{buildroot}%{_datadir}/%{name}/%{name}-sudoers
%{__install} -D -m 0750 %{SOURCE4} %{buildroot}%{_libexecdir}/%{name}/restart.sh
%{__install} -D -m 0755 %{SOURCE6} %{buildroot}%{_datadir}/%{name}/update-db-paths.sh
%files
%{_libdir}/%{name}/dashboard-ui/*
%attr(755,root,root) %{_bindir}/%{name}
%attr(644,root,root) %{_libdir}/%{name}/*.json
%attr(644,root,root) %{_libdir}/%{name}/*.pdb
%attr(755,root,root) %{_libdir}/%{name}/*.dll
%attr(755,root,root) %{_libdir}/%{name}/*.so
%attr(755,root,root) %{_libdir}/%{name}/*.a
%attr(755,root,root) %{_libdir}/%{name}/createdump
%attr(755,root,root) %{_libdir}/%{name}/jellyfin
%attr(644,root,root) %{_libdir}/%{name}/sosdocsunix.txt
%attr(644,root,root) %{_unitdir}/%{name}.service
%attr(600,root,root) %{_datadir}/%{name}/%{name}-sudoers
%attr(755,root,root) %{_datadir}/%{name}/update-db-paths.sh
%attr(750,root,root) %{_libexecdir}/%{name}/restart.sh
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%config(noreplace) %{_sysconfdir}/systemd/system/%{name}.service.d/override.conf
%attr(-,jellyfin,jellyfin) %dir %{_sharedstatedir}/jellyfin
%if 0%{?fedora}
%license LICENSE
%else
%{_datadir}/licenses/%{name}/LICENSE
%endif
%pre
getent group jellyfin >/dev/null || groupadd -r jellyfin
getent passwd jellyfin >/dev/null || \
useradd -r -g jellyfin -d %{_sharedstatedir}/jellyfin -s /sbin/nologin \
-c "Jellyfin default user" jellyfin
exit 0
%post
%systemd_post jellyfin.service
%preun
%systemd_preun jellyfin.service
%postun
%systemd_postun_with_restart jellyfin.service
%posttrans
echo -e "\e[31m
To enable In-App service control copy the sudo-policy (be sure to check it contents) with:
install -D -m 0600 %{_datadir}/%{name}/%{name}-sudoers %{_sysconfdir}/sudoers.d/%{name}-sudoers
and uncomment JELLYFIN_RESTART_OPT in %{_sysconfdir}/sysconfig/%{name} \e[0m" >> /dev/stderr
%changelog
* Sat Jan 05 2019 Thomas Büttner <thomas@vergesslicher.tech> - 3.5.2-3
- Added script for database migration
* Fri Jan 04 2019 Thomas Büttner <thomas@vergesslicher.tech> - 3.5.2-2
- Moved sudoers policy and added a note for In-App service control
- Set Restart=on-failure in jellyfin.service
* Thu Jan 03 2019 Thomas Büttner <thomas@vergesslicher.tech> - 3.5.2-1
- Initial RPM package

@ -0,0 +1,19 @@
# Allow jellyfin group to start, stop and restart itself
Cmnd_Alias RESTARTSERVER_SYSTEMD = /usr/bin/systemctl restart jellyfin, /bin/systemctl restart jellyfin
Cmnd_Alias STARTSERVER_SYSTEMD = /usr/bin/systemctl start jellyfin, /bin/systemctl start jellyfin
Cmnd_Alias STOPSERVER_SYSTEMD = /usr/bin/systemctl stop jellyfin, /bin/systemctl stop jellyfin
%jellyfin ALL=(ALL) NOPASSWD: RESTARTSERVER_SYSTEMD
%jellyfin ALL=(ALL) NOPASSWD: STARTSERVER_SYSTEMD
%jellyfin ALL=(ALL) NOPASSWD: STOPSERVER_SYSTEMD
Defaults!RESTARTSERVER_SYSTEMD !requiretty
Defaults!STARTSERVER_SYSTEMD !requiretty
Defaults!STOPSERVER_SYSTEMD !requiretty
# Uncomment to allow the server to mount iso images
# %jellyfin ALL=(ALL) NOPASSWD: /bin/mount
# %jellyfin ALL=(ALL) NOPASSWD: /bin/umount
Defaults:%jellyfin !requiretty

@ -0,0 +1,6 @@
#!/bin/sh
NAME=jellyfin
restart_cmd="/usr/bin/systemctl restart ${NAME}"
echo "sleep 2; sudo $restart_cmd > /dev/null 2>&1" | at now > /dev/null 2>&1
exit 0

@ -0,0 +1,12 @@
#!/bin/sh
db=${1:-/var/lib/jellyfin/data/library.db}
embypath=${2:-/var/lib/emby-server}
jellyfinpath=${3:-/var/lib/jellyfin}
sqlite3 ${db} << SQL
UPDATE Chapters2
SET ImagePath=REPLACE(ImagePath, '${embypath}', '${jellyfinpath}');
UPDATE TypedBaseItems
SET Path=REPLACE(Path, '${embypath}', '${jellyfinpath}');
UPDATE TypedBaseItems
SET data=REPLACE(data, '${embypath}', '${jellyfinpath}');
SQL
Loading…
Cancel
Save