Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Oct 2001 13:20:20 -0700 (PDT)
From:      Cyrille Lefevre <clefevre@citeweb.net>
To:        freebsd-ports@FreeBSD.org
Subject:   Re: ports/31216: New port: devel/plist-builder
Message-ID:  <200110112020.f9BKKKV15210@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR ports/31216; it has been noted by GNATS.

From: Cyrille Lefevre <clefevre@citeweb.net>
To: Ernst de Haan <ernst@jollem.com>
Cc: FreeBSD-gnats-submit@freebsd.org, sobomax@freebsd.org
Subject: Re: ports/31216: New port: devel/plist-builder
Date: Thu, 11 Oct 2001 22:15:44 +0200 (CEST)

 Ernst de Haan wrote:
 [snip]
 > X# New ports collection makefile for:   devel/plist-builder
 > X# Date created:        11 October 2001
 > X# Whom:                Ernst de Haan <ernst@jollem.com>
 > X
 > XPORTNAME=	plist-builder
 > XPORTVERSION=	1.0
 > XCATEGORIES=	devel
 > XMASTER_SITES=	http://www.jollem.com/~ernst/
 > XDISTNAME=	${PORTNAME}${PORTVERSION}
 ...
 > XWRKSRC=		${WRKDIR}/${PORTNAME}
 
 so, you are the creator of this script set, no ?
 why don't name the dist file ${PORTNAME}-${PORTVERSION}
 which avoid the DISTNAME line. also, much better is to create
 the archive like this :
 
 -rwxr-xr-x ernst/ernst    2718 Feb 20 14:28 2001 plist-builder-1.0/build-plist
 -rwxr-xr-x root/wheel      255 Jan  4 01:33 2001 plist-builder-1.0/purge.pl
                                                               ^^^^
 
 which avoid the need to overwrite WRKSRC. also, the bsd.port.pre/post.mk
 pair isn't needed in your port, a simple bsd.port.mk at the end do
 it well. to finish, you may want to use INSTALL_SCRIPT rather than CP,
 also, it would be better to put purge.pl in ${PREFIX}/libexec/${PORTNAME}
 than in bin. how about to replace the purge.pl call by something
 like `fgrep -v' or something like that ? isn't that sufficient ?
 
 IMHO, here is a more complete version of your scripts set.
 I name it pkgbld and should be called in place of make.
 pkgbld may not always generate up to date lists, in this case, run
 `pkgbld cleanfiles'.  mkmakeman should be rock :P
 
 #!/bin/sh -e
 #
 # @(#) pkgbld 1.1 (clefevre@citeweb) Thu Oct 11 21:25:53 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.
 #
 # pkgbld install
 # 		install things to ${TMPDIR}/${PKGNAME}
 # 
 # 		the basic structure is :
 # 
 # 		/tmp/package-version/local/
 # 			the package install tree
 # 		/tmp/package-version/local.dirs 
 # 			the local dir list
 # 		/tmp/package-version/local.files
 # 			the local file list
 # 		/tmp/package-version/mtree/
 # 			the mtree reference tree
 # 		/tmp/package-version/mtree.dirs
 # 			the mtree dir list
 # 		/tmp/package-version/mtree.diffs
 # 			contains the mtree.dirs vs. local.dirs diffs
 # 		/tmp/package-version/dbpkg/
 # 			the package database tree
 # 		/tmp/package-version/mlist
 # 			made by pkgbld mlist
 # 		/tmp/package-version/plist
 # 			made by pkgbld plist
 # 
 # pkgbld fetch|extract|patch|configure|build|package|deinstall|clean|distclean
 # 		common make targets (`build' is the default target).
 # 
 # pkgbld refetch|reextract|repatch|reconfigure|rebuild|reinstall|repackage
 # 		same as above but cookie files are deleted before to
 # 		call the target w/o re and `FORCE_PKG_REGISTER' is defined.   
 # 
 # pkgbld mlist
 # 		generates the manual pages variables
 # 		using `mkmakeman', a script I've submit some times ago
 # 		in the -ports mailing list as far as I remember me ?
 # 
 # pkgbld plist
 # 		generates the package plist.
 # 		@comment $FreeBSD, %%PORTDOCS%% and info files are handled.
 # 
 # pkgbld pkgadd
 # 		depends on `make package' (need to be called before)
 # 		runs `pkg_add' on the previously generated package archive.
 # 
 # pkgbld pkgdel
 # 		no comment.
 # 
 # pkgbld listfile|listman|listpkg|listdir
 # 		non standard targets, for debugging purpose...
 #
 # pkgbld cleanfile|cleandir
 #		non standard targets, for cleaning things up...
 
 awk=awk cat=cat comm=comm echo=echo find=find grep=grep make=make
 mkdir=mkdir mtree=mtree pkg_add=pkg_add pkg_delete=pkg_delete rm=rm
 sort=sort tee=tee tr=tr mkmakeman=mkmakeman
 
 TARGET=${1:-build}
 [ $# -gt 0 ] && shift
 
 PKGNAME=$(${make} -V PKGNAME)
 PKGFILE=$(${make} -V PKGFILE)
 MTREE_ARGS=$(${make} -V MTREE_ARGS)
 COOKIES="EXTRACT PATCH CONFIGURE BUILD INSTALL PACKAGE"
 for cookie in ${COOKIES}; do
 	eval ${cookie}_COOKIE=$(${make} -V ${cookie}_COOKIE)
 done
 cookies=$(${echo} ${COOKIES} | ${tr} A-Z a-z)
 
 TMPDIR=/tmp
 PKGDIR=${TMPDIR}/${PKGNAME}
 
 PREFIX=${PKGDIR}/local
 DBDIR=${PKGDIR}/dbpkg
 MTREE=${PKGDIR}/mtree
 MLIST=${PKGDIR}/mlist
 PLIST=${PKGDIR}/plist
 
 PREFIX_FILES=${PREFIX}.files
 PREFIX_DIRS=${PREFIX}.dirs
 DBDIR_FILES=${DBDIR}.files
 MTREE_DIRS=${MTREE}.dirs
 MTREE_DIFFS=${MTREE}.diffs
 
 cleandir () {
 	${rm} -rf ${PKGDIR}
 }
 
 cleanfile () {
 	${rm} -f ${PREFIX_FILES} ${DBDIR_FILES} \
 	      ${PREFIX_DIRS} ${MTREE_DIRS} ${MTREE_DIFFS} \
 	      ${MLIST} ${PLIST}
 }
 
 makemtree () {
 	[ -d ${MTREE} ] || {
 		${mkdir} -p ${MTREE}
 		${mtree} ${MTREE_ARGS} ${MTREE} > /dev/null
 	}
 	[ -f ${MTREE_DIRS} ] ||
 		(cd ${MTREE} && ${find} * -type d > ${MTREE_DIRS})
 }
 
 makedir () {
 	[ -d ${PREFIX} -a -d ${DBDIR} ] ||
 		${mkdir} -p ${PREFIX} ${DBDIR}
 	makemtree
 }
 
 runmake () {
 	case $1 in
 	install|package)
 		makedir
 		;;
 	esac
 	${make} "$@" PREFIX=${PREFIX} PKG_DBDIR=${DBDIR}
 }
 
 runpkgadd () {
 	PKG_DBDIR=${DBDIR} ${pkg_add} -p ${PREFIX} -f ${PKGFILE}
 }
 
 runpkgdel () {
 	PKG_DBDIR=${DBDIR} ${pkg_delete} -p ${PREFIX} -f ${PKGNAME}
 }
 
 runfind () {
 	[ ${PREFIX_FILES} -nt ${INSTALL_COOKIE} ] && return
 	(cd ${PREFIX} && ${find} * ! -type d | ${sort} > ${PREFIX_FILES})
 	(cd ${PREFIX} && ${find} * -type d > ${PREFIX_DIRS})
 	(cd ${DBDIR} && ${find} * ! -type d | ${sort} > ${DBDIR_FILES})
 }
 
 makediff () {
 	makemtree
 	runfind
 	${comm} -13 ${MTREE_DIRS} ${PREFIX_DIRS} |
 	{sort} -r |
 	${awk} '
 	/share\/locale/ {
 		print "@unexec rmdir %D/" $0 " 2>/dev/null || true"
 		next
 	}
 	{ print "@dirrm", $0 }
 	' > ${MTREE_DIFFS}
 }
 makemlist () {
 	${mkmakeman} -o ${MLIST} ${PREFIX}
 }
 makeplist () {
 	makediff
 	${echo} '@comment $FreeBSD$' |
 	${cat} - ${PREFIX_FILES} ${MTREE_DIFFS} |
 	${awk} '
 	/^info\/dir$/ { next }
 	/^man\/man/ { next }
 	/share\/doc/ {
 		print "%%PORTDOCS%%" $0
 		next
 	}
 	/\.info$/ {
 		print "@unexec install-info --quiet --delete %D/" $1 " %D/info/dir"
 		print
 		print "@exec install-info %D/" $1 " %D/info/dir"
 		next
 	}
 	/./' |
 	${tee} ${PLIST}
 }
 
 listfile () {
 	runfind
 	${grep} -v man/man ${PREFIX_FILES}
 }
 listman () {
 	runfind
 	${grep} man/man ${PREFIX_FILES}
 }
 listpkg () {
 	runfind
 	${cat} ${DBDIR_FILES}
 }
 listdir () {
 	makediff
 	${cat} ${MTREE_DIFFS}
 }
 
 # main
 case ${TARGET} in
 fetch|extract|patch|configure|build|''|install|package|deinstall)
 	runmake ${TARGET} "$@"
 	;;
 refetch|reextract|repatch|reconfigure|rebuild|reinstall|repackage)
 	flag=0
 	for target in ${cookies}; do
 		[ $target = ${TARGET#re} ] && flag=1
 		[ $flag = 1 ] && eval ${rm} -f \${$(${echo} $target | \
 						  ${tr} a-z A-Z)_COOKIE}
 	done
 	runmake ${TARGET#re} FORCE_PKG_REGISTER=yes "$@"
 	;;
 clean|distclean)
 	runmake ${TARGET} "$@"
 	cleandir
 	;;
 pkgadd|pkgdel)
 	eval run${TARGET}
 	;;
 mlist|plist)
 	eval make${TARGET}
 	;;
 listfile*|listman*|listpkg*|listdir*|cleanfile*|cleandir*)
 	eval ${TARGET%s}
 	;;
 *)
 	cat << EOF >&2
 usage: pkgbld {[re]fetch [re]extract [re]patch [re]configure [re]build
 	       [re]install [re]package deinstall clean distclean
 	       listfile listman listdir listpkg mlist plist cleanfile cleandir}
 	       arg...
 EOF
 	exit 64
 esac
 
 #!/bin/sh -e
 #
 # @(#) mkmakeman 1.1 (clefevre@citeweb) 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 echo=echo
 
 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                 mailto:clefevre@citeweb.net

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?200110112020.f9BKKKV15210>