Date: Wed, 5 Mar 2003 13:20:09 -0800 (PST) From: Sergey Matveychuk <sem@ciam.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/47145: Port conflict Checking for PKG_INSTALL tools (for 5.0) Message-ID: <200303052120.h25LK9vt068922@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/47145; it has been noted by GNATS.
From: Sergey Matveychuk <sem@ciam.ru>
To: freebsd-gnats-submit@FreeBSD.org, sem@ciam.ru
Cc:
Subject: Re: bin/47145: Port conflict Checking for PKG_INSTALL tools (for
5.0)
Date: Thu, 06 Mar 2003 00:12:05 +0300
This is a multi-part message in MIME format.
--------------060609060001020003050808
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Here is a new version of patch modified in according with remarks of
Kris Kennaway.
--------------060609060001020003050808
Content-Type: text/plain;
name="pkg_install.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="pkg_install.patch"
diff -ruN /usr/src/usr.sbin/pkg_install/add/perform.c pkg_install/add/perform.c
--- /usr/src/usr.sbin/pkg_install/add/perform.c Mon Feb 17 01:10:13 2003
+++ pkg_install/add/perform.c Mon Feb 17 00:27:04 2003
@@ -77,6 +77,11 @@
char pre_script[FILENAME_MAX] = INSTALL_FNAME;
char post_script[FILENAME_MAX];
char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX];
+ int conflictsfound=0;
+ char *conflict[2];
+ char **matched;
+ int i,errcode;
+
code = 0;
zapLogDir = 0;
@@ -246,6 +251,33 @@
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_CONFLICTS) {
+ conflict[0]=strdup(p->name);
+ conflict[1]=NULL;
+ matched = matchinstalled(MATCH_GLOB,conflict,&errcode);
+ free(conflict[0]);
+ 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 /usr/src/usr.sbin/pkg_install/add/pkg_add.1 pkg_install/add/pkg_add.1
--- /usr/src/usr.sbin/pkg_install/add/pkg_add.1 Mon Feb 17 01:10:13 2003
+++ pkg_install/add/pkg_add.1 Mon Feb 17 00:24:34 2003
@@ -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 @conflicts
+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 /usr/src/usr.sbin/pkg_install/create/create.h pkg_install/create/create.h
--- /usr/src/usr.sbin/pkg_install/create/create.h Mon Feb 17 01:10:13 2003
+++ pkg_install/create/create.h Mon Feb 17 00:24:34 2003
@@ -37,6 +37,7 @@
extern char *ExcludeFrom;
extern char *Mtree;
extern char *Pkgdeps;
+extern char *Conflicts;
extern char *Origin;
extern char *InstalledPkg;
extern char PlayPen[];
diff -ruN /usr/src/usr.sbin/pkg_install/create/main.c pkg_install/create/main.c
--- /usr/src/usr.sbin/pkg_install/create/main.c Mon Feb 17 01:10:13 2003
+++ pkg_install/create/main.c Mon Feb 17 00:29:14 2003
@@ -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 *Conflicts = NULL;
char *Origin = NULL;
char *InstalledPkg = NULL;
char PlayPen[FILENAME_MAX];
@@ -78,6 +79,10 @@
Contents = optarg;
break;
+ case 'C':
+ Conflicts = 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 /usr/src/usr.sbin/pkg_install/create/perform.c pkg_install/create/perform.c
--- /usr/src/usr.sbin/pkg_install/create/perform.c Mon Feb 17 01:10:13 2003
+++ pkg_install/create/perform.c Mon Feb 17 00:24:34 2003
@@ -145,6 +145,22 @@
printf(".\n");
}
+ /* Put the conflicts directly after the dependencies, if any */
+ if (Conflicts) {
+ if (Verbose && !PlistOnly)
+ printf("Registering conflicts:");
+ while (Conflicts) {
+ cp = strsep(&Conflicts, " \t\n");
+ if (*cp) {
+ add_plist(&plist, PLIST_CONFLICTS, 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 /usr/src/usr.sbin/pkg_install/create/pkg_create.1 pkg_install/create/pkg_create.1
--- /usr/src/usr.sbin/pkg_install/create/pkg_create.1 Mon Feb 17 01:10:13 2003
+++ pkg_install/create/pkg_create.1 Mon Feb 17 00:24:34 2003
@@ -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 @conflicts
+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 @conflicts 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 /usr/src/usr.sbin/pkg_install/info/show.c pkg_install/info/show.c
--- /usr/src/usr.sbin/pkg_install/info/show.c Mon Feb 17 01:10:13 2003
+++ pkg_install/info/show.c Mon Feb 17 00:24:34 2003
@@ -158,6 +158,10 @@
"\tdependency origin: %s\n", p->name);
break;
+ case PLIST_CONFLICTS:
+ printf(Quiet ? "@conflicts %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 /usr/src/usr.sbin/pkg_install/lib/lib.h pkg_install/lib/lib.h
--- /usr/src/usr.sbin/pkg_install/lib/lib.h Mon Feb 17 01:10:13 2003
+++ pkg_install/lib/lib.h Mon Feb 17 01:11:11 2003
@@ -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 20030217
#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_CONFLICTS, PLIST_MTREE, PLIST_DIR_RM,
+ PLIST_IGNORE_INST, PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN
};
typedef enum _plist_t plist_t;
diff -ruN /usr/src/usr.sbin/pkg_install/lib/plist.c pkg_install/lib/plist.c
--- /usr/src/usr.sbin/pkg_install/lib/plist.c Mon Feb 17 01:10:13 2003
+++ pkg_install/lib/plist.c Mon Feb 17 00:24:34 2003
@@ -241,6 +241,8 @@
return PLIST_DISPLAY;
else if (!strcmp(cmd, "pkgdep"))
return PLIST_PKGDEP;
+ else if (!strcmp(cmd, "conflicts"))
+ return PLIST_CONFLICTS;
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_CONFLICTS:
+ fprintf(fp, "%cconflicts %s\n", CMD_CHAR, plist->name);
break;
case PLIST_MTREE:
--------------060609060001020003050808--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303052120.h25LK9vt068922>
