Subject: misc/626: Optionally install man pages as compressed files
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: Bob Kemp <rsk@allegory.demon.co.uk>
List: netbsd-bugs
Date: 12/10/1994 09:05:10
>Number:         626
>Category:       misc
>Synopsis:       Optionally install man pages as compressed files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 10 09:05:05 1994
>Originator:     Bob Kemp
>Organization:

Bob Kemp		rsk@allegory.demon.co.uk
>Release:        1.0
>Environment:

System: NetBSD allegory 1.0 NetBSD 1.0 (ALLEGORY) #0: Thu Dec 8 22:38:18 GMT 1994 root@allegory:/usr/src/sys/arch/i386/compile/ALLEGORY i386

>Description:

	It's obviously very convenient to have the manual pages online
	but they take up a lot of disk space.  For a long time I've been
	gzipping all the man pages whenever I install a new version, so
	here are some changes to allow man pages to be compressed as they
	are installed -- this also catches pages with multiple links to
	them.

	My fix is in two parts:
	o	Add two new options to install -z and -Z.
		Only the former is used here but the latter might be
		useful for shared man dirs where another host has compress
		but not gzip.  (Perhaps that's unlikely, dunno)

	o	Changes to bsd.man.mk to use the new -z option to install.

	It could all have been done in bsd.man.mk but that would have required
	far more ugly changes there, IMHO.

	Since the modified install first overwrites (say) x.0 and then
	compresses it to x.0.gz, conversion to compressed pages is easy.
	To go back, type gunzip -r /usr/share/man

	Comments?

	I've tested it by installing "install" and "libc" into a free area.

>How-To-Repeat:
>Fix:

diff -r xinstall.ORIG/install.1 xinstall/install.1
43c43
< .Op Fl cs
---
> .Op Fl cszZ
49c49
< .Op Fl cs
---
> .Op Fl cszZ
93a94,100
> .It Fl z
> Compress the target file using the GNU gzip program.
> If both -z and -Z are given, the last occurrence prevails.
> .It Fl Z
> Compress the target file using the compress program.
> If both -z and -Z are given, the last occurrence prevails.
> 
diff -r xinstall.ORIG/xinstall.c xinstall/xinstall.c
58a59
> static enum{C_GZIP, C_COMPRESS, C_NONE} docompress = C_NONE;
72c73
< 	while ((ch = getopt(argc, argv, "cg:m:o:sd")) != EOF)
---
> 	while ((ch = getopt(argc, argv, "cg:m:o:sdzZ")) != EOF)
96a98,103
> 		case 'z':
> 			docompress = C_GZIP;
> 			break;
> 		case 'Z':
> 			docompress = C_COMPRESS;
> 			break;
104,105c111,112
< 	/* copy and strip options make no sense when creating directories */
< 	if ((docopy || dostrip) && dodir)
---
> 	/* copy/compress/strip options make no sense when creating directories*/
> 	if ((docopy || dostrip || docompress != C_NONE) && dodir)
209a217,229
> 
> 	if (docompress != C_NONE) {
> 		char cmdbuf[MAXPATHLEN+14];
> 		sprintf(cmdbuf, "%s %s",
> 			(docompress==C_GZIP ? "gzip --force" : "compress -f"),
> 			to_name);
> 
> 		if (system(cmdbuf)) {
> 			(void)unlink(to_name);
> 			error(to_name);
> 			exit(1);
> 		}
> 	}




*** mk/bsd.man.mk.ORIG	Wed Oct 19 20:18:00 1994
--- mk/bsd.man.mk	Sat Dec 10 00:53:58 1994
***************
*** 16,22 ****
--- 16,28 ----
  	@nroff -mandoc ${.IMPSRC} > ${.TARGET} || ( rm -f ${.TARGET} ; false )
  
  
+ .if defined(COMPRESSMAN)
+ MINSTALL=	install -z ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
+ ZSUFFIX=	.gz
+ .else
  MINSTALL=	install ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
+ ZSUFFIX=
+ .endif
  
  maninstall:
  .if defined(MAN1) && !empty(MAN1)
***************
*** 86,94 ****
  		shift; \
  		dir=${DESTDIR}${MANDIR}`expr $$name : '.*\.\(.*\)'`; \
  		t=$${dir}${MANSUBDIR}/`expr $$name : '\(.*\)\..*'`.0; \
! 		echo $$t -\> $$l; \
  		rm -f $$t; \
! 		ln $$l $$t; \
  	done; true
  .endif
  
--- 92,100 ----
  		shift; \
  		dir=${DESTDIR}${MANDIR}`expr $$name : '.*\.\(.*\)'`; \
  		t=$${dir}${MANSUBDIR}/`expr $$name : '\(.*\)\..*'`.0; \
! 		echo $${t}${ZSUFFIX} -\> $${l}${ZSUFFIX}; \
  		rm -f $$t; \
! 		ln $${l}${ZSUFFIX} $${t}${ZSUFFIX}; \
  	done; true
  .endif
  
>Audit-Trail:
>Unformatted: