pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/pkgtasks mk/pkgtasks: Fix bug in postinstall CONF_F...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/3e327ec50085
branches:  trunk
changeset: 366290:3e327ec50085
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Thu Aug 10 05:41:23 2017 +0000

description:
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:

 mk/pkgtasks/files.mk         |  32 +++++++++++++++++++++++++-------
 mk/pkgtasks/tests/files_test |  28 +++++++++++++++++++++-------
 2 files changed, 46 insertions(+), 14 deletions(-)

diffs (141 lines):

diff -r 987b429f8561 -r 3e327ec50085 mk/pkgtasks/files.mk
--- a/mk/pkgtasks/files.mk      Thu Aug 10 05:41:07 2017 +0000
+++ b/mk/pkgtasks/files.mk      Thu Aug 10 05:41:23 2017 +0000
@@ -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 @@
        ${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 -r 987b429f8561 -r 3e327ec50085 mk/pkgtasks/tests/files_test
--- a/mk/pkgtasks/tests/files_test      Thu Aug 10 05:41:07 2017 +0000
+++ b/mk/pkgtasks/tests/files_test      Thu Aug 10 05:41:23 2017 +0000
@@ -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 @@
 test2_head()
 {
        atf_set "descr" "_pkgtasks-files-postinstall-check"
+       atf_set "require.files" "/dev/null"
 }
 
 test2_body()
@@ -138,26 +139,39 @@
                ( 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"
+               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 (destdir)"
+       fi
+
        atf_pass
 }
 



Home | Main Index | Thread Index | Old Index