python/manuel: update to 1.13.0
[oi-userland.git] / components / foomatic / fppd / supportedonly.sh
blob64f03a0fdf2bc1635ba176e405528a45b59bed35
1 #!/bin/bash
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
23 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
26 # Find the PPD files delivered by foomatic that Solaris does not support.
27 # There are two reasons for non-support:
29 # 1. license/patent issues with the driver (listed in file nolicense). These
30 # files are removed and not delivered
31 # 2. The driver used by the PPD file must be brought downand compiled and
32 # Solaris has not chosen to do so. In that case the PPD file is delivered,
33 # but not included in the generated cache file.
35 # The unsupported PPD file should be listed in $BUILD_DIR/ppdunsupported for
36 # review. The catchall file, ppdsnomatch, should be empty. If not, a new
37 # case is needed in this script. The other files are there for debugging
38 # purposes.
40 # Notes:
41 # drivers come in several flavors: gs built in, gs uniprint, postscript,
42 # hpijs, and then the several other drivers.
43 # Drivers are noted in many PPD files with driverType. To sort these, look
44 # for: driverType G/GhostScript built-in:
45 # driverType U/GhostScript Uniprint:
46 # driverType F/Filter: ""
47 # Drivers are also noted in the name of the ppd file. This is used
48 # to cull out postscript, hpijs, and pxlmono . These do not reliably
49 # use driverType. note: pxlmono driver is a gs built-in but many of the
50 # ppd files that use this driver do not utilize the driverType line.
51 # driverType I/IJS: "" is not reliable for hpijs as not used in many ppds.
53 # driverType F/Filter: "" denotes ppd files that use GhostScript and
54 # then pipe that output to one or more other drivers. These will only be
55 # supported if Solaris compiles and delivers these drivers.
57 # Make sure that there are no undefined variables
58 set -ue
60 # Sanitize PATH
61 PATH=/usr/bin:/bin
63 if [ -z "${1-}" ] || [ -z "${2-}" ] ||
64 [ -z "${3-}" ] || [ -z "${4-}" ]; then
65 echo "Usage: $0 build-dir tree-of-ppds cache-file nolicense-file"
66 exit 1
69 # Build directory
70 BUILD_DIR="$1"
71 # Where PPD files are located
72 BASE="$2"
73 # Cache file to be created
74 CACHE="$3"
75 # File listing PPDs with no/invalid license
76 NOLICENSE="$4"
77 # Base install path for PPD files
78 IPATH=/usr/share/ppd/SUNWfoomatic
80 # Script will fail if set
81 FAIL_LATER=""
83 mkdir -p "$( dirname "$CACHE" )"
84 /bin/rm -f ${BUILD_DIR}/ppdunsupported \
85 ${BUILD_DIR}/ppdsupported \
86 ${BUILD_DIR}/ppdsnomatch \
87 "$CACHE"
89 # files which should be included in the cache
92 #-----
94 ## add_to_cache
96 ## That means the PPD will be included in ## generated cache. Function uses
97 ## global variables $i and $j. Function expects that we are already in
98 ## directory $i
100 #-----
101 add_to_cache() {
102 typeset SRCFILE
103 typeset PPDFILE
105 # Add the file to the cache
106 case "$j" in
107 *.gz)
108 SRCFILE=${BUILD_DIR}/ppd.$$
109 gzcat $BASE/$i/$j >${SRCFILE}
110 PPDFILE="${IPATH}/$i/$j"
113 SRCFILE=$BASE/$i/$j
114 PPDFILE="${IPATH}/$i/$j.gz"
116 esac
118 typeset MANU=$i
119 typeset MODEL
120 MODEL=`grep "*ModelName:" $SRCFILE | cut -d '"' -f2`
121 typeset NICKN
122 NICKN=`grep "*NickName:" $SRCFILE | cut -d '"' -f2`
124 typeset k
125 for k in ${MODEL}
127 # change / to \/ for sed
128 typeset i_clean=$(echo $k | sed -e 's/\//\\\//g')
129 NICKN=$( echo $NICKN |
130 sed -e "s/$i_clean//" | sed -e "s/^ //" )
131 done
133 echo ${MANU}:${MODEL}:${NICKN}:::${PPDFILE} >> ${CACHE}
137 #-----
139 ## supported
141 ## process PPD supported file.
143 #-----
144 supported() {
145 echo "$i/$j" >> ${BUILD_DIR}/ppdsupported
146 add_to_cache
149 #-----
151 ## unsupported
153 ## Handle PPD files NOT supported and thus included in the cache
155 #-----
156 unsupported() {
157 echo "$i/$j - $1" >> ${BUILD_DIR}/ppdunsupported
160 #-----
162 ## nomatch
164 ## Handle PPD files for which we don't know how to decide whether it's
165 ## supported or not
167 #-----
168 nomatch() {
169 echo "$i/$j" >> ${BUILD_DIR}/ppdsnomatch
170 echo "file '$i/$j' did not match any rule"
171 FAIL_LATER=1
174 # Go to directory with PPD files
175 cd "$BASE"
177 # Walk through all the PPD files available
178 for i in *
180 cd "$i"
181 for j in *
183 # First detect all files listed in the "nolicense" file
184 if ls $j | /usr/xpg4/bin/grep -f "$NOLICENSE" >/dev/null ; then
185 echo "Removing file '$j' because it is listed in 'nolicense' file"
186 /bin/rm $j
187 continue
190 # The following cases pull out supported drivers
191 if ls $j | grep Postscript > /dev/null; then
192 supported
193 continue
196 if grep "driverType G/GhostScript built-in: " $j >> /dev/null; then
197 supported
198 continue
201 if grep "driverType U/GhostScript Uniprint: " $j >> /dev/null; then
202 supported
203 continue
206 # HPLIP (hpijs) supplies it's own Foomatic PPD files
207 if ls $j | grep hpijs > /dev/null; then
208 unsupported 'hpijs'
209 continue
212 if ls $j | grep pxlmono > /dev/null; then
213 supported 'pxlmono'
214 continue
217 # These are the unsupported printers unless
218 # we build and deliver the drivers
219 if grep "driverType F/Filter: """ $j >> /dev/null; then
220 unsupported 'driverType F/Filter'
221 continue
224 # No match : this should not happen
225 nomatch
226 done
227 cd ..
228 done
230 if [ -n "$FAIL_LATER" ]; then
231 exit 1
232 else
233 exit 0