# Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 inherit autotools desktop flag-o-matic toolchain-funcs CANON_REL="18" DL_ID="1/0100005951/10" MY_PV="${PV//\./}" DESCRIPTION="Canon UFR II LT Printer Driver for Linux" HOMEPAGE="https://www.usa.canon.com/internet/portal/us/home/support/details/printers/black-and-white-laser/lbp6230dw" SRC_URI="https://gdlp01.c-wss.com/gds/${DL_ID}/linux-UFRIILT-drv-v${MY_PV}-usen-${CANON_REL}.tar.gz" LICENSE="Canon-UFR-II GPL-2 MIT" SLOT="0" KEYWORDS="-* ~amd64 ~x86" IUSE="gtk" DEPEND="dev-libs/libxml2:2 media-libs/jbigkit media-libs/libjpeg-turbo net-print/cups gtk? ( x11-libs/gtk+:2 gnome-base/libglade:2.0 )" RDEPEND="${DEPEND} !net-print/cndrvcups-common-lb !net-print/cndrvcups-lb !net-print/cnrdrvcups-lb" HTML_DOCS=( "${WORKDIR}"/linux-UFRIILT-drv-v${MY_PV}-usen/Documents/README-ufr2lt-5.0xUS.html "${WORKDIR}"/linux-UFRIILT-drv-v${MY_PV}-usen/Documents/UsersGuide-ufr2lt-US.html ) S="${WORKDIR}/linux-UFRIILT-drv-v${MY_PV}-usen/Sources" pkg_setup() { QA_PREBUILT="/usr/bin/cnsetuputil2l /usr/bin/cngplp /usr/bin/cnjbigsfp /usr/bin/cnpkmodulencapr /usr/bin/commandfilefilterr /usr/bin/cnrsdrvsfp /usr/bin/pksmncapr /usr/$(get_libdir)/cups/backend/cnusb /usr/$(get_libdir)/cups/filter/rastertosfp /usr/$(get_libdir)/libcaio_usb_cdcr.so.1.0.0 /usr/$(get_libdir)/libuictlncapr.so.1.0.0 /usr/$(get_libdir)/libcaiousb.so.1.0.0 /usr/$(get_libdir)/libcanon_commonr.so.1.0.0 /usr/$(get_libdir)/libcaiowrapsfp.so.1.0.0 /usr/$(get_libdir)/libcanon_slimsfp.so.1.0.0 /usr/$(get_libdir)/libcaepcmsfp.so.1.0 /usr/$(get_libdir)/libccpd_utilr.so.1.0.0 /usr/$(get_libdir)/libcnaccm.so.1.0 /usr/$(get_libdir)/libcanonncapr.so.1.0.0 /usr/$(get_libdir)/libcnlbcmr.so.1.0 /usr/$(get_libdir)/libcnncapcmr.so.1.0 /usr/$(get_libdir)/libCommIsolationr.so.1.0.0 /usr/$(get_libdir)/libColorGearCsfp.so.2.0.0 /usr/$(get_libdir)/libcomm_stdoutr.so.1.0.0 /usr/$(get_libdir)/libcomm_ncapcaior.so.1.0.0 /usr/$(get_libdir)/libcomm_usbmlportr.so.1.0.0 /usr/$(get_libdir)/libcomm_websrvr.so.1.0.0 /usr/$(get_libdir)/libinfo_analyzer.so.1.0.0 /usr/$(get_libdir)/libCUPS_Communicatorr.so.1.0.0 /usr/$(get_libdir)/libinfor.so.1.0.0 /usr/$(get_libdir)/libcomm_usbsockr.so.1.0.0 /usr/$(get_libdir)/libncapfilterr.so.1.0.0" QA_SONAME="/usr/$(get_libdir)/libcaiousb.so.1.0.0" } src_unpack() { unpack ${A} cd "${WORKDIR}/linux-UFRIILT-drv-v${MY_PV}-usen/Sources/" || die unpack ./cnrdrvcups-sfp-${PV}-1.tar.gz } common_op() { local i local components=( backend buftool cnjbig rasterfilter ) use gtk && components+=(cngplp) for i in "${components[@]}"; do cd "${S}/cnrdrvcups-common-${PV}/${i}" || die "failed to switch dir to ${i}" "${@}" cd "${S}" || die "failed to switch dir back from ${i} to ${S}" done } driver_op() { local i local components=( cpca ) use gtk && components+=(cngplp) use gtk && components+=(cngplp/files) for i in "${components[@]}"; do cd "${S}/cnrdrvcups-sfp-${PV}/${i}" || die "failed to switch dir to ${i}" "${@}" cd "${S}" || die "failed to switch dir back from ${i} to ${S}" done } src_prepare() { default common_op mv configure.in configure.ac || die "failed to move configure.in" driver_op mv configure.in configure.ac || die "failed to move configure.in" common_op sed -i -e 's/configure.in/configure.ac/' configure.ac || die driver_op sed -i -e 's/configure.in/configure.ac/' configure.ac || die # This should work with autoreconf use gtk && export "LIBS=-lgtk-x11-2.0 -lgobject-2.0 -lglib-2.0 -lgmodule-2.0" # Other components already depend on compiled product append-ldflags -L"${S}/cnrdrvcups-common-${PV}/buftool" common_op eautoreconf driver_op eautoreconf # Fix a QA issue with .desktop file, sed -i 's/Application;Utility/Utility/g' "${S}"/cnrdrvcups-utility-${PV}/data/cnsetuputil2l.desktop || die "Failed to modify cnsetuputil2l.desktop file." append-cflags -fcommon # For some reason, @AR@ is defined everywhere else correctly, but not here. sed -i -e "s/AR = ar/AR = $(tc-getAR)/g" ./cnrdrvcups-common-${PV}/buftool/Makefile.in || die } src_configure() { common_op econf driver_op econf } src_compile() { common_op emake driver_op emake } src_install() { common_op emake DESTDIR="${D}" install COMMON_SUFFIX=2 driver_op emake DESTDIR="${D}" install COMMON_SUFFIX=2 insinto /usr/share/cups/usb/ doins "${S}"/cnrdrvcups-sfp-${PV}/rules/canon-sfp-printerr.usb-quirks if use amd64; then cd "${S}"/lib/libs64/ || die "failed to switch into libs64" elif use x86; then cd "${S}"/lib/libs32/ || die "failed to switch into libs32" else die "I don't know what directory to switch into!" fi dolib.so libcaepcmsfp.so.1.0 \ libcaio_usb_cdcr.so.1.0.0 \ libcaiousb.so.1.0.0 \ libcaiowrapsfp.so.1.0.0 \ libcanon_commonr.so.1.0.0 \ libcanonncapr.so.1.0.0 \ libcanon_slimsfp.so.1.0.0 \ libccpd_utilr.so.1.0.0 \ libcnaccm.so.1.0 \ libcnlbcmr.so.1.0 \ libcnncapcmr.so.1.0 \ libColorGearCsfp.so.2.0.0 \ libCommIsolationr.so.1.0.0 \ libcomm_ncapcaior.so.1.0.0 \ libcomm_stdoutr.so.1.0.0 \ libcomm_usbmlportr.so.1.0.0 \ libcomm_usbsockr.so.1.0.0 \ libcomm_websrvr.so.1.0.0 \ libCUPS_Communicatorr.so.1.0.0 \ libinfo_analyzer.so.1.0.0 \ libinfor.so.1.0.0 \ libncapfilterr.so.1.0.0 dosym libcaepcmsfp.so.1.0 /usr/$(get_libdir)/libcaepcmsfp.so dosym libcaepcmsfp.so.1.0 /usr/$(get_libdir)/libcaepcmsfp.so.1 dosym libcanon_slimsfp.so.1.0.0 /usr/$(get_libdir)/libcanon_slimsfp.so dosym libcanon_slimsfp.so.1.0.0 /usr/$(get_libdir)/libcanon_slimsfp.so.1 dosym libinfor.so.1.0.0 /usr/$(get_libdir)/libinfor.so dosym libinfor.so.1.0.0 /usr/$(get_libdir)/libinfor.so.1 dosym libcomm_websrvr.so.1.0.0 /usr/$(get_libdir)/libcomm_websrvr.so dosym libcomm_websrvr.so.1.0.0 /usr/$(get_libdir)/libcomm_websrvr.so.1 dosym libccpd_utilr.so.1.0.0 /usr/$(get_libdir)/libccpd_utilr.so dosym libccpd_utilr.so.1.0.0 /usr/$(get_libdir)/libccpd_utilr.so.1 dosym libcomm_ncapcaior.so.1.0.0 /usr/$(get_libdir)/libcomm_ncapcaior.so dosym libcomm_ncapcaior.so.1.0.0 /usr/$(get_libdir)/libcomm_ncapcaior.so.1 dosym libcnaccm.so.1.0 /usr/$(get_libdir)/libcnaccm.so dosym libcnaccm.so.1.0 /usr/$(get_libdir)/libcnaccm.so.1 dosym libcomm_usbsockr.so.1.0.0 /usr/$(get_libdir)/libcomm_usbsockr.so dosym libcomm_usbsockr.so.1.0.0 /usr/$(get_libdir)/libcomm_usbsockr.so.1 dosym libinfo_analyzer.so.1.0.0 /usr/$(get_libdir)/libinfo_analyzer.so dosym libinfo_analyzer.so.1.0.0 /usr/$(get_libdir)/libinfo_analyzer.so.1 dosym libcomm_usbmlportr.so.1.0.0 /usr/$(get_libdir)/libcomm_usbmlportr.so dosym libcomm_usbmlportr.so.1.0.0 /usr/$(get_libdir)/libcomm_usbmlportr.so.1 dosym libcaiowrapsfp.so.1.0.0 /usr/$(get_libdir)/libcaiowrapsfp.so dosym libcaiowrapsfp.so.1.0.0 /usr/$(get_libdir)/libcaiowrapsfp.so.1 dosym libColorGearCsfp.so.2.0.0 /usr/$(get_libdir)/libColorGearCsfp.so dosym libColorGearCsfp.so.2.0.0 /usr/$(get_libdir)/libColorGearCsfp.so.2 dosym libColorGearCsfp.so.2.0.0 /usr/$(get_libdir)/libColorGearC.so.2 dosym libcomm_stdoutr.so.1.0.0 /usr/$(get_libdir)/libcomm_stdoutr.so dosym libcomm_stdoutr.so.1.0.0 /usr/$(get_libdir)/libcomm_stdoutr.so.1 dosym libcaio_usb_cdcr.so.1.0.0 /usr/$(get_libdir)/libcaio_usb_cdcr.so dosym libcaio_usb_cdcr.so.1.0.0 /usr/$(get_libdir)/libcaio_usb_cdcr.so.1 dosym libcnlbcmr.so.1.0 /usr/$(get_libdir)/libcnlbcmr.so dosym libcnlbcmr.so.1.0 /usr/$(get_libdir)/libcnlbcmr.so.1 dosym libcnncapcmr.so.1.0 /usr/$(get_libdir)/libcnncapcmr.so dosym libcnncapcmr.so.1.0 /usr/$(get_libdir)/libcnncapcmr.so.1 dosym libCommIsolationr.so.1.0.0 /usr/$(get_libdir)/libCommIsolationr.so dosym libCommIsolationr.so.1.0.0 /usr/$(get_libdir)/libCommIsolationr.so.1 dosym libCUPS_Communicatorr.so.1.0.0 /usr/$(get_libdir)/libCUPS_Communicatorr.so dosym libCUPS_Communicatorr.so.1.0.0 /usr/$(get_libdir)/libCUPS_Communicatorr.so.1 dosym libcanonncapr.so.1.0.0 /usr/$(get_libdir)/libcanonncapr.so dosym libcanonncapr.so.1.0.0 /usr/$(get_libdir)/libcanonncapr.so.1 dosym libncapfilterr.so.1.0.0 /usr/$(get_libdir)/libncapfilterr.so dosym libncapfilterr.so.1.0.0 /usr/$(get_libdir)/libncapfilterr.so.1 dosym libcanon_commonr.so.1.0.0 /usr/$(get_libdir)/libcanon_commonr.so dosym libcanon_commonr.so.1.0.0 /usr/$(get_libdir)/libcanon_commonr.so.1 dobin cnpkmodulencapr cnrsdrvsfp commandfilefilterr pksmncapr use gtk && dobin cnsetuputil2l insinto /usr/share/ncapfilterr doins ./ThLB* # These are locations driver expects things to be in local l for l in ccpd_utilr caio_usb_cdcr comm_ncapcaior comm_stdoutr comm_usbmlportr comm_usbsockr comm_websrvr; do dosym /usr/$(get_libdir)/lib$l.so.1.0.0 /usr/lib/Canon/CUPS_SFPR/Bidi/lib$l.so dosym /usr/$(get_libdir)/lib$l.so.1.0.0 /usr/lib/Canon/CUPS_SFPR/Bidi/lib$l.so.1 dosym /usr/$(get_libdir)/lib$l.so.1.0.0 /usr/lib/Canon/CUPS_SFPR/Bidi/lib$l.so.1.0.0 done for l in CUPS_Communicatorr CommIsolationr canon_commonr info_analyzer infor; do dosym /usr/$(get_libdir)/lib$l.so.1.0.0 /usr/lib/Canon/CUPS_SFPR/Libs/lib$l.so dosym /usr/$(get_libdir)/lib$l.so.1.0.0 /usr/lib/Canon/CUPS_SFPR/Libs/lib$l.so.1 dosym /usr/$(get_libdir)/lib$l.so.1.0.0 /usr/lib/Canon/CUPS_SFPR/Libs/lib$l.so.1.0.0 done dosym /usr/bin/commandfilefilterr /usr/lib/Canon/CUPS_SFPR/Bins/commandfilefilterr dosym /usr/bin/pksmncapr /usr/lib/Canon/CUPS_SFPR/Utilities/pksmncapr cd "${S}" || die "Failed to switch back into ${S} during installation." dosym ../../../$(get_libdir)/cups/backend/cnusb /usr/libexec/cups/backend/cnusb dosym ../../../$(get_libdir)/cups/filter/rastertosfp /usr/libexec/cups/filter/rastertosfp insinto /usr/share/caepcm/ doins -r "${S}"/lib/data/sfp/ insinto /usr/share/cups/model doins cnrdrvcups-sfp-${PV}/ppd/*.ppd use gtk && domenu ./cnrdrvcups-utility-${PV}/data/cnsetuputil2l.desktop use gtk && doicon ./cnrdrvcups-utility-${PV}/data/cnsetuputil.png einstalldocs newdoc "${S}"/cnrdrvcups-common-${PV}/README README.common newdoc "${S}"/cnrdrvcups-common-${PV}/cngplp/README README.cngplp.common newdoc "${S}"/cnrdrvcups-sfp-${PV}/README README.lb newdoc "${S}"/cnrdrvcups-sfp-${PV}/cngplp/README README.cngplp.driver find "${D}" -name '*.la' -type f -delete || die } pkg_postinst(){ mkdir -p -m 0770 "${EROOT}"/var/cache/Canon/CUPS_SFPR chown -R root:lp "${EROOT}"/var/cache/Canon/ }