# Maintainer: Jonathan Doman <jonathan.doman@gmail.com>
pkgname=brother-hl2270dw
_cupswrappername=cupswrapperHL2270DW
pkgver=2.0.4_2
pkgrel=3
pkgdesc="Brother HL-2270DW CUPS Driver"
arch=('i686' 'x86_64')
url='http://welcome.solutions.brother.com/bsc/public_s/id/linux/en/index.html'
license=('GPL')
depends=('a2ps' 'cups' 'lib32-glibc')
source=("http://www.brother.com/pub/bsc/linux/dlf/hl2270dwlpr-2.1.0-1.i386.rpm"
"http://www.brother.com/pub/bsc/linux/dlf/${_cupswrappername}-${pkgver//_/-}.i386.rpm")
md5sums=('69c1987c0636a64fb48f3c6826a3ae28'
'5a7cc60cafaf60d722d9bce3f2751164')
package() {
_cupswrapperFile="$srcdir/usr/local/Brother/Printer/HL2270DW/cupswrapper/${_cupswrappername}-2.0.4"
sed -i -e '/^!ENDOFWFILTER!/ q' "${_cupswrapperFile}"
sed -i -e 's#/usr#$srcdir/usr#' "${_cupswrapperFile}"
sed -i -e 's#/usr/local#/usr/share#' "$srcdir/usr/local/Brother/Printer/HL2270DW/lpd/filterHL2270DW"
mkdir -p "$srcdir/usr/share/cups/model/"
# Run the install script to extract the PPD file
. "${_cupswrapperFile}"
# Remove unnecessary files
rm "$srcdir/usr/local/Brother/Printer/HL2270DW/inf/setupPrintcap2"
rm "${_cupswrapperFile}"
# Change the PPD description to match other listing for Brother printers in CUPS
sed -i -e 's/Brother HL2270DW for CUPS/Brother HL-2270DW/' "$srcdir/usr/share/cups/model/HL2270DW.ppd"
# Replace references to $srcdir
sed -i -e "s#$srcdir/usr#/usr#" "$srcdir/usr/lib/cups/filter/brlpdwrapperHL2270DW"
sed -i -e "s#/usr/local#/usr/share#" "$srcdir/usr/lib/cups/filter/brlpdwrapperHL2270DW"
chmod +x "$srcdir/usr/lib/cups/filter/brlpdwrapperHL2270DW"
# Changing the default paper size to letter seems to result in better positioning when
# printing on letter. Sorry to A4 users!
sed -i -e "s/PaperType=A4/PaperType=Letter/" "$srcdir/usr/local/Brother/Printer/HL2270DW/inf/brHL2270DWrc"
# Change the path for pstops
sed -i -e "s#/usr/sbin/pstops#/usr/lib/cups/filter/pstops#" "$srcdir/usr/local/Brother/Printer/HL2270DW/lpd/psconvert2"
sed -i -e "s#/usr/bin/pstops#/usr/lib/cups/filter/pstops#" "$srcdir/usr/local/Brother/Printer/HL2270DW/lpd/filterHL2270DW"
# Copy the src tree into the pkg tree
cp -R "$srcdir/usr/" "$pkgdir/"
cp -R "$srcdir/var/" "$pkgdir/"
mv "$pkgdir/usr/local/Brother" "$pkgdir/usr/share/"
rmdir "$pkgdir/usr/local"
}
# vim:set ts=2 sw=2 et: