Date: Sun, 28 Jan 2001 17:51:36 +0100 (CET) From: mavetju@chello.nl To: FreeBSD-gnats-submit@freebsd.org Subject: bin/24695: [patch] pkg_info: prefix search for a package Message-ID: <20010128165136.4DBE775@d9168.upc-d.chello.nl>
next in thread | raw e-mail | index | archive | help
>Number: 24695 >Category: bin >Synopsis: [patch] pkg_info: prefix search for a package >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jan 28 09:00:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Edwin Groothuis >Release: FreeBSD 4.2-RELEASE i386 >Organization: - >Environment: pkg_install, HEAD tag main.c: 1.27 pkg_info.1: 1.31 perform.c: 1.32 >Description: Sometimes I need to find the know the description or the version of an installed package. Of course, pkg_info -a | grep string works fine, but userfriendly? By adding the -F option (fuzzy search), it will not check for the full name of the package but use the given pkg-name as a prefix in the package to search for. >How-To-Repeat: [~] edwin@p6>pkg_info -F screen Information for screen-3.9.5: Comment: A multi-screen window manager [...] >Fix: Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/main.c,v retrieving revision 1.27 diff -u -r1.27 main.c --- main.c 2000/12/05 11:02:19 1.27 +++ main.c 2001/01/28 16:49:12 @@ -28,11 +28,12 @@ "$FreeBSD: src/usr.sbin/pkg_install/info/main.c,v 1.27 2000/12/05 11:02:19 sobomax Exp $"; #endif -static char Options[] = "acdDe:fhiIkl:LmopqrRst:v"; +static char Options[] = "acdDe:fFhiIkl:LmopqrRst:v"; int Flags = 0; Boolean AllInstalled = FALSE; Boolean Quiet = FALSE; +Boolean FuzzySearch = FALSE; char *InfoPrefix = ""; char PlayPen[FILENAME_MAX]; char *CheckPkg = NULL; @@ -86,6 +87,10 @@ case 'f': Flags |= SHOW_PLIST; + break; + + case 'F': + FuzzySearch = TRUE; break; case 'i': Index: perform.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/perform.c,v retrieving revision 1.32 diff -u -r1.32 perform.c --- perform.c 2000/10/23 07:01:31 1.32 +++ perform.c 2001/01/28 16:49:13 @@ -137,9 +137,27 @@ /* It's not an ininstalled package, try and find it among the installed */ else { char *tmp; + extern Boolean FuzzySearch; - sprintf(log_dir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, - pkg); + tmp = getenv(PKG_DBDIR) ? tmp : DEF_LOG_DIR; + sprintf(log_dir, "%s/%s", tmp, pkg); + if (FuzzySearch==TRUE) { + DIR *dirp=opendir(tmp); + struct dirent *dp; + + while ((dp = readdir(dirp)) != NULL) + if (strncmp(dp->d_name, pkg, strlen(pkg))==0) + break; + closedir(dirp); + + if (dp==NULL) { + warnx("can't find a package prefixed with `%s'!", pkg); + return 1; + } + sprintf(log_dir, "%s/%s", tmp, dp->d_name); + pkg=dp->d_name; + } + if (!fexists(log_dir)) { warnx("can't find package `%s' installed or in a file!", pkg); return 1; Index: pkg_info.1 =================================================================== RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/pkg_info.1,v retrieving revision 1.31 diff -u -r1.31 pkg_info.1 --- pkg_info.1 2000/12/27 15:30:19 1.31 +++ pkg_info.1 2001/01/28 16:49:13 @@ -24,13 +24,13 @@ .Nm pkg_info .Nd a utility for displaying information on software packages .Sh SYNOPSIS -.Nm -.Op Fl cdDfiIkLmopqrRsv +.Nm pkg_info +.Op Fl cdDfFiIkLmopqrRsv .Op Fl e Ar package .Op Fl l Ar prefix .Op Fl t Ar template .Ar pkg-name [pkg-name ...] -.Nm +.Nm pkg_info .Fl a .Op Ar flags .Sh DESCRIPTION @@ -69,6 +69,10 @@ Show the install-message file for each package. .It Fl f Show the packing list instructions for each package. +.It Fl F +Threat the +.Ar pkg-name +as a prefix of the named package being search for. .It Fl i Show the install script (if any) for each package. .It Fl I >Release-Note: >Audit-Trail: >Unformatted: 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?20010128165136.4DBE775>