diff options
-rw-r--r-- | .SRCINFO | 16 | ||||
-rw-r--r-- | PKGBUILD | 56 | ||||
-rw-r--r-- | brother-mfc-j4540dw.install | 79 |
3 files changed, 151 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..f95653cfbb35 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,16 @@ +pkgbase = brother-mfc-j4540dw + pkgdesc = LPR driver and CUPS wrapper for Brother MFC-j4540dw printer + pkgver = 3.5.0 + pkgrel = 1 + url = https://www.brother.co.uk/support/mfc-j4540dw/downloads + install = brother-mfc-j4540dw.install + arch = x86_64 + license = EULA + depends = perl + depends = cups + optdepends = brscan5 + source = https://download.brother.com/welcome/dlf105295/mfcj4540dwpdrv-3.5.0-1.i386.rpm + sha256sums = 3f1118903f7c28b5397799550724c49a8e89378d4a2a7d472f8e2d4fb09ed321 + depends_x86_64 = lib32-glibc + +pkgname = brother-mfc-j4540dw diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..f18d4be3bbfc --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,56 @@ +# Based on brother-mfc-j4340dw, which is: +# Based on brother-mfc-j4335dw, brother-mfc-j5845dw and brother-mfc-l2710dw +# +# Corrected according to the RPM postinstall script +# and the driver install script (cupswrapper/cupswrapper${_model}) +_model=mfcj4540dw +_device_name=MFC-j4540dw +pkgname=brother-mfc-j4540dw +pkgver=3.5.0 +pkgrel=1 +pkgdesc="LPR driver and CUPS wrapper for Brother ${_device_name} printer" +arch=("i686" "x86_64") +url="https://www.brother.co.uk/support/mfc-j4540dw/downloads" +license=("EULA") +source=("https://download.brother.com/welcome/dlf105299/${_model}pdrv-${pkgver}-${pkgrel}.i386.rpm") +sha256sums=('3f1118903f7c28b5397799550724c49a8e89378d4a2a7d472f8e2d4fb09ed321') +depends=('perl' 'cups') +depends_x86_64=('lib32-glibc') +optdepends=('brscan5') +install="$pkgname.install" + +package() { + SRC_PREFIX=/opt # unfortunately, /opt is hard-coded into driver binaries and cannot be replaced + PREFIX=/usr/share + + find "$srcdir$SRC_PREFIX/brother" -type d -exec chmod 755 '{}' + + find "$srcdir$SRC_PREFIX/brother" -type f -exec chmod 644 '{}' + + find "$srcdir$SRC_PREFIX/brother/Printers/$_model/lpd" -type f -exec chmod +x '{}' + + + mkdir -p "$pkgdir$SRC_PREFIX" + cp -R "$srcdir$SRC_PREFIX/brother" "$pkgdir$SRC_PREFIX" + + # /etc/printcap is managed by cups + find "$pkgdir" -type f -name 'setupPrintcap*' -delete + + # symlink for the PPD + ppd_file_name="$SRC_PREFIX/brother/Printers/$_model/cupswrapper/brother_${_model}_printer_en.ppd" + install -d "$pkgdir$PREFIX/cups/model/Brother" + ln -s "$ppd_file_name" "$pkgdir$PREFIX/cups/model/Brother/" + #install -d "$pkgdir$PREFIX/ppd/Brother" + #ln -s "$ppd_file_name" "$pkgdir$PREFIX/ppd/Brother/" + #install -d "$pkgdir$PREFIX/ppd/cupsfilters" + #ln -s "$ppd_file_name" "$pkgdir$PREFIX/ppd/cupsfilters/" + + ldpwrapper="$SRC_PREFIX/brother/Printers/$_model/cupswrapper/brother_lpdwrapper_${_model}" + chmod +x "$pkgdir$ldpwrapper" + mkdir -p "$pkgdir/usr/lib/cups/filter/" + ln -s "$ldpwrapper" "${pkgdir}/usr/lib/cups/filter/" + + # a couple architecture-specific symlinks + ln -s "$SRC_PREFIX/brother/Printers/$_model/lpd/$CARCH/br${_model}filter" "$pkgdir$SRC_PREFIX/brother/Printers/$_model/lpd/" + ln -s "$SRC_PREFIX/brother/Printers/$_model/lpd/$CARCH/brprintconf_${_model}" "$pkgdir$SRC_PREFIX/brother/Printers/$_model/lpd/" + + install -d "$pkgdir/usr/bin" + ln -s "$SRC_PREFIX/brother/Printers/$_model/lpd/brprintconf_${_model}" "$pkgdir/usr/bin/" +} diff --git a/brother-mfc-j4540dw.install b/brother-mfc-j4540dw.install new file mode 100644 index 000000000000..74d190fddc32 --- /dev/null +++ b/brother-mfc-j4540dw.install @@ -0,0 +1,79 @@ +PREFIX=/usr/share + +printer_model=""mfcj4540dw"" +printer_name=`echo $printer_model | tr '[a-z]' '[A-Z]'` +device_name=`echo $printer_name | eval sed -e 's/MFC/MFC-/' -e 's/DCP/DCP-/' -e 's/HL/HL-/' -e 's/FAX/FAX-/'` + +ppd_file_name=$PREFIX/cups/model/Brother/brother_${printer_model}_printer_en.ppd + +post_install() { + post_upgrade; + + echo "Register the new printer at \"http://localhost:631/\"." + print_lpadmin; + + apply_selinux_policy; +} + +post_upgrade() { + echo "Restart CUPS (cups.service) in order to load the new files." +} + +apply_selinux_policy() { + if [ "$(which semanage 2> /dev/null)" != '' ];then + semanage fcontext -a -t cupsd_rw_etc_t '/opt/brother/Printers/'${printer_model}'/inf(/.*)?' + semanage fcontext -a -t bin_t '/opt/brother/Printers/'${printer_model}'/lpd(/.*)?' + semanage fcontext -a -t bin_t '/opt/brother/Printers/'${printer_model}'/cupswrapper(/.*)?' + if [ "$(which restorecon 2> /dev/null)" != '' ];then + restorecon -R /opt/brother/Printers/${printer_model} + fi + fi +} + +print_lpadmin() { + uris=$(lpinfo -v) + + for uri in $uris + do + URI=$(echo $uri | grep ${device_name} | grep usb) + if [ "$URI" != '' ];then + break; + fi + done + + if [ "$URI" = '' ];then + for uri in $uris + do + URI=$(echo $uri | grep ${device_name} ) + if [ "$URI" != '' ];then + break; + fi + done + fi + + if [ "$URI" = '' ];then + for uri in $uris + do + URI=$(echo $uri | grep -i Brother | grep usb ) + if [ "$URI" != '' ];then + break; + fi + done + fi + + if [ "$URI" = '' ];then + for uri in $uris + do + URI=$(echo $uri | grep usb ) + if [ "$URI" != '' ];then + break; + fi + done + fi + + if [ "$URI" = '' ];then + URI="usb://dev/usb/lp0" + fi + + echo "or execute 'lpadmin -p ${printer_name} -E -v $URI -P ${ppd_file_name}'" +} |