pkgsrc-Changes archive

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

CVS commit: pkgsrc/mk/pkgformat/pkg



Module Name:    pkgsrc
Committed By:   jperkin
Date:           Wed Nov 23 11:17:51 UTC 2022

Modified Files:
        pkgsrc/mk/pkgformat/pkg: check.mk depends.mk metadata.mk package.mk
            scripts.mk

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 pkgsrc/mk/pkgformat/pkg/check.mk
cvs rdiff -u -r1.15 -r1.16 pkgsrc/mk/pkgformat/pkg/depends.mk
cvs rdiff -u -r1.33 -r1.34 pkgsrc/mk/pkgformat/pkg/metadata.mk
cvs rdiff -u -r1.17 -r1.18 pkgsrc/mk/pkgformat/pkg/package.mk
cvs rdiff -u -r1.4 -r1.5 pkgsrc/mk/pkgformat/pkg/scripts.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/pkgformat/pkg/check.mk
diff -u pkgsrc/mk/pkgformat/pkg/check.mk:1.2 pkgsrc/mk/pkgformat/pkg/check.mk:1.3
--- pkgsrc/mk/pkgformat/pkg/check.mk:1.2        Thu May 28 16:22:58 2020
+++ pkgsrc/mk/pkgformat/pkg/check.mk    Wed Nov 23 11:17:51 2022
@@ -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 @@ _pkgformat-check-vulnerable: .PHONY
        @${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

Index: pkgsrc/mk/pkgformat/pkg/depends.mk
diff -u pkgsrc/mk/pkgformat/pkg/depends.mk:1.15 pkgsrc/mk/pkgformat/pkg/depends.mk:1.16
--- pkgsrc/mk/pkgformat/pkg/depends.mk:1.15     Mon Mar 28 10:49:12 2022
+++ pkgsrc/mk/pkgformat/pkg/depends.mk  Wed Nov 23 11:17:51 2022
@@ -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 @@ _DEPENDS_INSTALL_CMD=                                                     \
        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 @@ _DEPENDS_INSTALL_CMD=                                                       \
        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 @@ _pkgformat-install-dependencies: .PHONY 
        ${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.

Index: pkgsrc/mk/pkgformat/pkg/metadata.mk
diff -u pkgsrc/mk/pkgformat/pkg/metadata.mk:1.33 pkgsrc/mk/pkgformat/pkg/metadata.mk:1.34
--- pkgsrc/mk/pkgformat/pkg/metadata.mk:1.33    Mon Apr  4 11:23:07 2022
+++ pkgsrc/mk/pkgformat/pkg/metadata.mk Wed Nov 23 11:17:51 2022
@@ -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 @@ PKG_DB_TMPDIR=        ${WRKDIR}/.pkgdb
 
 unprivileged-install-hook: ${PKG_DB_TMPDIR}
 ${PKG_DB_TMPDIR}:
-       ${RUN}${MKDIR} ${.TARGET}
+       @${MKDIR} ${.TARGET}
 
 ######################################################################
 ###
@@ -34,36 +34,43 @@ DARWIN_REQUIRES_FILTER=     ${CAT}
 .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 @@ ${_BUILD_INFO_FILE}: ${_PLIST_NOKEYWORDS
        done
 .endif
        ${RUN}                                                          \
-       rm -f ${.TARGET};                                               \
        sort ${.TARGET}.tmp > ${.TARGET};                               \
        rm -f ${.TARGET}.tmp
 
@@ -139,76 +145,68 @@ _BUILD_VERSION_FILE=      ${PKG_DB_TMPDIR}/+B
 _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}/", "");                 \
+                       printf "%s %s\n", t, $$0 }' |                   \
        while read file relfile; do                                     \
                ${GREP}                                                 \
                        -e '\$$NetBSD[:][^$$]*[$$]'                     \
@@ -220,7 +218,7 @@ ${_BUILD_VERSION_FILE}:
                  sub(":.*[$$]NetBSD", ":       $$NetBSD");             \
                  sub("[$$][^$$]*$$", "$$");                            \
                  print; }' |                                           \
-       ${SORT} -u > ${.TARGET} && ${RM} -f ${.TARGET}.tmp
+       ${SORT} -u > ${.TARGET}
 .endif
 
 ######################################################################
@@ -233,8 +231,9 @@ _COMMENT_FILE=              ${PKG_DB_TMPDIR}/+COMMEN
 _METADATA_TARGETS+=    ${_COMMENT_FILE}
 
 ${_COMMENT_FILE}:
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${ECHO} ${COMMENT:Q} > ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${ECHO} ${COMMENT:Q} > ${.TARGET}
 
 ######################################################################
 ###
@@ -246,13 +245,15 @@ _DESCR_FILE=              ${PKG_DB_TMPDIR}/+DESC
 _METADATA_TARGETS+=    ${_DESCR_FILE}
 
 ${_DESCR_FILE}: ${DESCR_SRC}
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${RM} -f ${.TARGET}
-       ${RUN}${CAT} ${.ALLSRC} > ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${CAT} ${.ALLSRC} > ${.TARGET}
 .if defined(HOMEPAGE)
-       ${RUN}${ECHO} >> ${.TARGET}
-       ${RUN}${ECHO} "Homepage:" >> ${.TARGET}
-       ${RUN}${ECHO} ""${HOMEPAGE:Q} >> ${.TARGET}
+       ${RUN} {                                                        \
+               ${ECHO};                                                \
+               ${ECHO} "Homepage:";                                    \
+               ${ECHO} ""${HOMEPAGE:Q};                                \
+       } >> ${.TARGET}
 .endif
 
 ######################################################################
@@ -306,9 +307,9 @@ MESSAGE_SUBST+=     PKGNAME=${PKGNAME}                                      \
 _MESSAGE_SUBST_SED=    ${MESSAGE_SUBST:S/=/}!/:S/$/!g/:S/^/ -e s!\\\${/}
 
 ${_MESSAGE_FILE}: ${MESSAGE_SRC}
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${CAT} ${.ALLSRC} |                       \
-               ${SED} ${_MESSAGE_SUBST_SED} > ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${SED} ${_MESSAGE_SUBST_SED} ${.ALLSRC} > ${.TARGET}
 .endif # MESSAGE_SRC
 
 ######################################################################
@@ -323,8 +324,9 @@ _PRESERVE_FILE=             ${PKG_DB_TMPDIR}/+PRESE
 _METADATA_TARGETS+=    ${_PRESERVE_FILE}
 
 ${_PRESERVE_FILE}:
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${DATE} > ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${DATE} > ${.TARGET}
 .endif
 
 ######################################################################
@@ -337,13 +339,12 @@ _SIZE_PKG_FILE=           ${PKG_DB_TMPDIR}/+SIZE_
 _METADATA_TARGETS+=    ${_SIZE_PKG_FILE}
 
 ${_SIZE_PKG_FILE}: ${PLIST}
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN} \
-       ${CAT} ${PLIST} |                                               \
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
        ${AWK} 'BEGIN { base = "${PREFIX}/" }                           \
                /^@cwd/ { base = $$2 "/" }                              \
                /^@/ { next }                                           \
-               { print base $$0 }' |                                   \
+               { print base $$0 }' ${PLIST} |                          \
        ${SORT} -u |                                                    \
        ${SED} -e "s,^/,${DESTDIR}/," -e "s/'/'\\\\''/g" -e "s/.*/'&'/" | \
        ${XARGS} -n 256 ${LS} -ld 2>/dev/null |                         \
@@ -361,8 +362,8 @@ _SIZE_ALL_FILE=             ${PKG_DB_TMPDIR}/+SIZE_
 _METADATA_TARGETS+=    ${_SIZE_ALL_FILE}
 
 ${_SIZE_ALL_FILE}: ${_RDEPENDS_FILE} ${_SIZE_PKG_FILE}
