Merge pull request #335 from EraYaN/build-system-consolidation

Build scripts and build system consolidation.
This commit is contained in:
Andrew Rabert 2019-01-14 20:06:28 -05:00 committed by GitHub
commit 8ea0c72070
78 changed files with 1006 additions and 162 deletions

View File

@ -3,3 +3,6 @@
Dockerfile
CONTRIBUTORS.md
README.md
deployment/*/dist
deployment/*/pkg-dist
deployment/collect-dist/

35
.gitignore vendored
View File

@ -1,5 +1,3 @@
!*
.directory
#################
@ -49,6 +47,8 @@ ProgramData-UI*/
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
.vs/
# User-specific files
*.suo
*.user
@ -204,7 +204,6 @@ $RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
@ -234,23 +233,33 @@ pip-log.txt
#Mr Developer
.mr.developer.cfg
/.vs
##########
# Rider
##########
.idea/
##########
# Visual Studio Code
##########
.vscode/
#########################
# Debian build artifacts
# Build artifacts
#########################
debian/.debhelper/
debian/*.debhelper
debian/debhelper-build-stamp
debian/files
debian/jellyfin.substvars
debian/jellyfin/
# Artifacts for debian-x64
deployment/debian-package-x64/pkg-src/.debhelper/
deployment/debian-package-x64/pkg-src/*.debhelper
deployment/debian-package-x64/pkg-src/debhelper-build-stamp
deployment/debian-package-x64/pkg-src/files
deployment/debian-package-x64/pkg-src/jellyfin.substvars
deployment/debian-package-x64/pkg-src/jellyfin/
# Don't ignore the debian/bin folder
!debian/bin/
!deployment/debian-package-x64/pkg-src/bin/
deployment/**/dist/
deployment/**/pkg-dist/
deployment/**/pkg-dist-tmp/
deployment/collect-dist/

View File

