Summary: Software for accessing digital cameras
Name: gphoto2
%define pkg gphoto2
%define pkgver 2.1.0
Version: %{pkgver}
Release: 7
License: LGPL
Group: Applications/Multimedia
BuildRoot: %{_tmppath}/%{name}-%{version}-root
#Source: http://www.gphoto.org/dist/%{pkg}-%{pkgver}.tar.gz
Source: ftp://ufies.org/pub/people/christophe/gphoto2/%{pkg}-%{pkgver}.tar.gz
Patch0: gphoto2-2.1.0-no-rpath.patch
Url: http://www.gphoto.org/
ExcludeArch: s390 s390x
# For /etc/hotplug/usb..
PreReq: hotplug >= 2001_04_24-13
PreReq: /sbin/ldconfig, grep, fileutils
Provides: libgphoto2
Requires: lockdev
BuildRequires: libusb-devel >= 0.1.5
BuildRequires: gtk-doc
BuildRequires: findutils perl
BuildRequires: transfig
BuildRequires: lockdev-devel

####################################
%description
The gPhoto2 project is a universal, free application and library
framework that lets you download images from several different
digital camera models, including the newer models with USB
connections. Note that
a) for some older camera models you must use the old "gphoto" package.
b) for USB mass storage models you must use the driver in the kernel

This package contains
i) the library that digital camera applications can use
ii) the command-line utility gphoto2

Other (GUI) frontends are available separately.

####################################
%package devel
Summary: Headers and links to compile against the libgphoto2 library.
Requires: %{name} = %{version}
Requires: pkgconfig
Group: Development/Libraries

####################################
%description devel
The gPhoto2 project is a universal, free application and library
framework that lets you download images from several different
digital camera models, including the newer models with USB
connections. Note that for some older camera models you must use
the old "gphoto" package.

This package contains the files needed to compile applications that
use libgphoto2.

########################################################################
# Building and installing the beast into %{buildroot}
########################################################################

####################################
%prep
rm -rf "${RPM_BUILD_DIR}/%{name}-%{version}"
%setup -q -n %{pkg}-%{pkgver}
%patch0 -p1 -b .no-rpath

####################################
%build
%define __libtoolize :
%configure --enable-docs --with-doc-dir=%{buildroot}%{_docdir}/%{name}
make

####################################
%install
rm -rf "${RPM_BUILD_ROOT}"

# Convince gphoto2 to be packaged.
perl -p -i -e "s|^libdir.*|libdir='$RPM_BUILD_ROOT%{_libdir}'|g" \
        libgphoto2_port/libgphoto2_port/libgphoto2_port.la

%makeinstall

# Fix up libtool libraries.
find $RPM_BUILD_ROOT -name '*.la' | \
  xargs perl -p -i -e "s|$RPM_BUILD_ROOT||g"

install -d -m755 %{buildroot}/etc/hotplug/usb/
install -m755 packaging/linux-hotplug/usbcam.console %{buildroot}/etc/hotplug/usb/usbcam

