# cups 1.4 - mtink broken without usblp?

## wumpyr

Hi

now that usblp is banned with cups 1.4, how do I retrieve ink levels for my Epson R800 printer?  strace is showing mtink is looking for usblp paths.  I tried net-print/ink but it doesn't seem to support R800.

thanks

----------

## hunky

 *wumpyr wrote:*   

> Hi
> 
> now that usblp is banned with cups 1.4, how do I retrieve ink levels for my Epson R800 printer?  strace is showing mtink is looking for usblp paths.  I tried net-print/ink but it doesn't seem to support R800.
> 
> thanks

 

Sorry for resurrecting and old thread but was there resolution for this? I'm trying to get an R800 working - it is seen now by cups after removing usblp from the kernel, but no inklevels. I've read this bug:

https://bugs.gentoo.org/show_bug.cgi?id=285166 but am confused if it resolves anything.

I have read lots of webpages about setting up printers but they all seem outdated for a system with no usblp (no dev/usblp0 or lp0.) Tried mtink but despite setting the SUID it still complains about not getting to access the printer. I tried to install the pips-spr800 driver but with Make I get an error:

```
gcc -DGS_PATH=\"gs\" -DLOCALEDIR=\"/usr/share/locale\" "-DPRINTER_MODEL=\"Stylus Photo R800\"" -DSPR800 -DLIBPATH=\"/usr/lib/libspr800.so\" -DRSC_PATH=\"/etc/pipsrc\" -DSPOOL_NAME=\"spr800\" -DLOCALE_PATH=\"/usr/share/locale\" -DNAVI_PATH=\"/usr/bin/ekpnavi\" -DDATA_PATH=\"/usr/local/EPKowa/SPR800\" -DRULED_PATH=\"/usr/local/EPKowa/SPR800/BID.PRN\" -DPATCH_PATH=\"/usr/local/EPKowa/SPR800/PATCH.PRN\" -DBAND_PATH=\"/usr/local/EPKowa/SPR800/BAND.PRN\" -DCUT_PATH=\"/usr/local/EPKowa/SPR800/CUT.PRN\" -D_LPR_DIRECT -fsigned-char -DCUPS_FILTER_PATH=\"/usr/libexec/cups/filter\" -g -O2 -Wall -o pips-spr800 ekpcom.o gLoad.o getstat.o inkbox.o paper.o paramConf.o pfatt.o pferr.o pfimg.o pfmem.o pfpng.o pips.o pips1_to_2.o pipsCom.o pipsError.o setup.o uiModule.o uiParts.o str.o  ../libltdl/.libs/libltdlc.al ./.libs/libcutils.al -lpthread -ldl

pfimg.o: In function `set_raster':

/home/jim/Opt/pips-spr800-2.6.2/pips-spr800-2.6.2/src/pfimg.c:1323: undefined reference to `floor'

pfimg.o: In function `load_image_out':

/home/jim/Opt/pips-spr800-2.6.2/pips-spr800-2.6.2/src/pfimg.c:531: undefined reference to `floor'

collect2: ld returned 1 exit status

make[2]: *** [pips-spr800] Error 1

```

 which google hasn't found me a resolution for yet - something to do with LM and math functions.

thanks for any help..  /jd

----------

## RedSquirrel

You can patch cups-1.4. See my post here.

----------

## hunky

 *RedSquirrel wrote:*   

> You can patch cups-1.4. See my post here.

 

thanks for that. Do you know then if this makes the ink levels for the printers in question work (display)? Probably by using 'ink' or 'mtink' ?

----------

## RedSquirrel

I don't have an R800 and I don't know if mtink supports that model. I have an old Epson Stylus Color 580 and mtink works fine for me (and always has as long as usblp support is enabled in my kernel  :Wink: ).

cups-1.4 works fine for me with that patch.

----------

## hunky

I can't figure out how to patch this ebuild. I'm trying a few things. I've copied the ebuild and files directory to /usr/local/portage/net-print/cups/ and put this in the cups ebuild:

