pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/mk/check



Module Name:    pkgsrc
Committed By:   jperkin
Date:           Wed Nov 23 11:55:43 UTC 2022

Modified Files:
        pkgsrc/mk/check: check-files.mk check-headers.mk check-interpreter.mk
            check-perms.mk check-pie.mk check-portability.mk check-relro.mk
            check-shlibs.mk check-ssp.mk check-stripped.mk check-wrkref.mk

Log Message:
mk: check performance improvements.

Inline ${RUN} calls where appropriate.  Avoid useless use of cat(1).  Avoid
unnecessary calls to rm.  Use xargs(1) to reduce number of calls to egrep,
previously it was called once per file.

The last change in particular can have huge performance improvements, for
example saving around 5,000 execs during the build of ansible-core, and
significantly reducing the build and system times.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 pkgsrc/mk/check/check-files.mk
cvs rdiff -u -r1.7 -r1.8 pkgsrc/mk/check/check-headers.mk \
    pkgsrc/mk/check/check-relro.mk
cvs rdiff -u -r1.31 -r1.32 pkgsrc/mk/check/check-interpreter.mk
cvs rdiff -u -r1.22 -r1.23 pkgsrc/mk/check/check-perms.mk
cvs rdiff -u -r1.3 -r1.4 pkgsrc/mk/check/check-pie.mk \
    pkgsrc/mk/check/check-ssp.mk
cvs rdiff -u -r1.19 -r1.20 pkgsrc/mk/check/check-portability.mk
cvs rdiff -u -r1.34 -r1.35 pkgsrc/mk/check/check-shlibs.mk
cvs rdiff -u -r1.6 -r1.7 pkgsrc/mk/check/check-stripped.mk
cvs rdiff -u -r1.25 -r1.26 pkgsrc/mk/check/check-wrkref.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/mk/check/check-files.mk
diff -u pkgsrc/mk/check/check-files.mk:1.37 pkgsrc/mk/check/check-files.mk:1.38
--- pkgsrc/mk/check/check-files.mk:1.37 Sun Dec 20 19:49:25 2020
+++ pkgsrc/mk/check/check-files.mk      Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-files.mk,v 1.37 2020/12/20 19:49:25 gutteridge Exp $
+# $NetBSD: check-files.mk,v 1.38 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that the list of installed files matches the PLIST.
 # For that purpose it records the file list of LOCALBASE before and
@@ -279,7 +279,7 @@ ${_CHECK_FILES_MISSING}: ${_CHECK_FILES_
 
 ${_CHECK_FILES_MISSING_REAL}: ${_CHECK_FILES_MISSING}
        ${RUN}                                  \
-       ${CAT} ${_CHECK_FILES_MISSING} | ${_CHECK_FILES_SKIP_FILTER}    \
+       ${_CHECK_FILES_SKIP_FILTER} < ${_CHECK_FILES_MISSING}           \
                > ${.TARGET} || ${TRUE}
 
 ${_CHECK_FILES_MISSING_SKIP}:                                          \
@@ -305,29 +305,26 @@ ${_CHECK_FILES_ERRMSG.prefix}:                                            \
                ${_CHECK_FILES_MISSING_REAL}                            \
                ${_CHECK_FILES_MISSING_SKIP}                            \
                ${_CHECK_FILES_EXTRA}
-       ${RUN}${RM} -f ${.TARGET}
-       ${RUN}                                  \
-       if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_DELETED}; then         \
+       ${RUN}                                                          \
+       ${RM} -f ${.TARGET};                                            \
+       if [ -s ${_CHECK_FILES_DELETED} ]; then                         \
                ${ECHO} "The following files have been deleted"         \
                        "from ${PREFIX}!";                              \
                ${SED} "s|^|        |" ${_CHECK_FILES_DELETED};         \
-       fi >> ${.TARGET}
-       ${RUN}                                  \
-       if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_MISSING_REAL}; then    \
+       fi >> ${.TARGET};                                               \
+       if [ -s ${_CHECK_FILES_MISSING_REAL} ]; then                    \
                ${ECHO} "************************************************************"; \
                ${ECHO} "The following files are in the"                \
-                       "PLIST but not in ${DESTDIR}${PREFIX}:";                        \
+                       "PLIST but not in ${DESTDIR}${PREFIX}:";        \
                ${SED} "s|^|        |" ${_CHECK_FILES_MISSING_REAL};    \
-       fi >> ${.TARGET}
-       ${RUN}                                  \
-       if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_EXTRA}; then           \
+       fi >> ${.TARGET};                                               \
+       if [ -s ${_CHECK_FILES_EXTRA} ]; then                           \
                ${ECHO} "************************************************************"; \
                ${ECHO} "The following files are in"                    \
-                       "${DESTDIR}${PREFIX} but not in the PLIST:";            \
+                       "${DESTDIR}${PREFIX} but not in the PLIST:";    \
                ${SED} "s|^|        |" ${_CHECK_FILES_EXTRA};           \
-       fi >> ${.TARGET}
-       ${RUN}                                  \
-       if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_MISSING_SKIP}; then    \
+       fi >> ${.TARGET};                                               \
+       if [ -s ${_CHECK_FILES_MISSING_SKIP} ]; then                    \
                ${ECHO} "************************************************************"; \
                ${ECHO} "The following files are in both the"           \
                        "PLIST and CHECK_FILES_SKIP:";                  \

Index: pkgsrc/mk/check/check-headers.mk
diff -u pkgsrc/mk/check/check-headers.mk:1.7 pkgsrc/mk/check/check-headers.mk:1.8
--- pkgsrc/mk/check/check-headers.mk:1.7        Sun Oct 12 23:39:17 2014
+++ pkgsrc/mk/check/check-headers.mk    Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-headers.mk,v 1.7 2014/10/12 23:39:17 joerg Exp $
+# $NetBSD: check-headers.mk,v 1.8 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks the C and C++ header files for possible problems.
 #
@@ -32,9 +32,9 @@ pre-build-checks-hook: _check-headers
 
 .PHONY: _check-headers
 _check-headers:
-       @${STEP_MSG} "Checking for possible problems in header files"
        ${RUN}                                                          \
+       ${STEP_MSG} "Checking for possible problems in header files";   \
        [ -d ${WRKSRC}/. ] || exit 0;                                   \
        cd ${WRKSRC};                                                   \
-       env     SKIP_FILTER=${CHECK_HEADERS_SKIP:@p@${p}) skip=yes;;@:Q} \
+       env SKIP_FILTER=${CHECK_HEADERS_SKIP:@p@${p}) skip=yes;;@:Q}    \
                sh ${PKGSRCDIR}/mk/check/check-headers.sh
Index: pkgsrc/mk/check/check-relro.mk
diff -u pkgsrc/mk/check/check-relro.mk:1.7 pkgsrc/mk/check/check-relro.mk:1.8
--- pkgsrc/mk/check/check-relro.mk:1.7  Thu Aug 18 00:19:34 2022
+++ pkgsrc/mk/check/check-relro.mk      Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-relro.mk,v 1.7 2022/08/18 00:19:34 joerg Exp $
+# $NetBSD: check-relro.mk,v 1.8 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file verifies that RELRO (read-only relocations) was applied
 # accordingly at build-time.
@@ -69,9 +69,8 @@ CHECK_RELRO_NATIVE_ENV+=      CHECK_WRKREF_EX
 
 privileged-install-hook: _check-relro
 _check-relro: error-check .PHONY
-       @${STEP_MSG} "Checking for RELRO in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
-       ${RUN}                                  \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking for RELRO in ${PKGNAME}";                 \
        cd ${DESTDIR:Q}${PREFIX:Q};                                     \
        ${_CHECK_RELRO_FILELIST_CMD} |                                  \
        ${EGREP} -h ${_CHECK_RELRO_ERE:Q} |                             \

Index: pkgsrc/mk/check/check-interpreter.mk
diff -u pkgsrc/mk/check/check-interpreter.mk:1.31 pkgsrc/mk/check/check-interpreter.mk:1.32
--- pkgsrc/mk/check/check-interpreter.mk:1.31   Fri Mar 11 21:11:47 2016
+++ pkgsrc/mk/check/check-interpreter.mk        Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-interpreter.mk,v 1.31 2016/03/11 21:11:47 dholland Exp $
+# $NetBSD: check-interpreter.mk,v 1.32 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that after installation, all files of the package
 # that start with a "#!" line will find their interpreter. Files that
@@ -45,8 +45,9 @@ privileged-install-hook: _check-interpre
 .endif
 
 _check-interpreter: error-check .PHONY
-       @${STEP_MSG} "Checking for non-existent script interpreters in ${PKGNAME}"
-       ${RUN} cd ${DESTDIR}${PREFIX};                                  \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking for non-existent script interpreters in ${PKGNAME}"; \
+       cd ${DESTDIR}${PREFIX};                                         \
        ${_CHECK_INTERP_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g' |\
        while read file; do                                             \
                case "$$file" in                                        \

Index: pkgsrc/mk/check/check-perms.mk
diff -u pkgsrc/mk/check/check-perms.mk:1.22 pkgsrc/mk/check/check-perms.mk:1.23
--- pkgsrc/mk/check/check-perms.mk:1.22 Fri Mar 13 08:04:08 2020
+++ pkgsrc/mk/check/check-perms.mk      Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-perms.mk,v 1.22 2020/03/13 08:04:08 rillig Exp $
+# $NetBSD: check-perms.mk,v 1.23 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that after installation of a package, all files and
 # directories of that package have sensible permissions set.
@@ -73,8 +73,9 @@ _CHECK_PERMS_GETDIRS_AWK=                                             \
        }
 
 _check-perms: .PHONY
-       @${STEP_MSG} "Checking file permissions in ${PKGNAME}"
-       ${RUN} ${HOST_PKG_INFO} -qe "checkperms>=1.1"                   \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking file permissions in ${PKGNAME}";          \
+       ${HOST_PKG_INFO} -qe "checkperms>=1.1"                          \
        || {                                                            \
                ${WARNING_MSG} "[check-perms.mk] Skipping file permissions check."; \
                ${WARNING_MSG} "[check-perms.mk] Install sysutils/checkperms to enable this check."; \

Index: pkgsrc/mk/check/check-pie.mk
diff -u pkgsrc/mk/check/check-pie.mk:1.3 pkgsrc/mk/check/check-pie.mk:1.4
--- pkgsrc/mk/check/check-pie.mk:1.3    Mon Mar  7 16:53:08 2022
+++ pkgsrc/mk/check/check-pie.mk        Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-pie.mk,v 1.3 2022/03/07 16:53:08 nia Exp $
+# $NetBSD: check-pie.mk,v 1.4 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file verifies that MKPIE (position-independent executables) was applied
 # accordingly at build-time.
@@ -60,18 +60,17 @@ _CHECK_PIE_ENV+=    READELF=${TOOLS_PATH.re
        !empty(_CHECK_PIE_CMD)
 privileged-install-hook: _check-pie
 _check-pie: error-check .PHONY
-       @${STEP_MSG} "Checking for PIE in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
        ${RUN}                                                          \
-               cd ${DESTDIR:Q}${PREFIX:Q};                             \
-               ${_CHECK_PIE_FILELIST_CMD} |                            \
-               ${EGREP} -h ${_CHECK_PIE_ERE:Q} |                       \
-               while read file; do                                     \
-                       case "$$file" in                                \
-                               ${CHECK_PIE_SKIP:@p@${p}) continue;;@}  \
-                               *) ${ECHO} "$$file";                    \
-                       esac;                                           \
-               done |                                                  \
-               ${PKGSRC_SETENV} ${_CHECK_PIE_ENV} ${_CHECK_PIE_CMD}    \
-                       > ${ERROR_DIR}/${.TARGET}
+       ${STEP_MSG} "Checking for PIE in ${PKGNAME}";                   \
+       cd ${DESTDIR:Q}${PREFIX:Q};                                     \
+       ${_CHECK_PIE_FILELIST_CMD} |                                    \
+       ${EGREP} -h ${_CHECK_PIE_ERE:Q} |                               \
+       while read file; do                                             \
+               case "$$file" in                                        \
+                       ${CHECK_PIE_SKIP:@p@${p}) continue;;@}          \
+                       *) ${ECHO} "$$file";                            \
+               esac;                                                   \
+       done |                                                          \
+       ${PKGSRC_SETENV} ${_CHECK_PIE_ENV} ${_CHECK_PIE_CMD}            \
+               > ${ERROR_DIR}/${.TARGET}
 .endif
Index: pkgsrc/mk/check/check-ssp.mk
diff -u pkgsrc/mk/check/check-ssp.mk:1.3 pkgsrc/mk/check/check-ssp.mk:1.4
--- pkgsrc/mk/check/check-ssp.mk:1.3    Mon Mar 23 09:25:58 2020
+++ pkgsrc/mk/check/check-ssp.mk        Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-ssp.mk,v 1.3 2020/03/23 09:25:58 jperkin Exp $
+# $NetBSD: check-ssp.mk,v 1.4 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file verifies that stack-smashing protection, commonly known as SSP,
 # was applied correctly at build-time.
