Skip site navigation (1)Skip section navigation (2)
Date:      22 Apr 2003 23:14:44 -0400
From:      Joe Marcus Clarke <marcus@marcuscom.com>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        Sergey Matveychuk <sem@ciam.ru>
Subject:   Re: Recent bsd.port.mk changes
Message-ID:  <1051067683.68327.19.camel@shumai.marcuscom.com>
In-Reply-To: <1051065189.68327.9.camel@shumai.marcuscom.com>
References:  <000501c3074c$e5c2be80$0a2da8c0@sem> <3EA48724.3080602@ciam.ru> <3EA53B4A.4030700@ciam.ru> <3EA5EA0D.8070500@ciam.ru> <20030423013231.GA66663@rot13.obsecurity.org> <1051065189.68327.9.camel@shumai.marcuscom.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-lOvJrBm5gKZGbfdJ6h8H
Content-Type: multipart/mixed; boundary="=-PUtj7+WgMNzmtzw6kUt8"


--=-PUtj7+WgMNzmtzw6kUt8
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Tue, 2003-04-22 at 22:33, Joe Marcus Clarke wrote:
> On Tue, 2003-04-22 at 21:32, Kris Kennaway wrote:
> > On Wed, Apr 23, 2003 at 05:19:09AM +0400, Sergey Matveychuk wrote:
> > > Kris Kennaway wrote:
> > > >features enabled ("foo-1.2.3" vs "foo-esound-1.2.3" etc.)  This is w=
hy
> > > >I suggested that comparing the installation prefix and pkg-plist for
> > > >overlap with ports that have the same origin may be the only way to =
do
> > > >this reliably.
> > >=20
> > > I don't know how to compare pkg-plist files? How to make decision a p=
ort=20
> > >  is older version and not variant of current one? It must be some=20
> > > evristic method. Some files can be moved in other place, some files c=
an=20
> > > be new, some files can be moved away in new version.
> > > In port's variant case path can be changed or file name can be change=
d=20
> > > (libsome.so and libsome_r.so).
> >=20
> > You can extract the prefix from the installed package by grepping for
> > @cwd in +CONTENTS.
>=20
> Or you can use pkg_info -p -q ${PKGNAME} which is what the patch I sent
> you uses.
>=20
> >   Similarly you can extract the list of installed
> > files by doing grep -v ^@ +CONTENTS. =20
>=20
> pkg_info -f -q ${PKGNAME} should provide this.
>=20
> > For each package that has our
> > origin (or a previous origin as looked up in the MOVED file), do the
> > following: if the installed prefix =3D=3D $PREFIX and one or more of th=
e
> > installed files matches a file in pkg-plist (checked using
> > e.g. comm(1)), then we are going to conflict and we should not
> > install.  I can't immediately think of how to implement the installed
> > plist extraction without using a temporary file, but it should be
> > possible with some thought.
>=20
> I can try to modify the patch I sent you to do this check as well.  It
> already does the ${PREFIX} check.

Okay, I think this works.  It doesn't need a temp file, and seems to get
the job done.  However, I may have missed something.

Joe

>=20
> Joe
>=20
> >=20
> > Kris
--=20
PGP Key : http://www.marcuscom.com/pgp.asc

--=-PUtj7+WgMNzmtzw6kUt8
Content-Disposition: attachment; filename=bsd.port.mk.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=bsd.port.mk.diff; charset=iso-8859-1

--- bsd.port.mk.orig	Sat Apr 19 18:35:28 2003
+++ bsd.port.mk	Tue Apr 22 23:10:49 2003
@@ -513,6 +513,7 @@
 # reinstall		- Install the results of a build, ignoring "already installed=
"
 #				  flag.
 # deinstall		- Remove the installation.
+# deinstall-all	- Remove all installations with the same PKGORIGIN.
 # package		- Create a package from an _installed_ port.
 # describe		- Try to generate a one-line description for each port for
 #				  use in INDEX files and the like.
@@ -2875,12 +2876,30 @@
 .if !target(check-already-installed)
 check-already-installed:
 .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
-	@if [ -d ${PKG_DBDIR}/${PKGNAME} -o \
-	    "x`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`" !=3D "x" ]; then \
-		${ECHO_CMD} "=3D=3D=3D>  ${PKGNAME} is already installed - perhaps an ol=
der version?"; \
+	@already_installed=3D`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
+	found_package=3D""; \
+	check_name=3D""; \
+	if [ -n "$${already_installed}" ]; then \
+		for p in $${already_installed}; do \
+			prfx=3D`${PKG_INFO} -q -p $${p} 2> /dev/null | ${SED} -e 's|^@cwd ||'`;=
 \
+			if [ "x${PREFIX}" =3D "x$${prfx}" ]; then \
+				for df in `${PKG_INFO} -q -f $${p} 2> /dev/null | ${GREP} -v "^@"`; do=
 \
+					if ${GREP} -q "^$${df}$$" ${PLIST}; then \
+				        found_package=3D$${p}; \
+				        check_name=3D$${p}; \
+						break 2; \
+					fi; \
+				done; \
+			fi; \
+		done; \
+	fi; \
+	${TEST} -z $${check_name} && check_name=3D${PKGNAME}; \
+	if [ -d ${PKG_DBDIR}/${PKGNAME} -o \
+		-n "$${found_package}" ]; then \
+		${ECHO_CMD} "=3D=3D=3D>  ${PKGORIGIN} is already installed ($${check_nam=
e})- perhaps an older version?"; \
 		${ECHO_CMD} "      If so, you may wish to \`\`make deinstall'' and insta=
ll"; \
 		${ECHO_CMD} "      this port again by \`\`make reinstall'' to upgrade it=
 properly."; \
-		${ECHO_CMD} "      If you really wish to overwrite the old port of ${PKG=
NAME}"; \
+		${ECHO_CMD} "      If you really wish to overwrite the old port of ${PKG=
ORIGIN}"; \
 		${ECHO_CMD} "      without deleting it first, set the variable \"FORCE_P=
KG_REGISTER\""; \
 		${ECHO_CMD} "      in your environment or the \"make install\" command l=
ine."; \
 		exit 1; \
@@ -3228,14 +3247,35 @@
=20
 .if !target(deinstall)
 deinstall:
+	@if ${PKG_INFO} -e ${PKGNAME}; then \
+	    deinstall_name=3D${PKGNAME}; \
+	else \
+	    deinstall_name=3D`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
+	fi; \
+	${TEST} -z $${deinstall_name} && deinstall_name=3D${PKGNAME}; \
+	${ECHO_MSG} "=3D=3D=3D>  Deinstalling for ${PKGORIGIN} ($${deinstall_name=
})"; \
+	if ${PKG_INFO} -e $${deinstall_name}; then \
+	    ${PKG_DELETE} -f $${deinstall_name}; \
+	else \
+	    ${ECHO_MSG} "=3D=3D=3D>   ${PKGORIGIN} not installed, skipping"; \
+	fi
+	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
+.endif
+
+# Deinstall-all
+#
+# Special target to remove installation of all ports of the same origin
+
+.if !target(deinstall-all)
+deinstall-all:
 	@deinstall_name=3D`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
 	${TEST} -z $${deinstall_name} && deinstall_name=3D${PKGNAME}; \
 	${ECHO_MSG} "=3D=3D=3D>  Deinstalling for ${PKGORIGIN} ($${deinstall_name=
})"; \
 	if ${PKG_INFO} -e $${deinstall_name}; then \
 		${PKG_DELETE} -f $${deinstall_name}; \
-	 else \
-	    ${ECHO_MSG} "=3D=3D=3D>   ${PKGORIGIN} not installed, skipping"; \
-	 fi
+	else \
+		${ECHO_MSG} "=3D=3D=3D>   ${PKGORIGIN} not installed, skipping"; \
+	fi
 	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 .endif
=20

--=-PUtj7+WgMNzmtzw6kUt8--

--=-lOvJrBm5gKZGbfdJ6h8H
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQA+pgUjb2iPiv4Uz4cRAto8AJwP2bdS6rXenZ5zWL1yua1lh5X4tgCdHo5n
6spKGHPceG+B0c5OeDPMs6w=
=yEwe
-----END PGP SIGNATURE-----

--=-lOvJrBm5gKZGbfdJ6h8H--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1051067683.68327.19.camel>