Skip to content

Commit

Permalink
Add proper multi-dist build process
Browse files Browse the repository at this point in the history
Adds the ability to configure and build per-release deb files that
can be used effectively with reprepro to provide compatibility
across distros and multiple architectures.

The package contains a set of static, single-binary ffmpeg and
ffprobe binaries that can be used instead of any system ffmpeg
packages, for whatever reason. ffmpeg 4.0.3 was chosen as the
latest Jellyfin-supported version.

The resulting binary files are located in `/usr/share` rather than
`/usr/bin`, so we don't need to `Conflicts` with system ffmpeg
packages. It does require various shared dependencies, following
as closely as possible (while compatible with all supported
releases) the default configurations, all of which should be
available on all releases and architectures by default (as would
the system ffmpeg).

A Docker-based infrastructure similar to the main Jelyfin package
build infrastructure is included to build the various packages
for the supported releases and architectures. The entrypoint
for users cloning the repo is `build`.

This configuration disables all tests as a number of them fail
arbitrarily for unknown reasons on armhf, but not amd64. This might
not be ideal long-term but provides a temporary solution. Reenabling
tests can be done by removing the `override_dh_auto_test:` line in
the `debian/rules` file.
  • Loading branch information
joshuaboniface committed Feb 26, 2019
1 parent a9f9024 commit 0966a03
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 105 deletions.
23 changes: 23 additions & 0 deletions Dockerfile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM DISTRO
# Docker build arguments
ARG SOURCE_DIR=/ffmpeg
ARG ARTIFACT_DIR=/dist
# Docker run environment
ENV ARCH=BUILD_ARCHITECTURE
ENV GCC_VER=GCC_RELEASE_VERSION
ENV SOURCE_DIR=/ffmpeg
ENV ARTIFACT_DIR=/dist
ENV DEB_BUILD_OPTIONS=noddebs

# Prepare Debian build environment
RUN apt-get update \
&& apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv equivs

# Link to docker-build script
RUN ln -sf ${SOURCE_DIR}/docker-build.sh /docker-build.sh

VOLUME ${ARTIFACT_DIR}/

COPY . ${SOURCE_DIR}/

ENTRYPOINT ["/docker-build.sh"]
9 changes: 9 additions & 0 deletions Dockerfile.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/make
DISTRO=stretch
GCC_VER=6
ARCH=amd64
.PHONY: Dockerfile
Dockerfile: Dockerfile.in
sed 's/DISTRO/$(DISTRO)/; s/BUILD_ARCHITECTURE/$(ARCH)/; s/GCC_RELEASE_VERSION/$(GCC_VER)/' $< > $@ || rm -f $@
clean:
rm -f Dockerfile
17 changes: 0 additions & 17 deletions INSTALL.md

This file was deleted.

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ FFmpeg README
FFmpeg is a collection of libraries and tools to process multimedia content
such as audio, video, subtitles and related metadata.

## For Jellyfin

This particular repository is designed to support building a static, portable,
FFMPEG release of 4.0.3 for the [Jellyfin project](https://github.com/jellyfin).

To build packages, use `./build <release> <arch>`, where `release` is one of:
* `stretch` (Debian 9.X "Stretch")
* `buster` (Debian 10.X "Buster")
* `xenial` (Ubuntu 16.04 "Xenial Xerus")
* `bionic` (Ubuntu 18.04 "Bionic Beaver")
* `cosmic` (Ubuntu 18.10 "Cosmic Cuttlefish")

And `arch` is one of:
* `amd64` (Standard 64-bit x86)
* `armhf` (ARMv6, Raspberry Pi)

The build setup requires `docker` support and may use a significant amount of
disk space. Binary releases are available in the [repository](https://repo.jellyfin.org/releases/server).

For older Ubuntu releases in between these officially supported versions, the
oldest should generally be compatible.

The build setup will attempt to generate both `amd64` and `armhf` binary packages
if the release supports it.

## Libraries

* `libavcodec` provides implementation of a wider range of codecs.
Expand Down
89 changes: 89 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash

usage() {
echo -e "Build Jellyfin FFMPEG packages"
echo -e " $0 <release> <arch>"
echo -e "Releases: Arches:"
echo -e " * stretch * amd64"
echo -e " * buster * armhf"
echo -e " * xenial"
echo -e " * bionic"
echo -e " * cosmic"
}

if [[ -z ${1} ]]; then
usage
exit 1
fi

cli_release="${1}"
case ${cli_release} in
'stretch')
release="debian:stretch"
gcc_version="6"
;;
'buster')
release="debian:buster"
gcc_version="7"
;;
'xenial')
release="ubuntu:xenial"
gcc_version="6"
;;
'bionic')
release="ubuntu:bionic"
gcc_version="7"
;;
'cosmic')
release="ubuntu:cosmic"
gcc_version="7"
;;
*)
echo "Invalid release."
usage
exit 1
;;
esac

