Subject: pkg/21095: pkg_add upgrade in place (diff included)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <reed@reedmedia.net>
List: netbsd-bugs
Date: 04/11/2003 10:41:17
>Number:         21095
>Category:       pkg
>Synopsis:       allow pkg_add to upgrade without pkg_delete first
>Confidential:   yes
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 11 10:42:01 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.6
>Organization:
http://bsd.reedmedia.net/
>Environment:
	
	
System: NetBSD rainier.reedmedia.net 1.6 NetBSD 1.6 (JCR-20020927) #3: Sat Sep 28 13:40:20 PDT 2002 reed@rainier.reedmedia.net:/usr/src/sys/arch/i386/compile/JCR-20020927 i386
Architecture: i386
Machine: i386
>Description:
Please allow pkg_add to upgrade a package without deleting first.
This will make it useful to upgrade essential software that
may be used during the upgrade.
>How-To-Repeat:
	
>Fix:
Note that this patch changes the current -u to -r for replace
as discussed on tech-pkg list. This patch also includes
man page changes. (Why does this include formatted manpage too?)

Also this fixes pkgdb_remove_pkg() in files/lib/pkgdb.c which I
don't think worked in the first place.

This was made against pkgsrc before changes a few hours ago.

cvs server: Diffing pkgtools/pkg_install/files
cvs server: Diffing pkgtools/pkg_install/files/add
Index: pkgtools/pkg_install/files/add/main.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/main.c,v
retrieving revision 1.2
diff -b -u -r1.2 main.c
--- pkgtools/pkg_install/files/add/main.c	2003/01/14 15:18:32	1.2
+++ pkgtools/pkg_install/files/add/main.c	2003/04/11 16:25:30
@@ -56,7 +56,7 @@
 #include "add.h"
 #include "verify.h"
 
-static char Options[] = "IMRSVfhnp:s:t:uv";
+static char Options[] = "IMRSVfhnp:rs:t:uv";
 
 char   *Prefix = NULL;
 Boolean NoInstall = FALSE;
@@ -70,6 +70,7 @@
 char    FirstPen[FILENAME_MAX];
 add_mode_t AddMode = NORMAL;
 int	upgrade = 0;
+int	overwrite = 0;
 
 static void
 usage(void)
@@ -117,6 +118,10 @@
 			Verbose = TRUE;
 			break;
 
+		case 'r':
+			upgrade = 1; /* replace with pkg_delete first */
+			break;
+
 		case 's':
 			set_verification(optarg);
 			break;
@@ -139,7 +144,9 @@
 
 		case 'u':
 			upgrade = 1;
+			overwrite = 1; /* do not pkg_delete */
 			break;
+
 		case 'h':
 		case '?':
 		default:
Index: pkgtools/pkg_install/files/add/perform.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
retrieving revision 1.4
diff -b -u -r1.4 perform.c
--- pkgtools/pkg_install/files/add/perform.c	2003/03/29 18:41:56	1.4
+++ pkgtools/pkg_install/files/add/perform.c	2003/04/11 16:25:32
@@ -56,6 +56,8 @@
 #include <sys/wait.h>
 #endif
 
+static char installed[FILENAME_MAX]; /* already installed package name */
+
 static char LogDir[FILENAME_MAX];
 static int zapLogDir;		/* Should we delete LogDir? */
 
@@ -134,6 +136,7 @@
 
 	errc = 0;
 	zapLogDir = 0;
+	installed[0] = '\0';
 	LogDir[0] = '\0';
 	strcpy(playpen, FirstPen);
 	inPlace = 0;
