File libgphoto2.spec of Package libgphoto2

#
# spec file for package libgphoto2
#
# Copyright (c) 2014 SUSE LINUX Products 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/
#


%if %( echo `rpm -q --queryformat %%{version} udev` ) > 190
%define _udevrulesdir /usr/lib/udev/rules.d
%else
%define _udevrulesdir /lib/udev/rules.d
%endif

%define major 6

Name:           libgphoto2
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gd-devel
BuildRequires:  libexif-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libtool
BuildRequires:  libusb-1_0-devel
BuildRequires:  libusb-devel
BuildRequires:  libxml2-devel
BuildRequires:  lockdev-devel
BuildRequires:  pkg-config
BuildRequires:  udev
%if 0%{?suse_version} > 1230
BuildRequires:  systemd-rpm-macros
%endif
Url:            http://gphoto.org/
# bug437293
%ifarch ppc64
Obsoletes:      libgphoto2-64bit
%endif
#
%define prefix /usr
Summary:        A Digital Camera Library
License:        LGPL-2.1+
Group:          Hardware/Camera
Version:        2.5.4.1
Release:        0
Source0:        %{name}-%{version}.tar.bz2
Source1:        %{name}-%{version}.tar.bz2.asc
Source2:        %name.keyring
Source3:        baselibs.conf
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Recommends:     %{name}-%{major}-lang = %{version}

%package -n libgphoto2-%{major}
Summary:        A Digital Camera Library
Group:          Hardware/Camera
Recommends:     %{name}-%{major}-lang = %{version}

%package devel
Summary:        Development headers for libgphoto2
Group:          Hardware/Camera
Requires:       libexif-devel
Requires:       libgphoto2-%{major} = %version
Requires:       libusb-1_0-devel

%description
gPhoto (GNU Photo) is a set of libraries for previewing, retrieving,
and capturing images from a range of supported digital cameras to your
local hard drive. It does not support digital cameras based on the USB
storage protocol. Those can be mounted by Linux directly.

As of this time, gPhoto supports around 1700 cameras, listed on:

http://gphoto.org/proj/libgphoto2/support.php

or by running

gphoto2 --list-cameras

%description -n libgphoto2-%{major}
gPhoto (GNU Photo) is a set of libraries for previewing, retrieving,
and capturing images from a range of supported digital cameras to your
local hard drive. It does not support digital cameras based on the USB
storage protocol as those can be mounted by Linux directly.

As of this time, gPhoto supports around 1700 cameras, listed on:

http://gphoto.org/proj/libgphoto2/support.php

or by running

gphoto2 --list-cameras

%description devel
gPhoto (GNU Photo) is a set of libraries for previewing, retrieving,
and capturing images from a range of supported digital cameras to your
local hard drive.

These are its development libraries and headers.

%lang_package -n libgphoto2-%{major}

%prep
%setup -q

%build
#AUTOPOINT=true autoreconf -fi
PATH="/usr/X11R6/bin:$PATH"			\
%configure					\
  --with-doc-dir=%{_defaultdocdir}/%{name}	\
  --without-hal \
  --with-drivers=all
make %{?_smp_mflags}

%check
make check

%install
# skip-check-libtool-deps
export LIBRARY_PATH=$RPM_BUILD_ROOT%{_libdir}
%makeinstall
%{find_lang} libgphoto2-%{major}
%{find_lang} libgphoto2_port-10
cat libgphoto2-%{major}.lang libgphoto2_port-10.lang > libgphoto2-all.lang
pushd packaging/generic
	export CAMLIBS=$RPM_BUILD_ROOT/%_libdir/libgphoto2/%version/
	# new style UDEV rules (gudev) which will obsolete HAL fdi files
	if [ ! -d %{_udevrulesdir} ] ; then
		echo "*** The udev rules file location has changed. Fix the build."
		exit 1
	fi
%if 0%{?suse_version} > 1230
	install -m 0755 -d         $RPM_BUILD_ROOT/%{_udevhwdbdir}
	./print-camera-list hwdb > $RPM_BUILD_ROOT/%{_udevhwdbdir}/20-gphoto.hwdb
	# We still need UDEV rules for /dev/sg* and /dev/sd* for picture frames.
	# We also need it for PTP cameras that we do not know to appear in GVFS.
	install -m 0755 -d                           $RPM_BUILD_ROOT%{_udevrulesdir}
	./print-camera-list udev-rules version 201 > $RPM_BUILD_ROOT%{_udevrulesdir}/40-libgphoto2.rules
%else
	install -m 0755 -d                           $RPM_BUILD_ROOT%{_udevrulesdir}
	./print-camera-list udev-rules version 175 > $RPM_BUILD_ROOT%{_udevrulesdir}/40-libgphoto2.rules
%endif
popd
# udev helpers not used here.
rm $RPM_BUILD_ROOT/usr/%_lib/udev/check-ptp-camera
mv doc/doxygen-output/libgphoto2-api.html apidocs 
fn=$RPM_BUILD_ROOT/%{_libdir}/pkgconfig/libgphoto2_port.pc
grep -v driverdir= $fn > $fn.new
mv $fn.new $fn

find "%buildroot/%_libdir" -type f -name "*.la" -delete
%fdupes $RPM_BUILD_ROOT

%files -n libgphoto2-%{major}
%defattr(-,root,root)
%{_libdir}/libgphoto2
%{_libdir}/libgphoto2_port
%dir %{_defaultdocdir}/%{name}
%{_defaultdocdir}/%{name}/*
%{prefix}/share/%{name}
%{_libdir}/libgphoto2.so.*
%{_libdir}/libgphoto2_port.so.*
%{_mandir}/man3/libgphoto2.3*
%{_mandir}/man3/libgphoto2_port.3*
%if 0%{?suse_version} > 1230
%{_udevhwdbdir}/20-gphoto.hwdb
%endif
%{_udevrulesdir}/40-libgphoto2.rules

%files -n libgphoto2-%{major}-lang -f libgphoto2-all.lang

%files devel
%defattr(-,root,root)
%doc apidocs
%{prefix}/include/gphoto2
%{prefix}/bin/gphoto2-config
%{prefix}/bin/gphoto2-port-config
%{_libdir}/libgphoto2.so
%{_libdir}/libgphoto2_port.so
%{_libdir}/pkgconfig/libgphoto2.pc
%{_libdir}/pkgconfig/libgphoto2_port.pc

%post -n %name-%major
/sbin/ldconfig
%if 0%{?suse_version} > 1230
%udev_hwdb_update
%endif
udevadm control --reload 2>&1 > /dev/null || :

%postun -n %name-%major
/sbin/ldconfig
if [ $1 -eq 0 ]; then
%if 0%{?suse_version} > 1230
        %udev_hwdb_update
        %udev_rules_update
%endif
udevadm control --reload 2>&1 > /dev/null || :
fi

%{nil}

%changelog