Subject: replace-all target for bsd.pkg.mk
To: None <tech-pkg@NetBSD.org>
From: pancake <pancake@phreaker.net>
List: tech-pkg
Date: 01/17/2006 15:19:34
I have been using pkgsrc for years and I always found hard to upgrade large dependency programs with pkgsrc. BTW the most silly tip is imho the impossibility to automatize the replace of dependencies of the main package.

Ok, I understand that pkgsrc must handle this by default, but user must be free to force the complete replacement of all dependencies, to skip the error message:

"${pkgname} is already installed - perhaps an older version?"
"***  - "pkg_delete ${pkgname}" and "${MAKE} reinstall" to upgrade properly"
"***  - "${MAKE} replace" to replace only the package without re-linking"
"***    dependencies, risking various problems."

I sent a patch fixing this some years ago, but I would like to discuss this patch again.

This patch adds a new make target called "replace-all" that acts like the "replace" target but calls "replace" instead of "install" for the dependency targets already installed.

The major problems caused by the replace target are known by everybody, and major problems (minor library name changes) can be fixed using "wip/apstget" with "relink".

It's lovely to upgrade long list of packages without staying in front of the screen all the time. :)


Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1788
diff -u -r1.1788 bsd.pkg.mk
--- bsd.pkg.mk  12 Jan 2006 23:43:56 -0000      1.1788
+++ bsd.pkg.mk  17 Jan 2006 13:59:48 -0000
@@ -58,6 +58,7 @@
 # Transform package Makefile variables and set defaults
 ############################################################################
 
+REPLACE_ALL?=  NO
 CHECK_SHLIBS?=         YES     # run check-shlibs after install
 CLEANDEPENDS?=         NO
 DEINSTALLDEPENDS?=     NO      # add -R to pkg_delete
@@ -2053,7 +2054,13 @@
 .  endif       # CONFLICTS
        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
        found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`";     \
-       if [ "$$found" != "" ]; then                                    \
+       if [ "$$found" != "" ]; then \
+       if [ "$$REPLACE_ALL" = "YES" ]; then \\
+               ${ECHO_MSG} "***" \
+               ${ECHO_MSG} "*** Automatic replace in process..."\
+               ${ECHO_MSG} "***" \
+               ${MAKE} replace \
+       else \
                ${ECHO_MSG} "${_PKGSRC_IN}> $$found is already installed - perhaps an older version?"; \
                ${ECHO_MSG} "*** If so, you may use either of:"; \
                ${ECHO_MSG} "***  - \"pkg_delete $$found\" and \"${MAKE} reinstall\" to upgrade properly "; \
@@ -2061,6 +2068,7 @@
                ${ECHO_MSG} "***  - \"${MAKE} replace\" to replace only the package without re-linking";  \
                ${ECHO_MSG} "***    dependencies, risking various problems."; \
                exit 1;                                                 \
+       fi \
        fi
 .endif # !NO_PKG_REGISTER && !NO_FORCE_REGISTER && overwrite
 .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
@@ -2645,6 +2653,12 @@
 replace: ${_PKGSRC_BUILD_TARGETS} real-replace
 .endif
 
+.PHONY: replace-all
+.if !target(replace-all)
+REPLACE_ALL=YES
+replace-all: ${_PKGSRC_BUILD_TARGETS} real-replace
+.endif
+
 .PHONY: undo-replace
 .if !target(undo-replace)
 undo-replace: real-undo-replace