ishcherb / rpms / openambit

Forked from rpms/openambit 6 years ago
Clone
Blob Blame History Raw

%global commit 5f2b7840d91121b44a9a16ac6d945b103a94c5a3
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name:           openambit
Version:        0.3
Release:        11%{?commit:.git%shortcommit}%{?dist}
Summary:        Open software for the Suunto Ambit(2)

License:        GPLv3+
URL:            http://openambit.org/
Source0:        https://github.com/openambitproject/openambit/archive/%{?commit:%commit}%{!?commit:%version}.tar.gz

# Fix some issues with the desktop file (upstreamed)
Patch0:         openambit_desktop-file.patch
# Add appdata file
Patch1:         openambit_appdata.patch
# Fix -Wstrict-aliasing issues, see https://github.com/openambitproject/openambit/pull/90
Patch2:         openambit_strict-aliasing-fixes.patch
# Fix -Wmaybe-uninitialized, see https://github.com/openambitproject/openambit/pull/91
Patch3:         openambit_fix-maybe-uninitialized.patch
# Unbundle hidapi (see also %%prep)
Patch4:         openambit_unbundle-hidapi.patch

BuildRequires:  cmake
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib
BuildRequires:  qjson-devel
BuildRequires:  qt4-devel
BuildRequires:  systemd-devel
BuildRequires:  wireshark-devel
BuildRequires:  hidapi-devel

Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
Requires:       hicolor-icon-theme

%description
Openambit is application for downloading moves from the Suunto
Ambit(2) outdoor watches, and synchronizing them with the
movescount website.


%package libs
Summary:        Libraries for %{name}
# For %%{_sysconfdir}/udev/rules.d/ ownership
Requires:       systemd

%description libs
The %{name}-libs package contains libraries for %{name}.


%package        devel
Summary:        Development files for %{name}
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%package        wireshark
Summary:        Wireshark dissector for %{name}
Requires:       wireshark%{?_isa} >= 1.12.6-3
License:        BSD

%description    wireshark
The %{name}-wireshark package contains the Wireshark dissector for %{name},
which parses pcap-files made with usbpcap.


%prep
%setup -q -n %{name}-%{?commit:%commit}%{!?commit:%version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1

# Remove exec permissions since it is installed as %%doc
chmod -x tools/movescountXmlDiff.pl

# Remove bundled hidapi files
rm -rf src/libambit/hidapi


%build
# libambit (using libambit-build since Findlibambit looks for the library there)
mkdir src/libambit-build
(
cd src/libambit-build
%cmake -DCMAKE_INSTALL_UDEVRULESDIR=%{_udevrulesdir} ../libambit
make %{?_smp_mflags}
)

# openambit 
mkdir src/openambit-build
(
cd src/openambit-build
%cmake ../openambit
make %{?_smp_mflags}
)

# wireshark dissector
mkdir wireshark_dissector-build
(
cd wireshark_dissector-build
%cmake ../wireshark_dissector
make %{?_smp_mflags}
)


%install
%make_install -C src/libambit-build
%make_install -C src/openambit-build
install -Dpm 0755 wireshark_dissector-build/ambit.so %{buildroot}%{_libdir}/wireshark/plugins/ambit.so

%{_bindir}/appstream-util validate-relax --nonet %{buildroot}%{_datadir}/appdata/%{name}.appdata.xml
%{_bindir}/desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop


%post
/usr/bin/update-desktop-database &> /dev/null || :
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%postun
/usr/bin/update-desktop-database &> /dev/null || :
if [ $1 -eq 0 ] ; then
    /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi

%posttrans
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
/usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :


%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig


%files
%license src/openambit/COPYING
%{_bindir}/%{name}
%{_datadir}/appdata/%{name}.appdata.xml
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/64x64/apps/%{name}.png

%files libs
%license src/libambit/COPYING
%{_libdir}/libambit.so.*
%{_udevrulesdir}/libambit.rules

%files devel
%doc src/example/ambitconsole.c
%doc tools/*
%{_includedir}/libambit.h
%{_libdir}/libambit.so

%files wireshark
%license wireshark_dissector/COPYING
%{_libdir}/wireshark/plugins/ambit.so


%changelog
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.3-11.git5f2b784
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Sat Jan 16 2016 Sandro Mani <manisandro@gmail.com> - 0.3-10.git5f2b784
- Rebuild (wireshark)

* Wed Jul 01 2015 Sandro Mani <manisandro@gmail.com> - 0.3-9.git5f2b784
- Install the wireshark plugin in %%{_libdir}/wireshark/plugins

* Mon Jun 29 2015 Sandro Mani <manisandro@gmail.com> - 0.3-8.git5f2b784
- Install the wireshark plugin in %%{_libdir}/wireshark/plugins/current

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3-7.git5f2b784
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Tue Jun 02 2015 Sandro Mani <manisandro@gmail.com> - 0.3-6.git5f2b784
- Fix location where udev rules are installed

* Fri May 15 2015 Sandro Mani <manisandro@gmail.com> - 0.3-5.git5f2b784
- Rebuild (wireshark)

* Sat May 02 2015 Kalev Lember <kalevlember@gmail.com> - 0.3-4.git5f2b784
- Rebuilt for GCC 5 C++11 ABI change

* Sun Mar 08 2015 Sandro Mani <manisandro@gmail.com> - 0.3-3.git5f2b784
- Rebuild (wireshark)

* Tue Jan 27 2015 Sandro Mani <manisandro@gmail.com> - 0.3-2.git5f2b784
- Bump wireshark version
- Fix License
- Add openambit_strict-aliasing-fixes.patch
- Add openambit_fix-maybe-uninitialized.patch
- Unbundle hidapi

* Sat Dec 27 2014 Sandro Mani <manisandro@gmail.com> - 0.3-1.git5f2b784
- Initial package