Date: Thu, 16 Jan 2003 19:07:14 +0300 From: Sergey Matveychuk <sem@ciam.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/47145: Port conflict Checking for PKG_INSTALL tools (for 5.0) Message-ID: <E18ZCXy-0002H4-00@mail.ciam.ru>
index | next in thread | raw e-mail
>Number: 47145
>Category: bin
>Synopsis: Port conflict Checking for PKG_INSTALL tools (for 5.0)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Jan 16 08:10:03 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Sergey Matveychuk <sem@ciam.ru>
>Release: FreeBSD 4.7-RELEASE-p3 i386
>Organization:
>Environment:
System: FreeBSD proxy.ciam.ru 4.7-RELEASE-p3 FreeBSD 4.7-RELEASE-p3 #0: Wed Jan 8 16:30:29 MSK 2003 root@orion.ciam.ru:/usr/obj/usr/src/sys/PROXY i386
>Description:
This patch is based on Scot W. Hetzel PR bin/13649 and rewriten by me.
The attached patch adds additional functionality to the pkg_install tools.
This will also allow bsd.port.mk (with appropriate patch) and pkg_add to check
for conflicting ports before installing a port.
pkg_create adds port conflicts to the package.
With the appropriate patches to bsd.port.mk, a port that has the following
in its Makefile:
CONFLICTS= apache*-1.2* apache*-1.3.[012345] apache-*+ssl_*
will result in @pkgcfl directives in its packing list.
@pkgcfl apache*-1.2*
@pkgcfl apache*-1.3.[012345]
@pkgcfl apache-*+ssl_*
>How-To-Repeat:
>Fix:
diff -ruN /tmp/current/src/usr.sbin/pkg_install/add/perform.c pkg_install/add/perform.c
--- /tmp/current/src/usr.sbin/pkg_install/add/perform.c Tue Sep 3 10:59:33 2002
+++ pkg_install/add/perform.c Sun Dec 1 21:29:21 2002
@@ -77,6 +77,7 @@
char pre_script[FILENAME_MAX] = INSTALL_FNAME;
char post_script[FILENAME_MAX];
char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX];
+ int conflictsfound=0;
code = 0;
zapLogDir = 0;
@@ -246,6 +247,36 @@
Plist.name);
code = 1;
goto success; /* close enough for government work */
+ }
+
+ /* Now check the packing list for conflicts */
+ for (p = Plist.head; p ; p = p->next) {
+ if (p->type == PLIST_PKGCFL) {
+ char *conflict[2];
+ char **matched;
+ int i,errcode;
+
+ conflict[0]=strdup(p->name);
+ conflict[1]=NULL;
+ matched = matchinstalled(MATCH_GLOB,conflict,&errcode);
+ if(errcode == 0 && matched != NULL)
+ for(i=0; matched[i] != NULL; i++)
+ if(isinstalledpkg(matched[i])) {
+ warnx("Package '%s' conflicts with %s", Plist.name,
+ matched[i]);
+ conflictsfound=1;
+ }
+
+ continue;
+ }
+ }
+ if(conflictsfound) {
+ if(!Force) {
+ warnx("please use pkg_delete first to remove it (them)");
+ code = 1;
+ goto bomb;
+ } else
+ warnx("proceeding anyway");
}
/* Now check the packing list for dependencies */
diff -ruN /tmp/current/src/usr.sbin/pkg_install/add/pkg_add.1 pkg_install/add/pkg_add.1
--- /tmp/current/src/usr.sbin/pkg_install/add/pkg_add.1 Tue Sep 10 06:42:59 2002
+++ pkg_install/add/pkg_add.1 Sun Dec 1 22:08:59 2002
@@ -208,20 +208,29 @@
.Sh TECHNICAL DETAILS
The
.Nm
-utility is fairly simple. It extracts each package's "packing list"
-into a special staging directory, parses it,
-and then runs through the following sequence to fully extract the contents:
+utility extracts each package's "packing list" into a special staging
+directory in /tmp (or $PKG_TMPDIR if set), parses it, and then runs
+through the following sequence to fully extract the contents of the package:
.Bl -enum
.It
-Check if the package is already recorded as installed. If so,
-terminate installation.
+A check is made to determine if the package is already recorded as installed.
+If it is, installation is terminated.
+.It
+A check is made to determine if the package conflicts (from
+.Cm @pkgcfl
+directives, see
+.Xr pkg_create 1 )
+with an already recorded as installed package. If it is,
+installation is terminated.
.It
Scan all the package dependencies (from
.Cm @pkgdep
directives, see
.Xr pkg_create 1 )
-and make sure each one is met. If not, try and find the missing
-dependencies' packages and auto-install them; if they can't be found
+are read from the packing list.
+If any of these required packages is not currently installed,
+an attempt is made to find and install it;
+if the missing package cannot be found or installed,
the installation is terminated.
.It
Search for any
@@ -384,11 +393,14 @@
consists of a directory name.
The current directory may be indicated
implicitly by an empty directory name, or explicitly by a single
-period.
+period. It is usually set to
+.Pa /usr/ports/packages/All .
.Pp
The environment variable
.Ev PKG_DBDIR
-specifies an alternative location for the installed package database.
+specifies an alternative location for the installed package database,
+default location is
+.Pa /var/db/pkg .
.Pp
The environment variables
.Ev PKG_TMPDIR
diff -ruN /tmp/current/src/usr.sbin/pkg_install/create/create.h pkg_install/create/create.h
--- /tmp/current/src/usr.sbin/pkg_install/create/create.h Sun Apr 21 01:20:58 2002
+++ pkg_install/create/create.h Sat Nov 30 16:00:28 2002
@@ -37,6 +37,7 @@
extern char *ExcludeFrom;
extern char *Mtree;
extern char *Pkgdeps;
+extern char *Pkgcfl;
extern char *Origin;
extern char *InstalledPkg;
extern char PlayPen[];
diff -ruN /tmp/current/src/usr.sbin/pkg_install/create/main.c pkg_install/create/main.c
--- /tmp/current/src/usr.sbin/pkg_install/create/main.c Sun Apr 21 01:20:58 2002
+++ pkg_install/create/main.c Sat Nov 30 15:59:59 2002
@@ -16,7 +16,7 @@
#include "lib.h"
#include "create.h"
-static char Options[] = "YNOhjvyzf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:b:";
+static char Options[] = "YNOhjvyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:o:b:";
char *Prefix = NULL;
char *Comment = NULL;
@@ -32,6 +32,7 @@
char *ExcludeFrom = NULL;
char *Mtree = NULL;
char *Pkgdeps = NULL;
+char *Pkgcfl = NULL;
char *Origin = NULL;
char *InstalledPkg = NULL;
char PlayPen[FILENAME_MAX];
@@ -78,6 +79,10 @@
Contents = optarg;
break;
+ case 'C':
+ Pkgcfl = optarg;
+ break;
+
case 'c':
Comment = optarg;
break;
@@ -195,11 +200,11 @@
usage()
{
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
-"usage: pkg_create [-YNOhvy] [-P pkgs] [-p prefix] [-f contents] [-i iscript]",
-" [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ",
-" [-t template] [-X excludefile] [-D displayfile] ",
-" [-m mtreefile] [-o origin] -c comment -d description ",
-" -f packlist pkg-filename",
+"usage: pkg_create [-YNOhvy] [-P pkgs] [-C cpkgs] [-p prefix] [-f contents] ",
+" [-i iscript] [-I piscript] [-k dscript] [-K pdscript] ",
+" [-r rscript] [-t template] [-X excludefile] ",
+" [-D displayfile] [-m mtreefile] [-o origin] ",
+" -c comment -d description -f packlist pkg-filename",
" pkg_create [-YNhvy] -b pkg-name [pkg-filename]");
exit(1);
}
diff -ruN /tmp/current/src/usr.sbin/pkg_install/create/perform.c pkg_install/create/perform.c
--- /tmp/current/src/usr.sbin/pkg_install/create/perform.c Sun Aug 25 05:01:08 2002
+++ pkg_install/create/perform.c Sat Nov 30 16:06:00 2002
@@ -145,6 +145,22 @@
printf(".\n");
}
+ /* Put the conflicts directly after the dependencies, if any */
+ if (Pkgcfl) {
+ if (Verbose && !PlistOnly)
+ printf("Registering conflicts:");
+ while (Pkgcfl) {
+ cp = strsep(&Pkgcfl, " \t\n");
+ if (*cp) {
+ add_plist(&plist, PLIST_PKGCFL, cp);
+ if (Verbose && !PlistOnly)
+ printf(" %s", cp);
+ }
+ }
+ if (Verbose && !PlistOnly)
+ printf(".\n");
+ }
+
/* If a SrcDir override is set, add it now */
if (SrcDir) {
if (Verbose && !PlistOnly)
diff -ruN /tmp/current/src/usr.sbin/pkg_install/create/pkg_create.1 pkg_install/create/pkg_create.1
--- /tmp/current/src/usr.sbin/pkg_install/create/pkg_create.1 Mon Aug 5 01:20:09 2002
+++ pkg_install/create/pkg_create.1 Sun Dec 1 21:46:53 2002
@@ -32,6 +32,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl YNOhjvyz
+.Op Fl C Ar cpkgs
.Op Fl P Ar pkgs
.Op Fl p Ar prefix
.Op Fl f Ar contents
@@ -142,6 +143,13 @@
when the package is later installed.
It will be passed the package's name as
the first argument.
+.It Fl C Ar cpkgs
+Set the initial package conflict list to
+.Ar cpkgs .
+This is assumed to be a whitespace separated list of package names
+and is meant as a convenient shorthand for specifying multiple
+.Cm @pkgcfl
+directives in the packing list (see PACKING LIST DETAILS section below).
.It Fl P Ar pkgs
Set the initial package dependency list to
.Ar pkgs .
@@ -482,6 +490,11 @@
package is deinstalled. Multiple
.Cm @pkgdep
directives may be used if the package depends on multiple other packages.
+.It Cm @pkgcfl Ar pkgcflname
+Declare a conflict with the
+.Ar pkgcflname
+package, as the two packages contain references to the same files,
+and so cannot co-exist on the same system.
.El
.Sh ENVIRONMENT
The environment variable
diff -ruN /tmp/current/src/usr.sbin/pkg_install/info/show.c pkg_install/info/show.c
--- /tmp/current/src/usr.sbin/pkg_install/info/show.c Thu Oct 24 21:27:32 2002
+++ pkg_install/info/show.c Sat Nov 30 18:17:53 2002
@@ -158,6 +158,10 @@
"\tdependency origin: %s\n", p->name);
break;
+ case PLIST_PKGCFL:
+ printf(Quiet ? "@pkgcfl %s\n" : "Conflicts: %s\n", p->name);
+ break;
+
case PLIST_MTREE:
printf(Quiet ? "@mtree %s\n" : "\tPackage mtree file: %s\n", p->name);
break;
diff -ruN /tmp/current/src/usr.sbin/pkg_install/lib/lib.h pkg_install/lib/lib.h
--- /tmp/current/src/usr.sbin/pkg_install/lib/lib.h Mon Sep 9 23:43:30 2002
+++ pkg_install/lib/lib.h Sun Dec 1 01:12:22 2002
@@ -86,7 +86,7 @@
* Version of the package tools - increase only when some
* functionality used by bsd.port.mk is changed, added or removed
*/
-#define PKG_INSTALL_VERSION 20020908
+#define PKG_INSTALL_VERSION 20021201
#define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf"
#define main(argc, argv) real_main(argc, argv)
@@ -99,8 +99,8 @@
PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE,
PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY,
- PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST,
- PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN
+ PLIST_PKGDEP, PLIST_PKGCFL, PLIST_MTREE, PLIST_DIR_RM,
+ PLIST_IGNORE_INST, PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN
};
typedef enum _plist_t plist_t;
diff -ruN /tmp/current/src/usr.sbin/pkg_install/lib/plist.c pkg_install/lib/plist.c
--- /tmp/current/src/usr.sbin/pkg_install/lib/plist.c Sun Sep 1 00:21:47 2002
+++ pkg_install/lib/plist.c Sat Nov 30 18:14:57 2002
@@ -241,6 +241,8 @@
return PLIST_DISPLAY;
else if (!strcmp(cmd, "pkgdep"))
return PLIST_PKGDEP;
+ else if (!strcmp(cmd, "pkgcfl"))
+ return PLIST_PKGCFL;
else if (!strcmp(cmd, "mtree"))
return PLIST_MTREE;
else if (!strcmp(cmd, "dirrm"))
@@ -362,6 +364,10 @@
case PLIST_PKGDEP:
fprintf(fp, "%cpkgdep %s\n", CMD_CHAR, plist->name);
+ break;
+
+ case PLIST_PKGCFL:
+ fprintf(fp, "%cpkgcfl %s\n", CMD_CHAR, plist->name);
break;
case PLIST_MTREE:
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E18ZCXy-0002H4-00>
