# Copyright (c) 1994 Geoffrey M. Rehmet, Rhodes University
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by Geoffrey M. Rehmet
# 4. Neither the name of Geoffrey M. Rehmet nor that of Rhodes University
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL GEOFFREY M. REHMET OR RHODES UNIVERSITY BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# $Id: manctl,v 1.5 1994/04/18 15:39:29 g89r4222 Exp $
# a utility for manipulating manual pages
# compress uncompressed man pages (elliminating .so's)
# this is now two-pass. If possible, .so's
# are replaced with hard links
# uncompress compressed man pages
# purge old formatted man pages (not implemented yet)
# Things to watch out for:
# Hard links - careful with g(un)zipping!
# .so's - throw everything through soelim before gzip!
# symlinks - ignore these - eg: expn is its own man page:
# don't want to compress this!
PATH
=/bin
:/sbin
:/usr
/bin
:/usr
/sbin
echo "not implemented yet\n" 2>&1
# less than 3 fields - don't know what to do with this
IFS
=" " ; echo ignoring
$pname 1>&2 ; return 0 ;
# construct name and section
IFS
=" " ; set `file $pname`
if [ $2 != "gzip" ] ; then
echo moving hard link
$pname 1>&2
mv $pname $fname.
$ext # link
if [ $2 != "symbolic" ] ; then
echo gunzipping page
$pname 1>&2
gunzip
-c $pname > /tmp
/manager.$$
cp /tmp
/manager.$$
$pname
# skip symlinks - this can be
# a program like expn, which is
echo skipping symlink
$pname 1>&2
echo skipping
file $pname 1>&2
# reset IFS - this is important!
# Uncompress manpages in paths
*cat?
) ;; # ignore cat directories
echo "directory $1 not found" 1>&2
# Remove .so's from one file
so_entries
=`grep "^\.so" $1 | wc -l`
if [ $so_entries -eq 0 ] ; then ; return 0 ; fi
# we have a page with a .so in it
echo $1 contains a .so entry
2>&1
# now check how many lines in the file
# if the file is only one line long, we can replace it
if [ $lines -eq 1 ] ; then
echo replacing
$fname with a hard link
echo inlining page
$fname 1>&2
(cd ..
; soelim
) > /tmp
/manager.$$
cp /tmp
/manager.$$
$fname
# Remove .so entries from man pages
# If a page consists of just one line with a .so,
# replace it with a hard link
IFS
=" " ; echo ignoring
$pname 1>&2 ; return 0 ;
# construct name and section
gz
) { echo file $pname already gzipped
1>&2 ; } ;;
Z
) { echo file $pname already compressed
1>&2 ; } ;;
IFS
=" " ; set `file $pname`
if [ $2 = "gzip" ] ; then
echo moving hard link
$pname 1>&2
mv $pname $pname.gz
# link
if [ $2 != "symbolic" ] ; then
echo "removing .so's in page $pname" 1>&2
# skip symlink - this can be
# a program like expn, which is
echo skipping symlink
$pname 1>&2
echo skipping
file $pname 1>&2
# reset IFS - this is important!
# We need to watch out for hard links here.
IFS
=" " ; echo ignoring
$pname 1>&2 ; return 0 ;
# construct name and section
gz
) { echo file $pname already gzipped
1>&2 ; } ;;
Z
) { echo file $pname already compressed
1>&2 ; } ;;
IFS
=" " ; set `file $pname`
if [ $2 = "gzip" ] ; then
echo moving hard link
$pname 1>&2
mv $pname $pname.gz
# link
if [ $2 != "symbolic" ] ; then
echo gzipping page
$pname 1>&2
(cd ..
; soelim
)|
gzip -c -- > /tmp
/manager.$$
cp /tmp
/manager.$$
$pname
# skip symlink - this can be
# a program like expn, which is
echo skipping symlink
$pname 1>&2
echo skipping
file $pname 1>&2
# reset IFS - this is important!
# Compress man pages in paths
*cat?
) ;; # ignore cat directories
echo "directory $1 not found" 1>&2
# Display a usage message
echo "usage : $1 -compress <path> ... " 1>&2
echo " $1 -uncompress <path> ... " 1>&2
echo " $1 -purge <days> <path> ... " 1>&2
echo " $1 -purge expire <path> ... " 1>&2
# remove .so's and do compress
# First remove all so's from the pages to be compressed
do_compress_so remove_so
"$@"
# now do ahead and compress the pages
do_compress_so compress_page
"$@"
if [ $# = 0 ] ; then ; ctl_usage
$0 ; fi ;
-compress) shift ; do_compress
"$@" ;;
-uncompress) shift ; do_uncompress
"$@" ;;
-purge) shift ; do_purge
"$@" ;;