rpms/hplip/F-13 hpcups-update-ppds.sh, NONE, 1.1 hplip.spec, 1.267, 1.268 sources, 1.37, 1.38

Tim Waugh twaugh at fedoraproject.org
Wed Apr 7 15:24:50 UTC 2010


Author: twaugh

Update of /cvs/pkgs/rpms/hplip/F-13
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv1882

Modified Files:
	hplip.spec sources 
Added Files:
	hpcups-update-ppds.sh 
Log Message:
* Wed Apr  7 2010 Tim Waugh <twaugh at redhat.com> - 3.10.2-8
- Regenerate hpcups PPDs on upgrade if necessary (bug #579355).



--- NEW FILE hpcups-update-ppds.sh ---
#!/bin/bash

## Copyright (C) 2010 Red Hat, Inc.
## Authors:
##  Tim Waugh <twaugh at redhat.com>

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

## Purpose: Update hpcups PPDs when necessary.

sock=/var/run/cups/cups.sock
running=$(LC_ALL=C lpstat -h "$sock" -r 2>/dev/null)
if [ "$?" -ne 0 ]
then
    # No lpstat in path
    exit 0
fi

if [ -z "${running##*not*}" ]
then
    # scheduler is not running
    exit 0
fi

trap 'rm -f "$tmpdir"/models; rmdir "$tmpdir"; exit 0' \
    0 HUP INT QUIT ILL ABRT PIPE TERM

debug=true
tmpdir="$(mktemp -d)"
for ppd in /etc/cups/ppd/*.ppd
do
    [ -r "$ppd" ] || continue
    queue="${ppd#/etc/cups/ppd/}"
    queue="${queue%.ppd}"
    lpstat -h "$sock" -p "$queue" &>/dev/null || continue

    # We have PPD associated with a queue.  Find out its NickName
    $debug && echo "Examining $queue"
    nickname="$(grep '^\*NickName:' "$ppd")"
    nickname="${nickname#*\"}" # strip text up to and incl first double quote
    nickname="${nickname%\"*}" # strip final double quote
    $debug && echo "NickName is: $nickname"

    # Is it an hpcups PPD?
    [ -z "${nickname##*, hpcups*}" ] || continue
    $debug && echo "hpcups: true"

    # Does it have an hpPrinterLanguage attribute?
    grep -q '^\*hpPrinterLanguage:' "$ppd" &>/dev/null && continue
    $debug && echo "No hpPrinterLanguage attribute"

    # No: need to regenerate the PPD.
    if [ ! -f "$tmpdir/models" ]
    then
	# Get list of driver URIs and NickNames
	lpinfo -h "$sock" --include-schemes=drv -m 2>/dev/null >"$tmpdir/models"
    fi

    # Strip hpcups version from NickName
    nickname="${nickname%, hpcups*}"
    $debug && echo "Stripped NickName: $nickname"
    while read line
    do
	uri=${line%% *}
	nn="${line#$uri }"
	[ -z "${nn##*, hpcups*}" ] || continue

	nn="${nn%, hpcups*}"
	if [ "$nn" == "$nickname" ]
	then
	    $debug && echo "Match found, URI: $uri"

	    # Unfortunately CUPS will reset the page size when we
	    # change the PPD, due to the weird page size names that
	    # HPLIP uses.  Try to maintain the existing page size.
	    size="$(grep '^\*DefaultPageSize:' "$ppd")"
	    size="${size##* }" # strip until after first ' '
	    size="${size%% *}" # strip after any ' '
	    $debug && echo "PageSize is $size"

	    if [ -z "${size#*Duplex}" ]
	    then
		# Special handling for duplex sizes because HPLIP
		# broke backwards compatibility with *that* too!
		size="${size%Duplex}.Duplex"
	    fi

	    null=/dev/null
	    $debug && null=/dev/stdout
	    lpadmin -h "$sock" -p "$queue" -m "$uri" &>"$null" || :
	    $debug && echo "PPD regenerated"

	    lpadmin -h "$sock" -p "$queue" -o PageSize="$size" &>"$null" || :
	    $debug && echo "PageSize restored to $size"
	    break
	fi
    done <"$tmpdir/models"
done
exit 0


Index: hplip.spec
===================================================================
RCS file: /cvs/pkgs/rpms/hplip/F-13/hplip.spec,v
retrieving revision 1.267
retrieving revision 1.268
diff -u -p -r1.267 -r1.268
--- hplip.spec	7 Apr 2010 14:33:46 -0000	1.267
+++ hplip.spec	7 Apr 2010 15:24:50 -0000	1.268
@@ -1,7 +1,7 @@
 Summary: HP Linux Imaging and Printing Project
 Name: hplip
 Version: 3.10.2
-Release: 7%{?dist}
+Release: 8%{?dist}
 License: GPLv2+ and MIT
 Group: System Environment/Daemons
 Conflicts: system-config-printer < 0.6.132
@@ -389,7 +389,7 @@ fi
 %{_bindir}/hpcups-update-ppds &>/dev/null ||:
 
 %changelog
-* Wed Apr  7 2010 Tim Waugh <twaugh at redhat.com> - 3.10.2-7
+* Wed Apr  7 2010 Tim Waugh <twaugh at redhat.com> - 3.10.2-8
 - Regenerate hpcups PPDs on upgrade if necessary (bug #579355).
 
 * Fri Mar 26 2010 Jiri Popelka <jpopelka at redhat.com> - 3.10.2-6


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/hplip/F-13/sources,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -p -r1.37 -r1.38
--- sources	7 Apr 2010 14:33:46 -0000	1.37
+++ sources	7 Apr 2010 15:24:50 -0000	1.38
@@ -1,2 +1 @@
 4df6f16c47ae7edd015bf2cf5155f26f  hplip-3.10.2.tar.gz
-110820c749dc7ec81e949c193187cb39  hpcups-update-ppds.sh



More information about the scm-commits mailing list