Subject: pkg/17488: papersize support ghostscript
To: None <gnats-bugs@gnats.netbsd.org>
From: None <reed@reedmedia.net>
List: netbsd-bugs
Date: 07/05/2002 15:35:11
>Number:         17488
>Category:       pkg
>Synopsis:       papersize should support ghostscript
>Confidential:   yes
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 05 15:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.5.3_RC2
>Organization:
http://bsd.reedmedia.net/
>Environment:
	
	
System: NetBSD rainier.reedmedia.net 1.5.3_RC2 NetBSD 1.5.3_RC2 (JCR-1.5-20020520) #0: Mon May 20 17:26:50 PDT 2002 reed@rainier.reedmedia.net:/usr/src/sys/arch/i386/compile/JCR-1.5-20020520 i386
Architecture: i386
Machine: i386
>Description:
I made a patch for papersize package to support ghostscript.

 $ getpapersize
 a2ps has default papersize: A4
 ghostscript has default papersize: (unknown)
 $ setpapersize letter ghostscript
 Set ghostscript package default paper size to Letter in
 /usr/pkg/share/ghostscript/6.01vflib/lib/gs_init.ps
 $ getpapersize
 a2ps has default papersize: A4
 ghostscript has default papersize: letter

By the way, setpapersize(1) should:
- check for success before overwriting current configs;
- probably should use some mktemp for temp files;
- only output that it was Set if really set.
And getpapersize(1) should say unknown if unknown.

>How-To-Repeat:
See http://mail-index.netbsd.org/tech-pkg/2002/05/08/0015.html 
for my other comments.

>Fix:


diff -u orig/getpapersize /usr/pkgsrc/print/papersize/files/getpapersize
--- orig/getpapersize	Wed May  8 18:59:08 2002
+++ /usr/pkgsrc/print/papersize/files/getpapersize	Wed May  8 21:05:12 2002
@@ -6,7 +6,7 @@
 #

 if [ $# -eq 0 ]; then
-	pkgs="a2ps ddd enscript magicfilter psutils";
+	pkgs="a2ps ddd enscript ghostscript magicfilter psutils";
 else
 	pkgs=$@
 fi
@@ -33,6 +33,18 @@
 		if [ -e $f ]; then
 			echo -n "$1 has default papersize: "
 			awk '/^DefaultMedia:.*/ { gsub(".*:", "", $0); print $0; }' $f
+		fi
+		;;
+	ghostscript)
+		f=`ls @localbase@/share/ghostscript/*/lib/gs_init.ps 2>/dev/null | tail -1`
+		if [ -e $f ]; then
+			echo -n "$1 has default papersize: "
+			gssize=`sed -n -e '/^% Optionally choose a default paper size other than U.S. letter.$/N' -e 's/^% Optionally.*\n[[:space:]]*(\(.*\)) \/PAPERSIZE where.*$/\1/p' $f`
+			if [ -z "$gssize" ] ; then
+				echo "(unknown)"
+			else
+				echo $gssize
+			fi
 		fi
 		;;
 	magicfilter)
diff -u orig/getpapersize.1 /usr/pkgsrc/print/papersize/files/getpapersize.1
--- orig/getpapersize.1	Wed May  8 18:59:08 2002
+++ /usr/pkgsrc/print/papersize/files/getpapersize.1	Wed May  8 19:08:45 2002
@@ -12,8 +12,8 @@
 The
 .Nm
 utility shows the default paper size for a number of packages.
-At the present time, these are the a2ps, ddd, enscript, magicfilter
-and psutils packages.
+At the present time, these are the a2ps, ddd, enscript, ghostscript,
+magicfilter, and psutils packages.
 If no package argument is given, all packages are assumed.
 The
 .Xr setpapersize 1
diff -u orig/setpapersize /usr/pkgsrc/print/papersize/files/setpapersize
--- orig/setpapersize	Wed May  8 18:59:08 2002
+++ /usr/pkgsrc/print/papersize/files/setpapersize	Wed May  8 21:05:12 2002
@@ -37,7 +37,7 @@
 lowpaper=`echo $papersize | tr '[A-Z]' '[a-z]'`

 if [ $# -eq 0 ]; then
-	pkgs="a2ps ddd enscript magicfilter psutils";
+	pkgs="a2ps ddd enscript ghostscript magicfilter psutils";
 else
 	pkgs=$@
 fi
@@ -67,6 +67,14 @@
 			mv $enscriptfile $enscriptfile.old
 			sed -e 's|^DefaultMedia:.*|DefaultMedia: '$papersize'|' $enscriptfile.old > $enscriptfile && rm $enscriptfile.old
 			echo "Set $1 package default paper size to $papersize in $enscriptfile"
+		fi
+		;;
+	ghostscript)
+		ghostscriptfile=`ls @localbase@/share/ghostscript/*/lib/gs_init.ps 2>/dev/null | tail -1`
+		if [ -e $ghostscriptfile ]; then
+			mv $ghostscriptfile $ghostscriptfile.old
+			sed -e '/^% Optionally choose a default paper size other than U.S. letter.$/N' -e 's/^\(% Optionally.*\n\)[%[:space:]]*(.*\() \/PAPERSIZE where.*\)$/\1('$lowpaper'\2/' $ghostscriptfile.old > $ghostscriptfile && rm $ghostscriptfile.old
+			echo "Set $1 package default paper size to $papersize in $ghostscriptfile"
 		fi
 		;;
 	magicfilter)
diff -u orig/setpapersize.1 /usr/pkgsrc/print/papersize/files/setpapersize.1
--- orig/setpapersize.1	Wed May  8 18:59:08 2002
+++ /usr/pkgsrc/print/papersize/files/setpapersize.1	Wed May  8 19:08:45 2002
@@ -13,8 +13,8 @@
 The
 .Nm
 utility sets the default paper size for a number of packages.
-At the present time, these are the a2ps, ddd, enscript, magicfilter
-and psutils packages.
+At the present time, these are the a2ps, ddd, enscript, ghostscript,
+magicfilter and psutils packages.
 If no package argument is given, all packages are assumed.
 The
 .Ar PAPERSIZE

>Release-Note:
>Audit-Trail:
>Unformatted: