tech-pkg archive

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

"make replace" when package is not already installed



On Fri, 10 May 2013, matthew sporleder wrote:
- I'm not sure how to reliably test if the package is already
installed and make replace doesn't handle it for me like pkg_add does.

I have patched "make replace" to make it work when the package is not already installed. I think the attached patch is all you need. Please try it.

If people other than you and me are interested, then I can commit it.

--apb (Alan Barrett)
--- mk/pkgformat/pkg/replace.mk 15 Oct 2011 00:23:09 -0000      1.1
+++ mk/pkgformat/pkg/replace.mk 16 Oct 2011 16:41:04 -0000
@@ -15,23 +15,21 @@
 # currently isn't, and the check-files target for other packages
 # can be confused when a +REQUIRED_BY files suddenly disappears.
 #
-_pkgformat-replace: \
-       replace-names \
-       replace-tarup \
-       replace-preserve-installed-info \
-       replace-preserve-required-by \
-       deinstall \
-       install-clean \
-       install \
-       replace-fixup-required-by \
-       replace-fixup-installed-info \
-       .PHONY
+_pkgformat-replace: .PHONY
+       ${MAKE} replace-names \
+       && ( ${MAKE} replace-tarup || true ) \
+       && ${MAKE} replace-preserve-installed-info \
+       && ${MAKE} replace-preserve-required-by \
+       && ${MAKE} deinstall \
+       && ${MAKE} install-clean \
+       && ${MAKE} install \
+       && ${MAKE} replace-fixup-required-by \
+       && ${MAKE} replace-fixup-installed-info
 
-_pkgformat-destdir-replace: \
-       replace-names \
-       replace-tarup \
-       replace-destdir \
-       .PHONY
+_pkgformat-destdir-replace: .PHONY
+       ${MAKE} replace-names \
+       && ( ${MAKE} replace-tarup || true ) \
+       && ${MAKE} replace-destdir
 
 # _pkgformat-undo-replace:
 #      Undoes the actions from a previous _pkgformat-replace.
@@ -39,21 +37,19 @@ _pkgformat-destdir-replace: \
 # See also:
 #      undo-replace
 #
-_pkgformat-undo-replace: \
-       undo-replace-check \
-       replace-preserve-installed-info \
-       replace-preserve-required-by \
-       deinstall \
-       undo-replace-install \
-       replace-fixup-required-by \
-       replace-clean \
-       .PHONY
+_pkgformat-undo-replace: .PHONY
+       ${MAKE} undo-replace-check \
+       && ${MAKE} replace-preserve-installed-info \
+       && ${MAKE} replace-preserve-required-by \
+       && ${MAKE} deinstall \
+       && ${MAKE} undo-replace-install \
+       && ${MAKE} replace-fixup-required-by \
+       && ${MAKE} replace-clean
 
-_pkgformat-destdir-undo-replace: \
-       undo-replace-check \
-       undo-destdir-replace-install \
-       replace-clean \
-       .PHONY
+_pkgformat-destdir-undo-replace: .PHONY
+       ${MAKE} undo-replace-check \
+       && ${MAKE} undo-destdir-replace-install \
+       && ${MAKE} replace-clean
 
 _INSTALLED_INFO_FILE=  ${WRKDIR}/.replace-+INSTALLED_INFO
 _REQUIRED_BY_FILE=     ${WRKDIR}/.replace-+REQUIRED_BY
@@ -84,10 +80,12 @@ replace-tarup: .PHONY
        ${RUN} [ -x ${_PKG_TARUP_CMD:Q} ] \
        || ${FAIL_MSG} ${_PKG_TARUP_CMD:Q}" was not found.";            \
        ${_REPLACE_OLDNAME_CMD};                                        \
-       ${PKGSRC_SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX}   \
+       if [ -n "$${oldname}" ]; then                                   \
+           ${PKGSRC_SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \
                PKGREPOSITORY=${WRKDIR}                                 \
                ${_PKG_TARUP_CMD} $${oldname} ||                        \
-       ${FAIL_MSG} "Could not pkg_tarup $${oldname}".
+           ${FAIL_MSG} "Could not pkg_tarup $${oldname}". ;            \
+       fi
 
 # Re-installs the old package that has been saved by replace-tarup.
 #
@@ -113,7 +111,7 @@ replace-names: .PHONY
        else                                                            \
                wildcard="${OLDNAME}-[0-9]*";                           \
        fi;                                                             \
-       ${_PKG_BEST_EXISTS} "$${wildcard}" > ${_REPLACE_OLDNAME_FILE}
+       ${_PKG_BEST_EXISTS} "$${wildcard}" > ${_REPLACE_OLDNAME_FILE} || true
        ${RUN} ${ECHO} ${PKGNAME} > ${_REPLACE_NEWNAME_FILE}
        ${RUN} ${CP} -f ${_REPLACE_NEWNAME_FILE} ${_COOKIE.replace}
 


Home | Main Index | Thread Index | Old Index