335N/A#!/bin/bash
335N/A#
335N/A# CDDL HEADER START
335N/A#
335N/A# The contents of this file are subject to the terms of the
335N/A# Common Development and Distribution License (the "License").
335N/A# You may not use this file except in compliance with the License.
335N/A#
335N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
335N/A# or http://www.opensolaris.org/os/licensing.
335N/A# See the License for the specific language governing permissions
335N/A# and limitations under the License.
335N/A#
335N/A# When distributing Covered Code, include this CDDL HEADER in each
335N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
335N/A# If applicable, add the following below this CDDL HEADER, with the
335N/A# fields enclosed by brackets "[]" replaced with your own identifying
335N/A# information: Portions Copyright [yyyy] [name of copyright owner]
335N/A#
335N/A# CDDL HEADER END
335N/A#
335N/A#
335N/A# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
335N/A#
335N/A
335N/A# Find the PPD files delivered by foomatic that Solaris does not support.
335N/A# There are two reasons for non-support:
335N/A#
335N/A# 1. license/patent issues with the driver (listed in file nolicense). These
335N/A# files are removed and not delivered
335N/A# 2. The driver used by the PPD file must be brought downand compiled and
335N/A# Solaris has not chosen to do so. In that case the PPD file is delivered,
335N/A# but not included in the generated cache file.
335N/A#
335N/A# The unsupported PPD file should be listed in $BUILD_DIR/ppdunsupported for
335N/A# review. The catchall file, ppdsnomatch, should be empty. If not, a new
335N/A# case is needed in this script. The other files are there for debugging
335N/A# purposes.
335N/A
335N/A# Notes:
335N/A# drivers come in several flavors: gs built in, gs uniprint, postscript,
335N/A# hpijs, and then the several other drivers.
335N/A# Drivers are noted in many PPD files with driverType. To sort these, look
335N/A# for: driverType G/GhostScript built-in:
335N/A# driverType U/GhostScript Uniprint:
335N/A# driverType F/Filter: ""
335N/A# Drivers are also noted in the name of the ppd file. This is used
335N/A# to cull out postscript, hpijs, and pxlmono . These do not reliably
335N/A# use driverType. note: pxlmono driver is a gs built-in but many of the
335N/A# ppd files that use this driver do not utilize the driverType line.
335N/A# driverType I/IJS: "" is not reliable for hpijs as not used in many ppds.
335N/A
335N/A# driverType F/Filter: "" denotes ppd files that use GhostScript and
335N/A# then pipe that output to one or more other drivers. These will only be
335N/A# supported if Solaris compiles and delivers these drivers.
335N/A
335N/A# Make sure that there are no undefined variables
335N/Aset -ue
335N/A
335N/A# Sanitize PATH
335N/APATH=/usr/bin:/bin
335N/A
335N/Aif [ -z "${1-}" ] || [ -z "${2-}" ] ||
335N/A [ -z "${3-}" ] || [ -z "${4-}" ]; then
335N/A echo "Usage: $0 build-dir tree-of-ppds cache-file nolicense-file"
335N/A exit 1
335N/Afi
335N/A
335N/A# Build directory
335N/ABUILD_DIR="$1"
335N/A# Where PPD files are located
335N/ABASE="$2"
335N/A# Cache file to be created
335N/ACACHE="$3"
335N/A# File listing PPDs with no/invalid license
335N/ANOLICENSE="$4"
335N/A# Base install path for PPD files
335N/AIPATH=/usr/share/ppd/SUNWfoomatic
335N/A
335N/A# Script will fail if set
335N/AFAIL_LATER=""
335N/A
335N/Amkdir -p "$( dirname "$CACHE" )"
335N/A/bin/rm -f ${BUILD_DIR}/ppdunsupported \
335N/A ${BUILD_DIR}/ppdsupported \
335N/A ${BUILD_DIR}/ppdsnomatch \
335N/A "$CACHE"
335N/A
335N/A# files which should be included in the cache
335N/A
335N/A
335N/A#-----
335N/A##
335N/A## add_to_cache
335N/A##
335N/A## That means the PPD will be included in ## generated cache. Function uses
335N/A## global variables $i and $j. Function expects that we are already in
335N/A## directory $i
335N/A##
335N/A#-----
335N/Aadd_to_cache() {
335N/A typeset SRCFILE
335N/A typeset PPDFILE
335N/A
335N/A # Add the file to the cache
335N/A case "$j" in
335N/A *.gz)
335N/A SRCFILE=${BUILD_DIR}/ppd.$$
335N/A gzcat $BASE/$i/$j >${SRCFILE}
335N/A PPDFILE="${IPATH}/$i/$j"
335N/A ;;
335N/A *)
335N/A SRCFILE=$BASE/$i/$j
335N/A PPDFILE="${IPATH}/$i/$j.gz"
335N/A ;;
335N/A esac
335N/A
335N/A typeset MANU=$i
335N/A typeset MODEL
335N/A MODEL=`grep "*ModelName:" $SRCFILE | cut -d '"' -f2`
335N/A typeset NICKN
335N/A NICKN=`grep "*NickName:" $SRCFILE | cut -d '"' -f2`
335N/A
335N/A typeset k
335N/A for k in ${MODEL}
335N/A do
335N/A # change / to \/ for sed
335N/A typeset i_clean=$(echo $k | sed -e 's/\//\\\//g')
335N/A NICKN=$( echo $NICKN |
335N/A sed -e "s/$i_clean//" | sed -e "s/^ //" )
335N/A done
335N/A
335N/A echo ${MANU}:${MODEL}:${NICKN}:::${PPDFILE} >> ${CACHE}
335N/A}
335N/A
335N/A
335N/A#-----
335N/A##
335N/A## supported
335N/A##
335N/A## process PPD supported file.
335N/A##
335N/A#-----
335N/Asupported() {
335N/A echo "$i/$j" >> ${BUILD_DIR}/ppdsupported
335N/A add_to_cache
335N/A}
335N/A
335N/A#-----
335N/A##
335N/A## unsupported
335N/A##
335N/A## Handle PPD files NOT supported and thus included in the cache
335N/A##
335N/A#-----
335N/Aunsupported() {
335N/A echo "$i/$j - $1" >> ${BUILD_DIR}/ppdunsupported
335N/A}
335N/A
335N/A#-----
335N/A##
335N/A## nomatch
335N/A##
335N/A## Handle PPD files for which we don't know how to decide whether it's
335N/A## supported or not
335N/A##
335N/A#-----
335N/Anomatch() {
335N/A echo "$i/$j" >> ${BUILD_DIR}/ppdsnomatch
335N/A echo "file '$i/$j' did not match any rule"
335N/A FAIL_LATER=1
335N/A}
335N/A
335N/A# Go to directory with PPD files
335N/Acd "$BASE"
335N/A
335N/A# Walk through all the PPD files available
335N/Afor i in *
335N/Ado
335N/A cd "$i"
335N/A for j in *
335N/A do
335N/A # First detect all files listed in the "nolicense" file
335N/A if ls $j | /usr/xpg4/bin/grep -f "$NOLICENSE" >/dev/null ; then
335N/A echo "Removing file '$j' because it is listed in 'nolicense' file"
335N/A /bin/rm $j
335N/A continue
335N/A fi
335N/A
335N/A # The following cases pull out supported drivers
335N/A if ls $j | grep Postscript > /dev/null; then
335N/A supported
335N/A continue
335N/A fi
335N/A
335N/A if grep "driverType G/GhostScript built-in: " $j >> /dev/null; then
335N/A supported
335N/A continue
335N/A fi
335N/A
335N/A if grep "driverType U/GhostScript Uniprint: " $j >> /dev/null; then
335N/A supported
335N/A continue
335N/A fi
335N/A
335N/A # HPLIP (hpijs) supplies it's own Foomatic PPD files
335N/A if ls $j | grep hpijs > /dev/null; then
335N/A unsupported 'hpijs'
335N/A continue
335N/A fi
335N/A
335N/A if ls $j | grep pxlmono > /dev/null; then
335N/A supported 'pxlmono'
335N/A continue
335N/A fi
335N/A
335N/A # These are the unsupported printers unless
335N/A # we build and deliver the drivers
335N/A if grep "driverType F/Filter: """ $j >> /dev/null; then
335N/A unsupported 'driverType F/Filter'
335N/A continue
335N/A fi
335N/A
335N/A # No match : this should not happen
335N/A nomatch
335N/A done
335N/A cd ..
335N/Adone
335N/A
335N/Aif [ -n "$FAIL_LATER" ]; then
335N/A exit 1
335N/Aelse
335N/A exit 0
335N/Afi