File usbmuxd.spec of Package usbmuxd.2701

#
# spec file for package usbmuxd
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


%{!?_udevrulesdir: %global _udevrulesdir %(pkg-config --variable=udevdir udev)/rules.d}

Name:           usbmuxd
%define _libname   libusbmuxd
Version:        1.0.8
Release:        0
Summary:        Socket daemon for the usbmux protocol used by Apple devices
License:        (GPL-2.0 or GPL-3.0) and LGPL-2.1+
Group:          System/Libraries
Url:            http://cgit.sukimashita.com/usbmuxd.git/
Source:         http://www.libimobiledevice.org/downloads/%{name}-%{version}.tar.bz2
Patch0:         0001-Add-support-for-automatic-activation-as-systemd-serv.patch
# PATCH-FIX-UPSTREAM usbmuxd-CVE-2016-5104.patch CVE-2016-5104 boo#982014 mgorse@suse.com - Make sure sockets only listen locally
Patch1:         usbmuxd-CVE-2016-5104.patch
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  libplist-devel
BuildRequires:  libusb-1_0-devel >= 1.0.3
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(udev)
Requires(pre):  pwdutils
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{?systemd_requires}

%description
This package provides the usbmuxd daemon for software to use through the
libusbmuxd library to talk with iPhone/iPod Touch devices.

Usbmux is an encapsulation protocol (think IP, ATM, PPP) that allows
multiplexing several conversations onto a single pair of wires.

%package -n %{_libname}2

Summary:        A library to abstract socket/protocol communication to the usbmuxd daemon
Group:          System/Libraries
Requires:       %{name}
Provides:       %{_libname} = %{version}
Obsoletes:      %{_libname} < %{version}

%description -n %{_libname}2
This package contains the libusbmuxd library which provides an interface to
talk to the usbmux daemon, create connections and list attached devices.

%package -n %{_libname}-devel

Summary:        Development files for %{_libname}
Group:          Development/Libraries/C and C++
Requires:       %{_libname} = %{version}
Requires:       glibc-devel

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

%package -n iproxy
Summary:        Proxy enabling TCP tunneling to iPhone/iPod Touch via USB cable
Group:          System/Libraries
Requires:       %{_libname} = %{version}

%description -n iproxy
Proxy enabling TCP tunneling to iPhone/iPod Touch via USB cable.

It allows you to map a port of a service running on the device (like sshd) and
redirect it to your local machine where you can interact with it.

%pre
getent passwd usbmux >/dev/null || useradd -r -g nogroup -d /var/lib/%{name} -s /sbin/nologin -c "%{name} daemon" usbmux
%service_add_pre usbmuxd.service
exit 0

%preun
%service_del_preun usbmuxd.service

%post
%{?udev_rules_update:%udev_rules_update}
%service_add_post usbmuxd.service

%postun
%service_del_postun usbmuxd.service

%prep
%setup -q
%patch0 -p1
%patch1 -p1
sed -i -e 's,/lib/udev/rules.d,%{_udevrulesdir},g' udev/CMakeLists.txt
%if 0%{?suse_version} >= 1230
sed -i -e 's,/lib/systemd/system,%{_unitdir},g' udev/CMakeLists.txt
%endif

%build
mkdir build
cd build
export CFLAGS="%{optflags} -fno-strict-aliasing"
cmake -DBUILD_STATIC_LIBS:BOOL=OFF -DCMAKE_INSTALL_PREFIX=%{_prefix} \
%if "%{_lib}" == "lib64"
      -DLIB_SUFFIX:STRING=64 \
%endif
      -DCMAKE_VERBOSE_MAKEFILE=TRUE \
      -DCMAKE_C_FLAGS_RELEASE:STRING="%{optflags}" \
      -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags}" \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_SKIP_RPATH=1 \
      -DBUILD_TESTING=OFF \
%if %{undefined suse_version}
      -DCMAKE_INSTALL_DO_STRIP=1 \
%endif
      -DWANT_SYSTEMD=ON \
      ..
make %{?_smp_mflags}

%install
cd build
%{__make} install DESTDIR=%{buildroot}

%clean
rm -rf %{buildroot}

%post -n %{_libname}2 -p /sbin/ldconfig

%postun -n %{_libname}2 -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc AUTHORS COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv2.1 README
%{_sbindir}/usbmuxd
%{_udevrulesdir}/85-usbmuxd.rules
%{_unitdir}/usbmuxd.service

%files -n %{_libname}2
%defattr(-,root,root)
%{_libdir}/libusbmuxd.so.*

%files -n %{_libname}-devel
%defattr(-,root,root,-)
%doc README.devel
%{_includedir}/usbmuxd.h
%{_includedir}/usbmuxd-proto.h
%{_libdir}/%{_libname}.so
%{_libdir}/pkgconfig/%{_libname}.pc

%files -n iproxy
%defattr(-,root,root)
%{_bindir}/iproxy

%changelog
openSUSE Build Service is sponsored by