@ -26,6 +26,6 @@ COPY --from=builder /jellyfin /jellyfin
COPY --from=ffmpeg /ffmpeg-bin/* /usr/bin/
EXPOSE 8096
VOLUME /config /media
RUN apt update \
&& apt install -y libfontconfig1 # needed for Skia
RUN apt-get update \
&& apt-get install -y libfontconfig1 --no-install-recommends # needed for Skia
ENTRYPOINT dotnet /jellyfin/jellyfin.dll -programdata /config

View File

@ -3,6 +3,7 @@ ARG DOTNET_VERSION=3.0
FROM microsoft/dotnet:${DOTNET_VERSION}-sdk as builder
WORKDIR /repo
COPY . .
#TODO Remove or update the sed line when we update dotnet version.
RUN export DOTNET_CLI_TELEMETRY_OPTOUT=1 \
&& find . -type f -exec sed -i 's/netcoreapp2.1/netcoreapp3.0/g' {} \; \
&& dotnet clean \
@ -14,7 +15,7 @@ RUN export DOTNET_CLI_TELEMETRY_OPTOUT=1 \
FROM microsoft/dotnet:${DOTNET_VERSION}-runtime
COPY --from=builder /jellyfin /jellyfin
EXPOSE 8096
RUN apt update \
&& apt install -y ffmpeg
RUN apt-get update \
&& apt-get install -y ffmpeg
VOLUME /config /media
ENTRYPOINT dotnet /jellyfin/jellyfin.dll -programdata /config

View File

@ -1,24 +0,0 @@
#!/usr/bin/env sh
# Build a Jellyfin .deb file with Docker on Linux
# Places the output .deb file in the parent directory
set -o errexit
set -o xtrace
set -o nounset
package_temporary_dir="`mktemp -d`"
current_user="`whoami`"
image_name="jellyfin-debuild"
cleanup() {
set +o errexit
docker image rm $image_name --force
rm -rf "$package_temporary_dir"
}
trap cleanup EXIT INT
docker build . -t "$image_name" -f ./Dockerfile.debian_package
docker run --rm -v "$package_temporary_dir:/temp" "$image_name" cp -r /dist /temp/
sudo chown -R "$current_user" "$package_temporary_dir"
mv "$package_temporary_dir"/dist/*.deb ../

View File

@ -1 +0,0 @@
tar-ignore = ".git*"

8
deployment/README.md Normal file
View File

@ -0,0 +1,8 @@
# Build scripts
All `build.sh` and `package.sh` scripts are for *nix platforms (or WSL on Windows 10).
After running both, check the `*/pkg-dist/` folders for the archives and packages.
`build_all.sh` will invoke every build and package script.
Use `collect_all.sh` to copy all artifact to one directory for easy uploading.

21
deployment/clean.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
# Execute every clean.sh scripts in every folder.
echo "Running for platforms '$@'."
for directory in */ ; do
platform=`basename "${directory}"`
if [[ $@ == *"$platform"* || $@ = *"all"* ]]; then
echo "Processing ${platform}"
pushd "$platform"
if [ -f clean.sh ]; then
echo ./clean.sh
fi
popd
else
echo "Skipping $platform."
fi
done
rm -rf ./collect-dist

20
deployment/collect_all.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
source common.build.sh
VERSION=`get_version ..`
COLLECT_DIR="./collect-dist"
mkdir -p ./collect-dist
DIRS=`find . -type d -name "pkg-dist"`
while read directory
do
echo "Collecting everything from '$directory'.."
PLATFORM=$(basename "$(dirname "$directory")")
# Copy all artifacts with extensions tar.gz, deb, exe, zip, rpm and add the platform name to resolve any duplicates.
find $directory \( -name "jellyfin*.tar.gz" -o -name "jellyfin*.deb" -o -name "jellyfin*.rpm" -o -name "jellyfin*.zip" -o -name "jellyfin*.exe" \) -exec sh -c 'cp "$1" "'${COLLECT_DIR}'/jellyfin_'${PLATFORM}'_${1#*jellyfin}"' _ {} \;
done <<< "${DIRS}"

108
deployment/common.build.sh Executable file
View File

@ -0,0 +1,108 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
DEFAULT_BUILD_CONTEXT="../.."
DEFAULT_ROOT="."
DEFAULT_DOTNETRUNTIME="framework"
DEFAULT_CONFIG="Release"
DEFAULT_OUTPUT_DIR="dist/jellyfin-git"
DEFAULT_PKG_DIR="pkg-dist"
DEFAULT_DOCKERFILE="Dockerfile"
DEFAULT_IMAGE_TAG="jellyfin:"`git rev-parse --abbrev-ref HEAD`
# Run a build
build_jellyfin()
(
ROOT=${1-$DEFAULT_ROOT}
CONFIG=${2-$DEFAULT_CONFIG}
DOTNETRUNTIME=${3-$DEFAULT_DOTNETRUNTIME}
OUTPUT_DIR=${4-$DEFAULT_OUTPUT_DIR}
echo -e "${CYAN}Building jellyfin in '${ROOT}' for ${DOTNETRUNTIME} with configuration ${CONFIG} and output directory '${OUTPUT_DIR}'.${NC}"
if [[ $DOTNETRUNTIME == 'framework' ]]; then
dotnet publish "${ROOT}" --configuration "${CONFIG}" --output="${OUTPUT_DIR}"
else
dotnet publish "${ROOT}" --configuration "${CONFIG}" --output="${OUTPUT_DIR}" --self-contained --runtime ${DOTNETRUNTIME}
fi
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo -e "${GREEN}[DONE] Build jellyfin in '${ROOT}' for ${DOTNETRUNTIME} with configuration ${CONFIG} and output directory '${OUTPUT_DIR}' complete.${NC}"
else
echo -e "${RED}[FAIL] Build jellyfin in '${ROOT}' for ${DOTNETRUNTIME} with configuration ${CONFIG} and output directory '${OUTPUT_DIR}' FAILED.${NC}"
fi
)
# Run a docker
build_jellyfin_docker()
(
BUILD_CONTEXT=${1-$DEFAULT_BUILD_CONTEXT}
DOCKERFILE=${2-$DEFAULT_DOCKERFILE}
IMAGE_TAG=${3-$DEFAULT_IMAGE_TAG}
echo -e "${CYAN}Building jellyfin docker image in '${BUILD_CONTEXT}' with Dockerfile '${DOCKERFILE}' and tag '${IMAGE_TAG}'.${NC}"
docker build -t ${IMAGE_TAG} -f ${DOCKERFILE} ${BUILD_CONTEXT}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo -e "${GREEN}[DONE] Building jellyfin docker image in '${BUILD_CONTEXT}' with Dockerfile '${DOCKERFILE}' and tag '${IMAGE_TAG}' complete.${NC}"
else
echo -e "${RED}[FAIL] Building jellyfin docker image in '${BUILD_CONTEXT}' with Dockerfile '${DOCKERFILE}' and tag '${IMAGE_TAG}' FAILED.${NC}"
fi
)
# Clean a build
clean_jellyfin()
(
local ROOT=${1-$DEFAULT_ROOT}
local CONFIG=${2-$DEFAULT_CONFIG}
local OUTPUT_DIR=${3-$DEFAULT_OUTPUT_DIR}
local PKG_DIR=${4-$DEFAULT_PKG_DIR}
echo -e "${CYAN}Cleaning jellyfin in '${ROOT}'' with configuration ${CONFIG} and output directory '${OUTPUT_DIR}'.${NC}"
echo -e "${CYAN}Deleting '${OUTPUT_DIR}'${NC}"
rm -rf "$OUTPUT_DIR"
echo -e "${CYAN}Deleting '${PKG_DIR}'${NC}"
rm -rf "$PKG_DIR"
dotnet clean "${ROOT}" -maxcpucount:1 --configuration ${CONFIG}
local EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo -e "${GREEN}[DONE] Clean jellyfin in '${ROOT}' with configuration ${CONFIG} and output directory '${OUTPUT_DIR}' complete.${NC}"
else
echo -e "${RED}[FAIL] Clean jellyfin in '${ROOT}' with configuration ${CONFIG} and output directory '${OUTPUT_DIR}' failed.${NC}"
fi
)
# Parse the version from the AssemblyVersion
get_version()
(
local ROOT=${1-$DEFAULT_ROOT}
grep "AssemblyVersion" ${ROOT}/SharedVersion.cs | sed -E 's/\[assembly: ?AssemblyVersion\("([0-9\.]+)"\)\]/\1/' | sed -E 's/.0$//'
)
# Packages the output folder into an archive.
package_portable()
(
local ROOT=${1-$DEFAULT_ROOT}
local OUTPUT_DIR=${2-$DEFAULT_OUTPUT_DIR}
local PKG_DIR=${3-$DEFAULT_PKG_DIR}
# Package portable build result
if [ -d ${OUTPUT_DIR} ]; then
echo -e "${CYAN}Packaging build in '${OUTPUT_DIR}' for `basename "${OUTPUT_DIR}"` to '${PKG_DIR}' with root '${ROOT}'.${NC}"
mkdir -p ${PKG_DIR}
tar -zcvf "${PKG_DIR}/`basename "${OUTPUT_DIR}"`.portable.tar.gz" -C "`dirname "${OUTPUT_DIR}"`" "`basename "${OUTPUT_DIR}"`"
local EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo -e "${GREEN}[DONE] Packaging build in '${OUTPUT_DIR}' for `basename "${OUTPUT_DIR}"` to '${PKG_DIR}' with root '${ROOT}' complete.${NC}"
else
echo -e "${RED}[FAIL] Packaging build in '${OUTPUT_DIR}' for `basename "${OUTPUT_DIR}"` to '${PKG_DIR}' with root '${ROOT}' FAILED.${NC}"
fi
else
echo -e "${RED}[FAIL] Build artifacts do not exist for ${OUTPUT_DIR}. Run build.sh first.${NC}"
fi
)

View File

@ -1,4 +1,6 @@
FROM debian:9
ARG SOURCEDIR=/repo
ENV DEB_BUILD_OPTIONS=noddebs
# https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current
RUN apt-get update \
@ -11,12 +13,11 @@ RUN apt-get update \
&& chown root:root /etc/apt/sources.list.d/microsoft-prod.list \
&& apt-get update
WORKDIR /repo
WORKDIR ${SOURCEDIR}
COPY . .
COPY ./deployment/debian-package-x64/pkg-src ./debian
RUN yes|mk-build-deps -i \
&& dpkg-buildpackage -us -uc \
&& mkdir /dist \
&& mv /jellyfin*deb /dist
RUN yes | mk-build-deps -i debian/control \
&& dpkg-buildpackage -us -uc
WORKDIR /dist
WORKDIR /

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
# TODO get the version in the package automatically. And using the changelog to decide the debian package suffix version.
# Build a Jellyfin .deb file with Docker on Linux
# Places the output .deb file in the parent directory
package_temporary_dir="`pwd`/pkg-dist-tmp"
output_dir="`pwd`/pkg-dist"
current_user="`whoami`"
image_name="jellyfin-debuild"
cleanup() {
set +o errexit
docker image rm $image_name --force
rm -rf "$package_temporary_dir"
}
trap cleanup EXIT INT
docker build ../.. -t "$image_name" -f ./Dockerfile --build-arg SOURCEDIR="/jellyfin-${VERSION}"
mkdir -p "$package_temporary_dir"
mkdir -p "$output_dir"
docker run --rm -v "$package_temporary_dir:/temp" "$image_name" sh -c 'find / -maxdepth 1 -type f -name "jellyfin*" -exec mv {} /temp \;'
chown -R "$current_user" "$package_temporary_dir" \
|| sudo chown -R "$current_user" "$package_temporary_dir"
mv "$package_temporary_dir"/* "$output_dir"

View File

@ -3,4 +3,4 @@ pristine-tar = False
cleaner = fakeroot debian/rules clean
[import-orig]
filter = [ ".git*", ".hg*" ]
filter = [ ".git*", ".hg*", ".vs*", ".vscode*" ]

View File

@ -2,7 +2,7 @@
CONFIG := Release
TERM := xterm
SHELL := /bin/bash
DOTNETRUNTIME := linux-x64
DOTNETRUNTIME := debian-x64
export DH_VERBOSE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
@ -16,8 +16,8 @@ override_dh_auto_test:
override_dh_clistrip:
override_dh_auto_build:
dotnet publish --configuration $(CONFIG) --output='$(CURDIR)/usr/lib/jellyfin/bin' --self-contained --runtime $(DOTNETRUNTIME)
dotnet publish --configuration $(CONFIG) --output='$(CURDIR)/usr/lib/jellyfin/bin' --self-contained --runtime $(DOTNETRUNTIME) Jellyfin.Server
override_dh_auto_clean:
dotnet clean -maxcpucount:1 --configuration $(CONFIG) || true
dotnet clean -maxcpucount:1 --configuration $(CONFIG) Jellyfin.Server || true
rm -rf '$(CURDIR)/usr'

View File

@ -0,0 +1,11 @@
tar-ignore='.git*'
tar-ignore='**/.git'
tar-ignore='**/.hg'
tar-ignore='**/.vs'
tar-ignore='**/.vscode'
tar-ignore='deployment'
tar-ignore='**/bin'
tar-ignore='**/obj'
tar-ignore='**/.nuget'
tar-ignore='*.deb'
tar-ignore='ThirdParty'

7
deployment/debian-x64/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
build_jellyfin ../../Jellyfin.Server Release debian-x64 `pwd`/dist/jellyfin_${VERSION}

7
deployment/debian-x64/clean.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
package_portable ../.. `pwd`/dist/jellyfin_${VERSION}

12
deployment/docker/build.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
build_jellyfin_docker ../.. ../../Dockerfile jellyfin:amd64-${VERSION}
build_jellyfin_docker ../.. ../../Dockerfile.arm jellyfin:arm-${VERSION}
#build_jellyfin_docker ../.. ../../Dockerfile.arm64v8 jellyfin:arm64v8-${VERSION}
#build_jellyfin_docker ../.. ../../Dockerfile.arm32v7 jellyfin:arm32v7-${VERSION}

12
deployment/docker/package.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
docker manifest create jellyfin:${VERSION} jellyfin:amd64-${VERSION} jellyfin:arm32v7-${VERSION} jellyfin:arm64v8-${VERSION}
docker manifest annotate jellyfin:amd64-${VERSION} --os linux --arch amd64
#docker manifest annotate jellyfin:arm32v7-${VERSION} --os linux --arch arm --variant armv7
#docker manifest annotate jellyfin:arm64v8-${VERSION} --os linux --arch arm64 --variant armv8
#TODO publish.sh - docker manifest push jellyfin:${VERSION}

View File

@ -0,0 +1,15 @@
FROM fedora:29
ARG HOME=/build
RUN mkdir /build && \
dnf install -y @buildsys-build rpmdevtools dnf-plugins-core && \
dnf copr enable -y @dotnet-sig/dotnet && \
rpmdev-setuptree
WORKDIR /build/rpmbuild
COPY ./deployment/fedora-package-x64/pkg-src/jellyfin.spec SPECS
COPY ./deployment/fedora-package-x64/pkg-src/ SOURCES
RUN spectool -g -R SPECS/jellyfin.spec && \
rpmbuild -bs SPECS/jellyfin.spec && \
dnf build-dep -y SRPMS/jellyfin-*.src.rpm && \
rpmbuild -bb SPECS/jellyfin.spec;

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

View File

@ -0,0 +1,83 @@
#!/usr/bin/env sh
source ../common.build.sh
VERSION=`get_version ../..`
# TODO get the version in the package automatically. And using the changelog to decide the debian package suffix version.
# Build a Jellyfin .rpm file with Docker on Linux
# Places the output .rpm file in the parent directory
set -o errexit
set -o xtrace
set -o nounset
package_temporary_dir="`pwd`/pkg-dist-tmp"
output_dir="`pwd`/pkg-dist"
pkg_src_dir="`pwd`/pkg-src"
current_user="`whoami`"
image_name="jellyfin-rpmbuild"
cleanup() {
set +o errexit
docker image rm $image_name --force
rm -rf "$package_temporary_dir"
rm -rf "$pkg_src_dir/jellyfin-${VERSION}.tar.gz"
}
trap cleanup EXIT INT
GNU_TAR=1
mkdir -p "$package_temporary_dir"
echo "Bundling all sources for RPM build."
tar \
--transform "s,^\.,jellyfin-${VERSION}" \
--exclude='.git*' \
--exclude='**/.git' \
--exclude='**/.hg' \
--exclude='**/.vs' \
--exclude='**/.vscode' \
--exclude='deployment' \
--exclude='**/bin' \
--exclude='**/obj' \
--exclude='**/.nuget' \
--exclude='*.deb' \
--exclude='*.rpm' \
-Jcvf \
"$package_temporary_dir/jellyfin-${VERSION}.tar.xz" \
-C "../.." \
./ || true && GNU_TAR=0
if [ $GNU_TAR -eq 0 ]; then
echo "The installed tar binary did not support --transform. Using workaround."
mkdir -p "$package_temporary_dir/jellyfin-${VERSION}"
# Not GNU tar
tar \
--exclude='.git*' \
--exclude='**/.git' \
--exclude='**/.hg' \
--exclude='**/.vs' \
--exclude='**/.vscode' \
--exclude='deployment' \
--exclude='**/bin' \
--exclude='**/obj' \
--exclude='**/.nuget' \
--exclude='*.deb' \
--exclude='*.rpm' \
-zcf \
"$package_temporary_dir/jellyfin-${VERSION}/jellyfin.tar.gz" \
-C "../.." \
./
echo "Extracting filtered package."
tar -xzf "$package_temporary_dir/jellyfin-${VERSION}/jellyfin.tar.gz" -C "$package_temporary_dir/jellyfin-${VERSION}"
echo "Removing filtered package."
rm "$package_temporary_dir/jellyfin-${VERSION}/jellyfin.tar.gz"
echo "Repackaging package into final tarball."
tar -zcf "$pkg_src_dir/jellyfin-${VERSION}.tar.gz" -C "$package_temporary_dir" "jellyfin-${VERSION}"
fi
docker build ../.. -t "$image_name" -f ./Dockerfile
mkdir -p "$output_dir"
docker run --rm -v "$package_temporary_dir:/temp" "$image_name" sh -c 'find /build/rpmbuild -maxdepth 3 -type f -name "jellyfin*.rpm" -exec mv {} /temp \;'
chown -R "$current_user" "$package_temporary_dir" \
|| sudo chown -R "$current_user" "$package_temporary_dir"
mv "$package_temporary_dir"/*.rpm "$output_dir"

View File

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

View File

@ -0,0 +1,43 @@
# Jellyfin RPM
## Build Fedora Package with docker
Change into this directory `cd rpm-package`
Run the build script `./build-fedora-rpm.sh`.
Resulting RPM and src.rpm will be in `../../jellyfin-*.rpm`
## ffmpeg
The RPM package for Fedora/CentOS requires some additional repositories 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
```
## ISO mounting
To allow Jellyfin to mount/umount ISO files uncomment these two lines in `/etc/sudoers.d/jellyfin-sudoers`
```
# %jellyfin ALL=(ALL) NOPASSWD: /bin/mount
# %jellyfin ALL=(ALL) NOPASSWD: /bin/umount
```
## 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

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Jellyfin</short>
<description>The Free Software Media System.</description>
<port protocol="tcp" port="8096"/>
<port protocol="tcp" port="8920"/>
<port protocol="udp" port="1900"/>
<port protocol="udp" port="7359"/>
</service>

View File

@ -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"
# Program directories
JELLYFIN_DATA_DIRECTORY="/var/lib/jellyfin"
JELLYFIN_CONFIG_DIRECTORY="/etc/jellyfin"
JELLYFIN_LOG_DIRECTORY="/var/log/jellyfin"
# In-App service control
JELLYFIN_RESTART_OPT="-restartpath /usr/libexec/jellyfin/restart.sh"
# Additional options for the binary
JELLYFIN_ADD_OPTS=""

View File

@ -0,0 +1,7 @@
# Jellyfin systemd configuration options
# Use this file to override the user or environment file location.
[Service]
#User = jellyfin
#EnvironmentFile = /etc/sysconfig/jellyfin

View File

@ -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_DIRECTORY} -configdir ${JELLYFIN_CONFIG_DIRECTORY} -logdir ${JELLYFIN_LOG_DIRECTORY} ${JELLYFIN_RESTART_OPT} ${JELLYFIN_ADD_OPTS} ${JELLYFIN_FFMPEG}
TimeoutSec=15
Restart=on-failure
User=jellyfin
Group=jellyfin
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,139 @@
%global debug_package %{nil}
# jellyfin tag to package
%global gittag v10.0.1
# 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})
AutoReq: no
Name: jellyfin
Version: 10.0.1
Release: 1%{?dist}
Summary: The Free Software Media Browser
License: GPLv2
URL: https://jellyfin.media
Source0: %{name}-%{version}.tar.gz
Source1: jellyfin.service
Source2: jellyfin.env
Source3: jellyfin.sudoers
Source4: restart.sh
Source5: jellyfin.override.conf
Source6: jellyfin-firewalld.xml
%{?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
%{?fedora: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}-%{version}
%build
%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 fedora-x64 Jellyfin.Server
%{__install} -D -m 0644 LICENSE %{buildroot}%{_datadir}/licenses/%{name}/LICENSE
%{__install} -D -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d/override.conf
%{__install} -D -m 0644 Jellyfin.Server/Resources/Configuration/logging.json %{buildroot}%{_sysconfdir}/%{name}/logging.json
%{__mkdir} -p %{buildroot}%{_bindir}
tee %{buildroot}%{_bindir}/jellyfin << EOF
#!/bin/sh
exec %{_libdir}/%{name}/%{name} \${@}
EOF
%{__mkdir} -p %{buildroot}%{_sharedstatedir}/jellyfin
%{__mkdir} -p %{buildroot}%{_sysconfdir}/%{name}
%{__mkdir} -p %{buildroot}%{_var}/log/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}%{_sysconfdir}/sudoers.d/%{name}-sudoers
%{__install} -D -m 0755 %{SOURCE4} %{buildroot}%{_libexecdir}/%{name}/restart.sh
%{__install} -D -m 0644 %{SOURCE6} %{buildroot}%{_prefix}/lib/firewalld/service/%{name}.xml
%files
%{_libdir}/%{name}/jellyfin-web/*
%attr(755,root,root) %{_bindir}/%{name}
%{_libdir}/%{name}/*.json
%{_libdir}/%{name}/*.pdb
%{_libdir}/%{name}/*.dll
%{_libdir}/%{name}/*.so
%{_libdir}/%{name}/*.a
%{_libdir}/%{name}/createdump
# Needs 755 else only root can run it since binary build by dotnet is 722
%attr(755,root,root) %{_libdir}/%{name}/jellyfin
%{_libdir}/%{name}/sosdocsunix.txt
%{_unitdir}/%{name}.service
%{_libexecdir}/%{name}/restart.sh
%{_prefix}/lib/firewalld/service/%{name}.xml
%attr(755,jellyfin,jellyfin) %dir %{_sysconfdir}/%{name}
%config %{_sysconfdir}/sysconfig/%{name}
%config(noreplace) %attr(600,root,root) %{_sysconfdir}/sudoers.d/%{name}-sudoers
%config(noreplace) %{_sysconfdir}/systemd/system/%{name}.service.d/override.conf
%config(noreplace) %attr(644,jellyfin,jellyfin) %{_sysconfdir}/%{name}/logging.json
%attr(-,jellyfin,jellyfin) %dir %{_sharedstatedir}/jellyfin
%attr(-,jellyfin,jellyfin) %dir %{_var}/log/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
# Move existing configuration to /etc/jellyfin and symlink config to /etc/jellyfin
if [ $1 -gt 1 ] ; then
service_state=$(systemctl is-active jellyfin.service)
if [ "${service_state}" = "active" ]; then
systemctl stop jellyfin.service
fi
if [ ! -L %{_sharedstatedir}/%{name}/config ]; then
mv %{_sharedstatedir}/%{name}/config/* %{_sysconfdir}/%{name}/
rmdir %{_sharedstatedir}/%{name}/config
ln -sf %{_sysconfdir}/%{name} %{_sharedstatedir}/%{name}/config
fi
if [ ! -L %{_sharedstatedir}/%{name}/logs ]; then
mv %{_sharedstatedir}/%{name}/logs/* %{_var}/log/jellyfin
rmdir %{_sharedstatedir}/%{name}/logs
ln -sf %{_var}/log/jellyfin %{_sharedstatedir}/%{name}/logs
fi
if [ "${service_state}" = "active" ]; then
systemctl start jellyfin.service
fi
fi
%systemd_post jellyfin.service
%preun
%systemd_preun jellyfin.service
%postun
%systemd_postun_with_restart jellyfin.service
%changelog
* Fri Jan 11 2019 Thomas Büttner <thomas@vergesslicher.tech> - 10.0.2-1
- TODO Changelog for 10.0.2

View File

@ -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

View File

@ -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

8
deployment/framework/build.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
#Magic word framework will create a non self contained build
build_jellyfin ../../Jellyfin.Server Release framework `pwd`/dist/jellyfin_${VERSION}

7
deployment/framework/clean.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
package_portable ../.. `pwd`/dist/jellyfin_${VERSION}

7
deployment/linux-x64/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
build_jellyfin ../../Jellyfin.Server Release linux-x64 `pwd`/dist/jellyfin_${VERSION}

7
deployment/linux-x64/clean.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
package_portable ../.. `pwd`/dist/jellyfin_${VERSION}

34
deployment/make.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
git submodule update --init --recursive
pushd ../Jellyfin.Versioning
./update-version
popd
#TODO enabled proper flag parsing for enabling and disabling building, signing, packaging and publishing
# Execute all build.sh, package.sh, sign.sh and publish.sh scripts in every folder. In that order. Script should check for artifacts themselves.
echo "Running for platforms '$@'."
for directory in */ ; do
platform=`basename "${directory}"`
if [[ $@ == *"$platform"* || $@ = *"all"* ]]; then
echo "Processing ${platform}"
pushd "$platform"
if [ -f build.sh ]; then
./build.sh
fi
if [ -f package.sh ]; then
./package.sh
fi
if [ -f sign.sh ]; then
./sign.sh
fi
if [ -f publish.sh ]; then
./publish.sh
fi
popd
else
echo "Skipping $platform."
fi
done