-       ${RUN}${MKDIR} ${.TARGET:H}
        ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
        {                                                               \
                ${CAT} ${_SIZE_PKG_FILE} &&                             \
                ${_FULL_DEPENDS_CMD} | ${SORT} -u |                     \
@@ -462,8 +463,9 @@ _CONTENTS_TARGETS+= ${_SIZE_ALL_FILE}
 _CONTENTS_TARGETS+=    ${_SIZE_PKG_FILE}
 
 ${_CONTENTS_FILE}: ${_CONTENTS_TARGETS}
-       ${RUN}${MKDIR} ${.TARGET:H}
-       ${RUN}${PKG_CREATE} ${_PKG_ARGS_INSTALL} -O ${PKGFILE:T} > ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${PKG_CREATE} ${_PKG_ARGS_INSTALL} -O ${PKGFILE:T} > ${.TARGET}
 
 ######################################################################
 ### _pkgformat-generate-metadata (PRIVATE)

Index: pkgsrc/mk/pkgformat/pkg/package.mk
diff -u pkgsrc/mk/pkgformat/pkg/package.mk:1.17 pkgsrc/mk/pkgformat/pkg/package.mk:1.18
--- pkgsrc/mk/pkgformat/pkg/package.mk:1.17     Sat Dec 11 09:01:23 2021
+++ pkgsrc/mk/pkgformat/pkg/package.mk  Wed Nov 23 11:17:51 2022
@@ -1,4 +1,4 @@
-# $NetBSD: package.mk,v 1.17 2021/12/11 09:01:23 schmonz Exp $
+# $NetBSD: package.mk,v 1.18 2022/11/23 11:17:51 jperkin Exp $
 
 .if defined(PKG_SUFX)
 WARNINGS+=             "PKG_SUFX is deprecated, please use PKG_COMPRESSION"
@@ -41,19 +41,23 @@ _PKG_ARGS_PACKAGE+= -u ${REAL_ROOT_USER}
 .endif
 
 ${STAGE_PKGFILE}: ${_CONTENTS_TARGETS}
-       @${STEP_MSG} "Creating binary package ${.TARGET}"
-       ${RUN} ${MKDIR} ${.TARGET:H}; ${_ULIMIT_CMD}                    \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Creating binary package ${.TARGET}";               \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
+       ${_ULIMIT_CMD}                                                  \
        tmpname=${.TARGET:S,${PKG_SUFX}$,.tmp${PKG_SUFX},};             \
        if ! ${PKG_CREATE} ${_PKG_ARGS_PACKAGE} "$$tmpname"; then       \
                exitcode=$$?; ${RM} -f "$$tmpname"; exit $$exitcode;    \
        fi
 .if !empty(SIGN_PACKAGES:U:Mgpg)
-       @${STEP_MSG} "Signing binary package ${.TARGET} (GPG)"
-       ${RUN} tmpname=${.TARGET:S,${PKG_SUFX}$,.tmp${PKG_SUFX},};      \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Signing binary package ${.TARGET} (GPG)";          \
+       tmpname=${.TARGET:S,${PKG_SUFX}$,.tmp${PKG_SUFX},};             \
        ${PKG_ADMIN} gpg-sign-package "$$tmpname" ${.TARGET}
 .elif !empty(SIGN_PACKAGES:U:Mx509)
-       @${STEP_MSG} "Signing binary package ${.TARGET} (X509)"
-       ${RUN} tmpname=${.TARGET:S,${PKG_SUFX}$,.tmp${PKG_SUFX},};      \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Signing binary package ${.TARGET} (X509)";         \
+       tmpname=${.TARGET:S,${PKG_SUFX}$,.tmp${PKG_SUFX},};             \
        ${PKG_ADMIN} x509-sign-package "$$tmpname" ${.TARGET}           \
                ${X509_KEY} ${X509_CERTIFICATE}
 .else
@@ -63,8 +67,9 @@ ${STAGE_PKGFILE}: ${_CONTENTS_TARGETS}
 
 .if ${PKGFILE} != ${STAGE_PKGFILE}
 ${PKGFILE}: ${STAGE_PKGFILE}
-       @${STEP_MSG} "Creating binary package ${.TARGET}"
-       ${RUN} ${MKDIR} ${.TARGET:H};                                   \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Creating binary package ${.TARGET}";               \
+       ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H};               \
        ${LN} -f ${STAGE_PKGFILE} ${PKGFILE} 2>/dev/null ||             \
                ${CP} -pf ${STAGE_PKGFILE} ${PKGFILE} 2>/dev/null ||    \
                ${CP} -f ${STAGE_PKGFILE} ${PKGFILE}

Index: pkgsrc/mk/pkgformat/pkg/scripts.mk
diff -u pkgsrc/mk/pkgformat/pkg/scripts.mk:1.4 pkgsrc/mk/pkgformat/pkg/scripts.mk:1.5
--- pkgsrc/mk/pkgformat/pkg/scripts.mk:1.4      Wed Jun  7 20:24:09 2017
+++ pkgsrc/mk/pkgformat/pkg/scripts.mk  Wed Nov 23 11:17:51 2022
@@ -1,4 +1,4 @@
-# $NetBSD: scripts.mk,v 1.4 2017/06/07 20:24:09 jlam Exp $
+# $NetBSD: scripts.mk,v 1.5 2022/11/23 11:17:51 jperkin Exp $
 #
 # Copyright (c) 2017 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -116,19 +116,21 @@ INSTALL_SRC?=             # empty
 _DEINSTALL_FILE=       ${PKG_DB_TMPDIR}/+DEINSTALL
 
 ${_DEINSTALL_FILE}: ${DEINSTALL_SRC}
-       ${RUN}${MKDIR} ${.TARGET:H:Q}
-       ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}.tmp
-       ${RUN}${CHMOD} +x ${.TARGET}.tmp
-       ${RUN}${MV} -f ${.TARGET}.tmp ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H:Q} || ${MKDIR} ${.TARGET:H:Q};           \
+       ${SED} ${FILES_SUBST_SED} ${.ALLSRC} > ${.TARGET}.tmp;          \
+       ${CHMOD} +x ${.TARGET}.tmp;                                     \
+       ${MV} -f ${.TARGET}.tmp ${.TARGET}
 .endif
 .if !empty(INSTALL_SRC)
 _INSTALL_FILE=         ${PKG_DB_TMPDIR}/+INSTALL
 
 ${_INSTALL_FILE}: ${INSTALL_SRC}
-       ${RUN}${MKDIR} ${.TARGET:H:Q}
-       ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}.tmp
-       ${RUN}${CHMOD} +x ${.TARGET}.tmp
-       ${RUN}${MV} -f ${.TARGET}.tmp ${.TARGET}
+       ${RUN}                                                          \
+       ${TEST} -d ${.TARGET:H:Q} || ${MKDIR} ${.TARGET:H:Q};           \
+       ${SED} ${FILES_SUBST_SED} ${.ALLSRC} > ${.TARGET}.tmp;          \
+       ${CHMOD} +x ${.TARGET}.tmp;                                     \
+       ${MV} -f ${.TARGET}.tmp ${.TARGET}
 .endif
 
 .PHONY: _pkgformat-generate-install-scripts



Home | Main Index | Thread Index | Old Index