pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk/pkgformat/pkg mk: pkgformat performance improvements.
details: https://anonhg.NetBSD.org/pkgsrc/rev/f4ec3dca7569
branches: trunk
changeset: 388593:f4ec3dca7569
user: jperkin <jperkin%pkgsrc.org@localhost>
date: Wed Nov 23 11:17:51 2022 +0000
description:
mk: pkgformat performance improvements.
Inline ${RUN} calls where appropriate. Only call mkdir when necessary.
Remove useless use of cat(1). Avoid unnecessary expr(1). Use bmake
loop expansion. Avoid unnecessary temporary files.
Saves around 50 execs per build.
diffstat:
mk/pkgformat/pkg/check.mk | 9 +-
mk/pkgformat/pkg/depends.mk | 19 +-
mk/pkgformat/pkg/metadata.mk | 234 +++++++++++++++++++++---------------------
mk/pkgformat/pkg/package.mk | 23 ++-
mk/pkgformat/pkg/scripts.mk | 20 ++-
5 files changed, 157 insertions(+), 148 deletions(-)
diffs (truncated from 501 to 300 lines):
diff -r 9514e3a438a1 -r f4ec3dca7569 mk/pkgformat/pkg/check.mk
--- a/mk/pkgformat/pkg/check.mk Wed Nov 23 11:04:42 2022 +0000
+++ b/mk/pkgformat/pkg/check.mk Wed Nov 23 11:17:51 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check.mk,v 1.2 2020/05/28 16:22:58 maya Exp $
+# $NetBSD: check.mk,v 1.3 2022/11/23 11:17:51 jperkin Exp $
#
# _pkgformat-check-vulnerable:
@@ -24,9 +24,10 @@
@${AUDIT_PACKAGES} ${_AUDIT_PACKAGES_CMD} ${AUDIT_PACKAGES_FLAGS} ${PKGNAME} || ${TRUE}
. endif
. else
- @${PHASE_MSG} "Skipping vulnerability checks."
- @${WARNING_MSG} "No ${_VULNFILE} file found."
- @${WARNING_MSG} "To fix run: \`${DOWNLOAD_VULN_LIST}'."
+ ${RUN} \
+ ${PHASE_MSG} "Skipping vulnerability checks."; \
+ ${WARNING_MSG} "No ${_VULNFILE} file found."; \
+ ${WARNING_MSG} "To fix run: \`${DOWNLOAD_VULN_LIST}'."
. endif
.endif
diff -r 9514e3a438a1 -r f4ec3dca7569 mk/pkgformat/pkg/depends.mk
--- a/mk/pkgformat/pkg/depends.mk Wed Nov 23 11:04:42 2022 +0000
+++ b/mk/pkgformat/pkg/depends.mk Wed Nov 23 11:17:51 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: depends.mk,v 1.15 2022/03/28 10:49:12 tnn Exp $
+# $NetBSD: depends.mk,v 1.16 2022/11/23 11:17:51 jperkin Exp $
# This command prints out the dependency patterns for all full (run-time)
# dependencies of the package.
@@ -109,11 +109,10 @@
esac; \
case $$type in \
bootstrap|tool) \
- if expr "${USE_CROSS_COMPILE:Uno}" : '[yY][eE][sS]' >/dev/null; then \
- extradep=""; \
- else \
- extradep=" ${PKGNAME}"; \
- fi; \
+ case "${USE_CROSS_COMPILE:Uno:tl}" in \
+ yes) extradep="" ;; \
+ *) extradep=" ${PKGNAME}" ;; \
+ esac; \
cross=no; \
archopt=TARGET_ARCH=${MACHINE_ARCH}; \
pkg=`${_HOST_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \
@@ -176,8 +175,9 @@
esac
${_DEPENDS_FILE}:
- ${RUN} ${MKDIR} ${.TARGET:H}
- ${RUN} ${_LIST_DEPENDS_CMD} > ${.TARGET} || (${RM} -f ${.TARGET} && ${FALSE})
+ ${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ ${_LIST_DEPENDS_CMD} > ${.TARGET} || (${RM} -f ${.TARGET} && ${FALSE})
${_RDEPENDS_FILE}: ${_DEPENDS_FILE}
${RUN} ${_RESOLVE_DEPENDS_CMD} > ${.TARGET} || (${RM} -f ${.TARGET} && ${FALSE})
@@ -195,11 +195,10 @@
${RUN} \
${TEST} -n "${PKG_DBDIR_ERROR}" && ${ERROR_MSG} ${PKG_DBDIR_ERROR:Q} && exit 1; \
exec 3<&0; \
- ${CAT} ${_DEPENDS_FILE} | \
while read type pattern dir; do \
${TEST} "$$type" != "bootstrap" || continue; \
${_DEPENDS_INSTALL_CMD} 0<&3; \
- done
+ done < ${_DEPENDS_FILE}
# _pkgformat-post-install-dependencies:
# Targets after installing all dependencies.
diff -r 9514e3a438a1 -r f4ec3dca7569 mk/pkgformat/pkg/metadata.mk
--- a/mk/pkgformat/pkg/metadata.mk Wed Nov 23 11:04:42 2022 +0000
+++ b/mk/pkgformat/pkg/metadata.mk Wed Nov 23 11:17:51 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: metadata.mk,v 1.33 2022/04/04 11:23:07 riastradh Exp $
+# $NetBSD: metadata.mk,v 1.34 2022/11/23 11:17:51 jperkin Exp $
######################################################################
### The targets below are all PRIVATE.
@@ -13,7 +13,7 @@
unprivileged-install-hook: ${PKG_DB_TMPDIR}
${PKG_DB_TMPDIR}:
- ${RUN}${MKDIR} ${.TARGET}
+ @${MKDIR} ${.TARGET}
######################################################################
###
@@ -34,36 +34,43 @@
.endif
${_BUILD_INFO_FILE}: ${_PLIST_NOKEYWORDS}
- ${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${RM} -f ${.TARGET}.tmp
- ${RUN} (${_BUILD_DEFS:NPATH:@v@${ECHO} ${v}=${_BUILD_DEFS.${v}:Q:U${${v}:Q}} ;@}) \
- > ${.TARGET}.tmp
-.if !empty(USE_LANGUAGES)
- ${RUN}${ECHO} "CC_VERSION=${CC_VERSION}" >> ${.TARGET}.tmp
-.endif
-.if !empty(USE_TOOLS:Mperl\:run)
- ${RUN}${ECHO} "PERL=`${PERL5} --version 2>/dev/null | ${GREP} 'This is perl'`" >> ${.TARGET}.tmp
-.endif
-.if !empty(USE_TOOLS:Mgmake)
- ${RUN}${ECHO} "GMAKE=`${GMAKE} --version | ${GREP} Make`" >> ${.TARGET}.tmp
-.endif
- ${RUN}${ECHO} "PKGTOOLS_VERSION=${PKGTOOLS_VERSION_REQD}" >> ${.TARGET}.tmp
-.if defined(HOMEPAGE)
- ${RUN}${ECHO} "HOMEPAGE=${HOMEPAGE}" >> ${.TARGET}.tmp
-.endif
- ${RUN}${ECHO} "CATEGORIES=${CATEGORIES}" >> ${.TARGET}.tmp
- ${RUN}${ECHO} "MAINTAINER=${MAINTAINER}" >> ${.TARGET}.tmp
-.if defined(OWNER)
- ${RUN}${ECHO} "OWNER=${OWNER}" >> ${.TARGET}.tmp
-.endif
-.if defined(PREV_PKGPATH)
- ${RUN}${ECHO} "PREV_PKGPATH=${PREV_PKGPATH}" >> ${.TARGET}.tmp
-.endif
-.if defined(SUPERSEDES)
- ${RUN}${ECHO} "SUPERSEDES=${SUPERSEDES}" >> ${.TARGET}.tmp
-.endif
- ${RUN}${ECHO} "BUILD_DATE=${_BUILD_DATE_cmd:sh}" >> ${.TARGET}.tmp
- ${RUN}${ECHO} "BUILD_HOST=${_BUILD_HOST_cmd:sh}" >> ${.TARGET}.tmp
+ ${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ { \
+ (${_BUILD_DEFS:NPATH:@v@ \
+ ${ECHO} ${v}=${_BUILD_DEFS.${v}:Q:U${${v}:Q}}; \
+ @}); \
+ if [ -n "${USE_LANGUAGES}" ]; then \
+ ${ECHO} "CC_VERSION=${CC_VERSION}"; \
+ fi; \
+ case "${USE_TOOLS}" in \
+ *perl:run*) \
+ ${ECHO} "PERL=`${PERL5} --version 2>/dev/null | \
+ ${GREP} 'This is perl'`" || ${TRUE}; \
+ esac; \
+ case "${USE_TOOLS}" in \
+ *gmake*) \
+ ${ECHO} "GMAKE=`${GMAKE} --version | \
+ ${GREP} Make`" || ${TRUE}; \
+ esac; \
+ ${ECHO} "PKGTOOLS_VERSION=${PKGTOOLS_VERSION_REQD}"; \
+ if [ -n "${HOMEPAGE}" ]; then \
+ ${ECHO} "HOMEPAGE=${HOMEPAGE}"; \
+ fi; \
+ ${ECHO} "CATEGORIES=${CATEGORIES}"; \
+ ${ECHO} "MAINTAINER=${MAINTAINER}"; \
+ if [ -n "${OWNER}" ]; then \
+ ${ECHO} "OWNER=${OWNER}"; \
+ fi; \
+ if [ -n "${PREV_PKGPATH}" ]; then \
+ ${ECHO} "PREV_PKGPATH=${PREV_PKGPATH}"; \
+ fi; \
+ if [ -n "${SUPERSEDES}" ]; then \
+ ${ECHO} "SUPERSEDES=${SUPERSEDES}"; \
+ fi; \
+ ${ECHO} "BUILD_DATE=${_BUILD_DATE_cmd:sh}"; \
+ ${ECHO} "BUILD_HOST=${_BUILD_HOST_cmd:sh}"; \
+ } > ${.TARGET}.tmp
.if !empty(CHECK_SHLIBS_SUPPORTED:M[yY][eE][sS])
${RUN} \
case ${LDD:Q}"" in \
@@ -124,7 +131,6 @@
done
.endif
${RUN} \
- rm -f ${.TARGET}; \
sort ${.TARGET}.tmp > ${.TARGET}; \
rm -f ${.TARGET}.tmp
@@ -139,76 +145,68 @@
_METADATA_TARGETS+= ${_BUILD_VERSION_FILE}
.if !empty(USE_PKG_ADMIN_DIGEST:M[Yy][Ee][Ss])
${_BUILD_VERSION_FILE}:
- ${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${RM} -f ${.TARGET}.tmp
${RUN} \
- exec 1>>${.TARGET}.tmp; \
- ${FIND} ${FILESDIR} -type f 2> /dev/null | while read f; do \
- ${TEST} ! -f "$$f" || ${ECHO} "$$f"; \
- done
- ${RUN} \
- exec 1>>${.TARGET}.tmp; \
- for f in ${.CURDIR}/Makefile ${PKGDIR}/*; do \
- ${TEST} ! -f "$$f" || ${ECHO} "$$f"; \
- done
- ${RUN} \
- exec 1>>${.TARGET}.tmp; \
- ${TEST} -f ${DISTINFO_FILE:Q} || exit 0; \
- ${CAT} ${DISTINFO_FILE} | \
- ${AWK} 'NF == 4 && $$3 == "=" { gsub("[()]", "", $$2); print $$2 }' | \
- while read file; do \
- ${TEST} ! -f "${PATCHDIR}/$$file" || \
- ${ECHO} "${PATCHDIR}/$$file"; \
- done
- ${RUN} \
- exec 1>>${.TARGET}.tmp; \
- ${TEST} -d ${PATCHDIR} || exit 0; \
- cd ${PATCHDIR}; for f in *; do \
- case "$$f" in \
- "*"|*.orig|*.rej|*~) ;; \
- patch-*) ${ECHO} "${PATCHDIR}/$$f" ;; \
- esac; \
- done
- ${RUN} \
- ${CAT} ${.TARGET}.tmp | \
- ${AWK} '{ t=$$0; sub("^${PKGSRCDIR}/", ""); \
- printf "%s %s\n", t, $$0 }' | \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ { \
+ ${FIND} ${FILESDIR} -type f 2>/dev/null | \
+ while read f; do \
+ [ -f "$$f" ] && ${ECHO} "$$f"; \
+ done; \
+ for f in ${.CURDIR}/Makefile ${PKGDIR}/*; do \
+ [ -f "$$f" ] && ${ECHO} "$$f"; \
+ done; \
+ if [ -f ${DISTINFO_FILE:Q} ]; then \
+ ${AWK} 'NF == 4 && $$3 == "=" { \
+ gsub("[()]", "", $$2); print $$2; \
+ }' ${DISTINFO_FILE} | \
+ while read file; do \
+ [ -f "${PATCHDIR}/$$file" ] && \
+ ${ECHO} "${PATCHDIR}/$$file"; \
+ done; \
+ fi; \
+ if [ -d ${PATCHDIR} ]; then \
+ cd ${PATCHDIR}; for f in *; do \
+ case "$$f" in \
+ "*"|*.orig|*.rej|*~) ;; \
+ patch-*) ${ECHO} "${PATCHDIR}/$$f" ;; \
+ esac; \
+ done; \
+ fi; \
+ } | ${AWK} '{ t=$$0; sub("^${PKGSRCDIR}/", ""); \
+ printf "%s %s\n", t, $$0 }' | \
while read file relfile; do \
printf "%s: " "$$relfile"; \
${PKG_ADMIN} digest "$$file"; \
done | \
- ${SORT} -u > ${.TARGET} && ${RM} -f ${.TARGET}.tmp
+ ${SORT} -u > ${.TARGET}
.else
${_BUILD_VERSION_FILE}:
- ${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${RM} -f ${.TARGET}.tmp
${RUN} \
- exec 1>>${.TARGET}.tmp; \
- for f in ${.CURDIR}/Makefile ${FILESDIR:tA}/* ${PKGDIR:tA}/*; do \
- ${TEST} ! -f "$$f" || ${ECHO} "$$f"; \
- done
- ${RUN} \
- exec 1>>${.TARGET}.tmp; \
- ${TEST} -f ${DISTINFO_FILE:Q} || exit 0; \
- ${CAT} ${DISTINFO_FILE} | \
- ${AWK} 'NF == 4 && $$3 == "=" { gsub("[()]", "", $$2); print $$2 }' | \
- while read file; do \
- ${TEST} ! -f "${PATCHDIR}/$$file" || \
- ${ECHO} "${PATCHDIR:tA}/$$file"; \
- done
- ${RUN} \
- exec 1>>${.TARGET}.tmp; \
- ${TEST} -d ${PATCHDIR} || exit 0; \
- cd ${PATCHDIR}; for f in *; do \
- case "$$f" in \
- "*"|*.orig|*.rej|*~) ;; \
- patch-*) ${ECHO} "${PATCHDIR:tA}/$$f" ;; \
- esac; \
- done
- ${RUN} \
- ${CAT} ${.TARGET}.tmp | \
- ${AWK} '{ t=$$0; sub("^${PKGSRCDIR}/", ""); \
- printf "%s %s\n", t, $$0 }' | \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ { \
+ for f in ${.CURDIR}/Makefile ${FILESDIR:tA}/* \
+ ${PKGDIR:tA}/*; do \
+ [ -f "$$f" ] && ${ECHO} "$$f"; \
+ done; \
+ if [ -f ${DISTINFO_FILE:Q} ]; then \
+ ${AWK} 'NF == 4 && $$3 == "=" { \
+ gsub("[()]", "", $$2); print $$2; \
+ }' ${DISTINFO_FILE} | \
+ while read file; do \
+ [ -f "${PATCHDIR}/$$file" ] && \
+ ${ECHO} "${PATCHDIR:tA}/$$file"; \
+ done; \
+ fi; \
+ if [ -d ${PATCHDIR} ]; then \
+ cd ${PATCHDIR}; for f in *; do \
+ case "$$f" in \
+ "*"|*.orig|*.rej|*~) ;; \
+ patch-*) ${ECHO} "${PATCHDIR:tA}/$$f" ;; \
+ esac; \
+ done; \
+ fi; \
+ } | ${AWK} '{ t=$$0; sub("^${PKGSRCDIR}/", ""); \
Home |
Main Index |
Thread Index |
Old Index