File openant.spec of Package openant

Name:           openant
BuildRequires:  python-devel
BuildRequires:  python-setuptools
BuildRequires:  libusb-compat-devel
BuildRequires:  udev
Requires:       udev
Requires:       pyusb
BuildRequires:  pyusb
Version:        0.3
Release:        0
Summary:        ANT and ANT-FS Python Library 
License:        MIT
Group:          System/Libraries
Url:            https://github.com/Tigge/openant
Source0:        %{name}.tar
Patch0:         skip_udev_install.patch
BuildArch:      noarch


%description
python library to download and upload files from ANT-FS compliant devices (Garmin products).

%prep
tar xf ../SOURCES/openant.tar
%patch0 -p0

%build
cd openant
CFLAGS="$RPM_OPT_FLAGS" \
python setup.py build

%install
rm -rf $RPM_BUILD_ROOT
cd openant
python setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
/usr/lib/python2.7/site-packages/ant
/usr/lib/python2.7/site-packages/openant*


%post
if [ ! -e /etc/udev/rules.d/ant-usb-sticks.rules  ]; then
  mkdir -p /etc/udev/rules.d
  touch /etc/udev/rules.d/ant-usb-sticks.rules
  echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0fcf", ATTR{idProduct}=="1008", MODE="0666", SYMLINK+="ttyANT2", ACTION=="add"' >> /etc/udev/rules.d/ant-usb-sticks.rules
  echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0fcf", ATTR{idProduct}=="1009", MODE="0666", SYMLINK+="ttyANT3", ACTION=="add"' >> /etc/udev/rules.d/ant-usb-sticks.rules
fi
udevadm control --reload-rules || true
udevadm trigger --subsystem-match=usb --attr-match=idVendor=0fcf --action=add || true

#%postun
#rm /etc/udev/rules.d/ant-usb-sticks.rules

%changelog