Blob Blame History Raw
%global wireshark_ver 1.10.12
%global commit 5f2b7840d91121b44a9a16ac6d945b103a94c5a3
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name:           openambit
Version:        0.3
Release:        2%{?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 = %{wireshark_ver}
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} = %{wireshark_ver}
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 ../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/%{wireshark_ver}/ambit.so

%{_bindir}/appstream-util validate %{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.*
%{_sysconfdir}/udev/rules.d/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/%{wireshark_ver}/ambit.so


%changelog
* 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