diff options
author | jlam <jlam@pkgsrc.org> | 2006-07-06 21:07:33 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2006-07-06 21:07:33 +0000 |
commit | 38e1a9a77eb8ddc6ad44e774e762f59e36d6a1f5 (patch) | |
tree | 5c910ad9c759dc75bbf3da1d9617b924e253d8b0 /mk/bsd.pkg.mk | |
parent | eadca7ff9fdfa064b3a7d2c766ea720e71a14133 (diff) | |
download | pkgsrc-38e1a9a77eb8ddc6ad44e774e762f59e36d6a1f5.tar.gz |
Refactor the README.html generation code from bsd.pkg.mk into a separate
bsd.pkg.readme.mk and document the public targets and variables for this
new file.
Diffstat (limited to 'mk/bsd.pkg.mk')
-rw-r--r-- | mk/bsd.pkg.mk | 318 |
1 files changed, 4 insertions, 314 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk index 93909796f45..0753915332b 100644 --- a/mk/bsd.pkg.mk +++ b/mk/bsd.pkg.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkg.mk,v 1.1862 2006/07/06 16:58:17 jlam Exp $ +# $NetBSD: bsd.pkg.mk,v 1.1863 2006/07/06 21:07:33 jlam Exp $ # # This file is in the public domain. # @@ -1043,270 +1043,11 @@ su-bin-install: bin-install: su-target @${PHASE_MSG} "Binary install for "${PKGNAME_REQD:U${PKGNAME}:Q} - -################################################################ -# The special package-building targets -# You probably won't need to touch these -################################################################ - -# Set to "html" by the README.html target to generate HTML code, -# or to "svr4" to print SVR4 (Solaris, ...) short package names, from -# SVR4_PKGNAME variable. -# This variable is passed down via build-depends-list and run-depends-list -PACKAGE_NAME_TYPE?= name - -_HTML_PKGNAME= ${PKGNAME:S/&/\&/g:S/>/\>/g:S/</\</g} -_HTML_PKGPATH= ${PKGPATH:S/&/\&/g:S/>/\>/g:S/</\</g} -_HTML_PKGLINK= <a href="../../${_HTML_PKGPATH}/README.html">${_HTML_PKGNAME}</a> - -.PHONY: package-name -.if !target(package-name) -package-name: -. if (${PACKAGE_NAME_TYPE} == "html") - @${ECHO} ${_HTML_PKGLINK:Q} -. elif (${PACKAGE_NAME_TYPE} == "svr4") - @${ECHO} ${SVR4_PKGNAME} -. else - @${ECHO} ${PKGNAME} -. endif # PACKAGE_NAME_TYPE -.endif # !target(package-name) - -.PHONY: make-readme-html-help -.if !target(make-readme-html-help) -make-readme-html-help: - @${ECHO} '${PKGNAME:S/&/\&/g:S/>/\>/g:S/</\</g}</a>: <TD>'${COMMENT:S/&/\&/g:S/>/\>/g:S/</\</g:Q} -.endif # !target(make-readme-html-help) - -# Show (non-recursively) all the packages this package depends on. -# If PACKAGE_DEPENDS_WITH_PATTERNS is set, print as pattern (if possible) -PACKAGE_DEPENDS_WITH_PATTERNS?=true -.PHONY: run-depends-list -.if !target(run-depends-list) -run-depends-list: -. for dep in ${DEPENDS} - @pkg="${dep:C/:.*//}"; \ - dir="${dep:C/[^:]*://}"; \ - cd ${.CURDIR}; \ - if ${PACKAGE_DEPENDS_WITH_PATTERNS}; then \ - ${ECHO} "$$pkg"; \ - else \ - if cd $$dir 2>/dev/null; then \ - ${MAKE} ${MAKEFLAGS} package-name PACKAGE_NAME_TYPE=${PACKAGE_NAME_TYPE}; \ - else \ - ${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \ - fi; \ - fi -. endfor -.endif # target(run-depends-list) - -.PHONY: build-depends-list -.if !target(build-depends-list) -build-depends-list: - @for dir in `${MAKE} ${MAKEFLAGS} show-all-depends-dirs-excl`; \ - do \ - (cd ../../$$dir && \ - ${MAKE} ${MAKEFLAGS} package-name) \ - done -.endif - -# If PACKAGES is set to the default (../../pkgsrc/packages), the current -# ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory -# structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed. -# The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on -# the target used to generate the README.html file. -.PHONY: binpkg-list -.if !target(binpkg-list) -binpkg-list: - @if ${TEST} -d ${PACKAGES}; then \ - cd ${PACKAGES}; \ - case ${.CURDIR} in \ - */pkgsrc/packages) \ - for pkg in ${PKGREPOSITORYSUBDIR}/${PKGWILDCARD}${PKG_SUFX} ; \ - do \ - if [ -f "$$pkg" ] ; then \ - pkgname=`${ECHO} $$pkg | ${SED} 's@.*/@@'`; \ - ${ECHO} "<TR><TD>${MACHINE_ARCH}:<TD><a href=\"${PKG_URL}/$$pkg\">$$pkgname</a><TD>(${OPSYS} ${OS_VERSION})"; \ - fi ; \ - done ; \ - ;; \ - *) \ - cd ${PACKAGES}/../..; \ - for i in [1-9].*/*; do \ - if cd ${PACKAGES}/../../$$i/${PKGREPOSITORYSUBDIR} 2>/dev/null; then \ - for j in ${PKGWILDCARD}${PKG_SUFX}; \ - do \ - if [ -f "$$j" ]; then \ - ${ECHO} $$i/$$j;\ - fi; \ - done; \ - fi; \ - done | ${AWK} -F/ ' \ - { \ - release = $$1; \ - arch = $$2; \ - pkg = $$3; \ - gsub("\\.tgz","", pkg); \ - if (arch != "m68k" && arch != "mipsel") { \ - if (arch in urls) \ - urls[arch "/" pkg "/" release] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a>, " urls[arch]; \ - else \ - urls[arch "/" pkg "/" release] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a> "; \ - } \ - } \ - END { \ - for (av in urls) { \ - split(av, ava, "/"); \ - arch=ava[1]; \ - pkg=ava[2]; \ - release=ava[3]; \ - print "<TR><TD>" arch ":<TD>" urls[av] "<TD>(${OPSYS} " release ")"; \ - } \ - }' | ${SORT} \ - ;; \ - esac; \ - fi -.endif - ################################################################ # Everything after here are internal targets and really # shouldn't be touched by anybody but the release engineers. ################################################################ -# This target generates an index entry suitable for aggregation into -# a large index. Format is: -# -# distribution-name|package-path|installation-prefix|comment| \ -# description-file|maintainer|categories|build deps|run deps|for arch| \ -# not for opsys -# -.PHONY: describe -.if !target(describe) -describe: - @${ECHO_N} "${PKGNAME}|${.CURDIR}|"; \ - ${ECHO_N} "${PREFIX}|"; \ - ${ECHO_N} ${COMMENT:Q}; \ - if [ -f ${DESCR_SRC} ]; then \ - ${ECHO_N} "|${DESCR_SRC}"; \ - else \ - ${ECHO_N} "|/dev/null"; \ - fi; \ - ${ECHO_N} "|${MAINTAINER}|${CATEGORIES}|"; \ - case "A${BUILD_DEPENDS}B${DEPENDS}C" in \ - ABC) ;; \ - *) cd ${.CURDIR} && ${ECHO_N} `${MAKE} ${MAKEFLAGS} build-depends-list | ${SORT} -u`;; \ - esac; \ - ${ECHO_N} "|"; \ - if [ "${DEPENDS}" != "" ]; then \ - cd ${.CURDIR} && ${ECHO_N} `${MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u`; \ - fi; \ - ${ECHO_N} "|"; \ - if [ "${ONLY_FOR_PLATFORM}" = "" ]; then \ - ${ECHO_N} "any"; \ - else \ - ${ECHO_N} "${ONLY_FOR_PLATFORM}"; \ - fi; \ - ${ECHO_N} "|"; \ - if [ "${NOT_FOR_PLATFORM}" = "" ]; then \ - ${ECHO_N} "any"; \ - else \ - ${ECHO_N} "not ${NOT_FOR_PLATFORM}"; \ - fi; \ - ${ECHO} "" -.endif - -.PHONY: readmes -.if !target(readmes) -readmes: readme -.endif - -# This target is used to generate README.html files -.PHONY: readme -.if !target(readme) -FTP_PKG_URL_HOST?= ftp://ftp.NetBSD.org -FTP_PKG_URL_DIR?= /pub/NetBSD/packages - -readme: - @cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} README.html PKG_URL=${FTP_PKG_URL_HOST}${FTP_PKG_URL_DIR} -.endif - -# This target is used to generate README.html files, very like "readme" -# However, a different target was used for ease of use. -.PHONY: cdrom-readme -.if !target(cdrom-readme) -CDROM_PKG_URL_HOST?= file://localhost -CDROM_PKG_URL_DIR?= /usr/pkgsrc/packages - -cdrom-readme: - @cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} README.html PKG_URL=${CDROM_PKG_URL_HOST}${CDROM_PKG_URL_DIR} -.endif - -README_NAME= ${TEMPLATES}/README.pkg - -# set up the correct license information as a sed expression -.if defined(LICENSE) -SED_LICENSE_EXPR= -e 's|%%LICENSE%%|<p>Please note that this package has a ${LICENSE} license.</p>|' -.else -SED_LICENSE_EXPR= -e 's|%%LICENSE%%||' -.endif - -# set up the "more info URL" information as a sed expression -.if defined(HOMEPAGE) -SED_HOMEPAGE_EXPR= -e 's|%%HOMEPAGE%%|<p>This package has a home page at <a HREF="${HOMEPAGE}">${HOMEPAGE}</a>.</p>|' -.else -SED_HOMEPAGE_EXPR= -e 's|%%HOMEPAGE%%||' -.endif - -.PHONY: show-vulnerabilities-html -show-vulnerabilities-html: - ${_PKG_SILENT}${_PKG_DEBUG} \ - if [ -f ${PKGVULNDIR}/pkg-vulnerabilities ]; then \ - ${AWK} '/^${PKGBASE}[-<>=]+[0-9]/ { gsub("\<", "\\<", $$1); \ - gsub("\>", "\\>", $$1); \ - printf("<LI><STRONG>%s has a %s exploit (see <a href=\"%s\">%s</a> for more details)</STRONG></LI>\n", $$1, $$2, $$3, $$3) }' \ - ${PKGVULNDIR}/pkg-vulnerabilities; \ - fi - - -# If PACKAGES is set to the default (../../packages), the current -# ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory -# structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed. -# The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on -# the target used to generate the README.html file. -.PHONY: README.html -README.html: .PRECIOUS - @${SETENV} AWK=${AWK} BMAKE=${MAKE} ../../mk/scripts/mkdatabase -f $@.tmp1 - @if ${TEST} -d ${PACKAGES}; then \ - cd ${PACKAGES}; \ - case `${PWD_CMD}` in \ - ${PKGSRCDIR}/packages) \ - MULTIARCH=no; \ - ;; \ - *) \ - MULTIARCH=yes; \ - ;; \ - esac; \ - cd ${.CURDIR} ; \ - fi; \ - ${AWK} -f ../../mk/scripts/genreadme.awk \ - builddependsfile=/dev/null \ - dependsfile=/dev/null \ - AWK=${AWK:Q} \ - CMP=${CMP:Q} \ - DISTDIR=${DISTDIR:Q} \ - GREP=${GREP:Q} \ - PACKAGES=${PACKAGES:Q} \ - PKG_INFO=${PKG_INFO:Q} \ - PKG_SUFX=${PKG_SUFX:Q} \ - PKG_URL=${PKG_URL:Q} \ - PKGSRCDIR=${.CURDIR:C|/[^/]*/[^/]*$||:Q} \ - SED=${SED:Q} \ - SETENV=${SETENV:Q} \ - SORT=${SORT:Q} \ - TMPDIR=${TMPDIR:U/tmp:Q} \ - SINGLEPKG=${PKGPATH:Q} \ - $@.tmp1 - @${RM} $@.tmp1 - .PHONY: show-pkgtools-version .if !target(show-pkgtools-version) show-pkgtools-version: @@ -1334,60 +1075,6 @@ show-vars-eval: @${ECHO} ${var:C/^.*://}="${${var:C/:.*$//}:Q}" .endfor -.PHONY: print-build-depends-list -.if !target(print-build-depends-list) -print-build-depends-list: -. if !empty(BUILD_DEPENDS) || !empty(DEPENDS) - @${ECHO_N} 'This package requires package(s) "' - @${ECHO_N} `${MAKE} ${MAKEFLAGS} build-depends-list | ${SORT} -u` - @${ECHO} '" to build.' -. endif -.endif - -.PHONY: print-run-depends-list -.if !target(print-run-depends-list) -print-run-depends-list: -. if !empty(DEPENDS) - @${ECHO_N} 'This package requires package(s) "' - @${ECHO_N} `${MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u` - @${ECHO} '" to run.' -. endif -.endif - -# This target is used by the mk/scripts/mkreadme script to generate -# README.html files -.PHONY: print-summary-data -.if !target(print-summary-data) -print-summary-data: - @${ECHO} depends ${PKGPATH} ${DEPENDS:Q} - @${ECHO} build_depends ${PKGPATH} ${BUILD_DEPENDS:Q} - @${ECHO} conflicts ${PKGPATH} ${CONFLICTS:Q} - @${ECHO} index ${PKGPATH} ${PKGNAME:Q} - @${ECHO} htmlname ${PKGPATH} ${_HTML_PKGLINK:Q} - @${ECHO} homepage ${PKGPATH} ${HOMEPAGE:Q} - @${ECHO} wildcard ${PKGPATH} ${PKGWILDCARD:Q} - @${ECHO} comment ${PKGPATH} ${COMMENT:Q} - @${ECHO} license ${PKGPATH} ${LICENSE:Q} - @if [ "${ONLY_FOR_PLATFORM}" = "" ]; then \ - ${ECHO} "onlyfor ${PKGPATH} any"; \ - else \ - ${ECHO} "onlyfor ${PKGPATH} ${ONLY_FOR_PLATFORM}"; \ - fi - @if [ "${NOT_FOR_PLATFORM}" = "" ]; then \ - ${ECHO} "notfor ${PKGPATH} any"; \ - else \ - ${ECHO} "notfor ${PKGPATH} not ${NOT_FOR_PLATFORM}"; \ - fi; - @${ECHO} "maintainer ${PKGPATH} ${MAINTAINER}" - @${ECHO} "categories ${PKGPATH} ${CATEGORIES}" - @if [ -f ${DESCR_SRC} ]; then \ - ${ECHO} "descr ${PKGPATH} ${DESCR_SRC:S;${PKGSRCDIR}/;;g}"; \ - else \ - ${ECHO} "descr ${PKGPATH} /dev/null"; \ - fi - @${ECHO} "prefix ${PKGPATH} ${PREFIX}" -.endif - LICENSE_FILE?= ${PKGSRCDIR}/licenses/${LICENSE} .if !target(show-license) @@ -1442,6 +1129,9 @@ tags: . include "../../mk/bulk/bsd.bulk-pkg.mk" .endif +# README generation code. +.include "../../mk/bsd.pkg.readme.mk" + # Create a PKG_ERROR_HANDLER shell command for each class listed in # PKG_ERROR_CLASSES. The error handler is meant to be invoked within # a make target. |