1 # $NetBSD: bsd.pkg.readme.mk,v 1.24 2011/06/03 10:25:04 spz Exp $
3 # This Makefile fragment is included by bsd.pkg.mk and encapsulates the
4 # code to produce README.html files in each package directory.
6 # The following are the "public" targets provided by this module.
8 # readme This target generates a README.html file suitable
9 # for being served via FTP.
11 # cdrom-readme This target generates a README.html file suitable
12 # for being served from a mounted CD-ROM.
14 # The following are the user-settable variables that may be defined in
17 # FTP_PKG_URL_HOST is the host portion of the URL to embed in each
18 # README.html file to be served via FTP, and defaults to
19 # "ftp://ftp.NetBSD.org".
21 # FTP_PKG_URL_DIR is the directory portion of the URL to embed in each
22 # README.html file to be served via FTP, and defaults to
23 # "/pub/pkgsrc/packages".
25 # CDROM_PKG_URL_HOST is the host portion of the URL to embed in each
26 # README.html file to be served from a mounted CD-ROM, and defaults
27 # to "file://localhost".
29 # CDROM_PKG_URL_DIR is the directory portion of the URL to embed in each
30 # README.html file to be served from a mounted CD-ROM, and defaults
31 # to "/usr/pkgsrc/packages".
34 # Set to "html" by the README.html target to generate HTML code,
35 # or to "svr4" to print SVR4 (Solaris, ...) short package names, from
36 # SVR4_PKGNAME variable.
37 # This variable is passed down via build-depends-list and run-depends-list
38 PACKAGE_NAME_TYPE?
= name
40 _HTML_PKGLINK
= <a href
="../../${PKGPATH}/README.html">${PKGNAME}</a
>
43 .if
!target
(package-name
)
45 . if
(${PACKAGE_NAME_TYPE} == "html")
46 @
${ECHO} ${_HTML_PKGLINK
:Q
}
47 . elif
(${PACKAGE_NAME_TYPE} == "svr4")
48 @
${ECHO} ${SVR4_PKGNAME}
51 .
endif # PACKAGE_NAME_TYPE
52 .
endif # !target(package-name)
54 .PHONY
: make-readme-html-help
55 .if
!target
(make-readme-html-help
)
56 make-readme-html-help
:
57 @
${ECHO} '${PKGNAME}</a>: <TD>'${COMMENT
:Q
}
58 .
endif # !target(make-readme-html-help)
60 # Show (non-recursively) all the packages this package depends on.
61 # If PACKAGE_DEPENDS_WITH_PATTERNS is set, print as pattern (if possible)
62 PACKAGE_DEPENDS_WITH_PATTERNS?
=true
63 .PHONY
: run-depends-list
64 .if
!target
(run-depends-list
)
66 . for dep in
${DEPENDS}
67 @pkg
="${dep:C/:.*//}"; \
68 dir="${dep:C/[^:]*://}"; \
70 if
${PACKAGE_DEPENDS_WITH_PATTERNS}; then \
73 if cd
$$dir 2>/dev
/null
; then \
74 ${RECURSIVE_MAKE} ${MAKEFLAGS} package-name PACKAGE_NAME_TYPE
=${PACKAGE_NAME_TYPE}; \
76 ${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \
80 .
endif # target(run-depends-list)
82 .PHONY
: build-depends-list
83 .if
!target
(build-depends-list
)
85 @
${_DEPENDS_WALK_CMD} ${PKGPATH} | \
87 ( cd ..
/..
/$$dir && ${RECURSIVE_MAKE} ${MAKEFLAGS} package-name
) \
91 # If PACKAGES is set to the default (../../pkgsrc/packages), the current
92 # ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
93 # structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed.
94 # The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on
95 # the target used to generate the README.html file.
97 .if
!target
(binpkg-list
)
99 @if
${TEST} -d
${PACKAGES}; then \
103 for pkg in
${PKGREPOSITORYSUBDIR}/${PKGWILDCARD}${PKG_SUFX} ; \
105 if
[ -f
"$$pkg" ] ; then \
106 pkgname
=`${ECHO} $$pkg | ${SED} 's@.*/@@'`; \
107 ${ECHO} "<TR><TD>${MACHINE_ARCH}:<TD><a href=\"${PKG_URL}/$$pkg\">$$pkgname</a><TD>(${OPSYS} ${OS_VERSION})"; \
112 cd
${PACKAGES}/..
/..
; \
113 for i in
[1-9].
*/*; do \
114 if cd
${PACKAGES}/..
/..
/$$i/${PKGREPOSITORYSUBDIR} 2>/dev
/null
; then \
115 for j in
${PKGWILDCARD}${PKG_SUFX}; \
117 if
[ -f
"$$j" ]; then \
122 done |
${AWK} -F
/ ' \
127 gsub("\\.tgz","", pkg); \
128 if (arch != "m68k" && arch != "mipsel") { \
130 urls[arch "/" pkg "/" release] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a>, " urls[arch]; \
132 urls[arch "/" pkg "/" release] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a> "; \
137 split(av, ava, "/"); \
141 print "<TR><TD>" arch ":<TD>" urls[av] "<TD>(${OPSYS} " release ")"; \
149 # This target generates an index entry suitable for aggregation into
150 # a large index. Format is:
152 # distribution-name|package-path|installation-prefix|comment| \
153 # description-file|maintainer|categories|build deps|run deps|for arch| \
157 .if
!target
(describe
)
159 @
${ECHO_N} "${PKGNAME}|${.CURDIR}|"; \
160 ${ECHO_N} "${PREFIX}|"; \
161 ${ECHO_N} ${COMMENT
:Q
}; \
162 if
[ -f
"${DESCR_SRC}" ]; then \
163 ${ECHO_N} "|${DESCR_SRC}"; \
165 ${ECHO_N} "|/dev/null"; \
167 ${ECHO_N} "|${MAINTAINER}|${CATEGORIES}|"; \
168 case
"A${BUILD_DEPENDS}B${DEPENDS}C" in \
170 *) cd
${.CURDIR
} && ${ECHO_N} `${RECURSIVE_MAKE} ${MAKEFLAGS} build-depends-list | ${SORT} -u`;; \
173 if
[ "${DEPENDS}" != "" ]; then \
174 cd
${.CURDIR
} && ${ECHO_N} `${RECURSIVE_MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u`; \
177 if
[ "${ONLY_FOR_PLATFORM}" = "" ]; then \
180 ${ECHO_N} "${ONLY_FOR_PLATFORM}"; \
183 if
[ "${NOT_FOR_PLATFORM}" = "" ]; then \
186 ${ECHO_N} "not ${NOT_FOR_PLATFORM}"; \
196 # This target is used to generate README.html files
199 FTP_PKG_URL_HOST?
= ftp
://ftp.NetBSD.org
200 FTP_PKG_URL_DIR?
= /pub
/pkgsrc
/packages
203 @cd
${.CURDIR
} && ${RECURSIVE_MAKE} ${MAKEFLAGS} README.html PKG_URL
=${FTP_PKG_URL_HOST}${FTP_PKG_URL_DIR}
206 # This target is used to generate README.html files, very like "readme"
207 # However, a different target was used for ease of use.
209 .if
!target
(cdrom-readme
)
210 CDROM_PKG_URL_HOST?
= file
://localhost
211 CDROM_PKG_URL_DIR?
= /usr
/pkgsrc
/packages
214 @cd
${.CURDIR
} && ${RECURSIVE_MAKE} ${MAKEFLAGS} README.html PKG_URL
=${CDROM_PKG_URL_HOST}${CDROM_PKG_URL_DIR}
217 README_NAME
= ${TEMPLATES}/README.pkg
219 # set up the correct license information as a sed expression
221 SED_LICENSE_EXPR
= -e
's|%%LICENSE%%|<p>Please note that this package has a ${LICENSE} license.</p>|'
223 SED_LICENSE_EXPR
= -e
's|%%LICENSE%%||'
226 # set up the "more info URL" information as a sed expression
227 .if defined
(HOMEPAGE
)
228 SED_HOMEPAGE_EXPR
= -e
's|%%HOMEPAGE%%|<p>This package has a home page at <a HREF="${HOMEPAGE}">${HOMEPAGE}</a>.</p>|'
230 SED_HOMEPAGE_EXPR
= -e
's|%%HOMEPAGE%%||'
233 # If PACKAGES is set to the default (../../packages), the current
234 # ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
235 # structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed.
236 # The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on
237 # the target used to generate the README.html file.
239 README.html
: .PRECIOUS
240 @
${PKGSRC_SETENV} BMAKE
=${MAKE
:Q
} ${SH} ..
/..
/mk
/scripts
/mkdatabase
-f
$@.tmp1
241 @if
${TEST} -d
${PACKAGES}; then \
243 case
`${PWD_CMD}` in \
244 ${PKGSRCDIR}/packages
) \
253 if
[ `${PKG_ADMIN} -V` -lt
20080415 ]; then \
254 SCAN_VULNERABILITIES
=0; \
256 _PVDIR
=`${PKG_ADMIN} config-var PKGVULNDIR`; \
257 if
[ -e
"$${_PVDIR}"/pkg-vulnerabilities
]; then \
258 SCAN_VULNERABILITIES
=2; \
260 SCAN_VULNERABILITIES
=1; \
263 ${AWK} -f ..
/..
/mk
/scripts
/genreadme.awk \
264 builddependsfile
=/dev
/null \
265 dependsfile
=/dev
/null \
268 DISTDIR
=${DISTDIR
:Q
} \
270 PACKAGES
=${PACKAGES
:Q
} \
271 PKG_ADMIN
=${PKG_ADMIN
:Q
} \
272 PKG_INFO
=${PKG_INFO
:Q
} \
273 PKG_SUFX
=${PKG_SUFX
:Q
} \
274 PKG_URL
=${PKG_URL
:Q
} \
275 PKGSRCDIR
=${.CURDIR
:C|
/[^
/]*/[^
/]*$||
:Q
} \
276 PKGTOOLS_VERSION
=${PKGTOOLS_VERSION} \
277 SCAN_VULNERABILITIES
=$${SCAN_VULNERABILITIES} \
281 TMPDIR
=${TMPDIR
:U
/tmp
:Q
} \
282 SINGLEPKG
=${PKGPATH
:Q
} \
286 .PHONY
: print-build-depends-list
287 .if
!target
(print-build-depends-list
)
288 print-build-depends-list
:
289 . if
!empty
(BUILD_DEPENDS
) ||
!empty
(DEPENDS
)
290 @
${ECHO_N} 'This package requires package(s) "'
291 @
${ECHO_N} `${RECURSIVE_MAKE} ${MAKEFLAGS} build-depends-list | ${SORT} -u`
292 @
${ECHO} '" to build.'
296 .PHONY
: print-run-depends-list
297 .if
!target
(print-run-depends-list
)
298 print-run-depends-list
:
300 @
${ECHO_N} 'This package requires package(s) "'
301 @
${ECHO_N} `${RECURSIVE_MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u`
306 # This target is used by the mk/scripts/mkreadme script to generate
308 .PHONY
: print-summary-data
309 .if
!target
(print-summary-data
)
311 @
${ECHO} depends
${PKGPATH} ${DEPENDS
:Q
}
312 @
${ECHO} build_depends
${PKGPATH} ${BUILD_DEPENDS
:Q
}
313 @
${ECHO} conflicts
${PKGPATH} ${CONFLICTS
:Q
}
314 @
${ECHO} index
${PKGPATH} ${PKGNAME
:Q
}
315 @
${ECHO} htmlname
${PKGPATH} ${_HTML_PKGLINK
:Q
}
316 @
${ECHO} homepage
${PKGPATH} ${HOMEPAGE
:Q
}
317 @
${ECHO} wildcard ${PKGPATH} ${PKGWILDCARD
:Q
}
318 @
${ECHO} comment
${PKGPATH} ${COMMENT
:Q
}
319 @
${ECHO} license
${PKGPATH} ${LICENSE
:Q
}
320 @if
[ "${ONLY_FOR_PLATFORM}" = "" ]; then \
321 ${ECHO} "onlyfor ${PKGPATH} any"; \
323 ${ECHO} "onlyfor ${PKGPATH} ${ONLY_FOR_PLATFORM}"; \
325 @if
[ "${NOT_FOR_PLATFORM}" = "" ]; then \
326 ${ECHO} "notfor ${PKGPATH} any"; \
328 ${ECHO} "notfor ${PKGPATH} not ${NOT_FOR_PLATFORM}"; \
330 @if
[ -n
"${OWNER}" ]; then \
331 ${ECHO} "owner ${PKGPATH} ${OWNER}"; \
333 ${ECHO} "maintainer ${PKGPATH} ${MAINTAINER}"; \
335 @
${ECHO} "categories ${PKGPATH} ${CATEGORIES}"
336 @if
[ -f
"${DESCR_SRC}" ]; then \
337 ${ECHO} "descr ${PKGPATH} ${DESCR_SRC:S;${PKGSRCDIR}/;;g}"; \
339 ${ECHO} "descr ${PKGPATH} /dev/null"; \
341 @
${ECHO} "prefix ${PKGPATH} ${PREFIX}"