summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f4a931fa7796be6e0a8cbc7e33216b42cadc567e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Maintainer: Will Adams <willadams + dev at gmail dot com>
pkgname="brother-mfc-j415w"
_model="mfcj415w"
pkgver="1.1.3"
_pkgrel=1
pkgrel=1
pkgdesc="LPR and CUPS driver for the Brother MFC-J415W"
arch=('i686' 'x86_64')
url="http://solutions.brother.com/linux/en_us/"
license=('custom:brother commercial license')
depends=('cups')
install="$pkgname.install"
source=("http://download.brother.com/welcome/dlf006561/${_model}lpr-$pkgver-$_pkgrel.i386.rpm"
        "http://download.brother.com/welcome/dlf006563/${_model}cupswrapper-$pkgver-$_pkgrel.i386.rpm")
sha256sums=('2a4dee6c2d70e0ae72a95af78566e208c258779047a58f35e528cd912ed053b2'
            '939f108f64aba734492359085733eec52b2eaa71ecf6976aa2dc93e5000be533')

if test "$CARCH" == x86_64; then
  depends+=('lib32-glibc')
fi

prepare() {
    cd "$srcdir"
    filter_file="$srcdir/filter_file"
    filter_wrapper="$srcdir/filter_wrapper"
    ppd_file="$srcdir/ppd_file"

    # extract filter from cupswrapper
    cupswrapper="$(find $srcdir -iname cupswrapper${_model})"
    limit_string="$(sed -n 's/cat <<\ *\([^\ ]*\)\ *>.*/\1/p' $cupswrapper)"
    sed -n -e '/^printer_model/ p' \
           -e '/^printer_name/ p' \
           -e '/^device_name/ p' \
           -e '/^device_model/ p' \
           -e 's|>\ *\$tmp_filter||' \
           -e '1,3 { /^#\! \/bin\/sh/ p }' \
           -e 's|/model/Brother|/model|g' \
           -e 's|/usr/local/Brother|/usr/share/brother|g' \
           -e '/cat <<\s*'"$limit_string"'/,/'"$limit_string"'/ {
                 s/\(^[\ #]*brother print filter\)\ *>>.*/\1/I
                 p
               }' \
           "$cupswrapper" > "$filter_wrapper"
    chmod 0755 "$filter_wrapper"
    if "$filter_wrapper" > "$filter_file"; then 
        rm "$filter_wrapper"
        rm "$cupswrapper"
    fi

    # move ppd file
    mv "$(find -iname '*'$_model'*.ppd' -print -quit)" "$ppd_file"

    # delete setupPrintcap
    find "$srcdir" -type f -name 'setupPrintcap*' -delete 
}

package() {
    # install files in $pkgdir
    cp -R $srcdir/usr $pkgdir
    if [ -d $srcdir/opt ]; then cp -R $srcdir/opt $pkgdir; fi
    install -m 644 -D "$srcdir/ppd_file" \
        "${pkgdir}/usr/share/cups/model/brother_${_model}_printer_en.ppd"
    install -m 755 -D "$srcdir/filter_file" \
        "${pkgdir}/usr/lib/cups/filter/brlpdwrapper${_model}"
}