Subject: Re: pkg_info & search of current directory prevention
To: None <tech-pkg@NetBSD.org>
From: grant beattie <grant@NetBSD.org>
List: tech-pkg
Date: 02/10/2005 20:05:48
--TD8GDToEDw0WLGOL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Feb 10, 2005 at 07:34:56PM +1100, grant beattie wrote:

> while I agree with the intent of the change, the implementation still
> has some problems:

I've put my money where my mouth is and come up with the following
diff which cleans this up. :)

it gives the correct and expected behaviour for me on NetBSD-current,
whether my cwd contains binary packages or not.

if a path to a binary package file is specified, the action is taken
on the binary package. if the argument does not point to a binary
package, information from the installed package database is used. if
that is not present, the usual "can't find package `xxx'" is reported.

I post it here for some wider testing, and intend to commit it unless
there are any problems discovered that I did not account for.

grant.



Index: info/info.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/usr.sbin/pkg_install/info/info.h,v
retrieving revision 1.17
diff -u -r1.17 info.h
--- info/info.h	13 Aug 2004 13:34:42 -0000	1.17
+++ info/info.h	10 Feb 2005 08:53:15 -0000
@@ -64,7 +64,6 @@
 extern char *CheckPkg;
 extern size_t termwidth;
 extern lpkg_head_t pkgs;
-extern int usedot;
=20
 extern void show_file(char *, char *);
 extern void show_var(const char *, const char *);
Index: info/main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/usr.sbin/pkg_install/info/main.c,v
retrieving revision 1.44
diff -u -r1.44 main.c
--- info/main.c	29 Dec 2004 11:35:00 -0000	1.44
+++ info/main.c	10 Feb 2005 08:53:15 -0000
@@ -51,7 +51,6 @@
 char   *CheckPkg =3D NULL;
 size_t  termwidth =3D 0;
 lpkg_head_t pkgs;
-int	usedot;
=20
 static void
 usage(void)
@@ -74,9 +73,8 @@
 	setprogname(argv[0]);
 	while ((ch =3D getopt(argc, argv, Options)) !=3D -1)
 		switch (ch) {
-		case '.':
-			usedot =3D 1;
-			break;
+		case '.':	/* no longer required, but present for	*/
+			break;	/* backward compatibility.		*/
=20
 		case 'a':
 			AllInstalled =3D TRUE;
Index: info/perform.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/usr.sbin/pkg_install/info/perform.c,v
retrieving revision 1.58
diff -u -r1.58 perform.c
--- info/perform.c	29 Dec 2004 11:35:00 -0000	1.58
+++ info/perform.c	10 Feb 2005 08:53:15 -0000
@@ -58,7 +58,7 @@
 			strlcpy(fname, cp, sizeof(fname));
 			isTMP =3D TRUE;
 		}
-	} else if (usedot && fexists(pkg) && isfile(pkg)) {
+	} else if (fexists(pkg) && isfile(pkg)) {
 		int     len;
=20
 		if (*pkg !=3D '/') {
@@ -72,10 +72,6 @@
 			strlcpy(fname, pkg, sizeof(fname));
 		}
 		cp =3D fname;
-	} else if (usedot) {
-		if ((cp =3D fileFindByPath(pkg)) !=3D NULL) {
-			strncpy(fname, cp, MaxPathSize);
-		}
 	}
=20
 	if (cp) {
@@ -95,13 +91,6 @@
 				}
 				strcpy(PlayPen, cp2);
 			} else {
-				if (!usedot) {
-					/* only recognise a local uninstalled package if usedot was given */
-					warnx("can't find package file '%s'", fname);
-					code =3D 1;
-					goto bail;
-				}
-
 				/*
 				 * Apply a crude heuristic to see how much space the package will
 				 * take up once it's unpacked.  I've noticed that most packages
@@ -161,8 +150,7 @@
 			}
=20
 			/* No match */
-			warnx("can't find package `%s' installed%s!", pkg,
-				  usedot ? " or in a file" : "");
+			warnx("can't find package `%s'", pkg);
 			return 1;
 		}
 		if (chdir(log_dir) =3D=3D FAIL) {

--TD8GDToEDw0WLGOL
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iD8DBQFCCyPsluYOb9yiFXoRAqRuAJ0S4+TfkUHlpATdb5ljambO4TTfugCfWUNi
9cVDLQ2t8SfRcRGFr5cbmVw=
=xCGz
-----END PGP SIGNATURE-----

--TD8GDToEDw0WLGOL--