File gpsctl.spec of Package gpsctl

#
# spec file for package gpsctl
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

Name:           gpsctl
Version:        1.16
Release:        0
Summary:        Utility for U-Blox GPS receivers
License:        MIT
Group:          Hardware/Other
URL:            https://github.com/philrandal/gpsctl
Source:         https://github.com/philrandal/gpsctl/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        %{name}.service
Source2:        %{name}.sysconfig
Source3:        %{name}.1
Patch0:         gpsctl-fix-build.patch
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  wiringpi-devel
BuildRequires:  help2man
BuildRequires:  systemd-rpm-macros
ExclusiveArch:  %arm aarch64 x86_64

%description
A utility for querying, configuring, and using a U-Blox GPS.
All configurations are done via /etc/gpsctl.conf.

Some gpsctl functions work for any GPS streaming NMEA data over a serial port:
 * Echoes NMEA data to stdout, optionally filtered by NMEA message type.
 * Infers the GPS' baud rate from the stream of NMEA data.

Other gpsctl functions are specific to U-Blox GPS hardware:
 * Configures the baud rate that the U-Blox GPS uses for communication.
 * Configures whether the U-Blox GPS transmits NMEA data.
 * Infers the GPS' baud rate using the UBX protocol only.
 * Configures the use of the European Galileo satellites (which is off
   by default in U-Blox 3.01 firmware) and enables NMEA version 4.1
   output for Galileo.
 * Queries the U-Blox GPS for position, time, GPS version, GPS configuration,
   and GPS satellite information. The format of query results are selectable:
   either plain English or JSON.
 * Tests the pulse-per-second output of the U-Blox GPS (fundamental for NTP).
 * Configures the U-Blox GPS for maximum timing pulse accuracy (useful for
   building a stratum 1 NTP server based on the GPS' notion of time).
 * Disables NMEA RMC, VTG, GSA, GSV, GLL, GGA messages and enables ZDA (for
   NTP driver 20 mode 8)
 * Saves the U-Blox GPS configuration to on-module battery-backed memory.
 * Resets the U-Blox GPS.

Note: The gpsctl binary was renamed to gpsctl_ph to prevent a naming
      conflict with gpsctl from gpsd-clients !!!

%prep
%setup -q
%patch0 -p1

%build
%cmake
%cmake_build

%install
# FIXME: rename gpsctl to prevent a naming conflict with gpsctl from gpsd-clients
install -D -m0755 build/gpsctl %{buildroot}%{_bindir}/gpsctl_ph
install -D -m0644 etc/gpsctl.conf %{buildroot}/etc/gpsctl.conf
install -D -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
install -D -m0644 %{SOURCE2} %{buildroot}%{_fillupdir}/sysconfig.%{name}
install -D -m0644 %{SOURCE3} %{buildroot}/%{_mandir}/man1/%{name}_ph.1
install -d %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

%pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service
%fillup_only

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%license LICENSE
%doc Changelog README.md
%doc etc/gpsctl.conf.*
%{_bindir}/gpsctl_ph
%config(noreplace) %{_sysconfdir}/gpsctl.conf
%{_sbindir}/rc%{name}
%{_unitdir}/%{name}.service
%{_fillupdir}/sysconfig.%{name}
%{_mandir}/man1/%{name}_ph.1%{?ext_man}

%changelog
openSUSE Build Service is sponsored by