summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e09f7977f9cb896b366461816867d4ba60a71179 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Maintainer:  Chris Severance aur.severach aATt spamgourmet dott com

# TODO: Add more _printerids to make autodetect work for more models.
#   The printer ID is found inside the ()
#   Discovered Network Printers: B411 (OKI DATA CORP B411)

set -u
pkgname='oki-b411-b431'
_pkgnick='MB400PCL'
pkgver='5.0.0'
pkgrel='1'
pkgdesc='CUPS printer driver for the Okidata B410 B411 B420 B430 B431 B4100 B4200 B4250 B4300 B4350 B4400 B4500 B4550 B4600 MB460 MB470 MB480'
arch=('i686' 'x86_64')
url='http://www.okidata.com/'
license=('GPL')
depends=('cups')
makedepends=('gzip')
# install="${pkgname}.install"
# An Install is not necessary. Printers appear and disappear from cups
# without a systemctl reload org.cups.cupsd.service or killall -HUP cupsd
source=('ftp://ftp2.okidata.com/pub/drivers/linux/SFP/monochrome/desktop/MB400PCLv5.tar')
sha256sums=('3ab2df56a62e03d0c0f8dcbb09ea7cde757eac3eb9ab1772f5f3c421cbb6c73f')

_printerids=(
  # PPDName:Friendly Name (MATCH TEXT)
  'OKB411:Oki B411 (OKI DATA CORP B411) PCL'
)

prepare() {
  set -u
  cd "${_pkgnick}"
  # There's 101 ways to hack up this installer. I choose to
  # fix it the way it should be for most package makers.
  chmod 755 'install.sh'
  sed -e '# Disable unnecessary PATH statements' \
      -e 's:^PATH=/:# &:g' \
      -e 's:^export PATH:# &:g' \
      -e '# Ownership is managed by makepkg' \
      -e 's:\${CHOWN}:# &:g' \
      -e 's:\${CHGRP}:true # &:g' \
      -e '# Root is not necessary when packaging' \
      -e 's:\[ `\${ID} -u`:[ -z "${DESTDIR}" ] \&\& &:g' \
      -e '# Disable these variables to ensure that set -u catches us if we try to use them.' \
      -e 's:^_CUPS[A-Z]*=":# &:g' \
      -e '# Install to package folder' \
      -e 's:_PATH="/usr/:_PATH="${DESTDIR}/usr/:g' \
      -e '# Terminate before changing services' \
      -e 's:^\(for i in \${_CUPS}\):if [ "${DESTDIR}" != "" ]; then\n\texit 0\nfi\n\n\1:g' \
    -i 'install.sh'
  set +u
}

package() {
  set -u
  cd "${_pkgnick}"
  install -d "${pkgdir}/usr/share/cups/model"
  install -d "${pkgdir}/usr/lib/cups/filter"
  DESTDIR="${pkgdir}" \
  sh -u -e 'install.sh'

  # Add alternate nicknames to make autodetect work
  local _oldfile='OK400PCL.ppd.gz'
  local _printerid
  for _printerid in "${_printerids[@]}"; do
    local _newtag="${_printerid%%:*}"
    local _newid="${_printerid#*:}"
    local _newfile="${_oldfile//OK400/${_newtag}}"
    test "${_oldfile}" != "${_newfile}" || echo "${}"
    gunzip < "${_oldfile}" | \
    sed -e '# Fix autodetect *NickName' \
        -e "s:OKI B4000 / B400 / MB400 PCL:${_newid}:g" \
        -e "s:OK400PCL.PPD:${_newfile%\.gz}:g" \
        -e '# Make the printer sort in the list with foomatic' \
        -e '# I cant figure how how to change the display name without breaking autodetect' \
        -e '#/^*ModelName/ s:OKI DATA CORP:Oki:g ' \
        -e '#/^*ShortNickName/ s:OKI DATA CORP:Oki:g ' \
      | gzip > "${_newfile}"
    install -m644 "${_newfile}" -t "${pkgdir}/usr/share/cups/model/"
  done

  set +u
}
set +u