1#  iscan.spec.in -- an rpm spec file template
2#  Copyright (C) 2004--2006  Olaf Meeuwissen
3#
4#  This file is part of the "Image Scan!" build infra-structure.
5#
6#  The "Image Scan!" build infra-structure is free software.
7#  You can redistribute it and/or modify it under the terms of the GNU
8#  General Public License as published by the Free Software Foundation;
9#  either version 2 of the License or at your option any later version.
10#
11#  This program is distributed in the hope that it will be useful, but
12#  WITHOUT ANY WARRANTY;  without even the implied warranty of FITNESS
13#  FOR A PARTICULAR PURPOSE or MERCHANTABILITY.
14#  See the GNU General Public License for more details.
15#
16#  You should have received a verbatim copy of the GNU General Public
17#  License along with this program; if not, write to:
18#
19#	 Free Software Foundation, Inc.
20#	 59 Temple Place, Suite 330
21#	 Boston, MA  02111-1307	 USA
22
23#  Readability macro to help determine the C++ compiler's ABI version
24#  at RPM build time.
25#
26%define cxx_abi	%{__cxx} -E -dM - < /dev/null | %{__awk} '/GXX_ABI/{print $3}'
27
28#  Some handy macro definitions.
29#
30%define pkg	iscan
31%define ver	2.11.0
32%define rel	1
33%define abi	%(test 1002 = `%cxx_abi` && echo .c2)
34%define msg	%{_tmppath}/%{pkg}-%{ver}-%{rel}.msg
35
36%define ia32			i386 i486 i586 i686
37%define gimp_api_versions	1.2 2.0
38
39# 	general package information
40
41Name:		%{pkg}
42Version:	%{ver}
43Release:	%{rel}%{abi}
44Source:		%{pkg}_%{ver}-%{rel}.tar.gz
45License:	GPL (with exception clauses) and EAPL
46
47Vendor:		EPSON AVASYS Corporation
48URL:		http://www.avasys.jp/linux/index.html
49Packager:	EPSON AVASYS Corporation <pipsnews@avasys.jp>
50
51PreReq:		sane-backends
52Conflicts:	iscan-interpreter < 2.1, iscan-plugin-cx4400 < 2.1, iscan-plugin-gt-7200 < 2.1, iscan-plugin-gt-7300 < 2.1, iscan-plugin-gt-9400 < 2.1, iscan-plugin-gt-f500 < 2.1, iscan-plugin-gt-f520 < 2.1, iscan-plugin-gt-f600 < 2.1, iscan-plugin-gt-f670 < 2.1, iscan-plugin-gt-f700 < 2.1, iscan-plugin-gt-s600 < 2.1, iscan-plugin-gt-x750 < 2.1
53
54BuildRoot:	%{_tmppath}/%{pkg}-%{ver}-%{rel}-root
55BuildRequires:	libusb >= 0.1.6, sane-backends-devel
56
57%ifarch %{ia32}
58BuildRequires:	gtk2-devel, gimp-devel, libpng-devel, libjpeg-devel
59%endif
60
61Group:		Applications/Multimedia
62%ifnarch %{ia32}
63Summary:	SANE backend for SEIKO EPSON scanners and all-in-ones
64%description
65The scanner driver provided by this package can be used by any SANE
66standard compliant scanner utility.
67
68Note that some scanners are only supported on the ia32 architecture.
69%else
70Summary:	simple, easy to use scanner utility for EPSON scanners
71%description
72Image Scan! is a graphical scanner utility for people that do not need
73all the bells and whistles provided by several of the other utilities
74out there (xsane, QuiteInsane, Kooka).
75
76At the moment it only supports SEIKO EPSON scanners and all-in-ones.
77However, the scanner driver it provides can be used by any other SANE
78standard compliant scanner utility.
79
80Note that several scanners require a non-free plugin before they can
81be used with this software.
82%endif
83
84
85# 	rpmbuild sections
86
87%prep
88%setup -q
89
90
91%build
92%ifarch %{ia32}
93%configure \
94	--enable-frontend \
95	--enable-jpeg \
96	--enable-png
97%else
98%configure
99%endif
100make
101
102
103%install
104rm -rf ${RPM_BUILD_ROOT}
105make install DESTDIR=${RPM_BUILD_ROOT}
106test -d ${RPM_BUILD_ROOT}%{_sysconfdir}/hotplug/usb \
107    || mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/hotplug/usb
108%{__install} -m 0644 utils/hotplug/iscan.usermap \
109    ${RPM_BUILD_ROOT}%{_sysconfdir}/hotplug/usb
110%{__install} -m 0755 utils/hotplug/iscan-device \
111    ${RPM_BUILD_ROOT}%{_sysconfdir}/hotplug/usb
112#
113#  Recent rpmbuild versions follow a FASCIST packaging policy and bomb
114#  out on any installed files that are not packaged and non-installed
115#  files that are.  Clean up 'make install's act here.
116#
117sane_confdir=%{_sysconfdir}/sane.d
118./mkinstalldirs -m 0755 ${RPM_BUILD_ROOT}${sane_confdir}
119install -m 0644 backend/epkowa.conf ${RPM_BUILD_ROOT}${sane_confdir}
120rm ${RPM_BUILD_ROOT}%{_libdir}/sane/libsane-epkowa.so
121rm ${RPM_BUILD_ROOT}%{_libdir}/sane/libsane-epkowa.a
122#
123#  Create a list of message catalogs that should be included in the RPM
124#  binary package.  Use %lang(ll) notation so that sysadmins can choose
125#  the catalogs they want installed.
126#
127> %{msg}
128cd ${RPM_BUILD_ROOT}/%{_datadir}/locale
129for lang in *
130do
131    test -f ${lang}/LC_MESSAGES/%{pkg}.mo || continue
132    ll=`echo ${lang} | sed 's,@.*$,,'`
133    echo "%lang(${ll}) %{_datadir}/locale/${lang}/LC_MESSAGES/%{pkg}.mo" \
134	>> %{msg}
135done
136
137
138%clean
139make clean			# rm -rf %{_builddir}/%{name}-%{version}
140rm -rf ${RPM_BUILD_ROOT}
141rm -f %{msg}
142
143
144# 	rpm (un)installation scripts
145
146#  Believe it or not, but there are distros out there that do not have
147#  the sane service listed in their /etc/services.  Also note that the
148#  official service name, as registered with the IANA is not sane, but
149#  sane-port.  The saned alias is also commonly used.
150#
151%pre
152srv=/etc/services
153if [ -z "`grep 6566/tcp ${srv}`" ]
154then
155    cat >> ${srv} <<EOF
156sane-port       6566/tcp   sane saned   # SANE Control Port
157sane-port       6566/udp   sane saned   # SANE Control Port
158EOF
159fi
160
161
162%post
163#
164#  Create udev rules from our installed hotplug usermap.
165#
166%{_libdir}/%{pkg}/make-udev-rules \
167    %{_sysconfdir}/hotplug/usb/iscan.usermap \
168    %{_sysconfdir}/udev/rules.d
169#
170#  Enable the epkowa backend unconditionally, assuming that people who
171#  install this package want to use it.
172#
173dll=%{_sysconfdir}/sane.d/dll.conf
174if [ -n "`grep '#[[:space:]]*epkowa' ${dll}`" ]
175then				# uncomment existing entry
176    sed -i 's,#[[:space:]]*\(epkowa\),\1,' ${dll}
177elif [ -z "`grep epkowa ${dll}`" ]
178then				# append brand new entry
179    echo epkowa >> ${dll}
180fi
181#
182#  Enable the GIMP plug-ins functionality system wide.
183#
184if test -x %{_bindir}/iscan
185then
186    for prefix in %{_libdir} /opt/gnome/lib
187    do
188        [ -d ${prefix} ] || continue
189        for version in %{gimp_api_versions}
190        do
191	    dir=${prefix}/gimp/${version}/plug-ins
192            [ -d ${dir} ] || mkdir -p ${dir}
193	    ln -fs %{_bindir}/iscan ${dir}
194        done
195    done
196    plugindir="`gimptool --gimpplugindir 2> /dev/null`"
197    if [ x  = x"${plugindir}" ]; then
198        plugindir="`gimptool-2.0 --gimpplugindir 2> /dev/null`"
199    fi
200    if [ x != x"${plugindir}" ]; then
201        ln -fs %{_bindir}/iscan ${plugindir}/plug-ins
202    fi
203fi
204#
205#  Append our usermap data to usb.usermap for ancient hotplug versions
206#  that don't look below $HOTPLUG_DIR/usb/.
207#
208agent=%{_sysconfdir}/hotplug/usb.agent
209map=%{_sysconfdir}/hotplug/usb.usermap
210
211if [ -x $agent -a -f $map ]; then
212
213    notice='08-Aug-2002[[:space:]]*support for multiple usermaps'
214    source='for MAP in $MAP_USERMAP $HOTPLUG_DIR/usb/\*\.usermap'
215
216    if [ -z "$(grep "$notice" $agent)" -a -z "$(grep "$source" $agent)" ]
217    then
218	# We've got an ancient hotplug version that doesn't look for
219	# maps in $HOTPLUG_DIR/usb/*.usermap.  Append our usermap to
220	# usb.usermap to work around this.
221
222	header='# Following info courtesy of Image Scan!'
223	footer='# Preceding info courtesy of Image Scan!'
224
225	# Clean out any previous additions we've made
226
227	if [ -n "$(grep "$header" $map)" ]; then
228	    cp $map $map.orig
229	    sed "/^$header/,/^$footer/d" $map.orig > $map \
230		&& rm $map.orig
231	fi
232
233	# Add our latest and greatest usermap
234
235	echo "$header" >> $map
236	cat %{_sysconfdir}/hotplug/usb/iscan.usermap >> $map
237	echo "$footer" >> $map
238    fi
239fi
240
241
242#  We have nothing to do.
243#
244%preun
245
246
247#  Clean up left-overs from old iscan versions that silently clobbered
248#  libsane-epson.  These versions only used library version numbers of
249#  1.0.3 and 1.0.6.  Take care not to wipe symlinks to a sane-backends
250#  EPSON backend.  For most of the currently used distributions, these
251#  should all have a version number > 1.0.6.
252#  FTR, sane-backends-1.0.6 was released on 2001-11-05.
253#  Disable the backend we provide.
254#  Also clean up our data directory, but only if it is empty.
255#
256%postun
257if [ $1 = 0 ]
258then
259    for lib_ver in 1.0.3 1.0.6
260    do
261	libname=%{_libdir}/sane/libsane-epson.so
262	if [ "`readlink ${libname} 2>/dev/null`" = libsane-epson.so.${lib_ver} ]
263	then
264	    rm -f ${libname}.1
265	    rm -f ${libname}
266	fi
267    done
268    #
269    #  Clean out any additions to the top-level usermap
270    #
271    map=%{_sysconfdir}/hotplug/usb.usermap
272    header='# Following info courtesy of Image Scan!'
273    footer='# Preceding info courtesy of Image Scan!'
274    if [ -f $map ]; then
275	if [ -n "$(grep "$header" $map)" ]; then
276	    cp $map $map.orig
277	    sed "/^$header/,/^$footer/d" $map.orig > $map \
278		&& rm $map.orig
279	fi
280    fi
281    dll=%{_sysconfdir}/sane.d/dll.conf
282    if [ -n "`grep ^epkowa ${dll}`" ]
283    then
284	sed -i 's/^epkowa/#epkowa/' ${dll}
285    fi
286fi
287rmdir %{_datadir}/%{pkg} 2> /dev/null || true
288rmdir %{_libdir}/%{pkg}  2> /dev/null || true
289#
290#  Clean up the GIMP plug-ins.
291#
292for prefix in %{_libdir} /opt/gnome/lib
293do
294    for version in %{gimp_api_versions}
295    do
296	dir=${prefix}/gimp/${version}/plug-ins
297	rm    ${dir}/iscan 2> /dev/null || true
298	rmdir ${dir}       2> /dev/null || true
299	rmdir `dirname ${dir}` 2> /dev/null || true
300    done
301    rmdir ${prefix}/gimp 2> /dev/null || true
302done
303plugindir="`gimptool --gimpplugindir 2> /dev/null`"
304if [ x  = x"${plugindir}" ]; then
305    plugindir="`gimptool-2.0 --gimpplugindir 2> /dev/null`"
306fi
307if [ x != x"${plugindir}" ]; then
308    rm ${plugindir}/plug-ins/iscan 2> /dev/null || true
309fi
310
311
312# 	package contents
313
314#  Note that we generate the %%{msg} file during the %%install phase
315#  so that we can use %%lang(xx) notation without the need to resort
316#  to a manually maintained list here.
317#
318%files -f %{msg}
319%defattr(-,root,root)
320
321%doc NEWS    README    AUTHORS
322%doc COPYING COPYING.LIB
323%doc non-free/EAPL.en.txt
324#  This should really go into ${RPM_DOC_DIR}/examples/.
325%doc doc/xinetd.sane
326
327%doc NEWS.ja README.ja
328%doc non-free/EAPL.ja.txt
329
330%config(noreplace)	%{_sysconfdir}/sane.d/epkowa.conf
331
332%ifarch %{ia32}
333%{_bindir}/iscan
334%{_libdir}/libesmod.so*
335%endif
336%{_libdir}/sane/libsane-epkowa.la
337%{_libdir}/sane/libsane-epkowa.so.*
338%{_libdir}/%{pkg}/make-udev-rules
339%{_mandir}/man*/*
340%{_sysconfdir}/hotplug/usb
341
342
343# 	significant packaging changes
344
345%changelog
346* Tue May 23 2006  Olaf Meeuwissen <olaf.meeuwissen@avasys.jp>
347  - create udev rules from hotplug usermap using custom utility
348
349* Tue Jan 24 2006  Olaf Meeuwissen <olaf.meeuwissen@avasys.jp>
350  - turned the dependency on sane-backend into a PreReq: because our
351    %post mucks with its dll.conf
352  - disable the backend when uninstalling
353  - use sed's -i option to modify dll.conf in place
354
355* Sat Jan 21 2006  Olaf Meeuwissen <iscan@member.fsf.org>
356  - removed packaging of interpreter plugins
357
358* Fri Sep 30 2005  Olaf Meeuwissen <olaf.meeuwissen@avasys.jp>
359  - package the backend interpreter plugins in their own RPMs
360  - added support for build on architectures other than IA32
361  - beefed up the BuildRequires:
362
363* Thu Jun 16 2005  Olaf Meeuwissen <olaf.meeuwissen@avasys.jp>
364  - use gimptool to find the plugin directory (note that some distro's
365    prefer to provide gimptool-2.0 only!)
366
367* Thu May 19 2005  Olaf Meeuwissen <olaf.meeuwissen@avasys.jp>
368  - fixed broken dependency specification
369  - use release number defined in configure.ac
370
371* Mon Apr 25 2005  Olaf Meeuwissen <olaf.meeuwissen@avasys.jp>
372  - modified %doc entries to handle license file name changes
373  - updated URL: to reflect corporate name change
374
375* Sun Apr 10 2005  Olaf Meeuwissen <iscan@member.fsf.org>
376  - integrated iscan-1.14.0 changes to add hotplug support
377
378* Fri Dec 24 2004  Olaf Meeuwissen <iscan@member.fsf.org>
379  - bumped libusb versioned dependency to use the correct version
380
381* Fri Dec  3 2004  Olaf Meeuwissen <olaf@epkowa.co.jp>
382  - fixed creation of GIMP plug-in symlinks
383
384* Mon Nov  1 2004  Olaf Meeuwissen <olaf@epkowa.co.jp>
385  - fixed libesmod.so* path (it's not in %{_libdir}/%{pkg} yet)
386  - added Japanese documentation
387  - doubled %s in the spec file parts to un-confuse rpmbuild
388  - fixed typo in config file installation command
389  - fixed generation of message catalog list
390
391* Fri Oct 29 2004  Olaf Meeuwissen <iscan@member.fsf.org>
392  - adapt to Fascist build policy
393  - no longer install libsane-epkowa.so as this seems to have become
394    the vogue for non-development packages
395  - install libsane-epkowa.la so that the dll backend can still find
396    the epkowa backend
397
398* Tue Oct 19 2004  Olaf Meeuwissen <iscan@member.fsf.org>
399  - initial spec file
400
401# 	end of file
402