Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Oct 2000 14:42:52 +0300
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        bmah@FreeBSD.org
Cc:        Neil Blakey-Milner <nbm@mithrandr.moria.org>, Akinori -Aki- MUSHA <knu@idaemons.org>, freebsd-ports@FreeBSD.org, asami@FreeBSD.org
Subject:   PROPOSAL: Use @comment PLIST variable to track where installed packages  came from [Was: Enhancement of pkg_version's version comparison routine]
Message-ID:  <39DB17BB.12805565@FreeBSD.org>
References:  <86k8by6eis.wl@archon.local.idaemons.org> <20000927002401.A73341@mithrandr.moria.org> <39D9D006.652DC258@FreeBSD.org> <20001003161027.B67542@mithrandr.moria.org> <39D9EE01.7A880665@FreeBSD.org> <200010031657.e93Gvtg10718@bmah-freebsd-0.cisco.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------160205C298EA7560DFCAC670
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit

"Bruce A. Mah" wrote:

> If memory serves me right, Maxim Sobolev wrote:
> > Neil Blakey-Milner wrote:
> >
> > > On Tue 2000-10-03 (15:24), Maxim Sobolev wrote:
>
> I think that in your example, it's going to do the right thing.
> Instances where we allow multiple "production" versions of software
> (i.e. Tcl) are already differentiated by giving the port directories
> different names.
>
> Two things that came to mind for me:
>
> 1.  Someone once made the assertion that most third-party software was
> installed via packages, not building ports.  So we might need to handle
> some odd cases like only having the INDEX file, not having a ports tree
> at all, and so forth.  (In other words, we might not have filesystem
> access to the Makefile that generated a package.)
>
> 2.  This still doesn't solve the problem of updating dependencies.
>
> Still, I think this is an interesting idea.

Well, I did not tell that it will solve all our problems, but it really can help to
improve things a bit.

PROPOSAL
-------------

1. Why things need to be improved?

This should be almost obvious to anyone who was watching pkg_version development.
Lately, there were several attempts to cope with pkg_version's inability to
distinguish between packages generated from so-called `multi-version' ports (for
example gtk10/11/12, bash1/2 etc.) and as a result provide useful notification when
the package should be updated. Now it is clear that the problem could not be solved
completely w/o creating an AI bundled into pkg_version :), so I decided to approach
the problem from the slightly different side.

2. What is proposed?

It is proposed to plant into package short information about path  of the underlying
port, from which installed packages was generated, in the Ports Tree. Due to the fact
that it is going to change pkg_install tools it is proposed to do it in as less
intrusive way as possible, so the old packages generated by the previous version of
pkg_* tools will work with the new version of tools and vice versa. This defines
usage of @comment PLIST variable for the purpose.

3. How it would work?

When creating  package, bsd.port.mk will generate MASTERCATEGORY/PORTDIR string and
feed it to pkg_create. Here MASTERCATEGORY is the first category specified in port's
CATEGORIES and it should coincide with name of corresponding parent directory in the
ports tree. It was defined in such way to properly handle ports installed w/o parent
category directory (for example when you install package from the module received
using `cvs co ...'). pkg_create in turn will prefix it with appropriate @comment
magic and add into +CONTENTS.

Later, when you updated your ports tree and want to check if any new versions of the
installed packages are available, your designated for this purpose tool (pkg_version)
will call pkg_info with an appropriate option for all installed packages, create a
list of packages where origin is defined and check if appropriate ports' makefiles in
/usr/ports are in fact present. Then for all packages which can be handled under a
new scheme the tool will call appropriate `make -V PORTVERSION -f ...' to determine
current version of the package in the Ports Collection. All other packages (for
example old packages w/o origin, third party packages etc.) will be handled using
ports/INDEX.

Good side effect of the proposed scheme is that version checking tools would be able
to avoid relying on often outdated information provided by the ports/INDEX, so users
should stop spamming us with "Hey, pkg_version doesn't work - I cvsuped ports, but it
doesn't show me updated ports!" e-mails.

With this message I'm attaching appropriate patches for pkg_* tools and bsd.port.mk.

-Maxim


--------------160205C298EA7560DFCAC670
Content-Type: text/plain; charset=koi8-r;
 name="bsd.port.mk-origin.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="bsd.port.mk-origin.patch"

--- bsd.port.mk.orig	Mon Oct  2 09:10:12 2000
+++ bsd.port.mk	Wed Oct  4 10:58:15 2000
@@ -1070,6 +1070,17 @@
 PKGMESSAGE?=	${PKGDIR}/pkg-message
 .endif
 
+SED?=		/usr/bin/sed
+BASENAME?=	/usr/bin/basename
+
+.if ${OSVERSION} > 500012
+_PKGCATEGORY!=		${ECHO} ${CATEGORIES} | ${SED} -E 's|^ *||g ; s| .*$$||'
+_PORTDIRNAME!=		${BASENAME} ${.CURDIR}
+PKGCATEGORY?=		${_PKGCATEGORY}
+PORTDIRNAME?=		${_PORTDIRNAME}
+PKGORIGIN?=			${PKGCATEGORY}/${PORTDIRNAME}
+.endif
+
 # delete from here when NEWLAYOUT is default
 COMMENT?=	${PKGDIR}/COMMENT
 DESCR?=		${PKGDIR}/DESCR
@@ -1101,6 +1112,9 @@
 .if !defined(NO_MTREE)
 PKG_ARGS+=		-m ${MTREE_FILE}
 .endif
+.if defined(PKGORIGIN) && ${OSVERSION} > 500012
+PKG_ARGS+=		-o ${PKGORIGIN}
+.endif
 .endif
 .if defined(PKG_NOCOMPRESS)
 PKG_SUFX?=		.tar
@@ -1120,7 +1134,6 @@
 .endif
 
 AWK?=		/usr/bin/awk
-BASENAME?=	/usr/bin/basename
 CAT?=		/bin/cat
 CHMOD?=		/bin/chmod
 CHOWN?=		/usr/sbin/chown
@@ -1139,7 +1152,6 @@
 MV?=		/bin/mv
 RM?=		/bin/rm
 RMDIR?=		/bin/rmdir
-SED?=		/usr/bin/sed
 SETENV?=	/usr/bin/env
 SH?=		/bin/sh
 TR?=		/usr/bin/tr

--------------160205C298EA7560DFCAC670
Content-Type: text/plain; charset=koi8-r;
 name="pkg_install-origin.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="pkg_install-origin.patch"

Index: create/create.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/create.h,v
retrieving revision 1.15
diff -d -u -r1.15 create.h
--- create/create.h	1999/08/28 01:17:58	1.15
+++ create/create.h	2000/10/04 09:30:49
@@ -37,6 +37,7 @@
 extern char	*ExcludeFrom;
 extern char	*Mtree;
 extern char	*Pkgdeps;
+extern char	*Origin;
 extern char	PlayPen[];
 extern int	Dereference;
 extern int	PlistOnly;
Index: create/main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/main.c,v
retrieving revision 1.21
diff -d -u -r1.21 main.c
--- create/main.c	1999/08/28 01:17:58	1.21
+++ create/main.c	2000/10/04 09:30:49
@@ -18,7 +18,7 @@
 #include "lib.h"
 #include "create.h"
 
-static char Options[] = "YNOhvf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:";
+static char Options[] = "YNOhvf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:";
 
 char	*Prefix		= NULL;
 char	*Comment        = NULL;
@@ -34,6 +34,7 @@
 char	*ExcludeFrom	= NULL;
 char	*Mtree		= NULL;
 char	*Pkgdeps	= NULL;
+char	*Origin		= NULL;
 char	PlayPen[FILENAME_MAX];
 int	Dereference	= 0;
 int	PlistOnly	= 0;
@@ -129,6 +130,10 @@
 	    Pkgdeps = optarg;
 	    break;
 
+	case 'o':
+	    Origin = optarg;
+	    break;
+
 	case '?':
 	default:
 	    usage();
@@ -165,7 +170,7 @@
 "usage: pkg_create [-YNOhv] [-P pkgs] [-p prefix] [-f contents] [-i iscript]",
 "                  [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ",
 "                  [-t template] [-X excludefile] [-D displayfile] ",
-"                  [-m mtreefile] -c comment -d description -f packlist ",
-"                  pkg-name");
+"                  [-m mtreefile] [-o origin] -c comment -d description ",
+"                  -f packlist pkg-name");
     exit(1);
 }
Index: create/perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/perform.c,v
retrieving revision 1.49
diff -d -u -r1.49 perform.c
--- create/perform.c	1999/08/28 01:17:58	1.49
+++ create/perform.c	2000/10/04 09:30:49
@@ -85,6 +85,10 @@
     else
 	suf = "tar";
 
+    /* Add the origin if asked, at the top */
+    if (Origin)
+	add_plist(&plist, PLIST_COMMENT, strconcat("ORIGIN:", Origin));
+
     /* Stick the dependencies, if any, at the top */
     if (Pkgdeps) {
 	if (Verbose && !PlistOnly)
@@ -92,7 +96,7 @@
 	while (Pkgdeps) {
 	    cp = strsep(&Pkgdeps, " \t\n");
 	    if (*cp) {
-		add_plist(&plist, PLIST_PKGDEP, cp);
+		add_plist_top(&plist, PLIST_PKGDEP, cp);
 		if (Verbose && !PlistOnly)
 		    printf(" %s", cp);
 	    }
Index: create/pkg_create.1
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/pkg_create.1,v
retrieving revision 1.35
diff -d -u -r1.35 pkg_create.1
--- create/pkg_create.1	2000/03/01 14:09:01	1.35
+++ create/pkg_create.1	2000/10/04 09:30:54
@@ -45,6 +45,7 @@
 .Op Fl X Ar excludefile
 .Op Fl D Ar displayfile
 .Op Fl m Ar mtreefile
+.Op Fl o Ar originpath
 .Fl c Ar comment
 .Fl d Ar description
 .Fl f Ar packlist
@@ -243,6 +244,13 @@
 is the name of the first directory named by a
 .Cm @cwd
 directive.
+.It Fl o Ar originpath
+Record an
+.Ar originpath ,
+as location of the port from which package has been created in the
+.Em "FreeBSD Ports Collection" .
+It should be in the form
+.Pa MASTERCATEGORY/PORTDIR .
 .El
 .Pp
 .Sh PACKING LIST DETAILS
Index: info/info.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/info.h,v
retrieving revision 1.12
diff -d -u -r1.12 info.h
--- info/info.h	2000/07/07 13:06:32	1.12
+++ info/info.h	2000/10/04 09:30:54
@@ -44,6 +44,7 @@
 #define SHOW_REQBY	0x0400
 #define SHOW_MTREE	0x0800
 #define SHOW_SIZE	0x1000
+#define SHOW_ORIGIN	0x2000
 
 extern int Flags;
 extern Boolean AllInstalled;
@@ -57,5 +58,6 @@
 extern void	show_files(char *, Package *);
 extern void	show_index(char *, char *);
 extern void	show_size(char *, Package *);
+extern void	show_origin(char *, Package *);
 
 #endif	/* _INST_INFO_H_INCLUDE */
Index: info/main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/main.c,v
retrieving revision 1.24
diff -d -u -r1.24 main.c
--- info/main.c	2000/07/07 13:06:32	1.24
+++ info/main.c	2000/10/04 09:30:54
@@ -28,7 +28,7 @@
   "$FreeBSD: src/usr.sbin/pkg_install/info/main.c,v 1.24 2000/07/07 13:06:32 sobomax Exp $";
 #endif
 
-static char Options[] = "acdDe:fhiIkl:LmpqrRst:v";
+static char Options[] = "acdDe:fhiIkl:LmopqrRst:v";
 
 int	Flags		= 0;
 Boolean AllInstalled	= FALSE;
@@ -115,6 +115,10 @@
         case 's':
             Flags |= SHOW_SIZE;
             break;
+
+	case 'o':
+	    Flags |= SHOW_ORIGIN;
+	    break;
 
 	case 'l':
 	    InfoPrefix = optarg;
Index: info/perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/perform.c,v
retrieving revision 1.31
diff -d -u -r1.31 perform.c
--- info/perform.c	2000/09/25 07:27:05	1.31
+++ info/perform.c	2000/10/04 09:30:54
@@ -205,6 +205,8 @@
 	    show_files("Files:\n", &plist);
 	if ((Flags & SHOW_SIZE) && installed)
 	    show_size("Package Size:\n", &plist);
+	if (Flags & SHOW_ORIGIN)
+	    show_origin("Origin:\n", &plist);
 	if (!Quiet)
 	    puts(InfoPrefix);
     }
Index: info/pkg_info.1
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/pkg_info.1,v
retrieving revision 1.26
diff -d -u -r1.26 pkg_info.1
--- info/pkg_info.1	2000/09/25 10:49:10	1.26
+++ info/pkg_info.1	2000/10/04 09:30:54
@@ -25,7 +25,7 @@
 .Nd a utility for displaying information on software packages
 .Sh SYNOPSIS
 .Nm pkg_info
-.Op Fl cdDfikrRpLsqImv
+.Op Fl cdDfikorRpLsqImv
 .Op Fl e Ar package
 .Op Fl l Ar prefix
 .Op Fl t Ar template
@@ -88,6 +88,13 @@
 are generated.
 .It Fl s
 Show the total size occupied by files installed within each package.
+.It Fl o
+Show the
+.Dq origin
+path recorded on package generation.  This path
+intended to give an idea as to where the underlying port, from which
+package was generated, is located in the
+.Em "FreeBSD Ports Collection" .
 .It Fl e Ar pkg-name
 If the package identified by
 .Ar pkg-name
Index: info/show.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/show.c,v
retrieving revision 1.16
diff -d -u -r1.16 show.c
--- info/show.c	2000/09/25 07:27:04	1.16
+++ info/show.c	2000/10/04 09:30:54
@@ -256,3 +256,18 @@
     else
 	printf("%lu\n", size);
 }
+
+/* Show an "origin" path (usually category/portname) */
+void
+show_origin(char *title, Package *plist)
+{
+    PackingList p;
+
+    if (!Quiet)
+	printf("%s%s", InfoPrefix, title);
+    for (p = plist->head; p != NULL; p = p->next)
+	if (p->type == PLIST_COMMENT && !strncmp(p->name, "ORIGIN:", 7)) {
+	    printf("%s\n", p->name + 7);
+	    break;
+	}
+}

--------------160205C298EA7560DFCAC670--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




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