NetBSD Problem Report #43689
From dholland@eecs.harvard.edu Sun Aug 1 00:38:33 2010
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 0A90B63BB67
for <gnats-bugs@gnats.NetBSD.org>; Sun, 1 Aug 2010 00:38:33 +0000 (UTC)
Message-Id: <20100801003809.6DDB4F8D4@tanaqui.eecs.harvard.edu>
Date: Sat, 31 Jul 2010 20:38:09 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: USE_DESTDIR breaks undo-replace
X-Send-Pr-Version: 3.95
>Number: 43689
>Category: pkg
>Synopsis: USE_DESTDIR breaks undo-replace
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: pkg-manager
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Aug 01 00:40:01 +0000 2010
>Closed-Date: Mon Jun 20 06:10:50 +0000 2011
>Last-Modified: Mon Jun 20 06:10:50 +0000 2011
>Originator: David A. Holland
>Release: NetBSD 5.99.29 (pkgsrc 20100731)
>Organization:
>Environment:
System: NetBSD valkyrie 5.99.29 NetBSD 5.99.29 (VALKYRIE) #1: Sat May 29 23:00:44 EDT 2010 dholland@valkyrie:/usr/src/sys/arch/amd64/compile/VALKYRIE amd64
Architecture: x86_64
Machine: amd64
>Description:
If USE_DESTDIR is enabled (e.g. via PKG_DEVELOPER) it is no longer
possible to back out from "make replace": the old installed material
is not preserved and undo-replace fails.
>How-To-Repeat:
In some harmless already-installed package like xbiff, build it, then
do make replace, then make undo-replace:
# make replace
=> Bootstrap dependency digest>=20010302: found digest-20080510
WARNING: [license.mk] Every package should define a LICENSE.
===> Checking for vulnerabilities in xbiff-1.0.1nb1
===> Installing for xbiff-1.0.1nb1
=> Generating pre-install file lists
/bin/sh ./mkinstalldirs /usr/pkgsrc/mail/xbiff/work/.destdir/usr/pkg/bin
mkdir -p -- /usr/pkgsrc/mail/xbiff/work/.destdir/usr/pkg/bin
/usr/bin/install -c -s -o root -g wheel -m 755 xbiff /usr/pkgsrc/mail/xbiff/work/.destdir/usr/pkg/bin/xbiff
/bin/sh ./mkinstalldirs /usr/pkgsrc/mail/xbiff/work/.destdir/usr/pkg/man/man1
mkdir -p -- /usr/pkgsrc/mail/xbiff/work/.destdir/usr/pkg/man/man1
/usr/bin/install -c -o root -g wheel -m 644 xbiff.1 /usr/pkgsrc/mail/xbiff/work/.destdir/usr/pkg/man/man1/xbiff.1
=> Automatic manual page handling
=> Generating post-install file lists
=> Checking file-check results for xbiff-1.0.1nb1
=> Checking for non-existent script interpreters in xbiff-1.0.1nb1
=> Checking file permissions in xbiff-1.0.1nb1
=> Checking for missing run-time search paths in xbiff-1.0.1nb1
=> Checking for work-directory references in xbiff-1.0.1nb1
===> Building binary package for xbiff-1.0.1nb1
=> Creating binary package /usr/pkgsrc/packages/All/xbiff-1.0.1nb1.tgz
===> Replacing for xbiff-1.0.1nb1
WARNING: experimental target - DATA LOSS MAY OCCUR.
===> Updating using binary package of xbiff-1.0.1nb1
/usr/pkg/sbin/pkg_add -K /var/db/pkg -U /usr/pkgsrc/packages/All/xbiff-1.0.1nb1.tgz || /usr/pkg/sbin/pkg_add -K /var/db/pkg -U -f /usr/pkgsrc/packages/All/xbiff-1.0.1nb1.tgz
# make undo-replace
===> Undoing replacement for xbiff-1.0.1nb1
WARNING: experimental target - DATA LOSS MAY OCCUR.
=> Preserving existing +INSTALLED_INFO file.
=> Preserving existing +REQUIRED_BY file.
===> Deinstalling for xbiff-1.0.1nb1
Running /usr/pkg/sbin/pkg_delete -K /var/db/pkg xbiff-1.0.1nb1
===> Re-adding xbiff-1.0.1nb1 from saved tar-up package.
Installing saved package /usr/pkgsrc/mail/xbiff/work/xbiff-1.0.1nb1.tgz
pkg_add: no pkg found for '/usr/pkgsrc/mail/xbiff/work/xbiff-1.0.1nb1.tgz', sorry.
pkg_add: 1 package addition failed
*** Error code 1
Stop.
make: stopped in /usr/pkgsrc/mail/xbiff
*** Error code 1
Stop.
make: stopped in /usr/pkgsrc/mail/xbiff
Note that no package is saved; there is no way that undo-replace could
possibly succeed. Nor is the old metadata saved...
>Fix:
Probably something like this:
(Not tested though, and the metadata handling probably won't work)
Index: mk/flavor/pkg/replace.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/flavor/pkg/replace.mk,v
retrieving revision 1.30
diff -u -r1.30 replace.mk
--- mk/flavor/pkg/replace.mk 16 Jun 2010 15:15:05 -0000 1.30
+++ mk/flavor/pkg/replace.mk 1 Aug 2010 00:37:12 -0000
@@ -29,7 +29,12 @@
_flavor-destdir-replace: \
replace-names \
+ replace-tarup \
+ replace-preserve-installed-info \
+ replace-preserve-required-by \
replace-destdir \
+ replace-fixup-required-by \
+ replace-fixup-installed-info \
.PHONY
# _flavor-undo-replace:
>Release-Note:
>Audit-Trail:
From: "OBATA Akio" <obache@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/43689: USE_DESTDIR breaks undo-replace
Date: Wed, 04 May 2011 15:12:42 +0900
How about following patch?
Index: install/replace.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/install/replace.mk,v
retrieving revision 1.11
diff -u -r1.11 replace.mk
--- install/replace.mk 9 Jun 2009 08:40:28 -0000 1.11
+++ install/replace.mk 4 May 2011 06:03:07 -0000
@@ -22,6 +22,9 @@
# _flavor-undo-replace:
# Undoes a previous "make _flavor-replace".
+# _flavor-destdir-undo-replace:
+# Undoes a previous "make _flavor-destdir-replace".
+
.if ${_USE_DESTDIR} == "no"
_REPLACE_TARGETS+= ${_PKGSRC_BUILD_TARGETS}
.else
@@ -62,5 +65,9 @@
@${PHASE_MSG} "Undoing replacement for ${PKGNAME}"
@${WARNING_MSG} "experimental target - DATA LOSS MAY OCCUR."
+.if ${_USE_DESTDIR} == "no"
su-undo-replace: .PHONY _flavor-undo-replace
+.else
+su-undo-replace: .PHONY _flavor-destdir-undo-replace
+.endif
MAKEFLAGS.su-undo-replace= _UPDATE_RUNNING=yes
Index: flavor/pkg/replace.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/flavor/pkg/replace.mk,v
retrieving revision 1.31
diff -u -r1.31 replace.mk
--- flavor/pkg/replace.mk 14 Sep 2010 22:30:42 -0000 1.31
+++ flavor/pkg/replace.mk 4 May 2011 06:03:07 -0000
@@ -29,6 +29,7 @@
_flavor-destdir-replace: \
replace-names \
+ replace-tarup \
replace-destdir \
.PHONY
@@ -48,6 +49,12 @@
replace-clean \
.PHONY
+_flavor-destdir-undo-replace: \
+ undo-replace-check \
+ undo-destdir-replace-install \
+ replace-clean \
+ .PHONY
+
_INSTALLED_INFO_FILE= ${WRKDIR}/.replace-+INSTALLED_INFO
_REQUIRED_BY_FILE= ${WRKDIR}/.replace-+REQUIRED_BY
@@ -90,6 +97,12 @@
${ECHO} "Installing saved package ${WRKDIR}/$${oldname}${PKG_SUFX}"; \
${PKG_ADD} ${WRKDIR}/$${oldname}${PKG_SUFX}
+undo-destdir-replace-install: .PHONY
+ @${PHASE_MSG} "Re-adding ${PKGNAME} from saved tar-up package."
+ ${RUN} ${_REPLACE_OLDNAME_CMD}; \
+ ${ECHO} "Installing saved package ${WRKDIR}/$${oldname}${PKG_SUFX}"; \
+ ${PKG_ADD} -U -D ${WRKDIR}/$${oldname}${PKG_SUFX}
+
# Computes and saves the full names of the installed package to be replaced
# (oldname) and the package that will be installed (newname), so that these
# names are available later.
--
OBATA Akio / obache@NetBSD.org
State-Changed-From-To: open->feedback
State-Changed-By: obache@NetBSD.org
State-Changed-When: Sat, 04 Jun 2011 10:06:36 +0000
State-Changed-Why:
Commited proposed patch. Does it work as expected for you?
From: "OBATA Akio" <obache@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/43689 CVS commit: pkgsrc/mk
Date: Sat, 4 Jun 2011 10:05:00 +0000
Module Name: pkgsrc
Committed By: obache
Date: Sat Jun 4 10:05:00 UTC 2011
Modified Files:
pkgsrc/mk/flavor/pkg: replace.mk
pkgsrc/mk/install: replace.mk
Log Message:
Add support undo-replace with USE_DESTDIR.
fixes PR#43689.
To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 pkgsrc/mk/flavor/pkg/replace.mk
cvs rdiff -u -r1.11 -r1.12 pkgsrc/mk/install/replace.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 20 Jun 2011 06:10:50 +0000
State-Changed-Why:
Yes, works nicely. Sorry I took so long to reply :(
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.