package: create debian package with prebuilds

The generated variants include raspi and non-raspi platforms.
This commit is contained in:
Kamil Trzcinski 2023-05-26 14:53:38 +02:00
parent d80d039f3c
commit 69584c07db
17 changed files with 257 additions and 35 deletions

View File

@ -5,11 +5,12 @@ FROM ${DOCKER_ARCH}debian:${DEBIAN_VERSION} as build_env
# Default packages # Default packages
RUN apt-get -y update && apt-get -y install gnupg2 build-essential xxd cmake ccache git-core pkg-config \ RUN apt-get -y update && apt-get -y install gnupg2 build-essential xxd cmake ccache git-core pkg-config \
libavformat-dev libavutil-dev libavcodec-dev libssl-dev v4l-utils libavformat-dev libavutil-dev libavcodec-dev libssl-dev v4l-utils
RUN apt-get -y install debhelper
# Add RPI packages # Add RPI packages
ARG DEBIAN_VERSION ARG DEBIAN_VERSION
ARG BUILD_TYPE="non-rpi" ARG BUILD_TYPE="generic"
RUN [ "$BUILD_TYPE" != "rpi" ] || \ RUN [ "$BUILD_TYPE" != "raspi" ] || \
( \ ( \
echo "deb http://archive.raspberrypi.org/debian/ $DEBIAN_VERSION main" > /etc/apt/sources.list.d/raspi.list && \ echo "deb http://archive.raspberrypi.org/debian/ $DEBIAN_VERSION main" > /etc/apt/sources.list.d/raspi.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 82B129927FA3303E && \ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 82B129927FA3303E && \
@ -17,12 +18,21 @@ RUN [ "$BUILD_TYPE" != "rpi" ] || \
apt-get -y install libcamera-dev liblivemedia-dev \ apt-get -y install libcamera-dev liblivemedia-dev \
) )
FROM scratch as build FROM build_env as build
COPY --from=build_env / .
ADD / /src ADD / /src
WORKDIR /src WORKDIR /src
RUN git clean -ffdx RUN git clean -ffdx
RUN git submodule update --init --recursive --recommend-shallow RUN git submodule update --init --recursive --recommend-shallow
RUN git submodule foreach --recursive git clean -ffdx RUN git submodule foreach --recursive git clean -ffdx
RUN make -j$(nproc)
FROM build as deb_make
ARG GIT_VERSION
ARG BUILD_TYPE="generic"
ENV DEB_BUILD_PROFILES="$BUILD_TYPE"
RUN apt-get build-dep -y $PWD
RUN . /etc/os-release && \
export RELEASE_SUFFIX="$VERSION_CODENAME" && \
dpkg-buildpackage -us -uc -b
RUN mkdir -p /deb && mv ../*.deb /deb/

View File

@ -14,13 +14,14 @@ docker_arch=""
[[ -n "$2" ]] && docker_arch="$2/" && docker_image="${docker_image}_${2}" [[ -n "$2" ]] && docker_arch="$2/" && docker_image="${docker_image}_${2}"
PWD=$(pwd) PWD=$(pwd)
ROOT=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) ROOT=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../.." &> /dev/null && pwd)
set -xeo pipefail set -xeo pipefail
docker build -t "$docker_image" \ docker build -t "$docker_image" \
--build-arg "DOCKER_ARCH=$docker_arch" \ --build-arg "DOCKER_ARCH=$docker_arch" \
--build-arg "DEBIAN_VERSION=$debian_version" \ --build-arg "DEBIAN_VERSION=$debian_version" \
--target build_env - < Dockerfile --build-arg BUILD_TYPE \
--target build_env - < .github/ci/Dockerfile
exec docker run --rm -it -u "$UID" -v "$ROOT:$ROOT" -w "$ROOT" "$docker_image" exec docker run --rm -it -u "$UID" -v "$ROOT:$ROOT" -w "$ROOT" "$docker_image"

View File

@ -1,26 +0,0 @@
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
debian_version: [buster, bullseye]
docker_arch: [amd64, arm32v7, arm64v8]
build_type: ["non-rpi", "rpi"]
exclude:
- docker_arch: amd64
build_type: rpi
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build Dockerfile
run: docker build --build-arg DOCKER_ARCH --build-arg DEBIAN_VERSION --build-arg BUILD_TYPE .
env:
DEBIAN_VERSION: ${{ matrix.debian_version }}
DOCKER_ARCH: ${{ matrix.docker_arch }}/
BUILD_TYPE: ${{ matrix.build_type }}

61
.github/workflows/build_release.yaml vendored Normal file
View File

@ -0,0 +1,61 @@
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
debian_version: [bullseye]
docker_arch: [amd64, arm32v7, arm64v8]
build_type: [generic, raspi]
exclude:
- docker_arch: amd64
build_type: raspi
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set GIT_VERSION
shell: bash
run: |
majorVer=$(cat VERSION)
lastVer=$(git tag --sort version:refname --list "v$majorVer.*" | tail -n1)
if [[ -n "$lastVer" ]]; then
newVer=(${lastVer//./ })
newVer[-1]="$((${newVer[-1]}+1))"
nextVer="${newVer[*]}"
nextVer="${nextVer// /.}"
else
nextVer="$majorVer.0"
fi
echo "MajorVer=$majorVer LastVer=$lastVer NextVer=$nextVer"
echo "GIT_VERSION=$nextVer" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build Dockerfile
run: docker build --target deb_make --tag deb_make --file .github/ci/Dockerfile --build-arg GIT_VERSION --build-arg DOCKER_ARCH --build-arg DEBIAN_VERSION --build-arg BUILD_TYPE .
env:
DEBIAN_VERSION: ${{ matrix.debian_version }}
DOCKER_ARCH: ${{ matrix.docker_arch }}/
BUILD_TYPE: ${{ matrix.build_type }}
- name: Create container
run: docker create --name deb_make deb_make
- name: Copy files
run: 'docker cp deb_make:/deb/. deb/'
- name: 'Release debian files'
uses: ncipollo/release-action@v1
with:
tag: ${{ env.GIT_VERSION }}
artifacts: "deb/*.deb"
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
updateOnlyUnreleased: true
prerelease: true
generateReleaseNotes: true
bodyFile: RELEASE.md

44
.github/workflows/build_test.yaml vendored Normal file
View File

@ -0,0 +1,44 @@
on:
push:
paths-ignore:
- '.github/workflows/build_test.yaml'
- 'RELEASE.md'
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
debian_version: [buster, bullseye]
docker_arch: [amd64, arm32v7, arm64v8]
build_type: [generic, raspi]
exclude:
- docker_arch: amd64
build_type: raspi
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set GIT_VERSION
run: echo "GIT_VERSION=$(git describe --tags)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build Dockerfile
run: docker build --target deb_make --tag deb_make --file .github/ci/Dockerfile --build-arg GIT_VERSION --build-arg DOCKER_ARCH --build-arg DEBIAN_VERSION --build-arg BUILD_TYPE .
env:
DEBIAN_VERSION: ${{ matrix.debian_version }}
DOCKER_ARCH: ${{ matrix.docker_arch }}/
BUILD_TYPE: ${{ matrix.build_type }}
- name: Create container
run: docker create --name deb_make deb_make
- name: Copy files
run: docker cp deb_make:/deb/. deb/
- name: 'Upload debian files'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.debian_version }}-${{ matrix.docker_arch }}-${{ matrix.build_type }}.zip
path: deb/
retention-days: 14

7
.gitignore vendored
View File

@ -8,3 +8,10 @@ tmp/
.vscode/ .vscode/
/Procfile* /Procfile*
/version.h /version.h
/debian/.debhelper
/debian/debhelper-build-stamp
/debian/*.substvars
/debian/files
/debian/*.log
/debian/camera-streamer*/

