Received: by mail.netbsd.org (Postfix, from userid 605) id 3D55B84D6D; Sat, 19 Aug 2017 00:30:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id C326C84D57 for ; Sat, 19 Aug 2017 00:30:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id ClY3aJBAQhZM for ; Sat, 19 Aug 2017 00:30:43 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 1406D84CE0 for ; Sat, 19 Aug 2017 00:30:43 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 124E0FAD0; Sat, 19 Aug 2017 00:30:43 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1503102643280850" MIME-Version: 1.0 Date: Sat, 19 Aug 2017 00:30:43 +0000 From: "Johnny C. Lam" Subject: CVS commit: pkgsrc/mk/pkgtasks To: pkgsrc-changes@NetBSD.org Reply-To: jlam@netbsd.org X-Mailer: log_accum Message-Id: <20170819003043.124E0FAD0@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1503102643280850 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: jlam Date: Sat Aug 19 00:30:43 UTC 2017 Modified Files: pkgsrc/mk/pkgtasks: files.mk Log Message: mk/pkgtasks: Sometimes avoid error if source files don't exist. The shell code used to check for the existence of the source files listed in the various CONF_FILES (and related) variables has been refactored out into a separate macro variable. In addition, the macro has been modified to only emit a warning if the source file is not in ${PREFIX} and can't be found on the host system. This supports using /dev/null as a source file, which is a common idiom for creating an empty target file, even if ${DESTDIR} is non-empty. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 pkgsrc/mk/pkgtasks/files.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_1503102643280850 Content-Disposition: inline Content-Length: 4670 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/mk/pkgtasks/files.mk diff -u pkgsrc/mk/pkgtasks/files.mk:1.7 pkgsrc/mk/pkgtasks/files.mk:1.8 --- pkgsrc/mk/pkgtasks/files.mk:1.7 Thu Aug 10 05:41:23 2017 +++ pkgsrc/mk/pkgtasks/files.mk Sat Aug 19 00:30:42 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.mk,v 1.7 2017/08/10 05:41:23 jlam Exp $ +# $NetBSD: files.mk,v 1.8 2017/08/19 00:30:42 jlam Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -218,64 +218,70 @@ ${_PKGTASKS_DATA.files}: privileged-install-hook: _pkgtasks-files-postinstall-check +# _PKGTASKS_CHECK_EGFILE +# Shell script macro to test for the existence of $$egfile in +# ${DESTDIR} after normalizing it with respect to ${PREFIX}, and +# an error message is emitted if it is missing. +# +# If $$egfile is an absolute path that is not rooted inside +# ${PREFIX}, then it is checked to see if it is in the host system, +# and not under ${DESTDIR}, and only a warning message is emitted +# if it is missing. This allows for specifying source files for a +# cross-build without requiring that the source file exists on the +# host system. +# +_PKGTASKS_CHECK_EGFILE= \ + ${TEST} -n "$$varname" -a -n "$$egfile" || \ + ${FAIL_MSG} "_PKGTASKS_CHECK_EGFILES called with missing variables"; \ + case $$egfile in \ + ${PREFIX:Q}/*) canon_egfile=${DESTDIR:Q}"$$egfile" ;; \ + /*) canon_egfile= ;; \ + *) canon_egfile=${DESTDIR:Q}${PREFIX:Q}"/$$egfile" ;; \ + esac; \ + if ${TEST} -n "$$canon_egfile"; then \ + ${TEST} -f "$$canon_egfile" || \ + ${TEST} -c "$$canon_egfile" || \ + ${FAIL_MSG} "$$varname - $$canon_egfile does not exist."; \ + else \ + ${TEST} -f "$$egfile" || \ + ${TEST} -c "$$egfile" || \ + ${WARNING_MSG} "$$varname - $$egfile does not exist."; \ + fi + _pkgtasks-files-postinstall-check: .PHONY ${RUN}set -- args ${_CONF_FILES}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 2 || break; \ - case $$1 in \ - /*) egfile=${DESTDIR:Q}"$$1" ;; \ - *) egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1" ;; \ - esac; shift 2; \ - ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ - ${FAIL_MSG} "CONF_FILES $$egfile does not exist."; \ + egfile="$$1"; shift 2; \ + varname="CONF_FILES"; ${_PKGTASKS_CHECK_EGFILE}; \ done ${RUN}set -- args ${_CONF_FILES_PERMS}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 5 || break; \ - case $$1 in \ - /*) egfile=${DESTDIR:Q}"$$1" ;; \ - *) egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1" ;; \ - esac; shift 5; \ - ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ - ${FAIL_MSG} "CONF_FILES_PERMS $$egfile does not exist.";\ + egfile="$$1"; shift 5; \ + varname="CONF_FILES_PERMS"; ${_PKGTASKS_CHECK_EGFILE}; \ done ${RUN}set -- args ${_REQD_FILES}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 2 || break; \ - case $$1 in \ - /*) egfile=${DESTDIR:Q}"$$1" ;; \ - *) egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1" ;; \ - esac; shift 2; \ - ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ - ${FAIL_MSG} "REQD_FILES $$egfile does not exist."; \ + egfile="$$1"; shift 2; \ + varname="REQD_FILES"; ${_PKGTASKS_CHECK_EGFILE}; \ done ${RUN}set -- args ${_REQD_FILES_PERMS}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 5 || break; \ - case $$1 in \ - /*) egfile=${DESTDIR:Q}"$$1" ;; \ - *) egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1" ;; \ - esac; shift 5; \ - ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ - ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist.";\ + egfile="$$1"; shift 5; \ + varname="REQD_FILES_PERMS"; ${_PKGTASKS_CHECK_EGFILE}; \ done ${RUN}set -- args ${__INIT_SCRIPTS}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 2 || break; \ - case $$1 in \ - /*) egfile=${DESTDIR:Q}"$$1" ;; \ - *) egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1" ;; \ - esac; shift 2; \ - ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ - ${FAIL_MSG} "REQD_FILES $$egfile does not exist."; \ + egfile="$$1"; shift 2; \ + varname="INIT_SCRIPTS"; ${_PKGTASKS_CHECK_EGFILE}; \ done ${RUN}set -- args ${__INIT_SCRIPTS_PERMS}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 5 || break; \ - case $$1 in \ - /*) egfile=${DESTDIR:Q}"$$1" ;; \ - *) egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1" ;; \ - esac; shift 5; \ - ${TEST} -f "$$egfile" || ${TEST} -c "$$egfile" || \ - ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist.";\ + egfile="$$1"; shift 5; \ + varname="INIT_SCRIPTS_PERMS"; ${_PKGTASKS_CHECK_EGFILE}; \ done --_----------=_1503102643280850--