pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk mk: Minor performance improvement for error-check.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c109bbdfa323
branches:  trunk
changeset: 388619:c109bbdfa323
user:      jperkin <jperkin%pkgsrc.org@localhost>
date:      Wed Nov 23 15:31:43 2022 +0000

description:
mk: Minor performance improvement for error-check.

Avoid running rm/cat/mv on non-existent or zero-length files.

diffstat:

 mk/bsd.pkg.error.mk |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (47 lines):

diff -r 4c19aab7b96e -r c109bbdfa323 mk/bsd.pkg.error.mk
--- a/mk/bsd.pkg.error.mk       Wed Nov 23 14:04:47 2022 +0000
+++ b/mk/bsd.pkg.error.mk       Wed Nov 23 15:31:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.error.mk,v 1.5 2019/09/08 09:15:01 rillig Exp $
+# $NetBSD: bsd.pkg.error.mk,v 1.6 2022/11/23 15:31:43 jperkin Exp $
 
 ERROR_DIR=             ${WRKDIR}/.error
 WARNING_DIR=           ${WRKDIR}/.warning
@@ -29,26 +29,32 @@
 ###
 error-check: .USE
        ${RUN}                                                          \
-       ${RM} -f ${WARNING_DIR}/*.tmp;                                  \
        ${TEST} -d ${WARNING_DIR} || exit 0;                            \
        cd ${WARNING_DIR};                                              \
+       if [ `${ECHO} *.tmp` != '*.tmp' ]; then                         \
+               ${RM} -f *.tmp;                                         \
+       fi;                                                             \
        for file in ./*; do                                             \
                ${TEST} "$$file" != "./*" || exit 0;                    \
                break;                                                  \
        done;                                                           \
-       ${CAT} ./* | ${WARNING_CAT};                                    \
-       ${MV} -f ./* ${_WARNING_DONE_DIR}
+       if ${_NONZERO_FILESIZE_P} ./*; then                             \
+               ${CAT} ./* | ${WARNING_CAT};                            \
+               ${MV} -f ./* ${_WARNING_DONE_DIR};                      \
+       fi
 
        ${RUN}                                                          \
-       ${RM} -f ${ERROR_DIR}/*.tmp;                                    \
        ${TEST} -d ${ERROR_DIR} || exit 0;                              \
        cd ${ERROR_DIR};                                                \
+       if [ `${ECHO} *.tmp` != '*.tmp' ]; then                         \
+               ${RM} -f *.tmp;                                         \
+       fi;                                                             \
        for file in ./*; do                                             \
                ${TEST} "$$file" != "./*" || exit 0;                    \
                break;                                                  \
        done;                                                           \
-       ${CAT} * | ${ERROR_CAT};                                        \
        if ${_NONZERO_FILESIZE_P} ./*; then                             \
+               ${CAT} ./* | ${ERROR_CAT};                              \
                ${MV} -f ./* ${_ERROR_DONE_DIR};                        \
                exit 1;                                                 \
        fi



Home | Main Index | Thread Index | Old Index