cp -a %{buildroot}%{_docdir}/%{name} installed-doc
find installed-doc -name '*.sgml' | xargs rm
rm -rf %{buildroot}%{_docdir}/%{name}
rm -rf %{buildroot}%{_libdir}/gphoto2/*/*a
rm -rf %{buildroot}%{_libdir}/gphoto2_port/*/*a
rm -rf %{buildroot}%{_libdir}/*.a

%find_lang %{name}
%find_lang libgphoto2_port
cat libgphoto2_port.lang >> %{name}.lang


####################################
%clean
rm -rf "${RPM_BUILD_ROOT}"

########################################################################
# file list and installation for main package
########################################################################

####################################
%files -f %{name}.lang
%defattr(-,root,root)
%doc doc/gphoto2.txt doc/gphoto2-cli.txt
%doc AUTHORS README COPYING
%{_bindir}/gphoto2
/etc/hotplug/usb/usbcam
%{_datadir}/gphoto2
%dir %{_libdir}/gphoto2_port
%dir %{_libdir}/gphoto2_port/*
%{_libdir}/gphoto2_port/*/*.so
%dir %{_libdir}/gphoto2
%dir %{_libdir}/gphoto2/*
%{_libdir}/gphoto2/*/*.so
%{_libdir}/*.so.*
%{_mandir}/man1/gphoto2.1*


####################################
%post
# add supported cameras to /etc/hotplug/usb.usermap
grep -v '^usbcam' /etc/hotplug/usb.usermap > /etc/hotplug/usb.usermap.tmp
/usr/bin/gphoto2 --print-usb-usermap >> /etc/hotplug/usb.usermap.tmp
mv /etc/hotplug/usb.usermap.tmp /etc/hotplug/usb.usermap
# register libraries
/sbin/ldconfig

####################################
%postun
# unregister libraries
/sbin/ldconfig
if [ "$1" = 0 ]; then
    # remove supported cameras from /etc/hotplug/usb.usermap
    grep -v '^usbcam' /etc/hotplug/usb.usermap > /etc/hotplug/usb.usermap.new
    mv /etc/hotplug/usb.usermap.new /etc/hotplug/usb.usermap
fi

########################################################################
# file list and installation for -devel subpackage
########################################################################

####################################
%files devel
%defattr(-,root,root)
%doc installed-doc/html
%{_bindir}/gphoto2-config
%{_bindir}/gphoto2-port-config
%{_includedir}/gphoto2
%{_libdir}/*.la
%{_libdir}/*.so
%{_libdir}/pkgconfig/*
%{_mandir}/man3/*

########################################################################
# ChangeLog
########################################################################
%changelog
* Sat Feb 01 2003 Florian La Roche <Florian.LaRoche@redhat.de>
- only package man3 in devel rpm

* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
- rebuilt

* Sun Dec 01 2002 Florian La Roche <Florian.LaRoche@redhat.de>
- remove some old mainframe ifdefs

* Tue Nov 19 2002 Tim Waugh <twaugh@redhat.com> 2.1.0-5
- Fix file lists.
- Don't install files not shipped.
- Rebuild in new environment.

* Wed Jul 24 2002 Tim Waugh <twaugh@redhat.com> 2.1.0-4
- Rebuild, just in case (readline).

* Thu Jul 18 2002 Tim Waugh <twaugh@redhat.com> 2.1.0-3
- Own some more directories.

* Fri Jun 28 2002 Tim Waugh <twaugh@redhat.com> 2.1.0-2
- Don't use -rpath (bug #65983).

* Tue Jun 25 2002 Tim Waugh <twaugh@redhat.com> 2.1.0-1
- 2.1.0.
- No longer need cvsfixes or consolelock patches.

* Fri Jun 21 2002 Tim Powers <timp@redhat.com> 2.0-9
- automated rebuild

* Thu May 23 2002 Tim Powers <timp@redhat.com> 2.0-8
- automated rebuild

* Thu May  9 2002 Tim Waugh <twaugh@redhat.com> 2.0-7
- Require lockdev (bug #64193).

* Mon Apr 29 2002 Tim Waugh <twaugh@redhat.com> 2.0-6
- In fact, don't even build for mainframe.

* Mon Apr 29 2002 Florian La Roche <Florian.LaRoche@redhat.de> 2.0-5
- do not require hotplug for mainframe

* Mon Apr 15 2002 Nalin Dahyabhai <nalin@redhat.com> 2.0-4
- Set the owner of the device to the console lock holder, not the owner
  of /dev/console, in the hotplug agent, fixing access for users who log
  in at VTs and use startx (#62976).

* Fri Apr 12 2002 Tim Waugh <twaugh@redhat.com> 2.0-3
- Rebuild (fixed bug #63355).

* Wed Feb 27 2002 Tim Waugh <twaugh@redhat.com> 2.0-2
- Fix from CVS: close port unconditionally in gp_camera_exit().

* Mon Feb 25 2002 Tim Waugh <twaugh@redhat.com> 2.0-1
- 2.0 is released.
- Ship the .so symlinks in the devel package.

* Mon Feb 25 2002 Tim Waugh <twaugh@redhat.com> 2.0-0.rc4.1
- 2.0rc4.

* Fri Feb 22 2002 Tim Waugh <twaugh@redhat.com> 2.0-0.rc3.1
- 2.0rc3.  No longer need CVS patch.
- Build no longer requires xmlto.

* Thu Feb 21 2002 Tim Waugh <twaugh@redhat.com> 2.0-0.rc2.2
- Fix DC240 hangs (patch from CVS).
- Rebuild in new environment.

* Tue Feb 19 2002 Tim Waugh <twaugh@redhat.com> 2.0-0.rc2.1
- 2.0rc2 (bug #59993).  No longer need docs patch or man page.
- Really fix up libtool libraries (bug #60002).

* Fri Feb 15 2002 Tim Waugh <twaugh@redhat.com> 2.0-0.beta5.2
- PreReq /sbin/ldconfig, grep, and fileutils (bug #59941).

* Tue Feb 12 2002 Tim Waugh <twaugh@redhat.com> 2.0-0.beta5.1
- 2.0beta5.
- Fix Makefiles so that documentation can be built.
- Ship pkgconfig file.
- Add man page.

* Thu Feb  7 2002 Tim Waugh <twaugh@redhat.com> 2.0-0.beta4.1
- 2.0beta4.
- Build requires transfig, and at least version 0.1.5 of libusb.
- Clean up file lists.
- Build documentation.

* Fri Jan 25 2002 Tim Waugh <twaugh@redhat.com> 2.0-0.beta3.2
- Rebuild in new environment.
- Dump docbook-dtd30-sgml requirement; gtk-doc is sufficient.

* Sun Nov 18 2001 Tim Waugh <twaugh@redhat.com> 2.0-0.beta3.1
- Adapted for Red Hat Linux.

* Sat Oct 27 2001 Hans Ulrich Niedermann <gp@n-dimensional.de>
- fixed update behaviour for hotplug list (do not erase it when updating)

* Thu Oct 25 2001 Tim Waugh <twaugh@redhat.com>
- hotplug dependency is a prereq not a requires (the package scripts
  need it).

* Sun Oct 14 2001 Hans Ulrich Niedermann <gp@n-dimensional.de>
- integrated spec file into source package

* Sun Oct 14 2001 Hans Ulrich Niedermann <gp@n-dimensional.de>
- 2.0beta3

* Tue Oct  2 2001 Tim Waugh <twaugh@redhat.com> 2.0beta2-0.1
- Adapted for Red Hat Linux.
- 2.0beta2.

* Mon Aug  6 2001 Till Kamppeter <till@mandrakesoft.com> 2.0-0.beta1.2mdk
- Corrected "Requires:"

* Mon Aug  6 2001 Till Kamppeter <till@mandrakesoft.com> 2.0-0.beta1.1mdk
- Initial release