summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d1e19da16c746fc84f5663ac8ee2b009858ba67f (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
# Maintainer: Karol Babioch <karol@babioch.de>

pkgname=brother-ql720nw
pkgver=3.1.5r0
pkgrel=1
pkgdesc='LPR and CUPS driver for Brother QL-720NW label printer'
url='https://support.brother.com'
arch=('i686' 'x86_64')
license=('custom')
depends=('cups')
install="${pkgname}.install"
source=("https://download.brother.com/welcome/dlfp002203/ql720nwpdrv-${pkgver/r/-}.i386.rpm")
sha256sums=('07c2923aa60c502dae449d8716e4012331060fc60329098d1b92bb45064a8136')

prepare()
{
  # Create necessary CUPS directories
  install -d "${srcdir}/usr/share/cups/model"
  install -d "${srcdir}/usr/lib/cups/filter"

  # Locate cupswrapper script
  cd $(find -type d -name 'cupswrapper')
  _cupswrapper=$(ls cupswrapper*)

  # Patch cupswrapper script
  sed -i '/^sleep/d' ${_cupswrapper}
  sed -i '/^echo lpadmin/d' ${_cupswrapper}
  sed -i '/^lpadmin/d' ${_cupswrapper}
  sed -i "s|/usr|${srcdir}/usr|g" ${_cupswrapper}
  sed -i "s|/opt|${srcdir}/opt|g" ${_cupswrapper}
  sed -i "s|/model/Brother|/model|g" ${_cupswrapper}
  sed -i 's|lpinfo|echo|g' ${_cupswrapper}

  # Invoke cupswrapper script
  export srcdir=${srcdir}
  ./${_cupswrapper}

  # Patch resulting filter
  sed -i "s|${srcdir}||" ${srcdir}/usr/lib/cups/filter/*lpdwrapper*

  # Remove cupswrapper script and templates
  find "${srcdir}" -type d -name 'cupswrapper' -exec rm -rf {} +

  # Remove unneeded script (i.e. /etc/printcap is managed by CUPS)
  rm $(find "${srcdir}" -type f -name 'setupPrintcap*')

  # Remove binaries for different architectures
  if [ "${CARCH}" = 'x86_64' ]; then
    find "${srcdir}" -type d -name 'i686' -exec rm -rf {} +
  elif [ "${CARCH}" = 'i686' ]; then
    find "${srcdir}" -type d -name 'x86_64' -exec rm -rf {} +
  fi
}

package()
{
  # Install actual content
  cp -R "${srcdir}/usr" "${pkgdir}"
  cp -R "${srcdir}/opt" "${pkgdir}"

  # Handle license
  install -d "${pkgdir}/usr/share/licenses/${pkgname}"
  find "${pkgdir}" -type f -name 'LICENSE*.txt' -exec mv -t "${pkgdir}/usr/share/licenses/${pkgname}" {} +
}