cli_arch="${2}"
case ${cli_arch} in
'amd64')
arch="amd64"
;;
'armhf')
arch="armhf"
;;
*)
echo "Invalid architecture."
usage
exit 1
;;
esac

set -o xtrace
set -o errexit

image_name="jellyfin-ffmpeg-build-${cli_release}"
package_temporary_dir="$( mktemp -d )"
current_user="$( whoami )"

# Trap cleanup for latter sections
cleanup() {
# Clean up the Dockerfile
make -f Dockerfile.make clean
# Remove tempdir
rm -rf "${package_temporary_dir}"
}
trap cleanup EXIT INT

# Generate Dockerfile
make -f Dockerfile.make DISTRO=${release} GCC_VER=${gcc_version} ARCH=${arch}
# Set up the build environment docker image
docker build . -t "${image_name}"
# Build the APKs and copy out to ${package_temporary_dir}
docker run --rm -e "RELEASE=${release}" -v "${package_temporary_dir}:/dist" "${image_name}"
# Correct ownership on the APKs (as current user, then as root if that fails)
chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \
|| sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null
# Move the APKs to the parent directory
mv "${package_temporary_dir}"/deb/* ../
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
jellyfin-ffmpeg (4.0.3-3) unstable; urgency=medium

* Move binaries to /usr/share to keep compat with system ffmpeg

-- Joshua Boniface <[email protected]> Fri, 22 Feb 2019 23:31:07 -0500

jellyfin-ffmpeg (4.0.3-2) unstable; urgency=medium

* Use 'Provides: ffmpeg' to avoid breaking other packages
Expand Down
2 changes: 1 addition & 1 deletion debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11
10
62 changes: 24 additions & 38 deletions debian/control
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
Source: jellyfin-ffmpeg
Section: video
Priority: optional
Maintainer: Jellyfin Team <team@jellyfin.org>
Uploaders: Jellyfin Team <team@jellyfin.org>
Maintainer: Jellyfin Packaging Team <packaging@jellyfin.org>
Uploaders: Jellyfin Packaging Team <packaging@jellyfin.org>
Rules-Requires-Root: no
Homepage: https://ffmpeg.org/
Standards-Version: 4.2.1
Vcs-Git: https://github.com/jellyfin/jellyfin-ffmpeg.git
Vcs-Browser: https://github.com/jellyfin/jellyfin-ffmpeg
Build-Depends-Indep:
# needed to minify the CSS files
cleancss,
# Autogenerated documentation
doxygen,
# needed to create the CSS files for the HTML manuals
node-less
Build-Depends:
# needed for dh
debhelper (>= 11~),
debhelper,
# for build-profile support
dpkg-dev (>= 1.17.14),
dpkg-dev,
# --enable-libflite
flite1-dev,
# --enable-frei0r
frei0r-plugins-dev <!pkg.ffmpeg.stage1>,
frei0r-plugins-dev,
# --enable-ladspa
ladspa-sdk,
# --enable-libaom
libaom-dev,
# libaom-dev,
# --enable-libass
libass-dev,
# --enable-libbluray
Expand All @@ -41,15 +34,15 @@ Build-Depends:
# --enable-libcdio
libcdio-paranoia-dev,
# --enable-libchromaprint
libchromaprint-dev <!pkg.ffmpeg.stage1>,
libchromaprint-dev,
# --enable-libcodec2
libcodec2-dev,
# autodetected 'crystalhd'
libcrystalhd-dev [amd64 i386],
# libcrystalhd-dev,
# --enable-libdc1394
libdc1394-22-dev [linux-any],
libdc1394-22-dev,
# --enable-libdrm
libdrm-dev [linux-any],
libdrm-dev,
# --enable-libfontconfig
libfontconfig1-dev,
# --enable-libfreetype
Expand All @@ -66,18 +59,18 @@ Build-Depends:
libgsm1-dev,
# Fails to be detected by configure script, if not also libavc1394-dev is installed.
# --enable-libiec61883
libiec61883-dev [linux-any],
libavc1394-dev [linux-any],
libiec61883-dev,
libavc1394-dev,
# --enable-libjack
libjack-jackd2-dev,
# --enable-lv2
liblilv-dev,
# liblilv-dev,
# autodetected for the tiff decoder
liblzma-dev,
# --enable-libmp3lame
libmp3lame-dev,
# --enable-libmysofa
libmysofa-dev,
# libmysofa-dev,
# --enable-openal
libopenal-dev,
# --enable-omx
Expand All @@ -87,11 +80,11 @@ Build-Depends:
# --enable-libopencore_amrwb
libopencore-amrwb-dev,
# --enable-libopencv
libopencv-imgproc-dev <!pkg.ffmpeg.stage1>,
libopencv-imgproc-dev,
# --enable-libopenjpeg
libopenjp2-7-dev (>= 2.1),
libopenjp2-7-dev,
# --enable-libopenmpt
libopenmpt-dev,
# libopenmpt-dev,
# --enable-libopus
libopus-dev,
# --enable-libpulse
Expand All @@ -101,11 +94,11 @@ Build-Depends:
# --enable-librsvg
librsvg2-dev,
# autodetected: protocol 'sctp'
libsctp-dev [linux-any],
libsctp-dev,
# --enable-sdl2
libsdl2-dev,
# --enable-libshine
libshine-dev (>= 3.0.0),
libshine-dev,
# --enable-libsnappy
libsnappy-dev,
# --enable-libsoxr
Expand All @@ -124,11 +117,11 @@ Build-Depends:
# # --enable-libv4l2
# libv4l-dev [!hurd-any],
# autodetected: hwaccels 'h263_vaapi, mpeg2_vaapi, vc1_vaapi, h264_vaapi, mpeg4_vaapi, wmv3_vaapi'
libva-dev [!hurd-any],
libva-dev,
# autodetected: hwaccels 'h263_vdpau, mpeg2_vdpau, vc1_vdpau, h264_vdpau, mpeg4_vdpau, wmv3_vdpau, mpeg1_vdpau', decoders 'h264_vdpau, mpeg1_vdpau, mpeg4_vdpau, mpeg_vdpau, vc1_vdpau, wmv3_vdpau'
libvdpau-dev,
# --enable-libvidstab
libvidstab-dev,
# libvidstab-dev,
# --enable-libvo_amrwbenc
libvo-amrwbenc-dev,
# --enable-libvorbis
Expand All @@ -140,9 +133,9 @@ Build-Depends:
# --enable-libwebp
libwebp-dev,
# --enable-libx264
libx264-dev <!pkg.ffmpeg.stage1>,
libx264-dev,
# --enable-libx265
libx265-dev (>= 1.8),
libx265-dev,
# autodetected libxcb-shape
libxcb-shape0-dev,
# autodetected libxcb-shm
Expand Down Expand Up @@ -174,18 +167,11 @@ Build-Depends:
zlib1g-dev

Package: jellyfin-ffmpeg
Architecture: any
Architecture: amd64 armhf
Multi-Arch: foreign
Depends:
${shlibs:Depends},
${misc:Depends}
Breaks: libav-tools (<< 6:12~~),
qt-faststart (<< 7:2.7.1-3~),
winff (<< 1.5.5-5~),
Replaces: libav-tools (<< 6:12~~),
qt-faststart (<< 7:2.7.1-3~)
Conflicts: ffmpeg
Provides: ffmpeg
Description: Tools for transcoding, streaming and playing of multimedia files
FFmpeg is the leading multimedia framework, able to decode, encode, transcode,
mux, demux, stream, filter and play pretty much anything that humans and
Expand Down
4 changes: 2 additions & 2 deletions debian/jellyfin-ffmpeg.install
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ffmpeg usr/bin
ffprobe usr/bin
ffmpeg usr/share/jellyfin-ffmpeg
ffprobe usr/share/jellyfin-ffmpeg
36 changes: 0 additions & 36 deletions debian/qt-faststart.1

This file was deleted.

Loading

0 comments on commit 0966a03

Please sign in to comment.