diff options
author | abs <abs> | 2002-04-16 11:52:24 +0000 |
---|---|---|
committer | abs <abs> | 2002-04-16 11:52:24 +0000 |
commit | 074ef0c08731c659f5544b1945fb532a36044fd2 (patch) | |
tree | ebcab02f86f4202210a040030bbcf0ef96ac0a02 | |
parent | 106724377f0e978606aaeb22b205fe600582b9b5 (diff) | |
download | pkgsrc-074ef0c08731c659f5544b1945fb532a36044fd2.tar.gz |
Update if-psprint to 1.5
Switch to external distfile, slightly better getopt() handling
-rw-r--r-- | print/if-psprint/Makefile | 27 | ||||
-rwxr-xr-x | print/if-psprint/files/if-psprint.pl | 224 |
2 files changed, 10 insertions, 241 deletions
diff --git a/print/if-psprint/Makefile b/print/if-psprint/Makefile index 45ab2c4ba2a..6d024021553 100644 --- a/print/if-psprint/Makefile +++ b/print/if-psprint/Makefile @@ -1,29 +1,22 @@ -# $NetBSD: Makefile,v 1.9 2002/03/13 17:37:36 fredb Exp $ +# $NetBSD: Makefile,v 1.10 2002/04/16 11:52:24 abs Exp $ # -DISTNAME= if-psprint-1.4 -PKGREVISION= 1 -CATEGORIES= print -MASTER_SITES= # empty -DISTFILES= # empty +DISTNAME= if-psprint-1.5 +CATEGORIES= print +MASTER_SITES= http://www.mono.org/abs/tools/if-psprint/ -MAINTAINER= abs@netbsd.org -COMMENT= Print text or postscript to arbitrary printer, can use smb +MAINTAINER= abs@netbsd.org +HOMEPAGE= http://www.mono.org/abs/tools/if-psprint/ +COMMENT= Print text or postscript to arbitrary printer, can use smb DEPENDS+= ghostscript{,-nox11}-[6-9]*:../../print/ghostscript DEPENDS+= enscript-[0-9]*:../../print/enscript -USE_PERL5= YES - -EXTRACT_ONLY= # empty -WRKSRC= ${WRKDIR} -NO_CHECKSUM= yes -NO_PATCH= yes -NO_CONFIGURE= yes +USE_PERL5= YES do-build: - ${SED} -e 's|@PREFIX@|${PREFIX}|g' \ - < ${FILESDIR}/if-psprint.pl \ + ${SED} -e 's|/usr/local|${PREFIX}|g' \ + < ${WRKSRC}/if-psprint.pl \ > ${WRKSRC}/if-psprint pod2man ${WRKSRC}/if-psprint > ${WRKSRC}/if-psprint.1 diff --git a/print/if-psprint/files/if-psprint.pl b/print/if-psprint/files/if-psprint.pl deleted file mode 100755 index 03e8b09fd3c..00000000000 --- a/print/if-psprint/files/if-psprint.pl +++ /dev/null @@ -1,224 +0,0 @@ -#!@PREFIX@/bin/perl -w -# -# $NetBSD: if-psprint.pl,v 1.5 2001/06/26 10:41:25 abs Exp $ -# -# Copyright (c) 2000 David Brownlee <abs@netbsd.org>. All rights -# reserved. Provided as-is without express or implied warranties. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided the above copyright and this -# notice is retained. -# - -=head1 NAME - -if-psprint - send text, postscript, or native printer language to -arbitrary printer. - -=head1 SYNOPSIS - -Designed as a quick fix for the random printers that get hooked up to -the NetBSD server and random Windows boxes around the office. Uses enscript -to convert text to postscript, and ghostcript to convert to native printer -language as required. - -=head1 DESCRIPTION - -=over 4 - -=item * - -Overloads 'af' entry to contain printer type, and optional location. -in the form 'type[.model][/smb/smb_dest]'. Use type 'ps' for no gs filter. - -=item * - -Reads first 1k and calls 'file' to determine filetype. - -=item * - -Builds a spool command based on filetype: - -=over 4 - -=item * - -If text and not postscript, use enscript text->postscript - -=item * - -If enscripted or postscript, use gs postscript->printer_format - -=item * - -Otherwise assumed to be native printer language (its your rope) - -=back - -=item * - -Open pipe to spool command, send first 1k, then rest of data - -=item * - -requires ghostscript, enscript, and samba if printing to smb hosts - -=back - -=head1 EXAMPLE PRINTCAP ENTRIES - -(Remember to create spool dir [sd]) - -=over 4 - -=item * - -HP deskjet named 'leaves' connected to smb host 'tea'. -(using ghostscript 'hpdj' driver model 'unspec') - - leaves:\ - :if=@PREFIX@/libexec/if-psprint:lf=/var/log/lpd-errs:\ - :sh:mx=0:lp=/dev/null:sd=/var/spool/lpd/leaves:\ - :af=hpdj.unspec/smb/tea/leaves: - -=item * - -Canon bubblejet connected to /dev/lpa0 (using gs 'bjc800' driver) - - bubbly:\ - :if=@PREFIX@/libexec/if-psprint:lf=/var/log/lpd-errs:\ - :sh:mx=0:lp=/dev/lpa0:sd=/var/spool/lpd/bubbly:\ - :af=bjc800: - -=back - -=cut - -$ENV{'PATH'}="@PREFIX@/bin:/usr/bin:/bin"; - -use strict; -use Getopt::Std; -use IPC::Open3; - -my( $user, - $dest, - $spoolhost, - $device, - $model, - %opt, - ); - -# Parse options (ignore most) -# - -&getopts('vw:l:i:n:h:', \%opt); -$user = $opt{'n'}; -$user ||= $ENV{'USER'}; -$spoolhost = $opt{'h'}; -if (!$spoolhost) - { chomp($spoolhost = `hostname`); } - -if (@ARGV != 1 || $ARGV[0] !~ m#(\w+)(\.(\w+)|)(/smb/.*/.*|)#) - { usage_and_exit(); } -$device = $1; -$model = $3; -$dest = $4; -if ($dest) - { $dest =~ s#/smb/#smb:/#; } - -# Determine filetype -# - -my($data, $filetype); -if (!read(STDIN, $data, 1024)) # initial filetype check data - { &fail("No data to print"); } -$filetype = &filetype($data); - -# Generate spool command -# - -my($spool); -$spool = ''; -if ($filetype =~ /^PostScript/ || $filetype =~ /text/) - { - if ($filetype !~ /^PostScript/) - { $spool .= '|'.filter_enscript(); } - if ($model || $device ne 'ps') - { $spool .= '|'.filter_gs($device, $model); } - } - -if ($dest) - { $spool .= "|smbspool smb://$dest 1 $user $spoolhost 1 -"; } - -if ($spool eq '') - { $spool = '>&STDOUT'; } - -if ($opt{'v'}) - { print STDERR "$spool\n"; } -# Spool output -# -if (!open(OUTPUT, $spool)) - { &fail("Unable to run '$spool': $!"); } -print OUTPUT $data; # print initial filetype check data -while (read(STDIN, $data, 16*1024)) - { print OUTPUT $data; } -close(STDIN); -close(OUTPUT); -exit; - -sub fail - { - print STDERR "if-psprint: @_\n"; - exit 1; - } - -sub filetype - { - my($data) = @_; - my($pid, $filetype); - - unless ($pid = open3('WTRFH', 'RDRFH', 'ERRFH', 'file -b -')) - { &fail("Unable to run 'file': $!"); } - print WTRFH $data; - close(WTRFH); - close(ERRFH); - 0 && close(ERRFH); # Pacify perl's -w - chop($filetype = <RDRFH>); - close(RDRFH); - wait; - $filetype; - } - -sub filter_enscript - { - my($filter); - - $filter = "enscript -q -B -p -"; - } - -sub filter_gs - { - my($device, $model) = @_; - my($filter); - $filter = "gs -q -dBATCH -sDEVICE=$device"; - if (defined $model) - { $filter .= " -sModel=$model"; } - $filter .= " -SOutputFile=- -"; - } - -sub usage_and_exit - { - print "Usage: if-psprint [opts] gs_device[.gs_model]/smbdestination -[opts] - -v Verbose - -w width - -l lines - -i indent - -n user - -h host - -if-psprint is intended to be used from within printcap. See manpage for more -details. -"; - exit 1; - } |