Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building packages for the recording server #8788

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dfe7230
Use stdeb to build deb packages from Python packages
danxuliu Feb 20, 2023
2789868
Add basic README.md file as it is expected by Python sdist
danxuliu Feb 20, 2023
5862e5b
Set parameters in setup.py not properly read from pyproject.toml
danxuliu Mar 15, 2023
05d25fc
Move packaging related files to its own directory
danxuliu Mar 14, 2023
2c2ee8c
Use strict dependencies for Debian packages
danxuliu Feb 20, 2023
65e9127
Add non Python dependencies to Debian package
danxuliu Feb 24, 2023
7f4ce09
Create build files in their own directory
danxuliu Mar 14, 2023
23b04e5
Add rule to prevent bulding it again if the package is already built
danxuliu Mar 14, 2023
48fc766
Copy deb package to specific output directory
danxuliu Mar 14, 2023
c0310d0
Include OS version in package name
danxuliu Mar 14, 2023
19350fd
Move recording server packaging files to its own directory
danxuliu Mar 14, 2023
78c057b
Extract generic functions
danxuliu Mar 14, 2023
88a6a43
Do not explicitly install setuptools
danxuliu Mar 14, 2023
e27d176
Build Python dependencies not available in repositories
danxuliu Mar 14, 2023
178d848
Make builds reproducible
danxuliu Mar 14, 2023
cc27cf4
Add example configuration in the recording server package
danxuliu Mar 14, 2023
ff34f67
Add executable for the recording server
danxuliu Mar 14, 2023
3ed6f23
Add option to just show the version and exit
danxuliu Mar 15, 2023
dc3b015
Add systemd service for the recording server
danxuliu Mar 15, 2023
22e0394
Add helper script to build the packages
danxuliu Mar 15, 2023
79b4e59
Add dependency and executable for the benchmark tool
danxuliu Sep 11, 2023
f1528c8
Rename package to "nextcloud-talk-recording"
danxuliu Sep 20, 2023
2b27419
Add support for building packages in Debian 11
danxuliu Sep 20, 2023
54a747a
Add documentation for installing the recording server
danxuliu Mar 23, 2023
e6cd521
Fix typo
danxuliu Mar 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@

# JetBrains Fleet settings
/.fleet

# Recording server packages
/recording/packaging/build/
/recording/src/nextcloud/talk/recording/__pycache__/
/recording/src/nextcloud_talk_recording.egg-info/
7 changes: 7 additions & 0 deletions recording/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Nextcloud Talk Recording Server

This is the official recording server to be used with Nextcloud Talk (https://github.com/nextcloud/spreed).

It requires the standalone signaling server for Nextcloud Talk (https://github.com/strukturag/nextcloud-spreed-signaling).

The recording server only provides an HTTP API. It is expected that TLS termination will be provided by an additional component, like a reverse proxy.
6 changes: 3 additions & 3 deletions recording/docs/encoders.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Nevertheless, please note that VP8 and Opus are just the default ones and that t

A benchmark tool is provided to check the resources used by the recorder process as well as the quality of the output file using different configurations.

The benchmark tool does not record an actual call; it plays a video file and records its audio and video (or, optionally, only its audio). This makes possible to easily compare the quality between different configurations, as they can be generated from the same input. There is no default input file, though; a specific file must be provided.
The benchmark tool does not record an actual call; it plays a video file and records its audio and video (or, optionally, only its audio). This makes it possible to easily compare the quality between different configurations, as they can be generated from the same input. There is no default input file, though; a specific file must be provided.

### Usage example

The different options accepted by the benchmark tool can be seen with `python3 -m nextcloud.talk.recording.Benchmark --help`.
The different options accepted by the benchmark tool can be seen with `nextcloud-talk-recording-benchmark --help` (or, if the helper script is not available, directly with `python3 -m nextcloud.talk.recording.Benchmark --help`).

Each run of the benchmark tool records a single video (or audio) file with the given options. Using a Bash script several runs can be batched to check the result of running different options. For example:
```
Expand Down Expand Up @@ -51,6 +51,6 @@ do
# Split the input tuple on ","
IFS="," read FFMPEG_OUTPUT_VIDEO FILENAME_SUFFIX <<< "${TEST}"
# Run the test
python3 -m nextcloud.talk.recording.Benchmark --length 300 --ffmpeg-output-video "${FFMPEG_OUTPUT_VIDEO}" /tmp/recording/files/example.mkv /tmp/recording/files/test-"${FILENAME_SUFFIX}".webm
nextcloud-talk-recording-benchmark --length 300 --ffmpeg-output-video "${FFMPEG_OUTPUT_VIDEO}" /tmp/recording/files/example.mkv /tmp/recording/files/test-"${FILENAME_SUFFIX}".webm
done
```
6 changes: 5 additions & 1 deletion recording/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Nextcloud Talk Recording Server Documentation

## Configuration
## Setup

* [Installation](installation.md)

### Configuration

* [Encoders](encoders.md)

Expand Down
241 changes: 241 additions & 0 deletions recording/docs/installation.md

Large diffs are not rendered by default.

168 changes: 168 additions & 0 deletions recording/packaging/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#
# @copyright Copyright (c) 2023, Daniel Calviño Sánchez (danxuliu@gmail.com)
#
# @license GNU AGPL version 3 or any later version
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

OS_VERSION ?= $(shell . /etc/os-release 2> /dev/null && echo $$ID$$VERSION_ID)
RELEASE ?= 1
DEBIAN_VERSION ?= $(RELEASE)~$(OS_VERSION)

BUILD_DIR ?= build/$(OS_VERSION)

NEXTCLOUD_TALK_RECORDING_VERSION := $(shell cd ../src && python3 -c "from nextcloud.talk.recording import __version__; print(__version__)")

PULSECTL_VERSION := 22.3.2
PYVIRTUALDISPLAY_VERSION := 3.0
REQUESTS_VERSION := 2.25.0
SELENIUM_VERSION := 4.8.2

CERTIFI_VERSION := 2022.12.7
TRIO_VERSION := 0.21.0
TRIO_WEBSOCKET_VERSION := 0.9.2
URLLIB3_VERSION := 1.26.14

timestamp-from-git = git log -1 --pretty=%ct $(1)

timestamp-from-source-python-package = tar --list --verbose --full-time --gzip --file $(1) | head --lines 1 | sed 's/ \+/ /g' | cut --delimiter " " --fields 4-5 | date --file - +%s

build-source-python-package = python3 -m build --sdist --outdir $(1) $(2)

download-source-python-package = python3 -m pip download --dest $(BUILD_DIR) --no-binary :all: --no-deps "$(1) == $(2)"

extract-source-python-package = cd $(BUILD_DIR) && tar --extract --gzip --file $(1)-$(2).tar.gz

# Since the 60.0.0 release, Setuptools includes a local, vendored copy of
# distutils; this copy does not seem to work with stdeb, so it needs to be
# disabled with "SETUPTOOLS_USE_DISTUTILS=stdlib".
build-deb-package = cd $(BUILD_DIR)/$(1)-$(2)/ && SOURCE_DATE_EPOCH=$(3) SETUPTOOLS_USE_DISTUTILS=stdlib python3 setup.py --command-packages=stdeb.command sdist_dsc --debian-version $(DEBIAN_VERSION) bdist_deb

copy-binary-deb-package = cp $(BUILD_DIR)/$(1)-$(2)/deb_dist/$(3)_$(2)-$(DEBIAN_VERSION)_all.deb $(BUILD_DIR)/deb/

define build-deb-python-package-full
$(call download-source-python-package,$(1),$(2))
$(call extract-source-python-package,$(1),$(2))
$(call build-deb-package,$(1),$(2),$$($(call timestamp-from-source-python-package,../$(1)-$(2).tar.gz)))
$(call copy-binary-deb-package,$(1),$(2),python3-$(3))
endef

build-packages-deb: build-packages-deb-nextcloud-talk-recording build-packages-deb-nextcloud-talk-recording-dependencies

$(BUILD_DIR)/deb:
mkdir --parents $(BUILD_DIR)/deb

build-packages-deb-nextcloud-talk-recording: $(BUILD_DIR)/deb/nextcloud-talk-recording_$(NEXTCLOUD_TALK_RECORDING_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/nextcloud-talk-recording_$(NEXTCLOUD_TALK_RECORDING_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call build-source-python-package,$(BUILD_DIR),../)

$(call extract-source-python-package,nextcloud-talk-recording,$(NEXTCLOUD_TALK_RECORDING_VERSION))

# Add extra files needed to create Debian packages:
# - debian/py3dist-overrides: Python dependencies to Debian dependencies for
# dh_python3 (also needed in the regenerated Python package, as it is
# needed in the Debian package).
# - MANIFEST.in: the source package is regenerated to include the extra
# files needed for the Debian package; MANIFEST.in explicitly adds those
# files not included by default in a Python package (so setup.py does not
# need to be included in MANIFEST.in, but debian/py3dist-overrides does).
# - setup.py: legacy setup file needed for stdeb (also needed in the
# regenerated Python package, as stdeb is invoked through it to create the
# source Debian package).
# - stdeb.cfg: additional configuration for stdeb (not needed in the
# regenerated Python package, as stdeb loads it before changing to the
# uncompressed source Python package).
cp --recursive nextcloud-talk-recording/. $(BUILD_DIR)/nextcloud-talk-recording-$(NEXTCLOUD_TALK_RECORDING_VERSION)/
cp ../server.conf.in $(BUILD_DIR)/nextcloud-talk-recording-$(NEXTCLOUD_TALK_RECORDING_VERSION)/

# Build a source Debian package (with the systemd addon for dh) and then,
# from it, a binary Debian package.
cd $(BUILD_DIR)/nextcloud-talk-recording-$(NEXTCLOUD_TALK_RECORDING_VERSION)/ && SOURCE_DATE_EPOCH=$$($(call timestamp-from-git,../../../../)) SETUPTOOLS_USE_DISTUTILS=stdlib python3 setup.py --command-packages=stdeb.command sdist_dsc --with-dh-systemd --debian-version $(DEBIAN_VERSION) bdist_deb

$(call copy-binary-deb-package,nextcloud-talk-recording,$(NEXTCLOUD_TALK_RECORDING_VERSION),nextcloud-talk-recording)

# Builds the Python dependencies that are not included in at least one of the
# Ubuntu supported releases:
# - Debian 11 (bullseye): pulsectl, pyvirtualdisplay >= 2.0, selenium >= 4.6.0
# - Ubuntu 20.04 (focal): pulsectl, pyvirtualdisplay >= 2.0, requests >= 2.25, selenium >= 4.6.0
# - Ubuntu 22.04 (jammy): pulsectl, selenium >= 4.6.0
#
# requests is not an explicit dependency, but required by requests-toolbelt.
# However, requests < 2.25 is not compatible with urllib3 >= 1.26, which is
# required by selenium.
build-packages-deb-nextcloud-talk-recording-dependencies: build-packages-deb-nextcloud-talk-recording-dependencies-$(OS_VERSION)

build-packages-deb-nextcloud-talk-recording-dependencies-debian11: build-packages-deb-pulsectl build-packages-deb-pyvirtualdisplay build-packages-deb-selenium build-packages-deb-selenium-dependencies
build-packages-deb-nextcloud-talk-recording-dependencies-ubuntu20.04: build-packages-deb-pulsectl build-packages-deb-pyvirtualdisplay build-packages-deb-requests build-packages-deb-selenium build-packages-deb-selenium-dependencies
build-packages-deb-nextcloud-talk-recording-dependencies-ubuntu22.04: build-packages-deb-pulsectl build-packages-deb-selenium build-packages-deb-selenium-dependencies

build-packages-deb-pulsectl: $(BUILD_DIR)/deb/python3-pulsectl_$(PULSECTL_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/python3-pulsectl_$(PULSECTL_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call build-deb-python-package-full,pulsectl,$(PULSECTL_VERSION),pulsectl)

build-packages-deb-pyvirtualdisplay: $(BUILD_DIR)/deb/python3-pyvirtualdisplay_$(PYVIRTUALDISPLAY_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/python3-pyvirtualdisplay_$(PYVIRTUALDISPLAY_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call build-deb-python-package-full,PyVirtualDisplay,$(PYVIRTUALDISPLAY_VERSION),pyvirtualdisplay)

build-packages-deb-requests: $(BUILD_DIR)/deb/python3-requests_$(REQUESTS_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/python3-requests_$(REQUESTS_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call build-deb-python-package-full,requests,$(REQUESTS_VERSION),requests)

build-packages-deb-selenium: $(BUILD_DIR)/deb/python3-selenium_$(SELENIUM_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/python3-selenium_$(SELENIUM_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call download-source-python-package,selenium,$(SELENIUM_VERSION))

$(call extract-source-python-package,selenium,$(SELENIUM_VERSION))

# The Python dependencies are added automatically to the .deb dependencies,
# but they do not include the version. The supported distributions provide
# an incompatible version for some of the dependencies, so
# "debian/py3dist-overrides" is used to explicitly set the version in the
# .deb packages and ensure that the right dependency is installed.
cp --recursive selenium/debian $(BUILD_DIR)/selenium-$(SELENIUM_VERSION)/
# The package provides its own MANIFEST.in, so the contents need to be
# appended rather than just copied.
cat selenium/MANIFEST.in >> $(BUILD_DIR)/selenium-$(SELENIUM_VERSION)/MANIFEST.in

$(call build-deb-package,selenium,$(SELENIUM_VERSION),$$($(call timestamp-from-source-python-package,../selenium-$(SELENIUM_VERSION).tar.gz)))

$(call copy-binary-deb-package,selenium,$(SELENIUM_VERSION),python3-selenium)

# Builds the Python dependencies that are not included in at least one of the
# Ubuntu supported releases:
# - Debian 11 (bullseye): python3-certifi >= 2021.10.8, python3-trio ~= 0.17, python3-trio-websocket ~= 0.9
# - Ubuntu 20.04 (focal): python3-certifi >= 2021.10.8, python3-trio ~= 0.17, python3-trio-websocket ~= 0.9, python3-urllib3 ~= 1.26
# - Ubuntu 22.04 (jammy): python3-certifi >= 2021.10.8, python3-trio-websocket ~= 0.9
build-packages-deb-selenium-dependencies: build-packages-deb-selenium-dependencies-$(OS_VERSION)

build-packages-deb-selenium-dependencies-debian11: build-packages-deb-certifi build-packages-deb-trio build-packages-deb-trio-websocket
build-packages-deb-selenium-dependencies-ubuntu20.04: build-packages-deb-certifi build-packages-deb-trio build-packages-deb-trio-websocket build-packages-deb-urllib
build-packages-deb-selenium-dependencies-ubuntu22.04: build-packages-deb-certifi build-packages-deb-trio-websocket

build-packages-deb-certifi: $(BUILD_DIR)/deb/python3-certifi_$(CERTIFI_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/python3-certifi_$(CERTIFI_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call build-deb-python-package-full,certifi,$(CERTIFI_VERSION),certifi)

build-packages-deb-trio: $(BUILD_DIR)/deb/python3-trio_$(TRIO_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/python3-trio_$(TRIO_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call build-deb-python-package-full,trio,$(TRIO_VERSION),trio)

build-packages-deb-trio-websocket: $(BUILD_DIR)/deb/python3-trio-websocket_$(TRIO_WEBSOCKET_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/python3-trio-websocket_$(TRIO_WEBSOCKET_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call build-deb-python-package-full,trio-websocket,$(TRIO_WEBSOCKET_VERSION),trio-websocket)

build-packages-deb-urllib: $(BUILD_DIR)/deb/python3-urllib3_$(URLLIB3_VERSION)-$(DEBIAN_VERSION)_all.deb
$(BUILD_DIR)/deb/python3-urllib3_$(URLLIB3_VERSION)-$(DEBIAN_VERSION)_all.deb: | $(BUILD_DIR)/deb
$(call build-deb-python-package-full,urllib3,$(URLLIB3_VERSION),urllib3)
Loading
Loading