components/hplip/cache.ksh
changeset 165 111c46cade93
equal deleted inserted replaced
164:d8515e072926 165:111c46cade93
       
     1 #!/usr/bin/ksh
       
     2 #
       
     3 # CDDL HEADER START
       
     4 #
       
     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.
       
     8 #
       
     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.
       
    13 #
       
    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]
       
    19 #
       
    20 # CDDL HEADER END
       
    21 #
       
    22 # Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
       
    23 #
       
    24 
       
    25 PPDSRC=${PPDSRC:-"${VER}/share/ppd"}
       
    26 
       
    27 MODEL="ModelName"
       
    28 NICK="NickName"
       
    29 SED="/usr/bin/sed"
       
    30 
       
    31 if [ -f ${CACHE} ];
       
    32 then
       
    33 	/bin/rm ${CACHE}
       
    34 fi
       
    35 
       
    36 #
       
    37 # build a ppdcache for the hpijs PPD files
       
    38 #
       
    39 cd ${PPDSRC}
       
    40 for i in `/bin/ls`
       
    41 do
       
    42   cd $i
       
    43   for j in `/bin/ls`
       
    44   do
       
    45 	case "$j" in
       
    46 	*.gz)
       
    47 		SRCFILE=/tmp/ppd.$$
       
    48 		gzcat $j >${SRCFILE}
       
    49 		PPDFILE="${IPATH}${i}/${j}"
       
    50 		;;
       
    51 	*)
       
    52 		SRCFILE=$j
       
    53 		PPDFILE="${IPATH}${i}/${j}.gz"
       
    54 		;;
       
    55 	esac
       
    56 	
       
    57 	/usr/bin/grep $SRCFILE ${DONOTINSTALL} > /dev/null
       
    58 	if [ $? = 1 ];
       
    59 	then
       
    60 	  MANU=$i
       
    61 	  MODEL=`/usr/bin/grep "*ModelName:" $SRCFILE | /usr/bin/cut -d '"' -f2`
       
    62 	  NICKN=`/usr/bin/grep "*NickName:" $SRCFILE | /usr/bin/cut -d '"' -f2`
       
    63 	  for k in ${MODEL}
       
    64 	  do
       
    65 	    # change / to \/ for sed
       
    66 	    typeset i_clean=$(echo $k | ${SED} -e 's/\//\\\//g')
       
    67 	    NICKN=$(echo $NICKN | ${SED} -e "s/$i_clean//"  | ${SED} -e "s/^ //")
       
    68 	  done
       
    69 
       
    70 	  echo ${MANU}:${MODEL}:${NICKN}:::${PPDFILE} >> ${CACHE}
       
    71 	fi
       
    72   done
       
    73   cd ..
       
    74 
       
    75 done