summaryrefslogtreecommitdiff
path: root/debian/cups-driver-gutenprint.postinst
blob: a16de74ab72acfaffda188e6e5ef32f7a0ab989e (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
#! /bin/sh
# postinst script for cupsys-driver-gutenprint
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see /usr/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

#s/^if\s+\[\s+"\$1"\s+=\s+"configure"\s+\];\s+then\s+ldconfig\b//m;

if [ "$1" = "configure" ]; then

  # Upgrade in-use PPD files
  /usr/sbin/cups-genppdupdate
  # Restart CUPSys (to register new and updated PPDs)
  [ -x /etc/init.d/cupsys ] && invoke-rc.d cupsys force-reload || true

  # Upgrade from obsolete epson and canon backends
  LC_ALL=C lpstat -v |
  while read devinfo; do
      printer=$(echo $devinfo | sed -e 's;device for \(..*\): \(..*\):/\(.*\);\1;')
      backend=$(echo $devinfo | sed -e 's;device for \(..*\): \(..*\):/\(.*\);\2;')
      device=$(echo $devinfo | sed -e 's;device for \(..*\): \(..*\):/\(.*\);/\3;')

      if [ "$backend" = "epson" ] || [ "$backend" = "canon" ]; then
	  echo "Backend $backend used by printer $printer is obsolete."
	  newbackend='parallel'
	  if ! echo "$device" | grep -q '^/dev'; then
	      newbackend='socket'
	  elif echo "$device" | grep -q 'usb'; then
	      newbackend='usb'
	  fi
	  echo "Updating $printer to use $newbackend backend: $newbackend:$device"
	  lpadmin -p "$printer" -v "$newbackend:$device"
	  lpstat -v "$printer"
      else
	  echo "Backend $backend used by printer $printer is current."
      fi
  done

elif [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-remove" ] || [ "$1" = "abort-deconfigure" ]; then
  :
else
  echo "postinst called with unknown argument \`$1'" >&2
  exit 0
fi

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0