Skip to content

Commit

Permalink
Merge pull request #80 from mefuller/rpm
Browse files Browse the repository at this point in the history
RPM packaging
  • Loading branch information
darrylb123 authored Jan 25, 2022
2 parents ef238a5 + ae67c8f commit 1476a27
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Debian:

Fedora:
```
##Install Python3 dev pacakage
##Install Python3 dev package
# dnf install python3-devel
```

Expand Down
117 changes: 117 additions & 0 deletions rpm/usbrelay.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
%global fork mefuller
%global branch rpm

Name: usbrelay
Version: 0.9
Release: 2%{?dist}
Summary: USB-connected electrical relay control, based on hidapi
License: GPLv2
URL: https://github.com/%{fork}/%{name}/
Source0: %{url}archive/%{branch}.tar.gz
Source1: ./%{name}.sysusers

BuildRequires: gcc
BuildRequires: git
BuildRequires: hidapi-devel
BuildRequires: make
BuildRequires: python3
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: systemd-rpm-macros


%global common_description %{expand: \
This package includes programs to operate some USB connected electrical relays.
Supported relays USB ID:
- 16c0:05df
- 0519:2018}

%description
%{common_description}


%package common
Summary: Common files needed for all usbrelay interfaces
%description common
%{common_description}


%package -n python3-%{name}
Requires: %{name}-common%{_isa} = %{version}-%{release}
Summary: Python 3 user interface for usbrelay
%description -n python3-%{name}
%{common_description}
.
This package includes the usbrelay Python 3 module.


%package mqtt
Requires: %{name}-common%{_isa} = %{version}-%{release}
Requires: python3-%{name}%{_isa} = %{version}-%{release}
Summary: Support for Home Assistant or nodered with usbrelay
%description mqtt
%{common_description}
.
This package provides the MQTT support for using usbrelay with Home Assistant
or nodered.


%prep
%autosetup -n %{name}-%{branch}


%build
%set_build_flags
make python HIDAPI=libusb
%py3_build


%install
make install DESTDIR=%{buildroot}
%py3_install


install -d %{buildroot}%{_prefix}/lib/udev/rules.d/
install 50-usbrelay.rules %{buildroot}%{_prefix}/lib/udev/rules.d/
install -d %{buildroot}%{_sbindir}
install usbrelayd %{buildroot}%{_sbindir}
install -d %{buildroot}%{_sysconfdir}/systemd/system
install usbrelayd.service %{buildroot}%{_sysconfdir}/systemd/system/
install usbrelayd.conf %{buildroot}%{_sysconfdir}/
install -d %{_buildroot}/share/man/man1/
install usbrelay.1 %{_buildroot}/share/man/man1/


%pre
%sysusers_create_compat %{SOURCE1}


%files common
%license LICENSE.md
%doc README.md
%{_bindir}/usbrelay
%{_libdir}/libusbrelay.so
%{_prefix}/lib/udev/rules.d/50-usbrelay.rules


%files -n python3-%{name}
%{python3_sitearch}/%{name}_*.egg-info
%{python3_sitearch}/%{name}_py*.so
%{python3_sitearch}/%{name}_py/


%files mqtt
%{_sbindir}/usbrelayd
%{_sysconfdir}/systemd/system/usbrelayd.service
%{_sysconfdir}/usbrelayd.conf


%changelog
* Tue Jan 25 2022 Mark E. Fuller <[email protected]> - 0.9.0-2
- continued spec development and upstream improvements

* Sat Jan 22 2022 Mark E. Fuller <[email protected]> - 0.9.0-1
- bump version

* Thu Jan 20 2022 Mark E. Fuller <[email protected]> - 0.8.0-1
- first attempt versions of spec file and packaging
3 changes: 3 additions & 0 deletions rpm/usbrelay.sysusers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Type Name ID GECOS Home directory Shell
u usbrelay - "user for MQTT" /run/usbrelay /sbin/nologin
g usbrelay - "usbrelay proivileged group" - -
42 changes: 31 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
from setuptools import setup, Extension

module1 = Extension('usbrelay_py',
libraries= ['usbrelay'],
library_dirs= ['./','/usr/lib','/usr/lib64','/usr/lib/x86_64-linux-gnu','/usr/lib/aarch64-linux-gnu','/usr/lib/arm-linux-gnueabihf'],
sources = ['libusbrelay_py.c', 'usbrelay_test.py'])

setup (name = 'usbrelay_py',
version = '1.0',
description = 'USB Relay board control from Python',
author = "Sean Mollet",
author_email = "[email protected]",
ext_modules = [module1])
module1 = Extension(
'usbrelay_py',
libraries= ['usbrelay'],
library_dirs= ['./','/usr/lib','/usr/lib64','/usr/lib/x86_64-linux-gnu','/usr/lib/aarch64-linux-gnu','/usr/lib/arm-linux-gnueabihf'],
sources = ['libusbrelay_py.c']
)

setup(
name = 'usbrelay_py',
version = '1.0',
description = 'USB Relay board control from Python',
url = 'https://github.com/darrylb123/usbrelay',
author = "Sean Mollet",
author_email = "[email protected]",
license = 'GPL-2.0',
ext_modules = [module1],
packages = ['usbrelay_py'],

classifiers = [
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],

)
8 changes: 8 additions & 0 deletions usbrelay_py/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
usbrelay_py
Python bindings to the usbrelay command line tool
"""

__version__ = "1.0"
__author__ = "Sean Mollet"
File renamed without changes.

0 comments on commit 1476a27

Please sign in to comment.