Allow specifying a package name without a version.

If no (installed) package is found with the given name, "-[0-9]*" is
appended, and the search retried. Withs with any options to pkg_delete
and (esp.) pkg_info:

	pkg_info kde
	pkg_info -e emacs
	pkg_info -qL xlock
	pkg_delete -v emacs
This commit is contained in:
hubertf 1999-08-19 19:37:20 +00:00
parent f2c2e160b1
commit c94d3e89cb
8 changed files with 74 additions and 25 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: delete.h,v 1.4 1999/03/08 00:20:21 hubertf Exp $ */
/* $NetBSD: delete.h,v 1.5 1999/08/19 19:37:20 hubertf Exp $ */
/* from FreeBSD Id: delete.h,v 1.4 1997/02/22 16:09:35 peter Exp */
@ -33,4 +33,6 @@ extern Boolean Force;
extern Boolean Recurse_up;
extern Boolean Recurse_down;
extern int find_fn(const char *pkg, char *data);
#endif /* _INST_DELETE_H_INCLUDE */

View File

@ -1,11 +1,11 @@
/* $NetBSD: main.c,v 1.11 1999/03/22 05:02:40 hubertf Exp $ */
/* $NetBSD: main.c,v 1.12 1999/08/19 19:37:21 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char *rcsid = "from FreeBSD Id: main.c,v 1.11 1997/10/08 07:46:48 charnier Exp";
#else
__RCSID("$NetBSD: main.c,v 1.11 1999/03/22 05:02:40 hubertf Exp $");
__RCSID("$NetBSD: main.c,v 1.12 1999/08/19 19:37:21 hubertf Exp $");
#endif
#endif
@ -54,7 +54,7 @@ usage(void)
exit(1);
}
static int
int
find_fn(const char *pkg, char *data)
{
lpkg_t *lpp;

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.23 1999/03/22 06:04:16 abs Exp $ */
/* $NetBSD: perform.c,v 1.24 1999/08/19 19:37:21 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.23 1999/03/22 06:04:16 abs Exp $");
__RCSID("$NetBSD: perform.c,v 1.24 1999/08/19 19:37:21 hubertf Exp $");
#endif
#endif
@ -475,6 +475,21 @@ pkg_do(char *pkg)
(void) snprintf(LogDir, sizeof(LogDir), "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR,
pkg);
if (!fexists(LogDir) || !isdir(LogDir)) {
{
/* Check if the given package name matches something
* with 'pkg-[0-9]*'
*/
char try[FILENAME_MAX];
snprintf(try, FILENAME_MAX, "%s-[0-9]*", pkg);
if (findmatchingname(_pkgdb_getPKGDB_DIR(), try,
find_fn, NULL) != 0) {
return 0; /* we've just appended some names to the pkgs list,
* they will be processed after this package.
*/
}
}
/* No match */
warnx("no such package '%s' installed", pkg);
return 1;
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_delete.1,v 1.12 1999/03/22 18:44:03 garbled Exp $
.\" $NetBSD: pkg_delete.1,v 1.13 1999/08/19 19:37:21 hubertf Exp $
.\"
.\" FreeBSD install - a package for the installation and maintainance
.\" of non-core utilities.
@ -70,7 +70,8 @@ The following command line options are supported:
.Bl -tag -width indent
.It Ar pkg-name ...
The named packages are deinstalled, wildcards can be used, see
.Xr pkg_info 1 .
.Xr pkg_info 1 . If no version is given, the one currently installed
will be removed.
If the
.Fl F
flag is given, one or more (absolute) filenames may be specified and

View File

@ -1,4 +1,4 @@
/* $NetBSD: info.h,v 1.9 1999/03/04 00:35:05 hubertf Exp $ */
/* $NetBSD: info.h,v 1.10 1999/08/19 19:37:22 hubertf Exp $ */
/* from FreeBSD Id: info.h,v 1.10 1997/02/22 16:09:40 peter Exp */
@ -58,11 +58,13 @@ extern char PlayPen[];
extern size_t PlayPenSize;
extern char *CheckPkg;
extern size_t termwidth;
extern lpkg_head_t pkgs;
extern void show_file(char *, char *);
extern void show_plist(char *, package_t *, pl_ent_t);
extern void show_files(char *, package_t *);
extern void show_depends(char *, package_t *);
extern void show_index(char *, char *);
extern int find_fn(const char *pkg, char *data);
#endif /* _INST_INFO_H_INCLUDE */

View File

@ -1,11 +1,11 @@
/* $NetBSD: main.c,v 1.16 1999/03/22 05:02:41 hubertf Exp $ */
/* $NetBSD: main.c,v 1.17 1999/08/19 19:37:22 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char *rcsid = "from FreeBSD Id: main.c,v 1.14 1997/10/08 07:47:26 charnier Exp";
#else
__RCSID("$NetBSD: main.c,v 1.16 1999/03/22 05:02:41 hubertf Exp $");
__RCSID("$NetBSD: main.c,v 1.17 1999/08/19 19:37:22 hubertf Exp $");
#endif
#endif
@ -61,7 +61,7 @@ usage(void)
exit(1);
}
static int
int
find_fn(const char *pkg, char *data)
{
lpkg_t *lpp;

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.25 1999/08/19 14:12:34 agc Exp $ */
/* $NetBSD: perform.c,v 1.26 1999/08/19 19:37:22 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.25 1999/08/19 14:12:34 agc Exp $");
__RCSID("$NetBSD: perform.c,v 1.26 1999/08/19 19:37:22 hubertf Exp $");
#endif
#endif
@ -76,6 +76,7 @@ pkg_do(char *pkg)
if ((cp = fileFindByPath(NULL, pkg)) != NULL)
strncpy(fname, cp, FILENAME_MAX);
}
if (cp) {
if (URLlength(pkg) > 0) {
/* file is already unpacked by fileGetURL() */
@ -99,17 +100,32 @@ pkg_do(char *pkg)
goto bail;
}
}
}
/*
* It's not an uninstalled package, try and find it among the
* installed
*/
else {
} else {
/*
* It's not an uninstalled package, try and find it among the
* installed
*/
char *tmp;
(void) snprintf(log_dir, sizeof(log_dir), "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR,
(void) snprintf(log_dir, sizeof(log_dir), "%s/%s",
(tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR,
pkg);
if (!fexists(log_dir) || !isdir(log_dir)) {
{
/* Check if the given package name matches something
* with 'pkg-[0-9]*'
*/
char try[FILENAME_MAX];
snprintf(try, FILENAME_MAX, "%s-[0-9]*", pkg);
if (findmatchingname(_pkgdb_getPKGDB_DIR(), try,
find_fn, NULL) != 0) {
return 0; /* we've just appended some names to the pkgs list,
* they will be processed after this package.
*/
}
}
/* No match */
warnx("can't find package `%s' installed or in a file!", pkg);
return 1;
}
@ -226,6 +242,17 @@ CheckForPkg(char *pkgspec, char *dbdir)
if (!error && !Quiet) {
printf("%s\n", pkgspec);
}
if (error) {
/* found nothing - try 'pkg-[0-9]*'
*/
char try[FILENAME_MAX];
snprintf(try, FILENAME_MAX, "%s-[0-9]*", pkgspec);
if (findmatchingname(_pkgdb_getPKGDB_DIR(), try,
foundpkg, NULL) != 0) {
error = 0;
}
}
return error;
}
@ -290,6 +317,7 @@ pkg_perform(lpkg_head_t *pkgs)
}
}
} else {
/* Show info on individual pkg(s) */
lpkg_t *lpp;
while ((lpp = TAILQ_FIRST(pkgs))) {

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_info.1,v 1.17 1999/03/22 18:44:04 garbled Exp $
.\" $NetBSD: pkg_info.1,v 1.18 1999/08/19 19:37:22 hubertf Exp $
.\"
.\" FreeBSD install - a package for the installation and maintainance
.\" of non-core utilities.
@ -47,10 +47,11 @@ command.
.Pp
The
.Ar pkg-name
may be the name of an installed package, a pattern matching several
installed packages (see the
may be the name of an installed package (with our without version), a
pattern matching several installed packages (see the
.Fl e
switch for a description of possible patterns), the pathname to a
switch for a description of possible patterns),
the pathname to a
package distribution file, a filename belonging to an installed
package (if
.Fl F