diff options
author | jlam <jlam@pkgsrc.org> | 2017-08-10 05:41:23 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2017-08-10 05:41:23 +0000 |
commit | dabd7bdc340729b07f1a50d8bef756335f2af14c (patch) | |
tree | 40386bec3a2e0eb4d2357f589432c622ad5e6516 /mk | |
parent | 7eefa0f2a65cc4ae44afc8f832815493999faa2c (diff) | |
download | pkgsrc-dabd7bdc340729b07f1a50d8bef756335f2af14c.tar.gz |
mk/pkgtasks: Fix bug in postinstall CONF_FILES assertion.
If ${DESTDIR} was non-empty and the source file was an absolute
path, the postinstall check target defined in mk/pkgtasks/files.mk
was improperly failing. Fix the bug by only prepending ${PREFIX}
if the source path is relative, and always prepending ${DESTDIR}.
Diffstat (limited to 'mk')
-rw-r--r-- | mk/pkgtasks/files.mk | 32 | ||||
-rwxr-xr-x | mk/pkgtasks/tests/files_test | 26 |
2 files changed, 45 insertions, 13 deletions
diff --git a/mk/pkgtasks/files.mk b/mk/pkgtasks/files.mk index 6acc8c16e95..1f1f65cf00d 100644 --- a/mk/pkgtasks/files.mk +++ b/mk/pkgtasks/files.mk @@ -1,4 +1,4 @@ -# $NetBSD: files.mk,v 1.6 2017/08/10 05:37:44 jlam Exp $ +# $NetBSD: files.mk,v 1.7 2017/08/10 05:41:23 jlam Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -222,42 +222,60 @@ _pkgtasks-files-postinstall-check: .PHONY ${RUN}set -- args ${_CONF_FILES}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 2 || break; \ - egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \ + 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."; \ done ${RUN}set -- args ${_CONF_FILES_PERMS}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 5 || break; \ - egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \ + 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.";\ done ${RUN}set -- args ${_REQD_FILES}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 2 || break; \ - egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \ + 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."; \ done ${RUN}set -- args ${_REQD_FILES_PERMS}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 5 || break; \ - egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \ + 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.";\ done ${RUN}set -- args ${__INIT_SCRIPTS}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 2 || break; \ - egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 2; \ + 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."; \ done ${RUN}set -- args ${__INIT_SCRIPTS_PERMS}; shift; \ while ${TEST} "$$#" -gt 0; do \ ${TEST} "$$#" -gt 5 || break; \ - egfile=${DESTDIR:Q}${PREFIX:Q}"/$$1"; shift 5; \ + 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.";\ done diff --git a/mk/pkgtasks/tests/files_test b/mk/pkgtasks/tests/files_test index 7e1a6b26dea..6ceebcdf48e 100755 --- a/mk/pkgtasks/tests/files_test +++ b/mk/pkgtasks/tests/files_test @@ -1,6 +1,6 @@ #!/usr/bin/env atf-sh # -# $NetBSD: files_test,v 1.2 2017/06/02 16:12:26 jlam Exp $ +# $NetBSD: files_test,v 1.3 2017/08/10 05:41:23 jlam Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -123,6 +123,7 @@ atf_test_case test2 test2_head() { atf_set "descr" "_pkgtasks-files-postinstall-check" + atf_set "require.files" "/dev/null" } test2_body() @@ -138,26 +139,39 @@ test2_body() ( exec > source$n ) done + # Create destdir source files. + local destdir="$(pwd)" + mkdir -p "./$destdir" + for n in 1 2 3 4 5 6 7 8 9; do + ( exec > "./$destdir/source$n" ) + done + cat > mk.conf << 'EOF' FAIL_MSG= echo LOCALBASE= ${.CURDIR} -DESTDIR= # empty CONF_FILES= source1 target1 source2 target2 CONF_FILES_PERMS= source3 target3 u3 g3 0640 \ - source4 target4 u4 g4 0640 + /dev/null target4 u4 g4 0640 REQD_FILES= source5 target5 source6 target7 REQD_FILES_PERMS= source8 target8 u8 g8 0400 \ source9 target9 u9 g9 0400 EOF ${MAKE} _pkgtasks-files-postinstall-check \ - PKGSRCDIR="${PKGSRCDIR}" > output + PKGSRCDIR="${PKGSRCDIR}" DESTDIR= > output + if grep -cq "^" output; then + cat output + atf_fail "postinstall checks failed (no destdir)" + fi + ${MAKE} _pkgtasks-files-postinstall-check \ + PKGSRCDIR="${PKGSRCDIR}" DESTDIR="$(pwd)" > output if grep -cq "^" output; then - cat output - atf_fail "postinstall checks failed" + cat output + atf_fail "postinstall checks failed (destdir)" fi + atf_pass } |