@@ -42,9 +42,9 @@ CHECK_SSP_SKIP?=              # none
 _CHECK_SSP_ERE=                (bin/|sbin/|libexec/|\.so$$|lib/lib.*\.so)
 
 _CHECK_SSP_FILELIST_CMD?=      ${SED} -e '/^@/d' ${PLIST} |            \
-       (while read file; do                                            \
+       while read file; do                                             \
                ${TEST} -h "$$file" || ${ECHO} "$$file";                \
-       done)
+       done
 
 .if !empty(CHECK_SSP:M[Yy][Ee][Ss]) && \
     !empty(CHECK_SSP_SUPPORTED:M[Yy][Ee][Ss]) && \
@@ -67,9 +67,8 @@ CHECK_SSP_NATIVE_ENV+=        CHECK_WRKREF_EXTR
 
 privileged-install-hook: _check-ssp
 _check-ssp: error-check .PHONY
-       @${STEP_MSG} "Checking for SSP in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
        ${RUN}                                                  \
+       ${STEP_MSG} "Checking for SSP in ${PKGNAME}";           \
        cd ${DESTDIR:Q}${PREFIX:Q};                             \
        ${_CHECK_SSP_FILELIST_CMD} |                            \
        ${EGREP} -h ${_CHECK_SSP_ERE:Q} |                       \

Index: pkgsrc/mk/check/check-portability.mk
diff -u pkgsrc/mk/check/check-portability.mk:1.19 pkgsrc/mk/check/check-portability.mk:1.20
--- pkgsrc/mk/check/check-portability.mk:1.19   Sun Jun  7 10:42:04 2020
+++ pkgsrc/mk/check/check-portability.mk        Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-portability.mk,v 1.19 2020/06/07 10:42:04 rillig Exp $
+# $NetBSD: check-portability.mk,v 1.20 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that the extracted shell programs don't contain
 # bashisms or other constructs that only work on some platforms.
@@ -44,8 +44,8 @@ pre-configure-checks-hook: _check-portab
 .endif
 .PHONY: _check-portability
 _check-portability:
-       @${STEP_MSG} "Checking for portability problems in extracted files"
        ${RUN}                                                          \
+       ${STEP_MSG} "Checking for portability problems in extracted files"; \
        [ -d ${WRKSRC}/. ] || exit 0;                                   \
        cd ${WRKSRC};                                                   \
        ${SETENV}                                                       \

Index: pkgsrc/mk/check/check-shlibs.mk
diff -u pkgsrc/mk/check/check-shlibs.mk:1.34 pkgsrc/mk/check/check-shlibs.mk:1.35
--- pkgsrc/mk/check/check-shlibs.mk:1.34        Mon Oct 11 20:26:28 2021
+++ pkgsrc/mk/check/check-shlibs.mk     Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-shlibs.mk,v 1.34 2021/10/11 20:26:28 jperkin Exp $
+# $NetBSD: check-shlibs.mk,v 1.35 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file verifies that all libraries used by the package can be found
 # at run-time.
@@ -49,9 +49,9 @@ CHECK_SHLIBS_SKIP?=           # none
 _CHECK_SHLIBS_ERE=     (bin/|sbin/|libexec/|\.(dylib|sl|so)$$|lib/lib.*\.(dylib|sl|so))
 
 _CHECK_SHLIBS_FILELIST_CMD?=   ${SED} -e '/^@/d' ${PLIST} |            \
-       (while read file; do                                            \
+       while read file; do                                             \
                ${TEST} -h "$$file" || ${ECHO} "$$file";                \
-       done)
+       done
 
 .if !empty(CHECK_SHLIBS:M[Yy][Ee][Ss]) && \
     !empty(CHECK_SHLIBS_SUPPORTED:M[Yy][Ee][Ss]) && \
@@ -85,9 +85,8 @@ CHECK_SHLIBS_NATIVE_ENV+=     CHECK_SHLIBS_T
 
 privileged-install-hook: _check-shlibs
 _check-shlibs: error-check .PHONY
