[prev in list] [next in list] [prev in thread] [next in thread]
List: openbsd-ports
Subject: generating readme.html from ports
From: Marc Espie <espie () nerim ! net>
Date: 2003-07-30 21:37:37
[Download RAW message or body]
The following patch allows reuse of the _flavor_fragment shell script.
Basically, it ensure directories are always converted to a full path
from PORTSDIR first.
Interesting side-effect: SKIPDIR becomes easier to use, e.g., you can
write SKIPDIR=devel/jdk/1.2, your location in the ports tree
notwithstanding.
Displaying of subdirectories uses pkg specs exclusively.
Accordingly, the generation of *.html files at each step becomes feasible.
There are also a few fixes/additions wrt MULTI_PACKAGES, again.
Okay ?
Index: mk/bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.569
diff -u -r1.569 bsd.port.mk
--- mk/bsd.port.mk 30 Jul 2003 19:59:48 -0000 1.569
+++ mk/bsd.port.mk 30 Jul 2003 21:33:23 -0000
@@ -533,13 +533,8 @@
.PRECIOUS: ${_PACKAGE_COOKIES} ${_INSTALL_COOKIE}
-.if !defined(PKGPATH)
-_PORTSDIR!= cd ${PORTSDIR} && pwd -P
-_CURDIR!= cd ${.CURDIR} && pwd -P
-PKGPATH=${_CURDIR:S,${_PORTSDIR}/,,}
-.endif
+.include "${PORTSDIR}/infrastructure/mk/pkgpath.mk"
-PKGDEPTH=${PKGPATH:C|[^./][^/]*|..|g}
.if empty(SUBPACKAGE)
FULLPKGPATH=${PKGPATH}${_FLAVOR_EXT2:S/-/,/g}
.else
@@ -1068,44 +1063,6 @@
# Dependency checking
################################################################
-# Code to invoke to split dir,-multi,flavor
-
-_flavor_fragment= \
- multi=''; flavor=''; sawflavor=false; \
- case "$$dir" in \
- *,*) \
- IFS=,; first=true; for i in $$dir; do \
- if $$first; then \
- dir=$$i; first=false; \
- else \
- case X"$$i" in \
- X-*) \
- multi="$$i";; \
- *) \
- sawflavor=true; \
- flavor="$$flavor $$i";; \
- esac \
- fi; \
- done; unset IFS;; \
- esac; \
- toset="PKGPATH=$$dir"; \
- case X$$multi in "X");; *) \
- toset="$$toset SUBPACKAGE=\"$$multi\"";; \
- esac; \
- if $$sawflavor; then \
- toset="$$toset FLAVOR=\"$$flavor\""; \
- fi; \
- cd ${PORTSDIR}; \
- if [ -L $$dir ]; then \
- echo 1>&2 ">> Broken dependency: $$dir is a symbolic link"; \
- exit 1; \
- fi; \
- if cd $$dir 2>/dev/null || cd mystuff/$$dir 2>/dev/null; then \
- :; \
- else \
- echo 1>&2 ">> Broken dependency: $$dir non existent"; \
- exit 1; \
- fi
# Various dependency styles
@@ -2114,35 +2071,51 @@
.endif
-HTMLIFY= sed -e 's/&/\&/g' -e 's/>/\>/g' -e 's/</\</g'
-
${FULLPKGNAME${SUBPACKAGE}}.html:
- @echo ${_COMMENT} >$@.tmp-comment
+ @echo ${_COMMENT} | ${HTMLIFY} >$@.tmp-comment
@echo ${FULLPKGNAME${SUBPACKAGE}} | ${HTMLIFY} > $@.tmp3
.if defined(HOMEPAGE)
@echo 'See <a href="${HOMEPAGE}">${HOMEPAGE}</a> for details.' >$@.tmp4
.else
@echo "" >$@.tmp4
.endif
+.if defined(MULTI_PACKAGES)
+. if empty(SUBPACKAGE)
+ @echo "<h2>Subpackages</h2>" >$@.tmp-subpackages
+ @echo "<ul>" >>$@.tmp-subpackages
+
+. for _S in ${MULTI_PACKAGES}
+ @name=`SUBPACKAGE=${_S} ${MAKE} _print-packagename _FULL_PACKAGE_NAME=No`; \
+ echo "<li><a href=\"$$name.html\">$$name</a>" >>$@.tmp-subpackages
+. endfor
+ @echo "</ul>" >>$@.tmp-subpackages
+. else
+ @name=`unset SUBPACKAGE; ${MAKE} _print-packagename _FULL_PACKAGE_NAME=No`; \
+ echo "<h2>Subpackage of <a href=\"$$name.html\">$$name</a></h2>" \
>$@.tmp-subpackages +. endif
+.else
+ @>$@.tmp-subpackages
+.endif
.for _I in build run
. if !empty(_ALWAYS_DEP) || !empty(_${_I:U}_DEP)
@cd ${.CURDIR} && ${MAKE} full-${_I}-depends _FULL_PACKAGE_NAME=Yes| \
while read n; do \
j=`dirname $$n|${HTMLIFY}`; k=`basename $$n|${HTMLIFY}`; \
- echo "<li><a href=\"${PKGDEPTH}/$$j/$$k.html\">$$k</a>"; \
+ echo "<li><a href=\"${PKGDEPTH}$$j/$$k.html\">$$k</a>"; \
done >$@.tmp-${_I}
. else
- @echo "<li>none" >$@.tmp${_I}
+ @echo "<li>none" >$@.tmp-${_I}
. endif
.endfor
@cat ${README_NAME} | \
- sed -e 's|%%PORT%%|'"`echo ${PKGPATH} | ${HTMLIFY}`"'|g' \
+ sed -e 's|%%PORT%%|'"`echo ${FULLPKGPATH} | ${HTMLIFY}`"'|g' \
-e '/%%PKG%%/r$@.tmp3' -e '//d' \
-e '/%%COMMENT%%/r$@.tmp-comment' -e '//d' \
- -e '/%%DESCR%%/r${PKGDIR}/DESCR' -e '//d' \
+ -e '/%%DESCR%%/r${PKGDIR}/DESCR${SUBPACKAGE}' -e '//d' \
-e '/%%HOMEPAGE%%/r$@.tmp4' -e '//d' \
-e '/%%BUILD_DEPENDS%%/r$@.tmp-build' -e '//d' \
-e '/%%RUN_DEPENDS%%/r$@.tmp-run' -e '//d' \
+ -e '/%%SUBPACKAGES%%/r$@.tmp-subpackages' -e '//d' \
>> $@
@rm -f $@.tmp*
Index: mk/bsd.port.subdir.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.subdir.mk,v
retrieving revision 1.51
diff -u -r1.51 bsd.port.subdir.mk
--- mk/bsd.port.subdir.mk 29 Jul 2003 22:27:09 -0000 1.51
+++ mk/bsd.port.subdir.mk 30 Jul 2003 21:33:23 -0000
@@ -1,3 +1,5 @@
+#-*- mode: Makefile; tab-width: 4; -*-
+# ex:ts=4 sw=4 filetype=make:
# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
# $OpenBSD: bsd.port.subdir.mk,v 1.51 2003/07/29 22:27:09 espie Exp $
# FreeBSD Id: bsd.port.subdir.mk,v 1.20 1997/08/22 11:16:15 asami Exp
@@ -38,6 +40,7 @@
.if !defined(BSD_OWN_MK)
. include <bsd.own.mk>
.endif
+PORTSDIR ?= /usr/ports
.if defined(show)
.MAIN: show
@@ -55,95 +58,37 @@
OPSYS= OpenBSD
.endif
-.if !defined(PKGPATH)
-_PORTSDIR!= cd ${PORTSDIR} && pwd -P
-_CURDIR!= cd ${.CURDIR} && pwd -P
-. if ${_PORTSDIR} == ${_CURDIR}
-PKGPATH=
-. else
-PKGPATH=${_CURDIR:S,${_PORTSDIR}/,,}
-. endif
-.endif
-.if empty(PKGPATH)
-_SEP=
-.else
-_SEP=/
-.endif
+.include "${PORTSDIR}/infrastructure/mk/pkgpath.mk"
ECHO_MSG?= echo
-RECURSIVE_FETCH_LIST?= No
-
REPORT_PROBLEM?=exit 1
-# Need an actual list of all subdirs to complete SKIPPED
-_ALL_SUBDIR:=${SUBDIR}
-SKIPPED=
-.if defined(SKIPDIR)
-. for i in ${SKIPDIR:S/:/,/}
-SKIPPED+=${_ALL_SUBDIR:M$i}
-SUBDIR:=${SUBDIR:N$i}
-. endfor
+# create a full list of SUBDIRS...
+.if empty(PKGPATH)
+FULLSUBDIR:=${SUBDIR}
+.else
+FULLSUBDIR:=${SUBDIR:S@^@${PKGPATH}/@g}
.endif
+SKIPPED=
+.for i in ${SKIPDIR}
+SKIPPED+=${FULLSUBDIR:M$i}
+SUBDIR:=${FULLSUBDIR:N$i}
+.endfor
+
+
_SUBDIRUSE: .USE
. for i in ${SKIPPED}
- @echo "===> ${PKGPATH}${_SEP}$i skipped"
+ @echo "===> $i skipped"
. endfor
- @for dir in ${SUBDIR}; do \
- multi=''; flavor=''; sawflavor=false; toset=''; \
- case "$$dir" in \
- *[,:]*) \
- IFS=',:'; first=true; insert=''; for i in $$dir; do \
- if $$first; then \
- dir=$$i; first=false; \
- else \
- case X"$$i" in \
- X-*) \
- multi="$$i";; \
- *) \
- sawflavor=true; \
- flavor="$$flavor$$insert$$i"; \
- insert=' ';; \
- esac \
- fi; \
- done; unset IFS; \
- case X$$multi in "X");; *) \
- toset="$$toset SUBPACKAGE=\"$$multi\"";; \
- esac; \
- esac; \
- if $$sawflavor; then \
- toset="$$toset FLAVOR=\"$$flavor\""; \
- display=" ($$flavor)"; \
- else \
- display=''; \
- fi; \
- if cd ${.CURDIR}/$${dir}.${MACHINE} 2>/dev/null; then \
- edir=$${dir}.${MACHINE}; \
- elif cd ${.CURDIR}/$${dir} 2>/dev/null; then \
- edir=$${dir}; \
- else \
- ${ECHO_MSG} "===> ${PKGPATH}${_SEP}$${dir} non-existent"; \
- ${REPORT_PROBLEM}; \
- continue; \
- fi; \
- ${ECHO_MSG} "===> ${PKGPATH}${_SEP}$${edir}$$display"; \
- set +e; \
- if eval $$toset \
- PKGPATH=${PKGPATH}${_SEP}$$edir \
- RECURSIVE_FETCH_LIST=${RECURSIVE_FETCH_LIST} \
- ${MAKE} ${.TARGET}; \
- then :; else ${REPORT_PROBLEM}; fi; \
- set -e; \
- done
-
-${SUBDIR}::
- @if test -d ${.TARGET}.${MACHINE}; then \
- cd ${.CURDIR}/${.TARGET}.${MACHINE}; \
- else \
- cd ${.CURDIR}/${.TARGET}; \
- fi; \
- ${MAKE} all
+. for d in ${FULLSUBDIR}
+ @dir=$d; ${_flavor_fragment}; \
+ ${ECHO_MSG} "===> $d"; \
+ set +e; \
+ if eval $$toset ${MAKE} ${.TARGET}; then :; \
+ else ${REPORT_PROBLEM}; fi
+.endfor
.for __target in all fetch fetch-list package fake extract configure \
build clean describe distclean deinstall install \
@@ -163,7 +108,6 @@
@rm -f README.html
@${MAKE} README.html
-PORTSDIR ?= /usr/ports
TEMPLATES ?= ${PORTSDIR}/infrastructure/templates
.if defined(PORTSTOP)
README= ${TEMPLATES}/README.top
@@ -172,26 +116,26 @@
.endif
README.html:
- @> $@.tmp
-.for entry in ${SUBDIR}
- @echo -n '<dt><a href="'${entry}/README.html'">'"`cd ${entry} && make package-name \
2>/dev/null||echo ${entry}`</a><dd>" >> $@.tmp
-. if exists(${entry}/pkg/COMMENT)
- @cat ${entry}/pkg/COMMENT >> $@.tmp
-. else
- @echo "(no description)" >> $@.tmp
-. endif
+ @>$@.tmp
+.for entry in ${FULLSUBDIR}
+ @dir=${entry}; ${_flavor_fragment}; \
+ name=`eval $$toset ${MAKE} _print-packagename`; \
+ case $$name in \
+ README) comment='';; \
+ *) comment=`eval $$toset ${MAKE} show=_COMMENT|sed -e 's,^",,' -e 's,"$$,,' \
|${HTMLIFY}`;; \ + esac; \
+ cd ${.CURDIR}; \
+ echo "<dt><a href=\"${PKGDEPTH}$$dir/$$name.html\">${entry}</a><dd>$$comment" \
>>$@.tmp
.endfor
- @sort -t '>' +1 -2 $@.tmp > $@.tmp2
@cat ${README} | \
sed -e 's%%CATEGORY%%'`echo ${.CURDIR} | sed -e 's.*/\([^/]*\)$$\1'`'g' \
-e '/%%DESCR%%/r${.CURDIR}/pkg/DESCR' -e '//d' \
- -e '/%%SUBDIR%%/r$@.tmp2' -e '//d' \
+ -e '/%%SUBDIR%%/r$@.tmp' -e '//d' \
> $@
- @rm -f $@.tmp $@.tmp2
+ @rm $@.tmp
_print-packagename:
- @echo 1>&2 "Error in dependency: ${PKGPATH} is not a package location"
- @exit 1
+ @echo "README"
.PHONY: all fetch fetch-list package extract configure build clean \
describe distclean deinstall reinstall checksum mirror-distfiles \
Index: mk/pkgpath.mk
===================================================================
RCS file: mk/pkgpath.mk
diff -N mk/pkgpath.mk
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ mk/pkgpath.mk 30 Jul 2003 21:33:23 -0000
@@ -0,0 +1,59 @@
+# $OpenBSD$
+# pkgpath.mk - 2003 Marc Espie
+# This file is in the public domain.
+
+# definitions common to bsd.port.mk and bsd.port.subdir.mk
+
+.if !defined(PKGPATH)
+_PORTSDIR!= cd ${PORTSDIR} && pwd -P
+_CURDIR!= cd ${.CURDIR} && pwd -P
+PKGPATH=${_CURDIR:S,${_PORTSDIR}/,,}
+.endif
+.if empty(PKGPATH)
+PKGDEPTH=
+.else
+PKGDEPTH=${PKGPATH:C|[^./][^/]*|..|g}/
+.endif
+
+# Code to invoke to split dir,-multi,flavor
+
+_flavor_fragment= \
+ multi=''; flavor=''; space=''; sawflavor=false; \
+ case "$$dir" in \
+ *,*) \
+ IFS=,; first=true; for i in $$dir; do \
+ if $$first; then \
+ dir=$$i; first=false; \
+ else \
+ case X"$$i" in \
+ X-*) \
+ multi="$$i";; \
+ *) \
+ sawflavor=true; \
+ flavor="$$flavor$$space$$i"; \
+ space=' ';; \
+ esac \
+ fi; \
+ done; unset IFS;; \
+ esac; \
+ toset="PKGPATH=$$dir"; \
+ case X$$multi in "X");; *) \
+ toset="$$toset SUBPACKAGE=\"$$multi\"";; \
+ esac; \
+ if $$sawflavor; then \
+ toset="$$toset FLAVOR=\"$$flavor\""; \
+ fi; \
+ cd ${PORTSDIR}; \
+ if [ -L $$dir ]; then \
+ echo 1>&2 ">> Broken dependency: $$dir is a symbolic link"; \
+ exit 1; \
+ fi; \
+ if cd $$dir 2>/dev/null || cd mystuff/$$dir 2>/dev/null; then \
+ :; \
+ else \
+ echo 1>&2 ">> Broken dependency: $$dir non existent"; \
+ exit 1; \
+ fi
+
+HTMLIFY= sed -e 's/&/\&/g' -e 's/>/\>/g' -e 's/</\</g'
+
Index: templates/README.port
===================================================================
RCS file: /cvs/ports/infrastructure/templates/README.port,v
retrieving revision 1.3
diff -u -r1.3 README.port
--- templates/README.port 13 Dec 2001 15:40:27 -0000 1.3
+++ templates/README.port 30 Jul 2003 21:33:23 -0000
@@ -9,6 +9,8 @@
--
%%COMMENT%%
</H2>
+
+%%SUBPACKAGES%%
<H2>Description</H2>
<pre>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic