# Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/media-gfx/iscan/iscan-2.11.0.ebuild,v 1.4 2008/06/30 17:52:50 sbriesen Exp $ WANT_AUTOCONF="latest" WANT_AUTOMAKE="latest" inherit eutils toolchain-funcs flag-o-matic autotools rpm SRC_REV="6" # revision used by upstream # HINTS: # -> isane frontend needs non-free modules # -> sane-epkowa should be usable on every arch # -> ${P}-${SRC_REV}.tar.gz (for gcc 3.2/3.3) # -> ${P}-${SRC_REV}.c2.tar.gz (for gcc 3.4 or later) # PLUGINS: # -> iscan-plugin-gt-7200 == Perfection 1250 PHOTO # -> iscan-plugin-gt-7300 == Perfection 1260 PHOTO # -> iscan-plugin-gt-9400 == Perfection 3170 PHOTO (esfw32.bin) # -> iscan-plugin-gt-f500 == Perfection 2480/2580 PHOTO (esfw41.bin) # -> iscan-plugin-gt-f520 == Perfection 3490/3590 PHOTO (esfw52.bin) # -> iscan-plugin-gt-f600 == Perfection 4180 PHOTO (esfw43.bin) # -> iscan-plugin-gt-x750 == Perfection 4490 PHOTO (esfw54.bin) # -> iscan-plugin-gt-s600 == Perfection V10/V100 PHOTO (esfw66.bin) # -> iscan-plugin-gt-f700 == Perfection V350 PHOTO (esfw68.bin) # -> iscan-plugin-gt-f670 == Perfection V200 PHOTO (esfw7A.bin) # -> iscan-plugin-gt-x770 == Perfection V500 PHOTO (esfw7C.bin) # -> iscan-plugin-cx4400 == Stylus CX4300/CX4400/CX4450/CX5500/CX5600/DX4400/DX4450 # FIXME: # Make jpeg/png optional. The problem is, that the # configure script ignores --disable-*, if the # corresponding lib is found on the system. # Furthermore, isane doesn't compile w/o libusb, # this should be fixed somehow. # available x86 plugins (will be assembled below) PLUGINS=" GT-F700/iscan-plugin-gt-f700-2.1.0-3.c2 GT-X770/iscan-plugin-gt-x770-2.1.1-2.c2 GT-F720/esci-interpreter-gt-f720-0.0.1-2 GT-F670/iscan-plugin-gt-f670-2.1.0-3.c2" # http://linux.avasys.jp/drivers/scanner-plugins/GT-F700/iscan-plugin-gt-f700-2.1.0-3.c2.i386.rpm # http://linux.avasys.jp/drivers/scanner-plugins/GT-X770/iscan-plugin-gt-x770-2.1.1-2.c2.i386.rpm # http://linux.avasys.jp/drivers/scanner-plugins/GT-F720/esci-interpreter-gt-f720-0.0.1-2.i386.rpm # http://linux.avasys.jp/drivers/scanner-plugins/GT-F670/iscan-plugin-gt-f670-2.1.0-3.c2.i386.rpm # Firmware files within plugin RPMs FIRMWARE=( "iscan/esfw41.bin Perfection 2480/2580 PHOTO" "iscan/esfw32.bin Perfection 3170 PHOTO" "iscan/esfw52.bin Perfection 3490/3590 PHOTO" "iscan/esfw43.bin Perfection 4180 PHOTO" "iscan/esfw54.bin Perfection 4490 PHOTO" "iscan/esfw66.bin Perfection V10/V100 PHOTO" "esci/esfw8b.bin Perfection V300 PHOTO" "iscan/esfw68.bin Perfection V350 PHOTO" "iscan/esfw7A.bin Perfection V200 PHOTO" "iscan/esfw7C.bin Perfection V500 PHOTO" ) SRC_GCC34="http://linux.avasys.jp/drivers/iscan/${PV}/${PN}_${PV}-${SRC_REV}.tar.gz" BIN_GCC34="" for X in ${PLUGINS}; do BIN_GCC34="${BIN_GCC34} http://linux.avasys.jp/drivers/scanner-plugins/${X}.i386.rpm" done BIN_AMD64="" for X in ${PLUGINS}; do BIN_AMD64="${BIN_AMD64} http://linux.avasys.jp/drivers/scanner-plugins/${X}.x86_64.rpm" done # feel free to add your arch, every non-x86 # arch doesn't install any x86-only stuff. KEYWORDS="~amd64 x86" DESCRIPTION="EPSON Image Scan! for Linux (including sane-epkowa backend and firmware)" HOMEPAGE="http://www.avasys.jp/english/linux_e/dl_scan.html" SRC_URI="${SRC_GCC34} x86? ( ${BIN_GCC34} ) amd64? ( ${BIN_AMD64} )" LICENSE="GPL-2 EAPL EPSON" SLOT="0" IUSE="X gimp" IUSE_LINGUAS="de es fr it ja ko nl pt zh_CN zh_TW" for X in ${IUSE_LINGUAS}; do IUSE="${IUSE} linguas_${X}"; done QA_TEXTRELS=" usr/lib$(get_libdir)/iscan/lib*" DEPEND="media-gfx/sane-backends media-libs/libpng media-libs/jpeg >=sys-fs/udev-103 >=dev-libs/libusb-0.1.12 X? ( sys-devel/gettext >=x11-libs/gtk+-2.0 gimp? ( media-gfx/gimp ) )" snapscan_firmware() { local i echo "#-------------- EPSON Image Scan! for Linux Scanner-Firmware --------------" for i in "${FIRMWARE[@]}"; do echo echo "# ${i#* } (${i%% *})" echo "#firmware /usr/share/${i%% *}" done echo cat 2>/dev/null "${1}" } usermap_to_udev() { echo '# udev rules file for iscan devices (udev >= 0.98)' echo '#' echo 'ACTION!="add", GOTO="iscan_rules_end"' echo 'SUBSYSTEM!="usb*", GOTO="iscan_rules_end"' echo 'KERNEL=="lp[0-9]*", GOTO="iscan_rules_end"' echo sed -n -e ' /^:model[[:space:]]*"[^"]/ { # Create model name string s|^:model[[:space:]]*"\([^"]\+\).*|# \1| # Copy to hold buffer h } /^:usbid[[:space:]]*"0x[[:xdigit:]]\+"[[:space:]]*"0x[[:xdigit:]]\+"/ { # Append next line N # Check status /\n:status[[:space:]]*:\(complete\|good\|untested\)/ { # Exchange with hold buffer x # Print (model name string) p # Exchange with hold buffer x # Create udev command string s|^:usbid[[:space:]]*"0x\([[:xdigit:]]\+\)"[[:space:]]*"0x\([[:xdigit:]]\+\)".*|ATTRS{idVendor}=="\1", ATTRS{idProduct}=="\2", MODE="0660", GROUP="scanner"| # Print (udev command string) p } } ' "${1}" echo echo 'LABEL="iscan_rules_end"' } pkg_setup() { local i # Select correct tarball for installed GCC. This is not a perfect # solution and should be expanded to other working GCC versions. einfo "GCC version: $(gcc-fullversion)" case "$(gcc-version)" in 3.4|4.[01234]) # 4.x seems to work (tested with Perfection 3490 PHOTO) MY_A="${SRC_GCC34##*/}" if use x86; then for i in ${BIN_GCC34}; do MY_A="${MY_A} ${i##*/}"; done else for i in ${BIN_AMD64}; do MY_A="${MY_A} ${i##*/}"; done fi ;; *) die "Your GCC version is not supported. You need either 3.4 or 4.x!" ;; esac } src_unpack() { local i cd "${WORKDIR}" for i in ${MY_A}; do case "${i}" in *.rpm) echo ">>> Unpacking ${i}" rpm_unpack "${DISTDIR}/${i}" || die "failure unpacking ${i}" ;; *) unpack "${i}" ;; esac done cd "${S}" # apply patches # epatch "${FILESDIR}/${P}-gcc43.patch" #epatch "${FILESDIR}/${P}-libltdl.patch" # convert japanese docs to UTF-8 if use linguas_ja; then for i in {NEWS,README}.ja non-free/*.ja.txt; do if [ -f "${i}" ]; then echo ">>> Converting ${i} to UTF-8" iconv -f eucjp -t utf8 -o "${i}~" "${i}" && mv -f "${i}~" "${i}" || rm -f "${i}~" fi done fi # autotool stuff #rm m4/libtool.m4 #eautoreconf } src_compile() { econf $(use_enable X frontend) || die "econf failed" emake CXX="$(tc-getCXX)" || die "emake failed" } src_install() { local MY_LIB="/usr/$(get_libdir)" make DESTDIR="${D}" install || die "make install failed" # --disable-static doesn't work, so we just remove obsolete static lib sed -i -e "s:^\(old_library=\):# \1:g" "${D}${MY_LIB}/sane/libsane-epkowa.la" rm -f "${D}${MY_LIB}/sane/libsane-epkowa.a" dodir ${MY_LIB}/iscan cp -df "${WORKDIR}"/${MY_LIB}/iscan/* "${D}${MY_LIB}"/iscan/. dodir ${MY_LIB}/esci cp -df "${WORKDIR}"/${MY_LIB}/esci/* "${D}${MY_LIB}"/esci/. # install scanner firmware (could be used by sane-backends) insinto /usr/share/iscan doins "${WORKDIR}"/usr/share/iscan/* insinto /usr/share/esci doins "${WORKDIR}"/usr/share/esci/* # install docs dodoc AUTHORS NEWS README doc/epkowa.desc use linguas_ja && dodoc NEWS.ja README.ja # remove 'make-udev-rules', we use our own stuff below rm -f "${D}usr/lib/iscan/make-udev-rules" # install USB hotplug stuff local USERMAP_FILE="doc/epkowa.desc" if [ -f ${USERMAP_FILE} ]; then dodir /etc/udev/rules.d usermap_to_udev ${USERMAP_FILE} \ > "${D}etc/udev/rules.d/99-iscan.rules" else die "Can not find USB devices description file: ${USERMAP_FILE}" fi # install sane config insinto /etc/sane.d doins backend/epkowa.conf # link iscan so it is seen as a plugin in gimp if use gimp; then local plugindir if [ -x /usr/bin/gimptool ]; then plugindir="$(gimptool --gimpplugindir)/plug-ins" elif [ -x /usr/bin/gimptool-2.0 ]; then plugindir="$(gimptool-2.0 --gimpplugindir)/plug-ins" else die "Can't find GIMP plugin directory." fi dodir "${plugindir}" dosym /usr/bin/iscan "${plugindir}" fi # install desktop entry if use X; then make_desktop_entry iscan "Image Scan! for Linux ${PV}" scanner.png fi } pkg_postinst() { local i local DLL_CONF="/etc/sane.d/dll.conf" local EPKOWA_CONF="/etc/sane.d/epkowa.conf" local SNAPSCAN_CONF="/etc/sane.d/snapscan.conf" elog if grep -q "^[ \t]*\" ${DLL_CONF}; then elog "Please edit ${EPKOWA_CONF} to suit your needs." elif grep -q "\" ${DLL_CONF}; then elog "Hint: to enable the backend, add 'epkowa' to ${DLL_CONF}" elog "Then edit ${EPKOWA_CONF} to suit your needs." else echo "epkowa" >> ${DLL_CONF} elog "A new entry 'epkowa' was added to ${DLL_CONF}" elog "Please edit ${EPKOWA_CONF} to suit your needs." fi elog elog "You can also use the 'snapscan' backend if you have a recent" elog "sane-backend installation. Firmware files for some newer" elog "EPSON scanners were installed into /usr/share/iscan:" elog for i in "${FIRMWARE[@]}"; do elog " ${i%% *}: ${i#* }" done elog if ! grep 2>/dev/null -q "/usr/share/iscan/.*\.bin" "${SNAPSCAN_CONF}"; then snapscan_firmware "${SNAPSCAN_CONF}" > "${SNAPSCAN_CONF}~~~" \ && mv -f "${SNAPSCAN_CONF}~~~" "${SNAPSCAN_CONF}" \ || rm -f "${SNAPSCAN_CONF}~~~" elog "The firmware entries were added to ${SNAPSCAN_CONF}" else elog "Please edit ${SNAPSCAN_CONF} to suit your needs." fi elog "Hint: not all models are supported by 'snapscan' yet!" elog elog "You can check which backend fits best for your scanner:" elog "http://www.sane-project.org/cgi-bin/driver.pl?manu=Epson&bus=any" elog }