pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk/pkginstall mk: pkginstall performance improvements.
details: https://anonhg.NetBSD.org/pkgsrc/rev/9559e988194d
branches: trunk
changeset: 388595:9559e988194d
user: jperkin <jperkin%pkgsrc.org@localhost>
date: Wed Nov 23 11:32:47 2022 +0000
description:
mk: pkginstall performance improvements.
Inline ${RUN} calls where appropriate. Use builtin "test -s" instead of
our custom awk script when testing single files for zero size. Avoid
unnecessary calls to mkdir and rm. Improve logic of certain targets that
would previously perform some work, only to later remove it if a certain
condition failed.
Saves around 100 execs per build.
diffstat:
mk/pkginstall/bsd.pkginstall.mk | 228 ++++++++++++++++++---------------------
1 files changed, 103 insertions(+), 125 deletions(-)
diffs (truncated from 516 to 300 lines):
diff -r bb134d1052fb -r 9559e988194d mk/pkginstall/bsd.pkginstall.mk
--- a/mk/pkginstall/bsd.pkginstall.mk Wed Nov 23 11:26:51 2022 +0000
+++ b/mk/pkginstall/bsd.pkginstall.mk Wed Nov 23 11:32:47 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.76 2022/05/14 21:48:51 dholland Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.77 2022/11/23 11:32:47 jperkin Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and implements the
# common INSTALL/DEINSTALL scripts framework. To use the pkginstall
@@ -279,17 +279,15 @@
.endfor
${_INSTALL_USERGROUP_DATAFILE}:
- ${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ exec 1>>${.TARGET}; \
set -- dummy ${_PKG_GROUPS:C/\:*$//}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
i="$$1"; shift; \
${ECHO} "# GROUP: $$i"; \
- done
- ${RUN} \
+ done; \
set -- dummy ${_PKG_USERS:C/\:*$//}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
i="$$1"; shift; \
${ECHO} "# USER: $$i"; \
@@ -299,13 +297,13 @@
${_INSTALL_USERGROUP_FILE}: \
../../mk/pkginstall/usergroup \
${INSTALL_USERGROUPFUNCS_FILE}
- ${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
- ${SED} -e "/^# platform-specific adduser\/addgroup functions/r${_INSTALL_USERGROUPFUNCS_FILE}" ../../mk/pkginstall/usergroup | \
- ${SED} ${FILES_SUBST_SED} > ${.TARGET}
- ${RUN} \
- if ${_ZERO_FILESIZE_P} ${_INSTALL_USERGROUP_DATAFILE}; then \
- ${RM} -f ${.TARGET}; \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ if [ -s ${_INSTALL_USERGROUP_DATAFILE} ]; then \
+ ${SED} -e "/^# platform-specific adduser\/addgroup functions/r${_INSTALL_USERGROUPFUNCS_FILE}" \
+ ../../mk/pkginstall/usergroup | \
+ ${SED} ${FILES_SUBST_SED} > ${.TARGET}; \
+ else \
${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
fi
@@ -314,8 +312,8 @@
${_INSTALL_USERGROUP_UNPACKER}: \
${_INSTALL_USERGROUP_FILE} \
${_INSTALL_USERGROUP_DATAFILE}
- ${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
exec 1>${.TARGET}; \
${ECHO} "#!${SH}"; \
${ECHO} ""; \
@@ -326,9 +324,8 @@
${ECHO} "SELF=\$$0"; \
${ECHO} "STAGE=UNPACK"; \
${ECHO} ""; \
- ${CAT} ${_INSTALL_USERGROUP_FILE} \
- ${_INSTALL_USERGROUP_DATAFILE}
- ${RUN}${CHMOD} +x ${.TARGET}
+ ${CAT} ${_INSTALL_USERGROUP_FILE} ${_INSTALL_USERGROUP_DATAFILE}; \
+ ${CHMOD} +x ${.TARGET}
.if defined(USERGROUP_PHASE)
. if !empty(USERGROUP_PHASE:M*configure)
@@ -422,8 +419,9 @@
_INSTALL_DATA_TMPL+= ${_INSTALL_PERMS_DATAFILE}
${_INSTALL_PERMS_DATAFILE}:
- ${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ ${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ ${_PKGINSTALL_FUNCS_SH}; \
set -- dummy ${SPECIAL_PERMS}; shift; \
exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
@@ -435,12 +433,12 @@
${_INSTALL_PERMS_FILE}: ${_INSTALL_PERMS_DATAFILE}
${_INSTALL_PERMS_FILE}: ../../mk/pkginstall/perms
- ${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
- ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/perms > ${.TARGET}
- ${RUN} \
- if ${_ZERO_FILESIZE_P} ${_INSTALL_PERMS_DATAFILE}; then \
- ${RM} -f ${.TARGET}; \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ if [ -s ${_INSTALL_PERMS_DATAFILE} ]; then \
+ ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/perms \
+ > ${.TARGET}; \
+ else \
${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
fi
@@ -544,19 +542,18 @@
done
${_INSTALL_FILES_DATAFILE}:
- ${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ ${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ ${_PKGINSTALL_FUNCS_SH}; \
+ exec 1>>${.TARGET}; \
set -- dummy ${_INSTALL_RCD_SCRIPTS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
script="$$1"; shift; \
file="${RCD_SCRIPTS_DIR:S/^${PREFIX}\///}/$$script"; \
egfile="${RCD_SCRIPTS_EXAMPLEDIR}/$$script"; \
${ECHO} "# FILE: $$file cr $$egfile ${RCD_SCRIPTS_MODE}"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${CONF_FILES}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
egfile="$$1"; file="$$2"; \
shift; shift; \
@@ -565,20 +562,16 @@
file=`strip_prefix "$$file"`; \
file=`shquote_backslash "$$file"`; \
${ECHO} "# FILE: $$file c $$egfile ${CONF_FILES_MODE}"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${REQD_FILES}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
egfile="$$1"; file="$$2"; \
shift; shift; \
egfile=`strip_prefix "$$egfile"`; \
file=`strip_prefix "$$file"`; \
${ECHO} "# FILE: $$file cf $$egfile ${REQD_FILES_MODE}"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${CONF_FILES_PERMS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
egfile="$$1"; file="$$2"; \
owner="$$3"; group="$$4"; mode="$$5"; \
@@ -586,10 +579,8 @@
egfile=`strip_prefix "$$egfile"`; \
file=`strip_prefix "$$file"`; \
${ECHO} "# FILE: $$file c $$egfile $$mode $$owner $$group"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${REQD_FILES_PERMS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
egfile="$$1"; file="$$2"; \
owner="$$3"; group="$$4"; mode="$$5"; \
@@ -601,12 +592,12 @@
${_INSTALL_FILES_FILE}: ${_INSTALL_FILES_DATAFILE}
${_INSTALL_FILES_FILE}: ../../mk/pkginstall/files
- ${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
- ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/files > ${.TARGET}
- ${RUN} \
- if ${_ZERO_FILESIZE_P} ${_INSTALL_FILES_DATAFILE}; then \
- ${RM} -f ${.TARGET}; \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ if [ -s ${_INSTALL_FILES_DATAFILE} ]; then \
+ ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/files \
+ > ${.TARGET}; \
+ else \
${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
fi
@@ -649,8 +640,9 @@
_INSTALL_DATA_TMPL+= ${_INSTALL_DIRS_DATAFILE}
${_INSTALL_DIRS_DATAFILE}:
- ${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ ${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ ${_PKGINSTALL_FUNCS_SH}; \
exec 1>>${.TARGET}; \
case ${PKG_SYSCONFSUBDIR:M*:Q}${CONF_FILES:M*:Q}${CONF_FILES_PERMS:M*:Q}"" in \
"") ;; \
@@ -667,58 +659,44 @@
;; \
esac; \
;; \
- esac
- ${RUN} \
- exec 1>>${.TARGET}; \
+ esac; \
case ${_INSTALL_RCD_SCRIPTS:M*:Q}"" in \
"") ;; \
*) ${ECHO} "# DIR: ${RCD_SCRIPTS_DIR:S/${PREFIX}\///} m" ;; \
- esac
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ esac; \
set -- dummy ${MAKE_DIRS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; shift; \
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir m"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${REQD_DIRS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; shift; \
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir fm"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${OWN_DIRS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; shift; \
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir mo"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${MAKE_DIRS_PERMS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
shift; shift; shift; shift; \
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir m $$mode $$owner $$group"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${REQD_DIRS_PERMS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
shift; shift; shift; shift; \
dir=`strip_prefix "$$dir"`; \
${ECHO} "# DIR: $$dir fm $$mode $$owner $$group"; \
- done
- ${RUN}${_PKGINSTALL_FUNCS_SH}; \
+ done; \
set -- dummy ${OWN_DIRS_PERMS}; shift; \
- exec 1>>${.TARGET}; \
while ${TEST} $$# -gt 0; do \
dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \
shift; shift; shift; shift; \
@@ -728,12 +706,12 @@
${_INSTALL_DIRS_FILE}: ${_INSTALL_DIRS_DATAFILE}
${_INSTALL_DIRS_FILE}: ../../mk/pkginstall/dirs
- ${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
- ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/dirs > ${.TARGET}
- ${RUN} \
- if ${_ZERO_FILESIZE_P} ${_INSTALL_DIRS_DATAFILE}; then \
- ${RM} -f ${.TARGET}; \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ if [ -s ${_INSTALL_DIRS_DATAFILE} ]; then \
+ ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/dirs \
+ > ${.TARGET}; \
+ else \
${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
fi
@@ -756,18 +734,18 @@
.endif
${_INSTALL_INFO_FILES_DATAFILE}:
- ${RUN}${MKDIR} ${.TARGET:H}
- ${RUN}${RM} -f ${.TARGET}
- ${RUN}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
+ ${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
+ ${TOUCH} ${TOUCH_ARGS} ${.TARGET}
${_INSTALL_INFO_FILES_FILE}: ${_INSTALL_INFO_FILES_DATAFILE}
${_INSTALL_INFO_FILES_FILE}: ../../mk/pkginstall/info-files
- ${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
+ ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/info-files > ${.TARGET}
.if !defined(INFO_FILES)
${RUN} \
- if ${_ZERO_FILESIZE_P} ${_INSTALL_INFO_FILES_DATAFILE}; then \
+ if [ ! -s ${_INSTALL_INFO_FILES_DATAFILE} ]; then \
${RM} -f ${.TARGET}; \
${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
fi
Home |
Main Index |
Thread Index |
Old Index