Skip site navigation (1)Skip section navigation (2)
Date:      22 May 2001 01:04:13 +0200
From:      Cyrille Lefevre <clefevre@poboxes.com>
To:        ports@FreeBSD.org
Subject:   Re: PR Review
Message-ID:  <y9rqqp76.fsf@gits.dyndns.org>
In-Reply-To: <4rues3ua.fsf@gits.dyndns.org>
References:  <200105210118.f4L1IZD10845@gits.dyndns.org> <0ae001c0e194$56f54d60$931576d8@inethouston.net> <4rues3ua.fsf@gits.dyndns.org>

next in thread | previous in thread | raw e-mail | index | archive | help
was Cc: "David W. Chapman Jr." <dwcjr@inethouston.net>,
	  "Will Andrews" <will@FreeBSD.org>

Cyrille Lefevre <clefevre@poboxes.com> writes:

> "David W. Chapman Jr." <dwcjr@inethouston.net> writes:
> 
> > Cool, I wasn't as proficient in awk sed and perl so I had to initially do
> > the conversion in foxpro on windows.  I think maybe we should try to get
> > that script on the porters handbook for the man pages, what do you think?
> 
> how about this one I've just written :P
> all is made in one pass w/ temporary files...
> 
> so, the Makefile.man I've sent to your PR can be obtained using the
> following commmand (except MANCOMPRESSED) :
> 
> mkmakeman -q -o Makefile.man -p /usr/X11R6 /usr/ports/x11/XFree86-4/pkg-plist
> 
> another sample using this command maybe, for fresh ports :
> 
> mkmakeman -q -a Makefile /tmp/local
> 
> which appends MAN? variables to the current Makefile.
> 
> you're free to write a manual page it you want. since english isn't my
> native language, well, humm! I didn't know how to say what I want to
> say in english ;^)
> 
> PS : if the license is a problem, let me know, I'll change it.
> 
> #!/bin/sh -e
> #
> # @(#) mkmakeman 1.0 (clefevre@poboxes.com) Tue May 22 00:49:18 CEST 2001
> #
> # Copyright (c) 2001 Cyrille Lefevre. All rights reserved.
> #
> # Redistribution and use in source and binary forms, with or without
> # modification, are permitted provided that the following conditions
> # are met:
> #
> # 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. The name of the authors and contributors may not be used to
> #    endorse or promote products derived from this software without
> #    specific prior written permission.
> # 
> # THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``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 THE AUTHORS
> # OR CONTRIBUTORS 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
> # SUCH DAMAGE.
> 
> append=
> quiet=
> mandir=man/man
> prefix=
> ofile=/dev/null
> sections="1 2 3 4 5 6 7 8 9 l n"
> ifile=
> 
> cat=cat make=make grep=grep find=find sort=sort
> xargs=xargs ls=ls sed=sed awk=awk tee=tee
> 
> usage () {
> 	# bip! game over, same player, play again ;^)
> 	$cat << EOF >&2
> usage: $0 [-q] [-m mandir] [-a|-o file] [-s sections] dir
>        $0 [-q] [-m mandir] [-p prefix] [-a|-o file] [-s sections] file
> EOF
> 	exit 64
> }
> 
> abspath () {
> 	# make the path absolute
> 	case $1 in
> 	/*)
> 		echo $1 ;;
> 	*)
> 		echo $(pwd)/$1 ;;
> 	esac
> }
> 
> while getopts a:m:o:p:qs: c; do
> 	case $c in
> 	a)
>                 append=-a
> 		ofile=$(abspath $OPTARG) ;;
> 	m)
> 		mandir=$OPTARG ;;
> 	o)
> 		ofile=$(abspath $OPTARG) ;;
> 	p)
> 		prefix=$OPTARG ;;
> 	q)
> 		quiet="> /dev/null" ;;
> 	s)
> 		sections=$OPTARG ;;
> 	*)
> 		usage ;;
> 	esac
> done
> shift $(($OPTIND - 1))
> 
> # no args, good bye
> if [ $# -eq 0 ]; then
> 	usage
> # a directory ?
> elif [ -d "$1" ]; then
> 	prefix=$1
> # a plain file then
> else
> 	if [ -z "$prefix" ]; then
> 		# no prefix, try the find one
> 		if [ -f Makefile ]; then
> 			prefix=$($make -V PREFIX)
> 		else
> 			usage
> 		fi
> 	fi
> 	ifile=$(abspath $1)
> fi
> 
> cd "$prefix" || exit
> 
> for sec in $sections; do
> 	if [ -n "$ifile" ]; then
> 		$grep "$mandir$sec" "$ifile"
> 	else
> 		# find all manual pages
> 		$find "$mandir$sec" ! -type d
> 	fi |
> 	# sort them
> 	$sort +8 |
> 	# expand symlinks
> 	$xargs $ls -ld |
> 	# mandir and suffix aren't needed
> 	$sed "s,$mandir$sec/,$sec ,;s/\.gz//g"
> 	#                    ^^^^^ we use that later
> done |
> $awk -v sections="$sections" '
> BEGIN {
> 	# this ugly thing works !
> 	nsections = split (sections, sections, " ")
> }
> # found a symlink
> /->/ {
> 	links [nlinks++] = $NF " " $(NF - 2)
> 	next
> }
> # so, its a plain file
> {
> 	# get the section number
> 	sec = $(NF - 1)
> 	# fill in an array by sections
> 	mans [sec,nmans [sec]++] = $NF
> }
> END {
> 	# for each sorted sections
> 	for (k = 1; k <= nsections; k++) {
> 		# get its name
> 		sec = sections [k]
> 		# is there any manual ?
> 		if (! nmans [sec])
> 			continue
> 		# ok, go on...
> 		printf "MAN%s=", toupper(sec)
> 		# let us go a lot faster
> 		j = nmans [sec] - 1
> 		# for each manual
> 		for (i = 0; i < nmans [sec]; i++)
> 			# dont put a \ on the last line
> 			printf "\t%s%s\n", mans [sec,i], i == j ? "" : " \\"
> 	}
> 	if (nlinks) {
> 		printf "MLINKS="
> 		j = nlinks - 1
> 		for (i = 0; i < nlinks; i++)
> 			printf "\t%s%s\n", links [i], i == j ? "" : " \\"
> 	}
> }
> ' |
> eval $tee $append "$ofile" $quiet

Cyrille.
--
Cyrille Lefevre - 12, Rue de Bizerte 75017 Paris  tel/fax: +33 (0)1 45 22 83 85
home: mailto:clefevre@poboxes.com   UNIX is user-friendly; it's just particular
work: mailto:Cyrille.Lefevre@edf.fr   about who it chooses to be friends with. 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?y9rqqp76.fsf>