postinst is in cups 1.5.2-9ubuntu1.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | #! /bin/sh
# postinst script for cups
#
# 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'.
dpkg-maintscript-helper rm_conffile /etc/modprobe.d/blacklist-cups-usblp.conf 1.5.2-3 -- "$@"
# Debconf
. /usr/share/debconf/confmodule
# Default Configuration file
if [ -e /etc/default/cups ]; then
. /etc/default/cups
fi
if [ "$1" = configure ]; then
# Set up lpadmin group.
if [ -z "`getent group lpadmin`" ]; then
addgroup --system lpadmin
fi
# set up custom PPD directory
chown root:lpadmin /usr/share/ppd/custom 2>/dev/null || true
chmod 3775 /usr/share/ppd/custom 2>/dev/null || true
# Generate raw MIME handling files if they don't already exist.
if [ ! -e /etc/cups/raw.types ]; then
cat >/etc/cups/raw.types <<EOF
# This file was generated by the cups package. You may change it, or
# reconfigure this file with dpkg-reconfigure. If it is removed, it
# will be regenerated by the package scripts.
application/octet-stream
EOF
fi
if [ ! -e /etc/cups/raw.convs ]; then
cat >/etc/cups/raw.convs <<EOF
# This file was generated by the cups package. You may change it, or
# reconfigure this file with dpkg-reconfigure. If it is removed, it
# will be regenerated by the package scripts.
application/octet-stream application/vnd.cups-raw 0 -
EOF
fi
# Set up raw printing of application/octet-stream if desired.
db_fget cupsys/raw-print changed
if [ "$RET" = "true" ]; then
mv /etc/cups/raw.convs /etc/cups/raw.convs-convert
db_get cupsys/raw-print
if [ "$RET" = "true" ]; then
sed 's/^\s*#\s*application/application/' \
< /etc/cups/raw.convs-convert > /etc/cups/raw.convs
else
sed 's/^application/#application/' \
< /etc/cups/raw.convs-convert > /etc/cups/raw.convs
fi
rm -f /etc/cups/raw.convs-convert
db_fset cupsys/raw-print changed false
fi
# Set up backends
db_get cupsys/backend && SELECTED=$RET
# We remove the scsi backend from the output as it got removed in CUPS 1.5.0
list=`echo $SELECTED | sed -e 's/, /,/g' | sed -e 's/scsi,*//g' | sed -e 's/parallel,*//g' | sed -e 's/serial,*//g'`
save_IFS=$IFS
IFS=,
(cd /usr/lib/cups/backend && rm -f http https ipp ipps lpd socket usb snmp dnssd mdns)
for module in $list; do
ln /usr/lib/cups/backend-available/$module /usr/lib/cups/backend/$module
if [ "$module" = "ipp" ]; then
ln /usr/lib/cups/backend/ipp /usr/lib/cups/backend/http
ln /usr/lib/cups/backend/ipp /usr/lib/cups/backend/https
ln /usr/lib/cups/backend/ipp /usr/lib/cups/backend/ipps
fi
if [ "$module" = "dnssd" ]; then
ln /usr/lib/cups/backend/dnssd /usr/lib/cups/backend/mdns
fi
done
IFS=$save_IFS
# activate new backends on upgrades
db_fset cupsys/backend changed false
# Resync Debconf database with real state
list=`( cd /usr/lib/cups/backend && for f in ipp lpd socket usb snmp dnssd; do [ -e $f ] && echo -n "$f, "; done ) | sed -e 's/, $//'`
db_set cupsys/backend $list;
if [ -f /etc/cups/classes.conf ]; then
chown root:lp /etc/cups/classes.conf ; chmod 600 /etc/cups/classes.conf
fi
if [ -f /etc/cups/printers.conf ]; then
chown root:lp /etc/cups/printers.conf ; chmod 600 /etc/cups/printers.conf
fi
# symlink snakeoil SSL certificate if present
if [ -e /etc/ssl/certs/ssl-cert-snakeoil.pem -a \
-e /etc/ssl/private/ssl-cert-snakeoil.key -a \
-n "`getent group ssl-cert`" -a ! -e /etc/cups/ssl/server.crt \
-a ! -e /etc/cups/ssl/server.key -a ! -h /etc/cups/ssl/server.crt \
-a ! -h /etc/cups/ssl/server.key ]; then
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/cups/ssl/server.crt
ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/cups/ssl/server.key
fi
APP_PROFILE=/etc/apparmor.d/usr.sbin.cupsd
if [ -f "$APP_PROFILE" ]; then
# Add the local/ include
LOCAL_APP_PROFILE=/etc/apparmor.d/local/usr.sbin.cupsd
[ -e "$LOCAL_APP_PROFILE" ] || \
[ -e /etc/apparmor.d/local -a ! -d /etc/apparmor.d/local ] || {
tmp=`mktemp`
cat <<EOM > "$tmp"
# Site-specific additions and overrides for usr.sbin.cupsd.
# For more details, please see /etc/apparmor.d/local/README.
EOM
mkdir `dirname $LOCAL_APP_PROFILE` 2>/dev/null || true
mv -f "$tmp" "$LOCAL_APP_PROFILE"
chmod 644 "$LOCAL_APP_PROFILE"
}
# Reload the profile, including any abstraction updates
if aa-status --enabled 2>/dev/null; then
apparmor_parser -r -T -W "$APP_PROFILE" || true
fi
fi
# Clear cache if we upgrade to 1.4.x
if dpkg --compare-versions "$2" lt-nl "1.4.1-5"; then
rm /var/cache/cups/* 2> /dev/null || :
fi
# Clear PPD cache if we upgrade to 1.5.x
if dpkg --compare-versions "$2" lt-nl "1.5.0-3"; then
rm /var/cache/cups/ppds.dat 2> /dev/null || :
fi
# Manage printcap file and associated symlinks
if [ -e /etc/cups/cupsd.conf ]; then
if [ -e /etc/printcap.cups ]; then
rm -f /etc/printcap.cups
fi
if [ -L /etc/printcap -a ! -e /etc/printcap ]; then
rm -f /etc/printcap
fi
printcap_file=`egrep '^Printcap ' /etc/cups/cupsd.conf | awk '{print $2}' | tail -n 1`
if [ -z "$printcap_file" ]; then
printcap_file=/var/run/cups/printcap
fi
if [ ! -e /etc/printcap -a -e $printcap_file ]; then
ln -s $printcap_file /etc/printcap
fi
fi
fi
# Automatically added by dh_installinit
if [ -e "/etc/init/cups.conf" ]; then
invoke-rc.d cups start || exit $?
fi
# End automatically added section
# ppd_updater is supposed to be launched only with a running CUPS.
ppd_updater () {
driverregexp="$1"
gennicknameregexp="$2"
[ ! -z "$gennicknameregexp" ] && \
gennicknameregexp="; $gennicknameregexp"
gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
tmpfile1=`mktemp -t updateppds.XXXXXX`
tempfiles="$tempfiles $tmpfile1"
grep -E $driverregexp $tmpfile0 > $tmpfile1 || :
cd /etc/cups/ppd
for ppd in *.ppd; do
[ -r "$ppd" ] || continue
queue=${ppd%.ppd}
lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
nickname=`grep '\*NickName:' "$ppd" | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
ppdfound="0"
englishppduri=""
tmpfile2=`mktemp -t updateppds.XXXXXX`
tempfiles="$tempfiles $tmpfile2"
cat $tmpfile1 | perl -p -e "$gennicknameregexp; s/\n*$/\n/s" | grep -E '^\S+\s+.*'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
while read newppduri; do
[ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
[ "$newlang" = "$lang" ] && ppdfound="1"
[ "$newlang" = "english" ] && englishppduri="$newppduri"
done < $tmpfile2
[ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
[ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
done
return 0
}
# Do the following only if CUPS is running and the needed CUPS tools
# are available
if which lpstat > /dev/null 2>&1 && \
which lpinfo > /dev/null 2>&1 && \
which lpadmin > /dev/null 2>&1 && \
LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
tempfiles=
trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
tmpfile0=`mktemp -t updateppds.XXXXXX`
tempfiles="$tempfiles $tmpfile0"
lpinfo -h /var/run/cups/cups.sock -m > $tmpfile0
if [ "$1" = configure ] ; then
# Update CUPS included drivers' queues
echo "Updating PPD files for cups ..."
ppd_updater 'lsb/usr/cups-included/|drv:///sample.drv/' 's/,\s*\d+\.\d+[\d\.]*$//i'
fi
if [ "$1" = triggered ] || [ "$1" = configure ] ; then
# Update external drivers' queues.
#
# We log the modification dates of the file in
# /usr/share/cups/ppd-updaters/* after updating the PPDs
# according to them. These dates are more or less the creation
# dates of the driver packages. Then we only update the PPDs of
# packages, where the /usr/share/cups/ppd-updaters/* file has a
# modification date different to the logged date as this means
# that a fresh /usr/share/cups/ppd-updaters/* file and
# therefore a fresh package got installed. This avoids updating
# of PPDs when the corresponding package was not changed.
logfile=/var/cache/cups/ppd-updates
touch $logfile
for driverfile in `ls /usr/share/cups/ppd-updaters`; do
driver=`echo $driverfile | perl -p -e 's/\.ppd-updater$//' | perl -p -e 's/^printer-driver-//'`
modtime=`ls -l --time-style=+%s /usr/share/cups/ppd-updaters/$driverfile | perl -p -e 's/^\s*\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s*$/$1\n/'`
oldmodtime=`cat $logfile | grep " $driver$" | cut -d ' ' -f 1`
if [ "$modtime" != "$oldmodtime" ]; then
echo "Updating PPD files for $driver ..."
. /usr/share/cups/ppd-updaters/${driverfile}
ppd_updater "${DRIVER_REGEXP}" "${GENNICKNAME_REGEXP}"
cat $logfile | grep -v " $driver$" > $logfile.new || touch $logfile.new
echo "$modtime $driver" >> $logfile.new
mv $logfile.new $logfile
fi
done
fi
fi
db_stop
exit 0
|