I need to get this thru my next bulk.
This should work around several existing issues.

First, PKGDIR must exist.  Creating it during fake is no longer possible,
because this doesn't work with dpb in privsep mode.

Having PKGDIR not be a directory/pointing in the wrong location means you
might miss MESSAGE/UNMESSAGE (which are not even written down in the PLIST)
or miss MESSAGE/RCscripts which must exist in the PLIST.

The more ambitious change involves changing the flow of creating new ports
to make it slightly faster.

Mainly, READMEs and RC installation is not really tweakable, since it happens
at the end of fake. So instead of doing it during fake, do it prior to
update-plist and package itself and (that's the cool part) do NOT generate
a cookie.   So it will happen each and every time. Accordingly, wipe existing
readmes and rc (this assumes RCDIR in the fake area is initially empty,
which should always be the case).

That way, a porter should be able to tweak the readmes/rc, add variables, 
add variable values, and quickly regen packages without having to wipe 
fake and redo it each time, which is a win.


(generate-readmes is possibly not the best name for the target, but does it
really matter ? :) )

Index: bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.1356
diff -u -p -r1.1356 bsd.port.mk
--- bsd.port.mk 19 Jun 2017 13:27:00 -0000      1.1356
+++ bsd.port.mk 26 Jun 2017 10:32:06 -0000
@@ -1926,6 +1926,7 @@ ${_PACKAGE_COOKIE${_S}}:
 .  else
        @${_MAKE} ${_PACKAGE_COOKIE_DEPS}
 # What PACKAGE normally does:
+       @${_MAKE} generate-readmes
        @${ECHO_MSG} "===>  Building package for ${FULLPKGNAME${_S}}"
        @${ECHO_MSG} "Create ${_PACKAGE_COOKIE${_S}}"
        @cd ${.CURDIR} && \
@@ -2357,6 +2358,7 @@ _extra_info += DEPPATHS${_s}="$$(${SETEN
 _internal-plist _internal-update-plist: _internal-fake 
${_FAKESUDO_CHECK_COOKIE}
        @${ECHO_MSG} "===>  Updating plist for ${FULLPKGNAME}${_MASTER}"
        @mkdir -p ${PKGDIR}
+       @${_MAKE} generate-readmes
        @DESTDIR=${WRKINST} \
        PREFIX=${TRUEPREFIX} \
        INSTALL_PRE_COOKIE=${_INSTALL_PRE_COOKIE} \
@@ -2788,22 +2790,31 @@ ${_FAKE_COOKIE}: ${_BUILD_COOKIE} ${_FAK
 .if target(_hook-post-install)
        @${_SUDOMAKESYS} _hook-post-install ${FAKE_SETUP}
 .endif
+       @${_FAKESUDO} ${_MAKE_COOKIE} $@
+
+# XXX this is a separate step that is "always on" and doesn't generate
+# cookies
+generate-readmes: ${_FAKE_COOKIE}
 .if ${MULTI_PACKAGES} == "-"
-       @if test -e ${PKGDIR}/README; then \
-               r=${WRKINST}${_README_DIR}/${FULLPKGNAME}; \
+       @r=${WRKINST}${_README_DIR}/${FULLPKGNAME}; \
+       if test -e ${PKGDIR}/README; then \
                echo "Installing ${PKGDIR}/README as $$r"; \
                ${_FAKESUDO} ${SUBST_CMD} ${_SHAREOWNGRP} -m ${SHAREMODE} -c 
${PKGDIR}/README $$r; \
+       else \
+               rm -f $$r; \
        fi
 .else
 .  for _s in ${MULTI_PACKAGES}
-       @if test -e ${PKGDIR}/README${_s}; then \
-               r=${WRKINST}${_README_DIR}/${FULLPKGNAME${_s}}; \
+       @r=${WRKINST}${_README_DIR}/${FULLPKGNAME${_s}}; \
+       if test -e ${PKGDIR}/README${_s}; then \
                echo "Installing ${PKGDIR}/README${_s} as $$r"; \
                ${_FAKESUDO} ${SUBST_CMD${_s}} ${_SHAREOWNGRP} -m ${SHAREMODE} 
-c ${PKGDIR}/README${_s} $$r; \
+       else \
+               rm -f $$r; \
        fi
 .  endfor
 .endif
-       @mkdir -p ${PKGDIR}
+       @rm -f ${WRKINST}${RCDIR}/*
        @cd ${PKGDIR} && for i in *.rc; do \
                if test X"$$i" != "X*.rc"; then \
                        r=${WRKINST}${RCDIR}/$${i%.rc}; \
@@ -2812,8 +2823,6 @@ ${_FAKE_COOKIE}: ${_BUILD_COOKIE} ${_FAK
                fi; \
        done
 
-       @${_FAKESUDO} ${_MAKE_COOKIE} $@
-
 print-plist:
        @${_PKG_CREATE} -n -q ${PKG_ARGS${SUBPACKAGE}} 
${_PACKAGE_COOKIE${SUBPACKAGE}}
 
@@ -3446,7 +3455,7 @@ _all_phony = ${_recursive_depends_target
     show-required-by subpackage uninstall _print-metadata \
        run-depends-args lib-depends-args all-lib-depends-args wantlib-args \
        port-wantlib-args fake-wantlib-args no-wantlib-args no-lib-depends-args 
\
-       _recurse-show-run-depends show-run-depends
+       _recurse-show-run-depends show-run-depends generate-readmes
 
 .if defined(_DEBUG_TARGETS)
 .  for _t in ${_all_phony}

Reply via email to