Skip to content

Commit 29afdd6

Browse files
authored
Merge pull request #64 from virtUOS/rpmbuild
Automatically build RPMs for releases
2 parents 89d0ae5 + 23e95c0 commit 29afdd6

5 files changed

Lines changed: 295 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=Opencast Camera Control
3+
Documentation=https://github.com/virtUOS/opencast-camera-control
4+
Wants=network.target
5+
6+
[Service]
7+
Type=simple
8+
User=opencastcamera
9+
ExecStart=/usr/bin/opencast-camera-control
10+
Restart=always
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Created by pyp2rpm-3.3.8
2+
%global pypi_name opencast-camera-control
3+
%global pypi_version %{_camera_control_version}
4+
5+
%define uid opencastcamera
6+
%define gid opencastcamera
7+
8+
Name: %{pypi_name}
9+
Version: %{pypi_version}
10+
Release: 1%{?dist}
11+
Summary: Automated Camera Control for Opencast
12+
13+
License: GPLv3+
14+
15+
URL: None
16+
Source0: https://github.com/virtUOS/%{name}/archive/refs/tags/%{version}.tar.gz
17+
Source1: https://raw.githubusercontent.com/virtUOS/%{name}/%{version}/camera-control.yml
18+
Source2: opencast-camera-control.service
19+
BuildArch: noarch
20+
21+
BuildRequires: python3-devel
22+
BuildRequires: python3dist(setuptools)
23+
24+
Requires: python3dist(confygure) >= 0.1
25+
Requires: python3dist(prometheus-client)
26+
Requires: python3dist(python-dateutil)
27+
Requires: python3dist(requests)
28+
Requires: python3dist(setuptools)
29+
30+
BuildRequires: systemd
31+
Requires(post): systemd
32+
Requires(preun): systemd
33+
Requires(postun): systemd
34+
35+
%description
36+
Control PTZ camera to move to certain presets when
37+
starting a scheduled recording.
38+
39+
%{?python_provide:%python_provide python3-%{pypi_name}}
40+
41+
42+
%prep
43+
%autosetup -n %{pypi_name}-%{pypi_version}
44+
# Remove bundled egg-info
45+
rm -rf %{pypi_name}.egg-info
46+
# Patch setup.py
47+
# This is a workaround for the Python toolchain in EL9 not supporting the new pyproject.toml
48+
echo 'from setuptools import setup' > setup.py
49+
echo "setup(name = 'opencast-camera-control', $(grep version pyproject.toml), packages=['occameracontrol']," >> setup.py
50+
echo " entry_points={'console_scripts':['opencast-camera-control = occameracontrol.__main__:main' ]})" >> setup.py
51+
52+
%build
53+
%py3_build
54+
55+
%install
56+
%py3_install
57+
58+
# Install configuration
59+
install -m 0644 -p -D %{SOURCE1} %{buildroot}%{_sysconfdir}/camera-control.yml
60+
61+
# Install Systemd unit file
62+
install -m 0644 -p -D %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
63+
64+
65+
%pre
66+
# Create user and group if nonexistent
67+
if [ ! $(getent group %{gid}) ]; then
68+
groupadd -r %{gid} > /dev/null 2>&1 || :
69+
fi
70+
if [ ! $(getent passwd %{uid}) ]; then
71+
useradd -M -r -g %{gid} %{uid} > /dev/null 2>&1 || :
72+
fi
73+
74+
75+
%post
76+
%systemd_post %{name}.service
77+
78+
79+
%preun
80+
%systemd_preun %{name}.service
81+
82+
83+
%postun
84+
%systemd_postun_with_restart %{name}.service
85+
86+
87+
%files
88+
%license LICENSE
89+
%doc README.md
90+
%{_bindir}/opencast-camera-control
91+
%{_unitdir}/%{name}.service
92+
%{python3_sitelib}/occameracontrol
93+
%{python3_sitelib}/opencast_camera_control-%{pypi_version}-py%{python3_version}.egg-info
94+
%config(noreplace) %{_sysconfdir}/camera-control.yml
95+
96+
%changelog
97+
* Tue Mar 26 2024 Lars Kiesow <lkiesow@uos.de> - 0.1.0-1
98+
- Initial package.

.github/rpm/python-confygure.spec

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Created by pyp2rpm-3.3.8
2+
%global pypi_name confygure
3+
%global pypi_version 0.1.0
4+
5+
Name: python-%{pypi_name}
6+
Version: %{pypi_version}
7+
Release: 1%{?dist}
8+
Summary: A simple YAML based configuration library for Python
9+
10+
License: MIT
11+
URL: None
12+
Source0: %{pypi_source}
13+
BuildArch: noarch
14+
15+
BuildRequires: python3-devel
16+
BuildRequires: python3dist(setuptools)
17+
18+
%description
19+
A simple YAML based configuration library for Python
20+
21+
%package -n python3-%{pypi_name}
22+
Summary: %{summary}
23+
%{?python_provide:%python_provide python3-%{pypi_name}}
24+
25+
Requires: python3dist(pyyaml)
26+
%description -n python3-%{pypi_name}
27+
A simple YAML based configuration library for Python
28+
29+
30+
%prep
31+
%autosetup -n %{pypi_name}-%{pypi_version}
32+
# Remove bundled egg-info
33+
rm -rf %{pypi_name}.egg-info
34+
# Patch setup.py
35+
# This is a workaround for the Python toolchain in EL9 not supporting the new pyproject.toml
36+
echo 'from setuptools import setup' > setup.py
37+
echo "setup(name = 'confygure', $(grep version pyproject.toml), packages=['confygure'])" >> setup.py
38+
39+
%build
40+
%py3_build
41+
42+
%install
43+
%py3_install
44+
45+
%files -n python3-%{pypi_name}
46+
%license LICENSE
47+
%doc README.md
48+
%{python3_sitelib}/%{pypi_name}
49+
%{python3_sitelib}/%{pypi_name}-%{pypi_version}-py%{python3_version}.egg-info
50+
51+
%changelog
52+
* Tue Mar 26 2024 Lars Kiesow <lkiesow@uos.de> - 0.1.0-1
53+
- Initial package.