View File

@ -15,6 +15,7 @@ endif
LIBDATACHANNEL_PATH ?= third_party/libdatachannel LIBDATACHANNEL_PATH ?= third_party/libdatachannel
USE_HW_H264 ?= 1
USE_FFMPEG ?= $(shell pkg-config libavutil libavformat libavcodec && echo 1) USE_FFMPEG ?= $(shell pkg-config libavutil libavformat libavcodec && echo 1)
USE_LIBCAMERA ?= $(shell pkg-config libcamera && echo 1) USE_LIBCAMERA ?= $(shell pkg-config libcamera && echo 1)
USE_RTSP ?= $(shell pkg-config live555 && echo 1) USE_RTSP ?= $(shell pkg-config live555 && echo 1)
@ -24,6 +25,10 @@ ifeq (1,$(DEBUG))
CFLAGS += -g CFLAGS += -g
endif endif
ifeq (1,$(USE_HW_H264))
CFLAGS += -DUSE_HW_H264
endif
ifeq (1,$(USE_FFMPEG)) ifeq (1,$(USE_FFMPEG))
CFLAGS += -DUSE_FFMPEG CFLAGS += -DUSE_FFMPEG
LDLIBS += -lavcodec -lavformat -lavutil LDLIBS += -lavcodec -lavformat -lavutil
@ -72,7 +77,7 @@ version:
$(CCACHE) $(CXX) $(CFLAGS) -o $@ $(filter-out cmd/%, $^) $(filter $</%, $^) $(LDLIBS) $(CCACHE) $(CXX) $(CFLAGS) -o $@ $(filter-out cmd/%, $^) $(filter $</%, $^) $(LDLIBS)
install: $(TARGET) install: $(TARGET)
install $(TARGET) /usr/local/bin/ install $(TARGET) $(DESTDIR)/usr/local/bin/
clean: clean:
rm -f .depend $(OBJS) $(OBJS:.o=.d) $(HTML_SRC) $(TARGET) rm -f .depend $(OBJS) $(OBJS:.o=.d) $(HTML_SRC) $(TARGET)