-       @${STEP_MSG} "Checking for missing run-time search paths in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
-       ${RUN}                                  \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking for missing run-time search paths in ${PKGNAME}"; \
        cd ${DESTDIR:Q}${PREFIX:Q};                                     \
        ${_CHECK_SHLIBS_FILELIST_CMD} |                                 \
        ${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} |                            \

Index: pkgsrc/mk/check/check-stripped.mk
diff -u pkgsrc/mk/check/check-stripped.mk:1.6 pkgsrc/mk/check/check-stripped.mk:1.7
--- pkgsrc/mk/check/check-stripped.mk:1.6       Sun Oct 12 23:39:17 2014
+++ pkgsrc/mk/check/check-stripped.mk   Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-stripped.mk,v 1.6 2014/10/12 23:39:17 joerg Exp $
+# $NetBSD: check-stripped.mk,v 1.7 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that after installation, all binaries conform to the
 # setting of INSTALL_UNSTRIPPED.
@@ -37,8 +37,9 @@ USE_TOOLS+=   file
 .endif
 
 _check-stripped: error-check .PHONY
-       @${STEP_MSG} "Checking whether binaries are ${_INSTALL_UNSTRIPPED:Dun:U}stripped."
-       ${RUN} cd ${DESTDIR}${PREFIX};                                  \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking whether binaries are ${_INSTALL_UNSTRIPPED:Dun:U}stripped."; \
+       cd ${DESTDIR}${PREFIX};                                         \
        want_stripped=${_INSTALL_UNSTRIPPED:Dno:Uyes};                  \
        ${_CHECK_STRIPPED_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g'\
        | while read file; do                                           \

Index: pkgsrc/mk/check/check-wrkref.mk
diff -u pkgsrc/mk/check/check-wrkref.mk:1.25 pkgsrc/mk/check/check-wrkref.mk:1.26
--- pkgsrc/mk/check/check-wrkref.mk:1.25        Sun Apr 26 14:23:25 2020
+++ pkgsrc/mk/check/check-wrkref.mk     Wed Nov 23 11:55:43 2022
@@ -1,4 +1,4 @@
-# $NetBSD: check-wrkref.mk,v 1.25 2020/04/26 14:23:25 rillig Exp $
+# $NetBSD: check-wrkref.mk,v 1.26 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that the installed files don't contain any strings
 # that point to the directory where the package had been built, to make
@@ -82,10 +82,8 @@ privileged-install-hook: _check-wrkref
 .endif
 
 _check-wrkref: error-check .PHONY
-       @${STEP_MSG} "Checking for work-directory references in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
-       ${RUN}                                  \
-       exec 1>${ERROR_DIR}/${.TARGET};                                 \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking for work-directory references in ${PKGNAME}"; \
        ${_CHECK_WRKREF_FILELIST_CMD} | ${SORT} |                       \
        while read file; do                                             \
                case "$$file" in                                        \
@@ -93,12 +91,16 @@ _check-wrkref: error-check .PHONY
                *) ;;                                                   \
                esac;                                                   \
                ${SHCOMMENT} "[$$file]";                                \
-               ${EGREP} ${_CHECK_WRKREF_DIRS:ts|:Q} "${DESTDIR}$$file" \
-                   2>/dev/null | ${SED} -e "s|^|$$file:        |";     \
-       done
-       ${RUN}                                                          \
+               ${ECHO} "${DESTDIR}$$file" >>${ERROR_DIR}/${.TARGET}.tmp; \
+       done;                                                           \
+       if [ -s ${ERROR_DIR}/${.TARGET}.tmp ]; then                     \
+               ${XARGS} -n 256 ${EGREP} ${_CHECK_WRKREF_DIRS:ts|:Q}    \
+                       < ${ERROR_DIR}/${.TARGET}.tmp 2>/dev/null       \
+                       >${ERROR_DIR}/${.TARGET} || ${TRUE};            \
+               ${RM} -f ${ERROR_DIR}/${.TARGET}.tmp;                   \
+       fi;                                                             \
        exec 1>>${ERROR_DIR}/${.TARGET};                                \
-       if ${_NONZERO_FILESIZE_P} ${ERROR_DIR}/${.TARGET}; then         \
+       if [ -s ${ERROR_DIR}/${.TARGET} ]; then                         \
                ${ECHO} "*** The above files still have references to the build directory."; \
                ${ECHO} "    This is possibly an error that should be fixed by unwrapping"; \
                ${ECHO} "    the files or adding missing tools to the package makefile!"; \



Home | Main Index | Thread Index | Old Index