.github/workflows/build-rpms.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Build RPMs
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
osversion:
13+
- '9'
14+
name: build (el${{ matrix.osversion }})
15+
runs-on: ubuntu-latest
16+
container:
17+
image: quay.io/centos/centos:stream${{ matrix.osversion }}
18+
steps:
19+
- name: install tools
20+
run: >
21+
dnf install -y
22+
createrepo
23+
'dnf-command(builddep)'
24+
git
25+
gnupg
26+
rpmdevtools
27+
rpm-sign
28+
29+
- name: clone repository
30+
uses: actions/checkout@v4
31+
32+
- name: prepare git
33+
run: |
34+
git config --global user.name "RPM Builder"
35+
git config --global user.email "virtuos@uni-osnabrueck.de"
36+
37+
- name: prepare gpg
38+
env:
39+
GPG_KEY: ${{ secrets.GPG_KEY }}
40+
run: |
41+
echo "${GPG_KEY}" | gpg --import
42+
echo '%_gpg_name D1D3C4C53BB1516C13C86647F3AC651D45D407D3' > ~/.rpmmacros
43+
44+
- name: get version
45+
run: >
46+
sed -n 's/^version *=[^0-9]*\(.*\). */%_camera_control_version \1/p'
47+
pyproject.toml >> ~/.rpmmacros
48+
49+
- name: prepare build tree
50+
run: |
51+
rpmdev-setuptree
52+
53+
- name: copy service file
54+
run: |
55+
cp .github/rpm/opencast-camera-control.service ~/rpmbuild/SOURCES/
56+
57+
- name: install build dependencies
58+
working-directory: .github/rpm/
59+
run: |
60+
dnf builddep -y opencast-camera-control.spec
61+
62+
- name: download sources
63+
working-directory: .github/rpm/
64+
run: |
65+
spectool -gR opencast-camera-control.spec
66+
67+
- name: build rpm
68+
working-directory: .github/rpm/
69+
run: |
70+
rpmbuild -ba opencast-camera-control.spec
71+
72+
- name: switch to repository branch
73+
run: |
74+
chown root:root .
75+
git fetch
76+
git checkout rpm-el${{ matrix.osversion }}
77+
78+
- name: sign rpms
79+
run: |
80+
rpmsign --addsign ~/rpmbuild/RPMS/noarch/*.rpm
81+
82+
- name: copy rpms to repository
83+
run: |
84+
cp -v ~/rpmbuild/RPMS/noarch/*.rpm .
85+
86+
- name: add new rpms
87+
run: |
88+
git add ./*.rpm
89+
90+
- name: update repository metadata
91+
run: |
92+
createrepo --update .
93+
git add ./repodata/
94+
95+
- name: commit changes
96+
run: |
97+
git status
98+
RPM="$(ls -1 ~/rpmbuild/RPMS/noarch/ | tail -n1)"
99+
git diff --staged --quiet || git commit -m "Build ${RPM} $(date)"
100+
101+
- name: push updates
102+
run: |
103+
git remote -v
104+
git push

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,36 @@ agent_calendar_update_time{agent="test_agent"} 1.707571943100096e+09
8282
camera_position{camera="http://camera-2-panasonic.example.com"} 10.0
8383
```
8484

85+
86+
## RPM Repository
87+
88+
On RHEL 9 like distributions (CentOS Stream, Rocky, Alma, …) you can use the RPM repository to install Opencast Camera Control.
89+
Install the repository by adding a file `/etc/yum.repos.d/opencast-camera-control.repo`:
90+
91+
```
92+
[opencast-camera-control]
93+
name = Opencast camera control el$releasever repository
94+
baseurl = https://raw.githubusercontent.com/virtUOS/opencast-camera-control/rpm-el$releasever/
95+
enabled = 1
96+
gpgcheck = 1
97+
gpgkey = https://raw.githubusercontent.com/virtUOS/opencast-camera-control/rpm-el$releasever/opencast-camera-control.key
98+
```
99+
100+
Then activate the EPEL repository and install `opencast-camera-control`:
101+
102+
```
103+
dnf install epel-release
104+
dnf install opencast-camera-control
105+
```
106+
107+
The RPM packages provide a Systemd unit to run the tool as service:
108+
109+
```
110+
systemctl start opencast-camera-control.service
111+
systemctl enable opencast-camera-control.service
112+
```
113+
114+
85115
## Docker
86116

87117
We also provide a container image.

0 commit comments

Comments
 (0)