Sat Jun 12 00:53:44 2010 UTC ()
Repair regression in "make replace" in DESTDIR case.

"make replace" is defined to replace a package with a newer version,
and update depdending packages to depend on the new version.  It has
long been understood that this is not always safe, with the responses
being "tell people to be careful" and the unsafe_depends variable
scheme and pkg_rolling-replace.  In the DESTDIR case, make replace is
implemented by pkg_add -U.  Usually, this is fine - even if the
ABI/shlib majors have changed, the package is replaced, and then a
later make replace of unsafe_depends=YES packages, either manually or
via pkg_rolling-replace, will bring the system to where it should be.
However, there are pinned dependencies on osabi where the depending
package will not accept the new version, and that causes pkg_add -U to
fail.  This is incorrect, as a) those packages don't depend on the
osabi exact version any more than packages depending on jpeg depeend
on the particular shlib major, yet jpeg dependencies aren't pinned.
And, osabi changing version is not necessarily an ABI change -
consider 5.0_STABLE just before 5.1RC1 and just after, where only the
version string changed.

Therefore, add -f to pkg_add -U so that the update will succeed.


(gdt)
diff -r1.28 -r1.29 pkgsrc/mk/flavor/pkg/replace.mk

cvs diff -r1.28 -r1.29 pkgsrc/mk/flavor/pkg/Attic/replace.mk (expand / switch to unified diff)

--- pkgsrc/mk/flavor/pkg/Attic/replace.mk 2010/01/30 21:07:29 1.28
+++ pkgsrc/mk/flavor/pkg/Attic/replace.mk 2010/06/12 00:53:43 1.29
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: replace.mk,v 1.28 2010/01/30 21:07:29 joerg Exp $ 1# $NetBSD: replace.mk,v 1.29 2010/06/12 00:53:43 gdt Exp $
2# 2#
3 3
4# _flavor-replace: 4# _flavor-replace:
5# Updates a package in-place on the system (USE_DESTDIR=no). 5# Updates a package in-place on the system (USE_DESTDIR=no).
6# 6#
7# _flavor-destdir-replace: 7# _flavor-destdir-replace:
8# Updates a package in-place on the system (USE_DESTDIR=yes). 8# Updates a package in-place on the system (USE_DESTDIR=yes).
9# 9#
10# See also: 10# See also:
11# replace 11# replace
12# 12#
13# XXX: The whole replacement, from deinstalling the old package up 13# XXX: The whole replacement, from deinstalling the old package up
14# to installing the new package, should be one transaction. It 14# to installing the new package, should be one transaction. It
@@ -171,35 +171,44 @@ replace-fixup-installed-info: .PHONY @@ -171,35 +171,44 @@ replace-fixup-installed-info: .PHONY
171 ${PKG_ADMIN} unset $$var $$newname; \ 171 ${PKG_ADMIN} unset $$var $$newname; \
172 done 172 done
173 173
174# Removes the state files for the "replace" target, so that it may be re-invoked. 174# Removes the state files for the "replace" target, so that it may be re-invoked.
175# 175#
176replace-clean: .PHONY 176replace-clean: .PHONY
177 ${RUN} ${_REPLACE_OLDNAME_CMD}; \ 177 ${RUN} ${_REPLACE_OLDNAME_CMD}; \
178 ${_REPLACE_NEWNAME_CMD}; \ 178 ${_REPLACE_NEWNAME_CMD}; \
179 ${RM} -f ${WRKDIR}/$$oldname${PKG_SUFX}; \ 179 ${RM} -f ${WRKDIR}/$$oldname${PKG_SUFX}; \
180 ${RM} -f ${WRKDIR}/$$newname${PKG_SUFX}; \ 180 ${RM} -f ${WRKDIR}/$$newname${PKG_SUFX}; \
181 ${RM} -f ${_REPLACE_OLDNAME_FILE} ${_REPLACE_NEWNAME_FILE} \ 181 ${RM} -f ${_REPLACE_OLDNAME_FILE} ${_REPLACE_NEWNAME_FILE} \
182 ${_COOKIE.replace} 182 ${_COOKIE.replace}
183 183
 184# Logically we would like to do a "pkg_add -U". However, that fails
 185# if there is a depending package that exactly depends on the package
 186# being replaced. Historically, 'make replace' would replace a
 187# package regardless of whether that broke depending packages
 188# (typically due to shlib ABI changes, especially major version
 189# bumps). Therefore, make replace in DESTDIR mode should behave the
 190# same way. unsafe_depends will be set on depending packages, and
 191# then those may be rebuilt via a manual process or by
 192# pkg_rolling-replace.
184replace-destdir: .PHONY 193replace-destdir: .PHONY
185 @${PHASE_MSG} "Updating using binary package of "${PKGNAME:Q} 194 @${PHASE_MSG} "Updating using binary package of "${PKGNAME:Q}
186.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) 195.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
187 @${MKDIR} ${_CROSS_DESTDIR}${PREFIX} 196 @${MKDIR} ${_CROSS_DESTDIR}${PREFIX}
188 ${PKG_ADD} -U -m ${MACHINE_ARCH} -I -p ${_CROSS_DESTDIR}${PREFIX} ${PKGFILE} 197 ${PKG_ADD} -U -f -m ${MACHINE_ARCH} -I -p ${_CROSS_DESTDIR}${PREFIX} ${PKGFILE}
189 @${ECHO} "Fixing recorded cwd..." 198 @${ECHO} "Fixing recorded cwd..."
190 @${SED} -e 's|@cwd ${_CROSS_DESTDIR}|@cwd |' ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS > ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp 199 @${SED} -e 's|@cwd ${_CROSS_DESTDIR}|@cwd |' ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS > ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp
191 @${MV} ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS 200 @${MV} ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS
192.else 201.else
193 ${PKG_ADD} -U ${PKGFILE} 202 ${PKG_ADD} -U -f ${PKGFILE}
194.endif 203.endif
195 ${RUN}${_REPLACE_OLDNAME_CMD}; \ 204 ${RUN}${_REPLACE_OLDNAME_CMD}; \
196 ${PKG_INFO} -qR ${PKGNAME:Q} | while read pkg; do \ 205 ${PKG_INFO} -qR ${PKGNAME:Q} | while read pkg; do \
197 [ -n "$$pkg" ] || continue; \ 206 [ -n "$$pkg" ] || continue; \
198 ${PKG_ADMIN} set unsafe_depends_strict=YES "$$pkg"; \ 207 ${PKG_ADMIN} set unsafe_depends_strict=YES "$$pkg"; \
199 if [ "$$oldname" != ${PKGNAME:Q} ]; then \ 208 if [ "$$oldname" != ${PKGNAME:Q} ]; then \
200 ${PKG_ADMIN} set unsafe_depends=YES "$$pkg"; \ 209 ${PKG_ADMIN} set unsafe_depends=YES "$$pkg"; \
201 fi; \ 210 fi; \
202 done 211 done
203 ${RUN}${PKG_ADMIN} unset unsafe_depends ${PKGNAME:Q} 212 ${RUN}${PKG_ADMIN} unset unsafe_depends ${PKGNAME:Q}
204 ${RUN}${PKG_ADMIN} unset unsafe_depends_strict ${PKGNAME:Q} 213 ${RUN}${PKG_ADMIN} unset unsafe_depends_strict ${PKGNAME:Q}
205 ${RUN}${PKG_ADMIN} unset rebuild ${PKGNAME:Q} 214 ${RUN}${PKG_ADMIN} unset rebuild ${PKGNAME:Q}