summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO23
-rw-r--r--PKGBUILD301
2 files changed, 263 insertions, 61 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 30da43eca7da..ca0fd9f2ee48 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,10 +1,10 @@
# Generated by mksrcinfo v8
-# Sun Oct 21 20:42:51 UTC 2018
+# Sun Dec 9 08:47:49 UTC 2018
pkgbase = brother-dcp7040
pkgdesc = LPR and CUPS driver for the Brother DCP-7040 printer
pkgver = 2.0.2_1
pkgrel = 1
- url = https://solutions.brother.com/linux/en_us/
+ url = https://support.brother.com/g/s/id/linux/en/
install = brother-dcp7040.install
arch = i686
arch = x86_64
@@ -18,19 +18,26 @@ pkgbase = brother-dcp7040
depends = grep
optdepends = ttf-dejavu: printing text files from lpr
optdepends = brscan3: Scanner support
+ optdepends = brscan-skey: Scanner button support
options = !strip
- source = http://www.brother.com/pub/bsc/linux/dlf/brdcp7040lpr-2.0.2-1.i386.rpm
- source = http://www.brother.com/pub/bsc/linux/dlf/cupswrapperDCP7040-2.0.2-1.i386.rpm
source = cupswrapper-license.txt
+ source = dcp7040-2.0.2_1.inf::http://www.brother.com/pub/bsc/linux/infs/DCP7040
+ source = http://www.brother.com/pub/bsc/linux/dlf/brother-laser2-cups-driver-2.0.2-1.tar.gz
source = lpr-license.txt
- md5sums = 418e58699d90a16e62059ba49fb51ad5
- md5sums = ca4a32afe0a30b4edbe2b26a8330f5d9
+ source = http://www.brother.com/pub/bsc/linux/packages/cupswrapperDCP7040-2.0.2-1.i386.rpm
+ source = http://www.brother.com/pub/bsc/linux/packages/brdcp7040lpr-2.0.2-1.i386.rpm
md5sums = 809c64563dbd89f89ca68f9218c59cf5
+ md5sums = 5a03383d8636c68c2e0184317ae48c2d
+ md5sums = fc331fb5bec1451a250547edc898c21b
md5sums = 4f14b328317aac0d22c7f7f73c581628
- sha256sums = 013958c343c3aa336138bab87a8b1b9c7266e5c59715636e2025b63815c216ce
- sha256sums = 04a515ed2a1a35eaf01d158fd8a0149d45b0a6167713b3fe424ffeffddcd94f0
+ md5sums = ca4a32afe0a30b4edbe2b26a8330f5d9
+ md5sums = 418e58699d90a16e62059ba49fb51ad5
sha256sums = c52eb0091a2854b031cc923bdd7c18e7fe09d2f26b679d804aec4e6c9567bb7d
+ sha256sums = 09822a451606075e0c6c4fc918d9630f91f7b45badaa9b4c7eb0d906186770e0
+ sha256sums = d303e86b9143bd6d2ac27294a33cb9676efd9e968b57912e496dac6e97e90641
sha256sums = b604def129534d245fa576f8cd7d01df1d2856b9bff6c1d2002404f77f7d4bb3
+ sha256sums = 04a515ed2a1a35eaf01d158fd8a0149d45b0a6167713b3fe424ffeffddcd94f0
+ sha256sums = 013958c343c3aa336138bab87a8b1b9c7266e5c59715636e2025b63815c216ce
depends_x86_64 = lib32-glibc
pkgname = brother-dcp7040
diff --git a/PKGBUILD b/PKGBUILD
index 8598f748e10d..c3fd2a0c285e 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,25 +3,39 @@
# Contributor: Libernux <dutchman55@gmx.com>
# Contributor: Roland Singer <roland@manjaro.org>
-# TODO: Add cupswrapper compile from source
# TODO: Check _rcfile A4 -> Letter fix
# TODO: Check printer autodetect
+_brinf=(
+[DCP-7040]
+PRN_CUP_RPM=cupswrapperDCP7040-2.0.2-1.i386.rpm
+PRN_CUP_DEB=cupswrapperDCP7040-2.0.2-1.i386.deb
+PRN_LPD_RPM=brdcp7040lpr-2.0.2-1.i386.rpm
+PRN_LPD_DEB=brdcp7040lpr-2.0.2-1.i386.deb
+PRINTERNAME=DCP7040
+SCANNER_DRV=brscan3
+SCANKEY_DRV=brscan-skey
+)
+_brinf+=(
+REQUIRE32LIB=yes
+)
+
+_opt_DEB=0
+
set -u
-_brothern='7040'
-_brotheru="DCP-${_brothern}"
+_brotheru='DCP-7040'
_brotherl="${_brotheru,,}" # mfc-0000dw
_brotherlnd="${_brotherl//-/}" # mfc0000dw
_brotherund="${_brotheru//-/}" # MFC0000DW
+_brotherxnd="${_brotherund}" # upper or lower as required by scripts
pkgname="brother-${_brotherlnd}"
pkgver='2.0.2_1'
pkgrel='1'
pkgdesc="LPR and CUPS driver for the Brother ${_brotheru} printer"
arch=('i686' 'x86_64')
-url='https://solutions.brother.com/linux/en_us/'
+url='https://support.brother.com/g/s/id/linux/en/'
license=('GPL' 'custom')
depends=('cups' 'ghostscript' 'psutils' 'a2ps' 'sed' 'grep')
-depends_x86_64=('lib32-glibc')
# We look at the scripts and find these programs from which we decide on the depends above.
# gs: lpr rendering
# pdf2ps: cups rendering
@@ -31,34 +45,121 @@ depends_x86_64=('lib32-glibc')
# sed grep awk
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=670055
# Printing a text file fails when Liberation is the only TrueType font available
+# depends+=('perl') # cupswrapper
optdepends=(
'ttf-dejavu: printing text files from lpr'
- 'brscan3: Scanner support'
)
options=('!strip')
install="${pkgname}.install"
-#_brsource="brother-laser2-cups-driver-${pkgver//_/-}"
-_dlf="http://www.brother.com/pub/bsc/linux/dlf"
+_brsource="brother-laser2-cups-driver-${pkgver//_/-}"
+_dlf='http://www.brother.com/pub/bsc/linux'
+_inf="${_brotherlnd}-${pkgver}.inf"
source=(
- "${_dlf}/brdcp7040lpr-${pkgver//_/-}.i386.rpm"
- "${_dlf}/cupswrapperDCP7040-${pkgver//_/-}.i386.rpm"
- #"${_dlf}/${_brsource}.tar.gz"
'cupswrapper-license.txt'
+ "${_inf}::${_dlf}/infs/${_brotherund}"
+ "${_dlf}/dlf/${_brsource}.tar.gz"
'lpr-license.txt'
)
-md5sums=('418e58699d90a16e62059ba49fb51ad5'
+md5sums=('809c64563dbd89f89ca68f9218c59cf5'
+ '5a03383d8636c68c2e0184317ae48c2d'
+ 'fc331fb5bec1451a250547edc898c21b'
+ '4f14b328317aac0d22c7f7f73c581628'
'ca4a32afe0a30b4edbe2b26a8330f5d9'
- '809c64563dbd89f89ca68f9218c59cf5'
- '4f14b328317aac0d22c7f7f73c581628')
-sha256sums=('013958c343c3aa336138bab87a8b1b9c7266e5c59715636e2025b63815c216ce'
+ '418e58699d90a16e62059ba49fb51ad5')
+sha256sums=('c52eb0091a2854b031cc923bdd7c18e7fe09d2f26b679d804aec4e6c9567bb7d'
+ '09822a451606075e0c6c4fc918d9630f91f7b45badaa9b4c7eb0d906186770e0'
+ 'd303e86b9143bd6d2ac27294a33cb9676efd9e968b57912e496dac6e97e90641'
+ 'b604def129534d245fa576f8cd7d01df1d2856b9bff6c1d2002404f77f7d4bb3'
'04a515ed2a1a35eaf01d158fd8a0149d45b0a6167713b3fe424ffeffddcd94f0'
- 'c52eb0091a2854b031cc923bdd7c18e7fe09d2f26b679d804aec4e6c9567bb7d'
- 'b604def129534d245fa576f8cd7d01df1d2856b9bff6c1d2002404f77f7d4bb3')
+ '013958c343c3aa336138bab87a8b1b9c7266e5c59715636e2025b63815c216ce')
+
+_mismatch=0
+_brverchk() {
+ local _ver="$1"
+ _ver="${_ver%.*}"
+ _ver="${_ver%.*}"
+ local _vb="${_ver%-*}"
+ _vb="${_vb%-*}-"
+ _ver="${_ver#${_vb}}"
+ local _pv="$2"
+ if [ -z "${_pv}" ]; then
+ _pv="$3"
+ fi
+ if [ -z "${_pv}" ]; then
+ _pv="$4"
+ fi
+ if [ "${_ver}" != "${_pv//_/-}" ]; then
+ echo "Version mismatch: ${_ver} ${_pv//_/-}" 1>&2
+ _mismatch=$((_mismatch+1))
+ fi
+}
+
+_procinf() {
+ local _fd _fvar _fval
+ for _fd in "${_brinf[@]}"; do
+ _fvar="${_fd%%=*}="
+ _fval="${_fd##*=}"
+ if [ ! -z "${_fval}" ]; then
+ case "${_fvar}" in
+ '['*);;
+ PRN_CUP_RPM=)
+ _brverchk "${_fval}" "${_cuprpmver:-}" "${_cupver:-}" "${pkgver}"
+ if [ "${_opt_DEB}" -eq 0 ]; then
+ source+=("${_dlf}/packages/${_fval}")
+ fi
+ ;;
+ PRN_CUP_DEB=)
+ _brverchk "${_fval}" "${_cupdebver:-}" "${_cupver:-}" "${pkgver}"
+ if [ "${_opt_DEB}" -ne 0 ]; then
+ source+=("${_dlf}/packages/${_fval}")
+ fi
+ ;;
+ PRN_LPD_RPM=)
+ _brverchk "${_fval}" "${_lprrpmver:-}" "${_lprver:-}" "${pkgver}"
+ if [ "${_opt_DEB}" -eq 0 ]; then
+ source+=("${_dlf}/packages/${_fval}")
+ fi
+ ;;
+ PRN_LPD_DEB=)
+ _brverchk "${_fval}" "${_lprdebver:-}" "${_lprver:-}" "${pkgver}"
+ if [ "${_opt_DEB}" -ne 0 ]; then
+ source+=("${_dlf}/packages/${_fval}")
+ fi
+ ;;
+ PRN_DRV_RPM=)
+ _brverchk "${_fval}" "" "" "${pkgver}"
+ if [ "${_opt_DEB}" -eq 0 ]; then
+ source+=("${_dlf}/packages/${_fval}")
+ fi
+ ;;
+ PRN_DRV_DEB=)
+ _brverchk "${_fval}" "" "" "${pkgver}"
+ if [ "${_opt_DEB}" -ne 0 ]; then
+ source+=("${_dlf}/packages/${_fval}")
+ fi
+ ;;
+ REQUIRE32LIB=)
+ if [ "${_fval}" = 'yes' ]; then
+ depends_x86_64+=('lib32-glibc')
+ fi
+ ;;
+ PRINTERNAME=);;
+ SCANNER_DRV=)optdepends+=("${_fval}: Scanner support");;
+ SCANKEY_DRV=)optdepends+=("${_fval}: Scanner button support");;
+ *) echo "Unrecognized line: ${_fd}" 1>&2; exit 1;;
+ esac
+ fi
+ done
+ test "${_mismatch}" -eq 0 || exit 1
+}
+_procinf
+unset -f _procinf _brverchk
+unset _mismatch _brinf
-# Conflicts with MFC-7340
# Must be same length as
# 'Brother'
-_conflict='bdc7040'
+#_conflict='brother'
+_conflict='bdc7040' # Conflicts with MFC-7340 and brother-lpr-drivers-laser
# We can't modify .install but we can stop and force the user to fix it.
_install_check() {
@@ -81,6 +182,20 @@ prepare() {
_install_check
+ shopt -s nullglob
+ local _deb
+ local _debn=1
+ for _deb in *.deb; do
+ local _dx="debextract.${_debn}"
+ mkdir "${_dx}"
+ bsdtar -C "${_dx}" -xf "${_deb}"
+ bsdtar -C "${_dx}" -xf "${_dx}"/control.tar.?z
+ bsdtar -xf "${_dx}"/data.tar.?z
+ rm "${_dx}"/*.tar.?z
+ _debn=$((_debn+1))
+ done
+ shopt -u nullglob
+
# Do not Install in '/usr/local'. Does not apply to all Brother models.
# This may modify binary blobs which only
# works when the old and new strings are exactly the same length.
@@ -92,9 +207,9 @@ prepare() {
fi
# setup cups-directories, some installers create these for us
- #install -d 'usr/lib/cups/filter'
+ install -d 'usr/lib/cups/filter'
install -d 'usr/share/cups/model'
- #install -dm755 "${srcdir}/usr/share/ppd" # For cups we don't need the ppd file here.
+ #install -d 'usr/share/ppd' # For cups we don't need the ppd file here.
# /etc/printcap is managed by cups
find . -type 'f' -name 'setupPrintcap*' -delete
@@ -104,41 +219,111 @@ prepare() {
set +u
}
+# $1: source file to patch or "" if none
+_patch_brprint() {
+ # allow cooexist with AUR package brother-lpr-drivers-laser
+ local _f1='brprintconflsr2'
+ local _f2='brprint7040lsr2'
+ if [ ! -z "$1" ]; then
+ sed -e "s:${_f1}:${_f2}:g" -i "$1"
+ fi
+ sed -e "s:${_f1}:${_f2}:g" -i "${srcdir}/usr/bin/brprintconfiglpr2"
+ mv "${srcdir}/usr/bin/${_f1}" "${srcdir}/usr/bin/${_f2}"
+ local _g1='libbrcomplpr2.so'
+ local _g2='libbr7040lpr2.so'
+ mv "${srcdir}/usr/bin/brprintconfiglpr2" "${srcdir}/usr/bin/brprint7040iglpr2"
+ # Editing a binary file requires the search and replace string to be the same size
+ # This changes the soname without the need for patchelf
+ sed -e "s:${_g1}:${_g2}:g" -i "${srcdir}/usr/share/${_conflict}/lpd/rawtobr2"
+ mv "${srcdir}/usr/lib/${_g1}" "${srcdir}/usr/lib/${_g2}"
+}
+
build() {
set -u
- # Get the dirs and the name of the wrapper. Either in /opt or /usr.
- # This is set up to adapt or crash. Unlike false, ${} shows the line number.
- cd 'opt' 2>/dev/null || cd 'usr'
- local _rcfile
- _rcfile="$(find "`pwd`" -type 'f' -ipath "*inf/br${_brotherund}rc")"
- test -f "${_rcfile}" || echo "${}"
-
- # go to the cupswrapper directory and find the source file from wich to generate a ppd- and wrapper-file
- local _wrapdir="$(find . -type 'd' -name 'cupswrapper')"
- test -d "${_wrapdir}" || echo "${}"
- cd "${_wrapdir}"
- echo "Wrapper dir: ${_wrapdir#./}"
- local _wrapper_source
- _wrapper_source=(cupswrapper*)
+
+ #local _basedir="opt/brother/Printers/${_brotherxnd}"
+ local _basedir="usr/share/${_conflict}"
+ #local _basedir="usr/share/${_conflict}/Printer/${_brotherxnd}"
+ shopt -s nullglob
+ local _wrapper_source=("${_basedir}/cupswrapper/cupswrapper${_brotherxnd}"*)
+ shopt -u nullglob
test "${#_wrapper_source[@]}" -eq 1 || echo "${}"
_wrapper_source="${_wrapper_source[0]}"
test -x "${_wrapper_source}" || echo "${}"
echo "Wrapper source: ${_wrapper_source}"
+ shopt -s nullglob
+ local _brcupsconf=("${_basedir}/cupswrapper"/brcupscon*); test "${#_brcupsconf[@]}" -eq 1 || echo "${}"
+ shopt -u nullglob
+ _brcupsconf="${_brcupsconf[0]}"
+ if [ ! -z "${_brsource:-}" ]; then
+ shopt -s nullglob
+ local _makedir=("${_brsource}/brcupsconf"*)
+ shopt -u nullglob
+ test "${#_makedir[@]}" -eq 1 || echo "${}"
+ _makedir="${_makedir[0]}"
+ test -d "${_makedir}" || echo "${}"
+
+ # Source is available for the cups binary, not the lpr binaries so we can't
+ # get away from multilib. Any usage of /opt is hardcoded into some binaries
+ # for which we can't find an equal length replacement so we can't easily get
+ # rid of that either.
+ pushd "${_makedir}" > /dev/null
+ _patch_brprint 'brcups_commands.h'
+ if [ -s 'Makefile' ]; then
+ 'ma''ke' -s
+ cp -p "${_brcupsconf##*/}" "${srcdir}/${_brcupsconf}"
+ else
+ # gcc options are pulled from other Brother makefiles.
+ gcc -pipe -Wall -W -O2 -s -o "${srcdir}/${_brcupsconf}" "brcupsconfig.c"
+ fi
+ popd > /dev/null
+
+ # Use the wrapper from the source file if available
+ pushd "${_brsource}" > /dev/null
+ [ -d 'scripts' ] && cd 'scripts'
+ [ -d 'SCRIPT' ] && cd 'SCRIPT'
+ [ -d 'cupswrapper' ] && cd 'cupswrapper'
+ shopt -s nullglob
+ local _wr2=("cupswrapper${_brotherxnd}"*)
+ shopt -u nullglob
+ if [ "${#_wr2[@]}" -eq 1 ]; then
+ rm "${srcdir}/${_wrapper_source}"
+ _wrapper_source="${_brsource}/${PWD#*/${_brsource}/}/${_wr2[0]}"
+ unset _wr2
+ set +u; msg2 "Alternate wrapper ${_wrapper_source}"; set -u
+ fi
+ popd >/dev/null
+
+ # Use the ppd supplied in the source
+ shopt -s nullglob
+ local _altppd=("${_brsource}"/[Pp][Pp][Dd]/)
+ shopt -u nullglob
+ if [ "${#_altppd[@]}" -eq 1 ]; then
+ _altppd="${_altppd[0]}"
+ local _altppdn="brother_${_brotherxnd}_printer_en.ppd"
+ mv "${_altppd}/${_altppdn}" "${_basedir}/cupswrapper/"
+ chmod 644 "${_basedir}/cupswrapper"/*.ppd
+ set +u; msg2 "Alternate ppd ${_altppdn}"; set -u
+ fi
+ else
+ _patch_brprint ''
+ fi
+
# Some Brother installers create files here
- #mkdir -p "${srcdir}/var/tmp"
+ mkdir -p 'var/tmp'
# Fix lpr driver.
sed -e '# Fix sbin reference' \
-e 's:/sbin/:/bin/:g' \
-e '#Fix hash bang' \
-e 's:#/bin/sh:#!/bin/sh:g' \
- -i $(find "${srcdir}/usr" -type f -name 'psconvert2')
+ -i "${_basedir}/lpd/psconvert2"
# Fix page shifted off center that affects some printers
# Letter prints off center shifted down and right with PaperType=A4
# I can only test printing A4 on Letter paper. A4 appears to print correctly with PaperType=Letter
- sed -e 's:^\(PaperType\)=.\+$:\1=Letter:g' -i "${_rcfile}"
+ sed -e 's:^\(PaperType\)=.\+$:\1=Letter:g' -i "${_basedir}/inf/br${_brotherxnd}rc"
# Modify the installer so we can finish the install here in PKGBUILD.
#cp -p "${_wrapper_source}" "${_wrapper_source}.Arch" # debug: diff compare with Total Commander
@@ -162,47 +347,57 @@ build() {
-e '# Fix a forgotten escape script error' \
-e 's: \$errorcode: \\$errorcode:g' \
-i "${_wrapper_source}"
- grep -lq "#Arch Linux Compatible$" "${_wrapper_source}" || echo "${}"
+ grep -lqe '#Arch Linux Compatible$' "${_wrapper_source}" || echo "${}"
test -f "${_wrapper_source}.Arch" && echo "${}" # Halt for debugging
# Generate PPD and wrapper. Use sh -x to debug
# Possible bug: copying to /usr/share/ppd is disabled.
_srcdir="${srcdir}" \
sh -u -e "${_wrapper_source}" -i
- chmod 644 "${srcdir}/usr/share/cups/model"/*.ppd # Some installers make ppd executable
- rm -rf "${srcdir}/var"
+ local _ppdir='usr/share/cups/model'
+ chmod 644 "${_ppdir}"/*.ppd # Some installers make ppd executable
+ rm -rf 'var'
+
+ #local _wrapgen="${_basedir}/cupswrapper/brother_lpdwrapper_${_brotherxnd}"
+ local _wrapgen="usr/lib/cups/filter/brlpdwrapper${_brotherxnd}"
+ test -s "${_wrapgen}" || echo "${}"
# Remove srcdir from the generated wrapper file.
+ # No paths in the generated ppd.
sed -e '# Remove the /home/... variety' \
-e "s:${srcdir}::" \
- -i "${srcdir}/usr/lib/cups/filter"/*lpdwrapper*
+ -i "${_wrapgen}"
+
+ # Ensure all paths were removed
+ grep -qFe $'${_srcdir}\n'"${srcdir}" "${_wrapgen}" && echo "${}"
# We did everything in the installer so we can get rid of it.
rm "${_wrapper_source}"
- cd "${srcdir}"
# Misnamed printer does not sort or autodetect properly
- sed -e "s:Brother ${_brotherund} :Brother ${_brotheru} :g" -i 'usr/share/cups/model'/*.ppd
+ sed -e "s:Brother ${_brotherund} :Brother ${_brotheru} :g" -i "${_ppdir}"/*.ppd
# Check to see if the lpd wrapper is referenced by the ppd
# Check to see if our compiled code is referenced by the lpd wrapper
local _nppdfound=0
- #local _ncodefound=0
+ local _ncodefound=0
local _lwrapper
for _lwrapper in 'usr/lib/cups/filter'/*; do
- if grep -q "$(basename "${_lwrapper}")" 'usr/share/cups/model'/*.ppd; then
+ if grep -q "$(basename "${_lwrapper}")" "${_ppdir}"/*.ppd; then
_nppdfound=$((_nppdfound+1))
fi
- #if grep -q "${_brcupsconf}" "${_lwrapper}"; then
- # _ncodefound=$((_ncodefound+1))
- #fi
+ if grep -q "${_brcupsconf##*/}" "${_lwrapper}"; then
+ _ncodefound=$((_ncodefound+1))
+ fi
done
test "${_nppdfound}" -ne 0 || echo "${}"
- #test "${_ncodefound}" -ne 0 || echo "${}"
- set +u
+ test "${_ncodefound}" -ne 0 || echo "${}"
+
+ set +u
}
package() {
set -u
+
local _dir
# /var/spool is not used anywhere in this package. Maybe it's needed for non cups lprng.
for _dir in 'usr' 'opt'; do # 'var'
@@ -212,8 +407,8 @@ package() {
done
# Ensure we got a ppd and a filter for CUPS
- test ! -z "$(find "${pkgdir}/usr/share/cups/model" -type f -name '*.ppd')"
- test ! -z "$(find "${pkgdir}/usr/lib/cups/filter/" -type f)"
+ test ! -z "$(find "${pkgdir}/usr/share/cups/model" -type 'f' -name '*.ppd')" || echo "${}"
+ test ! -z "$(find "${pkgdir}/usr/lib/cups/filter/" '(' -type 'f' -o -type 'l' ')')" || echo "${}"
# Ensure there are no forbidden paths
! grep -alqr "/sbin" "${pkgdir}" || echo "${}"