7
deployment/osx-x64/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
build_jellyfin ../../Jellyfin.Server Release osx-x64 `pwd`/dist/jellyfin_${VERSION}

7
deployment/osx-x64/clean.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

7
deployment/osx-x64/package.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
package_portable ../.. `pwd`/dist/jellyfin_${VERSION}

7
deployment/ubuntu-x64/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
build_jellyfin ../../Jellyfin.Server Release ubuntu-x64 `pwd`/dist/jellyfin_${VERSION}

7
deployment/ubuntu-x64/clean.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
package_portable ../.. `pwd`/dist/jellyfin_${VERSION}

View File

@ -0,0 +1,15 @@
# docker-templates
### Installation:
Open unRaid GUI (at least unRaid 6.5)
Click on the Docker tab
Add the following line under "Template Repositories"
https://github.com/jellyfin/jellyfin/blob/master/deployment/unraid/docker-templates
Click save than click on Add Container and select jellyfin.
Adjust to your paths to your liking and off you go!

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Containers>
<TemplateURL>https://raw.githubusercontent.com/jellyfin/jellyfin/deployment/unraid/docker-templates/jellyfin.xml</TemplateURL>
<Beta>False</Beta>
<Category>MediaApp:Video MediaApp:Music MediaApp:Photos MediaServer:Video MediaServer:Music MediaServer:Photos</Category>
<Name>JellyFin</Name>
<Description>
JellyFin is The Free Software Media Browser Converted By Community Applications Always verify this template (and values) against the dockerhub support page for the container!![br][br]
You can add as many mount points as needed for recordings, movies ,etc. [br][br]
[b][span style='color: #E80000;']Directions:[/span][/b][br]
[b]/config[/b] : this is where Jellyfin will store it's databases and configuration.[br][br]
[b]Port[/b] : This is the default port for Jellyfin. (Will add ssl port later)[br][br]
[b]Media[/b] : This is the mounting point of your media. When you access it in Jellyfin it will be /media or whatever you chose for a mount point
[b]Tip:[/b] You can add more volume mappings if you wish Jellyfin has access to it.
</Description>
<Overview>
Jellyfin Server is a home media server built on top of other popular open source technologies such as Service Stack, jQuery, jQuery mobile, and Mono and will remain completely free!
</Overview>
<Support>https://www.reddit.com/r/jellyfin/</Support>
<Registry>https://hub.docker.com/r/jellyfin/jellyfin/</Registry>
<GitHub>https://github.com/jellyfin/jellyfin/></GitHub>
<Repository>jellyfin/jellyfin</Repository>
<Project>https://jellyfin.media/</Project>
<BindTime>true</BindTime>
<Privileged>false</Privileged>
<Networking>
<Mode>host</Mode>
<Publish>
<Port>
<HostPort>8096</HostPort>
<ContainerPort>8096</ContainerPort>
<Protocol>tcp</Protocol>
</Port>
</Publish>
</Networking>
<Data>
<Volume>
<HostDir>/mnt/cache/appdata/config</HostDir>
<ContainerDir>/config</ContainerDir>
<Mode>rw</Mode>
</Volume>
<Volume>
<HostDir>/mnt/user</HostDir>
<ContainerDir>/media</ContainerDir>
<Mode>rw</Mode>
</Volume>
</Data>
<WebUI>http://[IP]:[PORT:8096]/</WebUI>
<Icon>https://raw.githubusercontent.com/binhex/docker-templates/master/binhex/images/emby-icon.png</Icon>
<ExtraParams></ExtraParams>
</Containers>

7
deployment/win-x64/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
build_jellyfin ../../Jellyfin.Server Release win-x64 `pwd`/dist/jellyfin_${VERSION}

7
deployment/win-x64/clean.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

9
deployment/win-x64/package.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
package_portable ../.. `pwd`/dist/jellyfin_${VERSION}
#TODO setup and maybe change above code to produce the Windows native zip format.

7
deployment/win-x86/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
build_jellyfin ../../Jellyfin.Server Release win-x86 `pwd`/dist/jellyfin_${VERSION}

7
deployment/win-x86/clean.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}

9
deployment/win-x86/package.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
source ../common.build.sh
VERSION=`get_version ../..`
package_portable ../.. `pwd`/dist/jellyfin_${VERSION}
#TODO setup and maybe change above code to produce the Windows native zip format.