#!/bin/sh ### a piece of ancient wisdom of SuSE # Make some general tests and adjustments for all PPDs (see manufacturer-PPDs.spec): ppdfile=$1 p=${ppdfile%.gz} [ "$p" = "$ppdfile" ] || gunzip $ppdfile # Correct or remove non-working PPDs: # Several HP PPDs contain "600x600x2dpi" which is not allowed # according to the Adobe PPD specification section 5.9 # and which can be simply replaced by "600x1200dpi" # because "600x1200dpi" is not used elsewhere in the PPD. # Some PPDs contain a "*cupsFilter: ... hppostprocessing" line # which cannot work because there is no "hppostprocessing" filter. # Some PPDs contain "1284DeviceId" which must be "1284DeviceID". perl -pi -e 's/600x600x2dpi/600x1200dpi/;' $p grep -q '^\*cupsFilter:.*hppostprocessing' $p && rm -v $p && echo "removed $p: has hppostprocessing entry" perl -pi -e 's/1284DeviceId/1284DeviceID/;' $p if [ "$p" = HP_LaserJet_5Si.ppd ]; then # HP_LaserJet_5Si.ppd works only when this printer has the optional PostScript module: sed -i -e '/^\*NickName:/s/ (recommended)//' HP_LaserJet_5Si.ppd sed -i -e '/^\*ModelName:/s/5Si/5Si MX/' HP_LaserJet_5Si.ppd fi if [ "$p" = HP_LaserJet_5MP.ppd ]; then # HP_LaserJet_5MP.ppd works only for the model with the built-in PostScript module ("MP"): sed -i -e '/^\*ModelName:/s/5P/5MP/' HP_LaserJet_5MP.ppd fi # Change default media size to A4 if this is an available choice in the PPD and then # set DefaultPageSize, DefaultPageRegion, DefaultImageableArea, DefaultPaperDimension to A4: for i in PageSize PageRegion ImageableArea PaperDimension do if grep -q "^\*$i[[:space:]]*A4[:/]" $p then grep -q "^\*Default$i:[[:space:]]*A4\$" $p || perl -pi -e "s/^\*Default$i:.*/\*Default$i: A4/" $p fi done # Final test by cupstestppd: # Only keep files which don't FAIL for cupstestppd. cupstestppd $p || { echo TODO: rm -v $p ; echo TODO: exit ; } # uncomment if in destination dir # To save disk space gzip the files (gzipped PPDs can also be used by CUPS): [ -e "$p" ] && ! [ "$p" = "$ppdfile" ] && gzip $p # End of the general tests and adjustments for all PPDs. # exit status true