0
RELEASE.md Normal file
View File

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.2

View File

@ -28,6 +28,11 @@ camera_options_t camera_options = {
.options = "compression_quality=80" .options = "compression_quality=80"
}, },
.video = { .video = {
#ifdef USE_HW_H264
.disabled = 0,
#else // USE_HW_H264
.disabled = 1,
#endif
.options = .options =
"video_bitrate_mode=0" OPTION_VALUE_LIST_SEP "video_bitrate_mode=0" OPTION_VALUE_LIST_SEP
"video_bitrate=2000000" OPTION_VALUE_LIST_SEP "video_bitrate=2000000" OPTION_VALUE_LIST_SEP

View File

@ -0,0 +1,3 @@
camera-streamer usr/bin/
service/camera-streamer-generic-usb-cam.service /usr/share/camera-streamer/examples/
tools/dump_cameras.sh /usr/share/camera-streamer/

5
debian/camera-streamer-raspi.install vendored Normal file
View File

@ -0,0 +1,5 @@
camera-streamer usr/bin/
service/*.service /usr/share/camera-streamer/examples/
tools/dump_cameras.sh /usr/share/camera-streamer/
tools/rpi_measure.sh /usr/share/camera-streamer/
tools/rpi_mem_usage.sh /usr/share/camera-streamer/

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
camera-streamer (0.1.0) unstable; urgency=medium
* Initial Release.
-- Kamil Trzciński <cs@ayufan.eu> Fri, 26 May 2023 13:15:22 +0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
10

37
debian/control vendored Normal file
View File

@ -0,0 +1,37 @@
Source: camera-streamer
Section: unknown
Priority: optional
Maintainer: Kamil Trzciński <cs@ayufan.eu>
Build-Depends:
debhelper,
libavformat-dev,
libavutil-dev,
libavcodec-dev,
libcamera-dev <raspi>,
liblivemedia-dev <raspi>,
v4l-utils,
pkg-config,
xxd,
build-essential,
cmake,
libssl-dev
Standards-Version: 4.5.1
Homepage: https://github.com/ayufan/camera-streamer
Vcs-Browser: https://github.com/ayufan/camera-streamer
Vcs-Git: https://github.com/ayufan/camera-streamer.git
Rules-Requires-Root: no
Package: camera-streamer-raspi
Provides: camera-streamer
Build-Profiles: <raspi>
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: camera-streamer with CSI and USB camera,
RTSP, WebRTC, and H264 support
Package: camera-streamer-generic
Provides: camera-streamer
Build-Profiles: <!raspi>
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: camera-streamer with USB camera support

62
debian/rules vendored Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export USE_FFMPEG ?= 1
#export GIT_VERSION ?= $(shell git describe --tags)
export DEB_VERSION ?= $(GIT_VERSION:v%=%)$(addprefix ~,$(RELEASE_SUFFIX))
ifneq ($(filter raspi,$(DEB_BUILD_PROFILES)),)
export USE_HW_H264 = 1
export USE_LIBDATACHANNEL = 1
export USE_LIBCAMERA = 1
export USE_RTSP = 1
else ifneq ($(filter generic,$(DEB_BUILD_PROFILES)),)
export USE_HW_H264 = 0
export USE_LIBCAMERA = 0
else
$(error Use DEB_BUILD_PROFILES=raspi or DEB_BUILD_PROFILES=generic)
endif
%:
dh $@
.PHONY: override_dh_auto_install
override_dh_auto_install:
.PHONY: override_dh_gencontrol
override_dh_gencontrol:
dh_gencontrol -- $(addprefix -v,$(DEB_VERSION))
.PHONY: override_dh_strip
override_dh_strip:
dh_strip --keep-debug
.PHONY: override_dh_shlibdeps
override_dh_shlibdeps:
dh_shlibdeps
# Make libcamera0 to be exact
sed -i "s/libcamera0 (>=[^)]*)/libcamera0 (= $$(dpkg -s libcamera0 | grep Version | cut -d" " -f2))/g" debian/camera-streamer*.substvars
.PHONY: override_dh_install
override_dh_install:
dh_install
sed -i "s|/usr/local/bin/camera-streamer|/usr/bin/camera-streamer|g" debian/camera-streamer*/usr/share/camera-streamer/examples/*.service
# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)