Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/usr.sbin/pkg_install/add Pull up revision 1.25 (request...
details: https://anonhg.NetBSD.org/src/rev/ebaac363e4e4
branches: netbsd-1-6
changeset: 528501:ebaac363e4e4
user: lukem <lukem%NetBSD.org@localhost>
date: Sun Jul 21 04:41:13 2002 +0000
description:
Pull up revision 1.25 (requested by yamt in ticket #530):
- remove handling of PKG_ADD_BASE.
- don't search current directory if PKG_PATH is set.
- don't prefer local directories.
- constify and cleanup.
discussed on tech-pkg.
diffstat:
usr.sbin/pkg_install/add/main.c | 111 +++------------------------------------
1 files changed, 9 insertions(+), 102 deletions(-)
diffs (145 lines):
diff -r df3ec84f00e9 -r ebaac363e4e4 usr.sbin/pkg_install/add/main.c
--- a/usr.sbin/pkg_install/add/main.c Sun Jul 21 04:37:11 2002 +0000
+++ b/usr.sbin/pkg_install/add/main.c Sun Jul 21 04:41:13 2002 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: main.c,v 1.23.2.1 2002/06/28 12:42:49 lukem Exp $ */
+/* $NetBSD: main.c,v 1.23.2.2 2002/07/21 04:41:13 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char *rcsid = "from FreeBSD Id: main.c,v 1.16 1997/10/08 07:45:43 charnier Exp";
#else
-__RCSID("$NetBSD: main.c,v 1.23.2.1 2002/06/28 12:42:49 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.23.2.2 2002/07/21 04:41:13 lukem Exp $");
#endif
#endif
@@ -65,9 +65,6 @@
{
int ch, error=0;
lpkg_head_t pkgs;
- lpkg_t *lpp;
- char *cp;
- char pkgname[MAXPATHLEN];
while ((ch = getopt(argc, argv, Options)) != -1) {
switch (ch) {
@@ -129,110 +126,20 @@
argc -= optind;
argv += optind;
+ path_create(getenv("PKG_PATH"));
TAILQ_INIT(&pkgs);
if (AddMode != SLAVE) {
/* Get all the remaining package names, if any */
for (ch = 0; *argv; ch++, argv++) {
- if (!strcmp(*argv, "-")) /* stdin? */
- lpp = alloc_lpkg("-");
- else if (IS_URL(*argv)) /* preserve URLs */
- lpp = alloc_lpkg(*argv);
- else { /* expand all pathnames to fullnames */
- char *s;
+ lpkg_t *lpp;
- if (fexists(*argv)) { /* refers to a file directly */
- if (!(cp = realpath(*argv, pkgname))) {
- lpp = NULL;
- warn("realpath failed for '%s'", *argv);
- } else
- lpp = alloc_lpkg(cp);
- } else if (ispkgpattern(*argv)) {
- if ((s = findbestmatchingname(dirname_of(*argv),
- basename_of(*argv))) != NULL) {
- char tmp[FILENAME_MAX];
-
- snprintf(tmp, sizeof(tmp), "%s/%s", dirname_of(*argv), s);
- free(s);
-
- if (Verbose)
- printf("Using %s for %s\n", tmp, *argv);
-
- if (!(cp = realpath(tmp, pkgname))) {
- lpp = NULL;
- warn("realpath failed for '%s'", tmp);
- error++;
- } else
- lpp = alloc_lpkg(cp);
- } else {
- lpp = NULL;
- warnx("can't find package pattern '%s'", *argv);
- error++;
- }
- } else {
- /* Maybe just a pkg name w/o pattern was given */
- char tmp[FILENAME_MAX];
-
- if (*argv[0] == '/'){
- /* given arg has path - ignore PKG_PATH */
- snprintf(tmp, sizeof(tmp), "%s-[0-9]*.t[bg]z", *argv);
- s = findbestmatchingname(dirname_of(tmp),
- basename_of(tmp));
- } else {
- /* try all elements of PKG_PATH, see also loop
- * in file.c::fileFindByPath() */
- /* This code prefers local pkgs over remote
- * pkgs - feature? */
- char *e;
-
- if (getenv("PKG_PATH"))
- e = strdup(getenv("PKG_PATH"));
- else
- e = NULL;
- s = NULL;
- while(s==NULL && e && *e) {
- char *e2 = strsep(&e, ";");
-
- if (IS_URL(e2)) {
- /* Let some other code do this */
- ;
- } else {
- snprintf(tmp, sizeof(tmp), "%s/%s-[0-9]*.t[bg]z",
- e2, *argv);
- s = findbestmatchingname(dirname_of(tmp),
- basename_of(tmp));
- }
- }
- }
- if (s) {
- char tmp2[FILENAME_MAX];
-
- snprintf(tmp2, sizeof(tmp2), "%s/%s", dirname_of(tmp), s);
- free(s);
-
- if (Verbose)
- printf("Using %s for %s\n", tmp2, *argv);
+ if (IS_STDIN(*argv))
+ lpp = alloc_lpkg("-");
+ else
+ lpp = alloc_lpkg(*argv);
- if (!(cp = realpath(tmp2, pkgname))) {
- lpp = NULL;
- warn("realpath failed for '%s'", tmp2);
- error++;
- } else
- lpp = alloc_lpkg(cp);
- } else {
- /* No go there... */
- /* look for the file(pattern) in the expected places */
- if (!(cp = fileFindByPath(NULL, *argv))) {
- lpp = NULL;
- warnx("can't find package '%s'", *argv);
- error++;
- } else
- lpp = alloc_lpkg(cp);
- }
- }
- }
- if (lpp)
- TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
+ TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
}
}
/* If no packages, yelp */
Home |
Main Index |
Thread Index |
Old Index