```
src_prepare() {

        # create a missing symlink to allow https printing via IPP, bug #217293

        epatch "${FILESDIR}/${PN}-1.4.0-backend-https.patch"

        # various build time fixes

        epatch "${FILESDIR}/${PN}-1.4.4-dont-compress-manpages.patch"

        epatch "${FILESDIR}/${PN}-1.4.4-fix-install-perms.patch"

        epatch "${FILESDIR}/${PN}-1.4.4-nostrip.patch"

        epatch "${FILESDIR}/${PN}-1.4.4-php-destdir.patch"

        epatch "${FILESDIR}/${PN}-1.4.4-perl-includes.patch"

        epatch "${FILESDIR}/usb-backend-both-usblp-and-libusb.patch"

        AT_M4DIR=config-scripts eaclocal

        eautoconf

}

```

 (I've renamed it from .dpatch to .patch just to see if that was the problem). So after doing the ebuild ... digest on the ebuild, when I try emerge -av cups I don't see it applying the patch, among the list of other patches. And cups doesn't see usb printers so I'm pretty sure it isn't patched.

I've tried without the forward slash in front of the patch in the ebuild as well as quotes placement to match the wiki:

http://en.gentoo-wiki.com/wiki/Writing_Ebuilds with no change.

help?  cheers, JD

----------

## RedSquirrel

That's odd. The code you have posted is OK.

Are you certain Portage is building cups using the ebuild in your local overlay and not the one from the Portage tree?

Do you have:

```
PORTDIR_OVERLAY="/usr/local/portage/"
```

in your /etc/make.conf?

Run:

```
# emerge -v cups
```

Press Ctrl-c after it applies the patches and post the emerge command output up to that point.

Post the output of:

```
$ grep usb /usr/local/portage/net-print/cups/Manifest
```

You could also post your cups ebuild.

----------

## hunky

 *RedSquirrel wrote:*   

> That's odd. The code you have posted is OK.
> 
> Are you certain Portage is building cups using the ebuild in your local overlay and not the one from the Portage tree?

 

No, not certain. How to be sure?

 *Quote:*   

> 
> 
> Do you have:
> 
> ```
> ...

 

I have: 

```
PORTDIR_OVERLAY="/usr/local/portage /var/lib/layman/pro-audio"
```

No trailing slash, if that could be a problem. 

 *Quote:*   

> 
> 
> Run:
> 
> ```
> ...

 

```
>>> Preparing source in /var/tmp/portage/net-print/cups-1.4.4-r2/work/cups-1.4.4 ...

 * Applying cups-1.4.0-backend-https.patch ...                           [ ok ]

 * Applying cups-1.4.4-dont-compress-manpages.patch ...                  [ ok ]

 * Applying cups-1.4.4-fix-install-perms.patch ...                       [ ok ]

 * Applying cups-1.4.4-nostrip.patch ...                                 [ ok ]

 * Applying cups-1.4.4-php-destdir.patch ...                             [ ok ]

 * Applying cups-1.4.4-perl-includes.patch ...                           [ ok ]

 * Running aclocal -I config-scripts ...                                 [ ok ]

 * Running autoconf ...                                                  [ ok ]

>>> Source prepared.
```

 *Quote:*   

> 
> 
> Post the output of:
> 
> ```
> ...

 

```
 # grep usb /usr/local/portage/net-print/cups/Manifest

AUX usb-backend-both-usblp-and-libusb.dpatch 18871 RMD160 32cba1dd8ebc62c40fbaea183876e9b95e9b3cf9 SHA1 0221c80a05b4f4bb3f0dbccea43579378e083338 SHA256 37936471dc8097a215140ce4337b0e230a6c6f77ba206a89286f8495c5abd3ce
```

(I've renamed it back to .dpatch just to see if that had made a difference. I had used gunzip on the downloaded patch ....dpatch.gz to extract - if that matters.)

 *Quote:*   

> 
> 
> You could also post your cups ebuild.

 

```
# Copyright 1999-2010 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

# $Header: /var/cvsroot/gentoo-x86/net-print/cups/cups-1.4.4-r2.ebuild,v 1.3 20$

EAPI=3

PYTHON_DEPEND="python? 2:2.5"

inherit autotools eutils flag-o-matic multilib pam perl-module python versionat$

MY_P=${P/_}

DESCRIPTION="The Common Unix Printing System"

HOMEPAGE="http://www.cups.org/"

SRC_URI="mirror://easysw/${PN}/${PV}/${MY_P}-source.tar.bz2"

LICENSE="GPL-2"

SLOT="0"

KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~spa$

IUSE="acl dbus debug gnutls java +jpeg kerberos ldap pam perl php +png python s$

\LANGS="da de es eu fi fr id it ja ko nl no pl pt pt_BR ru sv zh zh_TW"

for X in ${LANGS} ; do

        IUSE="${IUSE} linguas_${X}"

done

RDEPEND="

        app-text/libpaper

        dev-libs/libgcrypt

        acl? (

                kernel_linux? (

                        sys-apps/acl

                        sys-apps/attr

                )

        )

        dbus? ( sys-apps/dbus )

        java? ( >=virtual/jre-1.6 )

        jpeg? ( virtual/jpeg:0 )

        kerberos? ( virtual/krb5 )

        ldap? ( net-nds/openldap[ssl?,gnutls?] )

        pam? ( virtual/pam )

        perl? ( dev-lang/perl )

        php? ( dev-lang/php )

        png? ( >=media-libs/libpng-1.4.3 )

        slp? ( >=net-libs/openslp-1.0.4 )

        ssl? (

                gnutls? ( net-libs/gnutls )

                !gnutls? ( >=dev-libs/openssl-0.9.8g )

        )

        tiff? ( >=media-libs/tiff-3.5.5 )

        usb? ( virtual/libusb:0 )

        X? ( x11-misc/xdg-utils )

        xinetd? ( sys-apps/xinetd )

        !net-print/cupsddk

"

DEPEND="${RDEPEND}

        dev-util/pkgconfig

"

PDEPEND="

        app-text/ghostscript-gpl[cups]

        >=app-text/poppler-0.12.3-r3[utils]

"

PROVIDE="virtual/lpr"

# upstream includes an interactive test which is a nono for gentoo.

RESTRICT="test"

S="${WORKDIR}/${MY_P}"

pkg_setup() {

        enewgroup lp

        enewuser lp -1 -1 -1 lp

        enewgroup lpadmin 106

        # python 3 is no-go

        python_set_active_version 2

        python_pkg_setup

}

src_prepare() {

        # create a missing symlink to allow https printing via IPP, bug #217293

        epatch "${FILESDIR}/${PN}-1.4.0-backend-https.patch"

        # various build time fixes

        epatch "${FILESDIR}/${PN}-1.4.4-dont-compress-manpages.patch"

        epatch "${FILESDIR}/${PN}-1.4.4-fix-install-perms.patch"

        epatch "${FILESDIR}/${PN}-1.4.4-nostrip.patch"

        epatch "${FILESDIR}/${PN}-1.4.4-php-destdir.patch"

        epatch "${FILESDIR}/${PN}-1.4.4-perl-includes.patch"

        epatch "${FILESDIR}/usb-backend-both-usblp-and-libusb.dpatch"

        AT_M4DIR=config-scripts eaclocal

        eautoconf

}

src_configure() {

        export DSOFLAGS="${LDFLAGS}"

        # locale support

        strip-linguas ${LANGS}

        if [ -z "${LINGUAS}" ] ; then

                export LINGUAS=none

        fi

        local myconf

        if use ssl || use gnutls ; then

                myconf+="

                        $(use_enable gnutls)

                        $(use_enable !gnutls openssl)

                "

        else

                myconf+="

                        --disable-gnutls

                        --disable-openssl

                "

        fi

        econf \

                --libdir=/usr/$(get_libdir) \

                --localstatedir=/var \

                --with-cups-user=lp \

                --with-cups-group=lp \

                --with-docdir=/usr/share/cups/html \

                --with-languages="${LINGUAS}" \

                --with-pdftops=/usr/bin/pdftops \

                --with-system-groups=lpadmin \

                $(use_enable acl) \

                $(use_enable dbus) \

                $(use_enable debug) \

                $(use_enable debug debug-guards) \

                $(use_enable jpeg) \

                $(use_enable kerberos gssapi) \

                $(use_enable ldap) \

                $(use_enable pam) \

                $(use_enable png) \

                $(use_enable slp) \

                $(use_enable static-libs static) \

                $(use_enable threads) \

                $(use_enable tiff) \

                $(use_enable usb libusb) \

                $(use_with java) \

                $(use_with perl) \

                $(use_with php) \

                $(use_with python) \

                $(use_with xinetd xinetd /etc/xinetd.d) \

                --enable-libpaper \

                --disable-dnssd \

                ${myconf}

        # install in /usr/libexec always, instead of using /usr/lib/cups, as that

        # makes more sense when facing multilib support.

        sed -i -e 's:SERVERBIN.*:SERVERBIN = "$(BUILDROOT)"/usr/libexec/cups:' Makedefs || die

        sed -i -e 's:#define CUPS_SERVERBIN.*:#define CUPS_SERVERBIN "/usr/libexec/cups":' config.h || die

        sed -i -e 's:cups_serverbin=.*:cups_serverbin=/usr/libexec/cups:' cups-config || die

}

src_compile() {

        emake || die "emake failed"

        if use perl ; then

                cd "${S}"/scripting/perl

                perl-module_src_prep

                perl-module_src_compile

        fi

        if use php ; then

                cd "${S}"/scripting/php

                emake || die "emake php failed"

        fi

}

src_install() {

        emake BUILDROOT="${D}" install || die "emake install failed"

        dodoc {CHANGES,CREDITS,README}.txt || die "dodoc install failed"

        if use perl ; then

                cd "${S}"/scripting/perl

                perl-module_src_install

                fixlocalpod

        fi

        if use php ; then

                cd "${S}"/scripting/php

                emake DESTDIR="${D}" install || die "emake install for php bindings failed"

        fi

        # clean out cups init scripts

        rm -rf "${D}"/etc/{init.d/cups,rc*,pam.d/cups}

        # install our init script

        local neededservices

        use dbus && neededservices+=" dbus"

        [[ -n ${neededservices} ]] && neededservices="need${neededservices}"

        cp "${FILESDIR}"/cupsd.init.d "${T}"/cupsd || die

        sed -i \

                -e "s/@neededservices@/$neededservices/" \

                "${T}"/cupsd || die

        doinitd "${T}"/cupsd || die "doinitd failed"

        # install our pam script

        pamd_mimic_system cups auth account

        if use xinetd ; then

                # correct path

                sed -i \

                        -e "s:server = .*:server = /usr/libexec/cups/daemon/cups-lpd:" \

                        "${D}"/etc/xinetd.d/cups-lpd || die

                # it is safer to disable this by default, bug #137130

                grep -w 'disable' "${D}"/etc/xinetd.d/cups-lpd || \

                        { sed -i -e "s:}:\tdisable = yes\n}:" "${D}"/etc/xinetd.d/cups-lpd || die ; }

                # write permission for file owner (root), bug #296221

                fperms u+w /etc/xinetd.d/cups-lpd || die "fperms failed"

        else

                rm -rf "${D}"/etc/xinetd.d

        fi

        keepdir /usr/libexec/cups/driver /usr/share/cups/{model,profiles} \

                /var/cache/cups /var/cache/cups/rss /var/log/cups /var/run/cups/certs \

                /var/spool/cups/tmp

        keepdir /etc/cups/{interfaces,ppd,ssl}

        use X || rm -r "${D}"/usr/share/applications

        # create /etc/cups/client.conf, bug #196967 and #266678

        echo "ServerName /var/run/cups/cups.sock" >> "${D}"/etc/cups/client.conf

}

pkg_postinst() {

        echo

        elog "For information about installing a printer and general cups setup"

        elog "take a look at: http://www.gentoo.org/doc/en/printing-howto.xml"

        echo

}

```

----------

## RedSquirrel

When you try to emerge cups, Portage should show a message indicating your overlays and that it will build cups from /usr/local/portage.

The ebuild you posted above has some truncated lines (probably due to your editor or some copy/paste issue). I'm confident that the actual ebuild on your machine does not look like that ( :Wink: ). If the only change you made was to add the epatch line for the new patch, we won't worry about that for the moment.

Presence/absence of trailing slashes shouldn't matter and gunzipping the original patch is fine. (epatch seems to accept compressed patches, however.)

Please post the output of:

```
emerge -pv cups
```

```
ls -l /usr/local/portage/net-print/cups
```

```
ls -l /usr/local/portage/net-print/cups/files
```

----------

## hunky

 *RedSquirrel wrote:*   

> When you try to emerge cups, Portage should show a message indicating your overlays and that it will build cups from /usr/local/portage.
> 
> The ebuild you posted above has some truncated lines (probably due to your editor or some copy/paste issue). 

 

Yes - that's probably since I'm accessing my machine right now using putty from a work windows machine - don't tell.

 *Quote:*   

> 
> 
> Please post the output of:
> 
> ```
> ...

 

```
# emerge -pv cups

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R   ] net-print/cups-1.4.4-r2  USE="X acl dbus gnutls java jpeg ldap pam perl png python samba ssl threads tiff usb -debug -kerberos -php -slp -static -libs -xinetd" LINGUAS="-da -de -es -eu -fi -fr -id -it -ja -ko -nl -no -pl -pt -pt_BR -ru -sv -zh -zh_TW" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB
```

 *Quote:*   

> 
> 
> ```
> ls -l /usr/local/portage/net-print/cups
> ```
> ...

 

```
# ls -l /usr/local/portage/net-print/cups/

total 108

-rw-r--r-- 1 root    root    59643 Nov 12 09:07 ChangeLog

-rw-r--r-- 1 root    root     4670 Nov 30 15:56 Manifest

-rw-r--r-- 1 portage portage  8431 Aug 10 13:15 cups-1.3.11-r2.ebuild

-rw-r--r-- 1 root    root     8419 Nov 12 08:52 cups-1.3.11-r3.ebuild

-rw-r--r-- 1 portage portage  6190 Nov 30 15:56 cups-1.4.4-r2.ebuild

drwxr-xr-x 2 portage portage  4096 Nov 30 15:56 files

-rw-r--r-- 1 portage portage   161 Jul 19  2003 metadata.xml

```

 *Quote:*   

> 
> 
> ```
> ls -l /usr/local/portage/net-print/cups/files
> ```
> ...

 

```
 # ls -l /usr/local/portage/net-print/cups/files/

total 100

-rw-r--r-- 1 portage portage   651 Oct 10  2007 cups-1.3.0-configure.patch

-rw-r--r-- 1 portage portage   888 May 28  2009 cups-1.3.10-str3178.patch

-rw-r--r-- 1 portage portage  1782 Nov 30  2009 cups-1.3.11-str3200.patch

-rw-r--r-- 1 portage portage 12834 Nov 13  2009 cups-1.3.11-str3367-security-1.3v2.patch

-rw-r--r-- 1 portage portage   871 Nov 13  2009 cups-1.3.11-str3401-security-1.3v2-regression.patch

-rw-r--r-- 1 portage portage   450 Apr 14  2008 cups-1.3.7-backend-https.patch

-rw-r--r-- 1 portage portage   483 Sep 13  2009 cups-1.4.0-backend-https.patch

-rw-r--r-- 1 portage portage  1654 Nov 30  2009 cups-1.4.2-str3200.patch

-rw-r--r-- 1 portage portage   580 Sep 11 04:10 cups-1.4.4-dont-compress-manpages.patch

-rw-r--r-- 1 portage portage   838 Sep 11 04:10 cups-1.4.4-fix-install-perms.patch

-rw-r--r-- 1 portage portage   487 Sep 11 04:10 cups-1.4.4-nostrip.patch

-rw-r--r-- 1 portage portage   637 Sep 12 09:19 cups-1.4.4-perl-includes.patch

-rw-r--r-- 1 portage portage   679 Sep 11 04:10 cups-1.4.4-php-destdir.patch

-rw-r--r-- 1 portage portage   293 Nov  9  2007 cupsd.init.d

-rw-r--r-- 1 portage portage 10412 Dec 18  2007 pdftops-1.20.gentoo

-rw-r--r-- 1 portage portage 18871 Nov 30 11:46 usb-backend-both-usblp-and-libusb.dpatch

```

BTW, thank you very much for your help here - I really appreciate it.   cheers, JD

----------

## hunky

Well I see that cups just upgraded to cups-1.4.5. So I'm wondering if that patch will still work, should I figure out my local portage problem?

----------

## hunky

Ok - think I figured out my problem, although if I go to the Add Printers in cups it doesn't give the USB option. But as I had installed the USB printer before compiling back in the usblp driver in the kernel, the printer still works.

What I was missing in my local overlay was a profile and profile name, I guess. I found this thread:

https://forums.gentoo.org/viewtopic-t-824591-start-0.html and followed his first post with a few changes. I discovered that portage wasn't seeing my local overlay by running eix-update. It just showed the pro-audio and ladi overlays from layman. So I did this:

```
# mkdir /usr/local/portage/profiles/

# echo "local_overlay" > /usr/local/portage/profiles/repo_name 
```

and since in my /etc/make.conf file I had this:

```
source /var/lib/layman/make.conf
```

, I added /usr/local/portage/ to the var/lib/layman/make.conf so it now looks like this:

```
PORTDIR_OVERLAY="

/usr/local/portage/

/var/lib/layman/pro-audio

/var/lib/layman/ladi

$PORTDIR_OVERLAY

"

```

Then doing an emerge cups, it picked up the patch in question. (And, btw, it seemed to successfully work on cups-1.4.5).

So just to be safe I restarted cupsd and then fired it up in my browser - saw the printer was still there (and it printed a pending test job that suffered through all these emerges and edits) and mtink as well as ink both work to show ink levels.

thanks for all the help.  /jd

----------

## RedSquirrel

I'm glad you got it to work.

I noticed there's a --disable-libusb option (for use at the configure stage), which I assume would make cups-1.4 use usblp from the kernel instead of libusb. I haven't tested that yet though and I think I'll stick with the libusb-usblp hybrid patch for the time being.

----------