@@ -320,7 +323,6 @@
 
 		if ((s = strrchr(PkgName, '-')) != NULL) {
 			char    buf[FILENAME_MAX];
-			char    installed[FILENAME_MAX];
 
 			/*
 			 * See if the pkg is already installed. If so, we might
@@ -338,7 +340,7 @@
 						 dbdir, PkgName);
 
 					if (Verbose)
-						printf("Upgrading %s to %s.\n", installed, PkgName);
+						printf("Replacing %s with %s.\n", installed, PkgName);
 
 					if (fexists(upgrade_from)) {  /* Are there any dependencies? */
 					  	/*
@@ -447,10 +449,16 @@
 						upgrading = 1;
 					}
 
+					if (overwrite) {
+						if (Verbose) {
+							printf("Upgrading by overwriting '%s' with '%s'.\n", installed, PkgName);
+						}
+					}
+					else {
 					if (Verbose)
 						printf("pkg_delete '%s'\n", installed);
 					vsystem("%s/sbin/pkg_delete '%s'\n", PREFIX, installed);
-					
+					}		
 				} else {
 					warnx("other version '%s' already installed", installed);
 
@@ -463,7 +471,7 @@
 
 	/* See if there are conflicting packages installed */
 	for (p = Plist.head; p; p = p->next) {
-		char    installed[FILENAME_MAX];
+		char    also_installed[FILENAME_MAX];
 
 		if (p->type != PLIST_PKGCFL)
 			continue;
@@ -472,9 +480,9 @@
 
 		/* was: */
 		/* if (!vsystem("/usr/sbin/pkg_info -qe '%s'", p->name)) { */
-		if (findmatchingname(dbdir, p->name, note_whats_installed, installed) > 0) {
-			warnx("Conflicting package `%s'installed, please use\n"
-			      "\t\"pkg_delete %s\" first to remove it!", installed, installed);
+		if (findmatchingname(dbdir, p->name, note_whats_installed, also_installed) > 0) {
+			warnx("Conflicting package `%s' installed, please use\n"
+			      "\t\"pkg_delete %s\" first to remove it!", also_installed, also_installed);
 			++errc;
 		}
 	}
@@ -483,14 +491,14 @@
 	 * (e.g. version X is installed, but version Y is required)
 	 */
 	for (p = Plist.head; p; p = p->next) {
-		char installed[FILENAME_MAX];
+		char also_installed[FILENAME_MAX];
 		
 		if (p->type != PLIST_PKGDEP)
 			continue;
 		if (Verbose)
 			printf("Depends pre-scan: `%s' required.\n", p->name);
 		/* if (vsystem("/usr/sbin/pkg_info -qe '%s'", p->name)) { */
-		if (findmatchingname(dbdir, p->name, note_whats_installed, installed) <= 0) {
+		if (findmatchingname(dbdir, p->name, note_whats_installed, also_installed) <= 0) {
 			/* 
 			 * required pkg not found. look if it's available with a more liberal
 			 * pattern. If so, this will lead to problems later (check on "some
@@ -517,15 +525,15 @@
 				(void) snprintf(buf, sizeof(buf),
 				    skip ? "%.*s[0-9]*" : "%.*s-[0-9]*",
 				    (int)(s - p->name) + skip, p->name);
-				if (findmatchingname(dbdir, buf, note_whats_installed, installed) > 0) {
+				if (findmatchingname(dbdir, buf, note_whats_installed, also_installed) > 0) {
 					warnx("pkg `%s' required, but `%s' found installed.",
-					      p->name, installed);
+					      p->name, also_installed);
 
 					if (upgrading) {
 						printf("HF: upgrade note -- could 'pkg_delete %s', and let the normal\n"
 						       "dependency handling reinstall the updated package, assuming one IS\n"
 						       "available. But then I'd expect proper binary pkgs being available for\n"
-						       "the upgrade case.\n", installed);
+						       "the upgrade case.\n", also_installed);
 					}
 
 					if (Force) {
@@ -543,7 +551,6 @@
 
 	/* Now check the packing list for dependencies */
 	for (exact = NULL, p = Plist.head; p; p = p->next) {
-		char    installed[FILENAME_MAX];
 
 		if (p->type == PLIST_BLDDEP) {
 			exact = p->name;
@@ -601,8 +608,23 @@
 		}
 	}
 	
+	/* remove old package entries from database */
+	if (!Fake && overwrite && installed[0]) {
+
+		/* Open Package Database for writing */
+		if (!pkgdb_open(ReadWrite))
+			warnx("can't open pkgdb");
+		else {
+                       	if (pkgdb_remove_pkg(installed))
+				printf("Removed previous package entries from pkgdb.\n");
+			else
+				warnx("couldn't remove previous package entries from pkgdb.\n");
+		}
+		pkgdb_close();
+	}
+	
 	/* If we're really installing, and have an installation file, run it */
-	if (!NoInstall && fexists(INSTALL_FNAME)) {
+	if (!NoInstall && !overwrite && fexists(INSTALL_FNAME)) {
 		vsystem("%s +x %s", CHMOD_CMD, INSTALL_FNAME);	/* make sure */
 		if (Verbose)
 			printf("Running install with PRE-INSTALL for %s.\n", PkgName);
@@ -634,7 +656,7 @@
 	}
 
 	/* Run the installation script one last time? */
-	if (!NoInstall && fexists(INSTALL_FNAME)) {
+	if (!NoInstall && !overwrite && fexists(INSTALL_FNAME)) {
 		if (Verbose)
 			printf("Running install with POST-INSTALL for %s.\n", PkgName);
 		if (!Fake && vsystem("./%s %s POST-INSTALL", INSTALL_FNAME, PkgName)) {
@@ -644,6 +666,18 @@
 		}
 	}
 
+	/* Run the installation script if upgrading */
+	if (overwrite && !NoInstall && fexists(INSTALL_FNAME)) {
+		vsystem("%s +x %s", CHMOD_CMD, INSTALL_FNAME);	/* make sure */
+		if (Verbose)
+			printf("Running install with UPGRADE for %s.\n", PkgName);
+		if (!Fake && vsystem("./%s %s UPGRADE", INSTALL_FNAME, PkgName)) {
+			warnx("install script returned error status");
+			errc = 1;
+			goto fail;
+		}
+	}
+
 	/* Time to record the deed? */
 	if (!NoRecord && !Fake) {
 		char    contents[FILENAME_MAX];
@@ -739,6 +773,97 @@
 			printf("Package %s registered in %s\n", PkgName, LogDir);
 	}
 
+	/*
+	 * When upgrading, look at old +CONTENTS and make sure
+	 * that files and directories existing in old but not
+	 * new are removed.
+	*/
+	if (overwrite && installed[0]) {
+		static package_t old_Plist;
+		static char old_contents[FILENAME_MAX];
+
+		(void) snprintf(old_contents, sizeof(old_contents), "%s/%s/" CONTENTS_FNAME, dbdir, installed);
+		cfile = fopen(old_contents, "r");
+
+		if (!cfile)
+			warnx("unable to open table of contents file of old package `%s'.",
+			      old_contents);
+		else {
+			plist_t *p;
+			char    *s, try[FILENAME_MAX], t[FILENAME_MAX];
+			char    *old_Directory = ".";	
+
+			if (Verbose)
+				printf("Comparing previous CONTENTS: %s\n",
+					old_contents);
+			read_plist(&old_Plist, cfile);
+			fclose(cfile);
+
+			/* Open Package Database for reading */
+			if (!pkgdb_open(ReadOnly))
+				warnx("can't open pkgdb");
+			else {
+
+				for (p = old_Plist.head; p; p = p->next) {
+
+					switch (p->type) {
+
+					case PLIST_IGNORE:
+						p = p->next;
+						break;
+
+					case PLIST_CWD:
+						old_Directory = p->name;
+						break;
+
+					case PLIST_FILE:
+		/*	last_file = p->name; */
+		/*		char    try[FILENAME_MAX]; */
+
+						if (strrchr(p->name, '\''))
+							warnx("Bogus filename \"%s\"", p->name);
+						else {
+
+							(void) snprintf(t, sizeof(t), "%s/%s", old_Directory, p->name);
+							if (fexists(t)) {
+								/* remove file if not in database for new package */
+								s = pkgdb_retrieve(t);
+#ifdef PKGDB_DEBUG
+								printf("pkgdb_retrieve(\"%s\")=\"%s\"\n", t, s);	/* pkgdb-debug - HF */
+#endif
+								/* file exists */
+								if (!s) {
+									if (Verbose)
+										printf("%s is not in pkgdb; deleting.\n", t);
+
+									if (!Fake) 
+										vsystem("%s %s", RM, t);
+								}
+							}
+						}
+					}
+				}
+				pkgdb_close();
+				if (!Fake && old_contents[0])
+					vsystem("%s %s", RM, old_contents);
+			}
+		}
+		/* TODO -- get rid of old directories? */
+	} /* checks for files no longer part of new package during overwrite */
+
+	/* remove old package data files under /var/db/pkg */
+	if (overwrite && installed[0]) {
+		static char PreviousLogDir[FILENAME_MAX];
+		(void) snprintf(PreviousLogDir, sizeof(PreviousLogDir), "%s/%s", dbdir, installed);
+		if (isdir(PreviousLogDir) || islinktodir(PreviousLogDir)) {
+			if (Verbose)
+				printf("Removing old package data: %s\n", PreviousLogDir);
+			if (!Fake && PreviousLogDir[0])
+				vsystem("%s -rf %s", RM, PreviousLogDir);
+		}
+
+	}
+
 	if ((p = find_plist(&Plist, PLIST_DISPLAY)) != NULL) {
 		FILE   *fp;
 		char    buf[BUFSIZ];
@@ -776,6 +901,8 @@
 		 * Upgrade step 3/4: move back +REQUIRED_BY file
 		 * (see also step 2/4)
 		 */
+		if (Verbose)
+			printf("Move back +REQUIRED_BY file: %s\n", upgrade_to);
 		rc = rename(upgrade_via, upgrade_to);
 		assert(rc == 0);
 		
Index: pkgtools/pkg_install/files/add/pkg_add.1
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/pkg_add.1,v
retrieving revision 1.2
diff -b -u -r1.2 pkg_add.1
--- pkgtools/pkg_install/files/add/pkg_add.1	2003/03/29 18:41:56	1.2
+++ pkgtools/pkg_install/files/add/pkg_add.1	2003/04/11 16:25:33
@@ -25,7 +25,7 @@
 .Nd a utility for installing and upgrading software package distributions
 .Sh SYNOPSIS
 .Nm ""
-.Op Fl fIMnRSuVv
+.Op Fl fIMnRrSuVv
 .Bk -words
 .Op Fl s Ar verification-type
 .Ek
@@ -157,6 +157,15 @@
 Do not record the installation of a package.
 This means that you cannot deinstall it later, so only use this option if
 you know what you are doing!
+.It Fl r
+Replace currently installed package with a newer version.
+This uses
+.Xr pkg_delete 1
+to remove the old package.
+See below for a more detailed description of the process.
+Use the
+.Fl u
+flag to upgrade without deleting files first.
 .It Fl S
 Run in
 .Cm SLAVE
@@ -216,9 +225,12 @@
 file installation; often this is
 .Pa /usr .
 .It Fl u
-If the package that's being installed is already installed, either
-in the same or a different version, an update is performed.
+Upgrade a package to a newer version without deleting the currently
+installed files first. This upgrade option overwrites files.
 See below for a more detailed description of the process.
+Use the
+.Fl r
+flag instead to replace a package by cleanly deleting the files first.
 .It Fl V
 Print version number and exit.
 .It Fl v
@@ -269,19 +281,27 @@
 option is not given.
 .Pp
 If the
+.Fl r
+option or the
 .Fl u
-option is given, it's assumed the package should be upgraded instead.
+option is given, it's assumed the package should be replaced or upgraded
+instead.
 Before doing so, all packages that depend on the pkg being upgraded
 are checked if they also work with the new version. If that test is
 successful, the upgrade is prepared by moving an existing
 .Pa +REQUIRED_BY
-file aside (if it exists), and running
-.Xr pkg_delete 1
-on the installed package.
-Installation then proceeds as if the package
-was not installed, and restores the
+file aside (if it exists).
+When the
+.Fl u
+option is not used, then the installed package is removed with
+.Xr pkg_delete 1 .
+Installation then proceeds as if the package was not installed.
+The upgrade option overwrites files.
+Also, the upgrade option will delete any files from the previous package
+that no longer exist in the newly-installed version.
+Then, the
 .Pa +REQUIRED_BY
-file afterwards.
+file is restored.
 .It
 A check is made to determine if the package conflicts (from
 .Cm @pkgcfl
@@ -334,7 +354,9 @@
 .It
 If the package contains an
 .Ar install
-script, it is executed with the following arguments:
+script and an upgrade
+.Fl ( u )
+is not being done, it is executed with the following arguments:
 .Bl -tag -width indentindent
 .It Ar pkg-name
 The name of the package being installed.
@@ -380,13 +402,31 @@
 .It
 If an
 .Ar install
-script exists for the package, it is executed with the following arguments:
+script exists for the package
+script and an upgrade  
+.Fl ( u )
+is not being done, it is executed with the following arguments:
 .Bl -tag -width indentindent
 .It Ar pkg_name
 The name of the package being installed.
 .It Cm POST-INSTALL
 Keyword denoting that the script is to perform any actions needed
 after the package has been installed.
+.El
+.It
+During an upgrade
+.Fl ( u ) ,
+if an
+.Ar install
+script exists for the package,
+it is executed with the following arguments:
+.Bl -tag -width indentindent
+.It Ar pkg_name
+The name of the package being installed.
+.It Cm UPGRADE
+Keyword denoting that the script is to perform any actions needed
+after the package has been upgraded (i.e., the previous package
+was not cleanly uninstalled first).
 .El
 .It
 After installation is complete, a copy of the packing list,
Index: pkgtools/pkg_install/files/add/pkg_add.cat1
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/pkg_add.cat1,v
retrieving revision 1.1.1.1
diff -b -u -r1.1.1.1 pkg_add.cat1
--- pkgtools/pkg_install/files/add/pkg_add.cat1	2002/12/20 18:13:58	1.1.1.1
+++ pkgtools/pkg_install/files/add/pkg_add.cat1	2003/04/11 16:25:34
@@ -5,7 +5,7 @@
      butions
 
 SSYYNNOOPPSSIISS
-     ppkkgg__aadddd [--ffIIMMnnRRSSuuVVvv] [--ss _v_e_r_i_f_i_c_a_t_i_o_n_-_t_y_p_e] [--tt _t_e_m_p_l_a_t_e] [--pp _p_r_e_f_i_x]
+     ppkkgg__aadddd [--ffIIMMnnRRrrSSuuVVvv] [--ss _v_e_r_i_f_i_c_a_t_i_o_n_-_t_y_p_e] [--tt _t_e_m_p_l_a_t_e] [--pp _p_r_e_f_i_x]
              [ftp://[_u_s_e_r[:_p_a_s_s_w_o_r_d_]@]_h_o_s_t[:_p_o_r_t]][/_p_a_t_h_/]pkg-name ...
 
 DDEESSCCRRIIPPTTIIOONN
@@ -79,6 +79,11 @@
              cannot deinstall it later, so only use this option if you know
              what you are doing!
 
+     --rr      Replace currently installed package with a newer version.  This
+             uses pkg_delete(1) to remove the old package.  See below for a
+             more detailed description of the process.  Use the --uu flag to up-
+             grade without deleting files first.
+
      --SS      Run in SSLLAAVVEE mode.  This is a very specialized mode for running
              ppkkgg__aadddd and is meant to be run in conjunction with MMAASSTTEERR mode.
              When run in this mode, ppkkgg__aadddd expects the release contents to be
@@ -116,9 +121,11 @@
              _t_e_m_p_l_a_t_e to reside on the same disk partition as target directo-
              ries for package file installation; often this is _/_u_s_r.
 
-     --uu      If the package that's being installed is already installed, ei-
-             ther in the same or a different version, an update is performed.
-             See below for a more detailed description of the process.
+     --uu      Upgrade a package to a newer version without deleting the cur-
+             rently installed files first. This upgrade option overwrites
+             files.  See below for a more detailed description of the process.
+             Use the --rr flag instead to replace a package by cleanly deleting
+             the files first.
 
      --VV      Print version number and exit.
 
@@ -145,12 +152,18 @@
                 of it is already recorded as installed.  If it is, installa-
                 tion is terminated if the --uu option is not given.
 
-                If the --uu option is given, it's assumed the package should be
-                upgraded instead.  This is prepared by moving an existing
-                _+_R_E_Q_U_I_R_E_D___B_Y file aside (if it exists), and by running
-                pkg_delete(1) on the installed package.  Installation then
-                proceeds as if the package was not installed, and restores the
-                _+_R_E_Q_U_I_R_E_D___B_Y file afterwards.
+                If the --rr option or the --uu option is given, it's assumed the
+                package should be replaced or upgraded instead.  Before doing
+                so, all packages that depend on the pkg being upgraded are
+                checked if they also work with the new version. If that test
+                is successful, the upgrade is prepared by moving an existing
+                _+_R_E_Q_U_I_R_E_D___B_Y file aside (if it exists).  When the --uu option is
+                not used, then the installed package is removed with
+                pkg_delete(1).  Installation then proceeds as if the package
+                was not installed.  The upgrade option overwrites files.  Al-
+                so, the upgrade option will delete any files from the previous
+                package that no longer exist in the newly-installed version.
+                Then, the _+_R_E_Q_U_I_R_E_D___B_Y file is restored.
 
            2.   A check is made to determine if the package conflicts (from
                 @@ppkkggccffll directives, see pkg_create(1)) with an already record-
@@ -186,8 +199,9 @@
                 If the _r_e_q_u_i_r_e script exits with a non-zero status code, the
                 installation is terminated.
 
-           7.   If the package contains an _i_n_s_t_a_l_l script, it is executed with
-                the following arguments:
+           7.   If the package contains an _i_n_s_t_a_l_l script and an upgrade (--uu)
+                is not being done, it is executed with the following argu-
+                ments:
 
                 _p_k_g_-_n_a_m_e      The name of the package being installed.
 
@@ -210,16 +224,27 @@
                 or, if no --pp flag was specified, the name of the first direc-
                 tory named by a @@ccwwdd directive within this package.
 
-           10.  If an _i_n_s_t_a_l_l script exists for the package, it is executed
-                with the following arguments:
+           10.  If an _i_n_s_t_a_l_l script exists for the package script and an up-
+                grade (--uu) is not being done, it is executed with the follow-
+                ing arguments:
 
                 _p_k_g___n_a_m_e      The name of the package being installed.
 
                 PPOOSSTT--IINNSSTTAALLLL  Keyword denoting that the script is to perform
                               any actions needed after the package has been
                               installed.
+
+           11.  During an upgrade (--uu), if an _i_n_s_t_a_l_l script exists for the
+                package, it is executed with the following arguments:
+
+                _p_k_g___n_a_m_e      The name of the package being installed.
+
+                UUPPGGRRAADDEE       Keyword denoting that the script is to perform
+                              any actions needed after the package has been
+                              upgraded (i.e., the previous package was not
+                              cleanly uninstalled first).
 
-           11.  After installation is complete, a copy of the packing list,
+           12.  After installation is complete, a copy of the packing list,
                 _d_e_i_n_s_t_a_l_l script, description, and display files are copied
                 into _/_v_a_r_/_d_b_/_p_k_g_/_<_p_k_g_-_n_a_m_e_> for subsequent possible use by
                 pkg_delete(1).  Any package dependencies are recorded in the
@@ -227,9 +252,9 @@
                 the environment variable PKG_DBDIR is set, this overrides the
                 _/_v_a_r_/_d_b_/_p_k_g_/ path shown above).
 
-           12.  The staging area is deleted and the program terminates.
+           13.  The staging area is deleted and the program terminates.
 
-           13.  Finally, if we were upgrading a package, any _+_R_E_Q_U_I_R_E_D___B_Y file
+           14.  Finally, if we were upgrading a package, any _+_R_E_Q_U_I_R_E_D___B_Y file
                 that was moved aside before upgrading was started is now moved
                 back into place.
 
cvs server: Diffing pkgtools/pkg_install/files/admin
cvs server: Diffing pkgtools/pkg_install/files/create
cvs server: Diffing pkgtools/pkg_install/files/delete
cvs server: Diffing pkgtools/pkg_install/files/info
cvs server: Diffing pkgtools/pkg_install/files/lib
Index: pkgtools/pkg_install/files/lib/lib.h.in
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/lib.h.in,v
retrieving revision 1.4
diff -b -u -r1.4 lib.h.in
--- pkgtools/pkg_install/files/lib/lib.h.in	2003/03/16 19:44:10	1.4
+++ pkgtools/pkg_install/files/lib/lib.h.in	2003/04/11 16:25:35
@@ -449,6 +449,7 @@
 extern Boolean Fake;
 extern Boolean Force;
 extern int upgrade;
+extern int overwrite;
 
 /* We include it at the end, because it uses TAILQ_* */
 #include "path.h"
Index: pkgtools/pkg_install/files/lib/pkgdb.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c,v
retrieving revision 1.9
diff -b -u -r1.9 pkgdb.c
--- pkgtools/pkg_install/files/lib/pkgdb.c	2003/03/29 18:41:57	1.9
+++ pkgtools/pkg_install/files/lib/pkgdb.c	2003/04/11 16:25:36
@@ -240,7 +240,7 @@
 	if (pkgdbp == NULL) {
 		return 0;
 	}
-	cc = strlen(pkg);
+	cc = strlen(pkg) + 1;
 	for (ret = 1, type = R_FIRST; (*pkgdbp->seq)(pkgdbp, &key, &data, type) == 0 ; type = R_NEXT) {
 		if (cc == data.size && strncmp(data.data, pkg, cc) == 0) {
 			if (Verbose) {
>Release-Note:
>Audit-Trail:
>Unformatted: