Subject: Re: making 'make replace' safer
To: Hubert Feyrer <hubert@feyrer.de>
From: Greg Troxel <gdt@ir.bbn.com>
List: tech-pkg
Date: 07/16/2006 19:24:41
--=-=-=
Content-Transfer-Encoding: quoted-printable


Hubert Feyrer <hubert@feyrer.de> writes:

> On Sun, 16 Jul 2006, Greg Troxel wrote:
>> I'd like to commit step 1 - is this ok?
>
> Right now, 'make replace' is fairly simple & straight
> forward. Replacing it with something that's obviously not simple (as
> far as I understand your mail), I'd rather not see that happen for
> that target.

I'm not proposing to change in any significant way the behavior of
make replace.  The pkg_rolling-replace idea is to have a wrapper
script that invokes the basic operations, just like pkg_chk, but with
different logic.

> How about naming this different, maybe "abi-safe-replace"
> or something, so the old & simple method keeps available to us old
> farts who pretend to know what they want?

Step 1 really is very simple: all that is changed is that when make
replace happens, the packages that had a dependency updated get a
variable unsafe_depends set to yes.  There's one extra line in
replace.mk to call pkg_admin to do this - nothing more.  So while I
can't prove there will be zero additional side effects, it seems very
simple.  And even those who don't want to use pkg_rolling-replace will
benefit by being able to to ask the package system if a package has
had a dependency updated.  If you don't try to look at the variable, I
bet you won't notice that anything has changed.

I sometimes mentally keep track of what would be labeled as
unsafe_depends, and do further make replace operations.  The proposed
change wouldn't take this away from you, but only keep track so you
could check your memory.

> Replacing known behaviour for something unknown seems the wrong way to
> me, and you can always rename the target later when it's stable.

If make replace invoked a new script, I'd agree with you.  I'm only
proposing changing make replace to do the basic bookkeeping of what's
unsafe.  To maintain the invariant that all unsafe sitations are
recorded, the bookkeeping has to be done on every make replace.

Here's the patch (prepared by Nick) that I'd like to commit, with a
lot more context this time --- do you think there will be negative
consequences for anyone?

Index: mk/flavor/pkg/replace.mk
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/pkgsrc/mk/flavor/pkg/replace.mk,v
retrieving revision 1.4
diff -u -u -1 -5 -r1.4 replace.mk
=2D-- mk/flavor/pkg/replace.mk	7 Jul 2006 21:24:28 -0000	1.4
+++ mk/flavor/pkg/replace.mk	16 Jul 2006 23:19:01 -0000
@@ -138,30 +138,31 @@
 	newname=3D`${CAT} ${_REPLACE_NEWNAME_FILE}`;			\
 	${CAT} ${_REQUIRED_BY_FILE} |					\
 	while read pkg; do						\
 		case $$pkg in						\
 		/*)	pkgdir=3D"$$pkg" ;;				\
 		*)	pkgdir=3D"${_PKG_DBDIR}/$$pkg" ;;			\
 		esac;							\
 		contents=3D"$$pkgdir/+CONTENTS";				\
 		newcontents=3D"$$contents.$$$$";				\
 		${SETENV} OLDNAME=3D"$$oldname" NEWNAME=3D"$$newname"	\
 		${AWK} '($$0 ~ "^@pkgdep " ENVIRON["OLDNAME"])		\
 			{ print "@pkgdep " ENVIRON["NEWNAME"]; next }	\
 			{ print }'					\
 			$$contents > $$newcontents;			\
 		${MV} -f $$newcontents $$contents;			\
+		${PKG_ADMIN} set unsafe_depends=3DYES $$pkg;		\
 	done
=20
 ######################################################################
 ### replace-clean (PRIVATE)
 ######################################################################
 ### replace-clean removes the state files for the "replace" target so
 ### that it may be re-invoked.
 ###
 .PHONY: replace-clean
 replace-clean:
 	${_PKG_SILENT}${_PKG_DEBUG}					\
 	${TEST} -f ${_REPLACE_OLDNAME_FILE} || exit 0;			\
 	oldname=3D`${CAT} ${_REPLACE_OLDNAME_FILE}`;			\
 	${RM} -f ${WRKDIR}/$$oldname${PKG_SUFX}
 	${_PKG_SILENT}${_PKG_DEBUG}					\



See http://acert.ir.bbn.com/viewvc/acert/pkgsrc-acert/ if you want to
read the (very much work in progress) script.  I plan to move it to
pkgtools when it is stable.

=2D-=20
        Greg Troxel <gdt@ir.bbn.com>

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (NetBSD)

iD8DBQFEusq9+vesoDJhHiURAj+yAJ4kJW1tCiB5iZa7PENYmg+sL/hjlQCgiuAN
hIKmdqTjt722g4p4e6xWNFE=
=y0Jv
-----END PGP SIGNATURE-----
--=-=-=--