Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/pkg_install - remove handling of PKG_ADD_BASE.
details: https://anonhg.NetBSD.org/src/rev/d7d4660f9920
branches: trunk
changeset: 534185:d7d4660f9920
user: yamt <yamt%NetBSD.org@localhost>
date: Fri Jul 19 19:04:33 2002 +0000
description:
- 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 +--------
usr.sbin/pkg_install/add/perform.c | 302 ++++++-------------------
usr.sbin/pkg_install/admin/main.c | 8 +-
usr.sbin/pkg_install/create/perform.c | 12 +-
usr.sbin/pkg_install/info/main.c | 6 +-
usr.sbin/pkg_install/info/perform.c | 10 +-
usr.sbin/pkg_install/info/pkg_info.1 | 6 +-
usr.sbin/pkg_install/lib/Makefile | 4 +-
usr.sbin/pkg_install/lib/file.c | 400 +++++++++++----------------------
usr.sbin/pkg_install/lib/ftpio.c | 11 +-
usr.sbin/pkg_install/lib/lib.h | 26 +-
usr.sbin/pkg_install/lib/path.c | 147 ++++++++++++
usr.sbin/pkg_install/lib/path.h | 38 +++
usr.sbin/pkg_install/lib/pen.c | 8 +-
usr.sbin/pkg_install/lib/plist.c | 8 +-
usr.sbin/pkg_install/lib/str.c | 25 +-
16 files changed, 475 insertions(+), 647 deletions(-)
diffs (truncated from 1733 to 300 lines):
diff -r c8ba3ca2bded -r d7d4660f9920 usr.sbin/pkg_install/add/main.c
--- a/usr.sbin/pkg_install/add/main.c Fri Jul 19 18:53:15 2002 +0000
+++ b/usr.sbin/pkg_install/add/main.c Fri Jul 19 19:04:33 2002 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: main.c,v 1.24 2002/06/09 11:56:59 yamt Exp $ */
+/* $NetBSD: main.c,v 1.25 2002/07/19 19:04:33 yamt 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.24 2002/06/09 11:56:59 yamt Exp $");
+__RCSID("$NetBSD: main.c,v 1.25 2002/07/19 19:04:33 yamt 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 */
diff -r c8ba3ca2bded -r d7d4660f9920 usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c Fri Jul 19 18:53:15 2002 +0000
+++ b/usr.sbin/pkg_install/add/perform.c Fri Jul 19 19:04:33 2002 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: perform.c,v 1.68 2002/07/13 16:38:00 toshii Exp $ */
+/* $NetBSD: perform.c,v 1.69 2002/07/19 19:04:34 yamt Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
#else
-__RCSID("$NetBSD: perform.c,v 1.68 2002/07/13 16:38:00 toshii Exp $");
+__RCSID("$NetBSD: perform.c,v 1.69 2002/07/19 19:04:34 yamt Exp $");
#endif
#endif
@@ -46,7 +46,7 @@
static char *Home;
static int
-sanity_check(char *pkg)
+sanity_check(const char *pkg)
{
int errc = 0;
@@ -65,121 +65,28 @@
/* install a pre-requisite package. Returns 1 if it installed it */
static int
-installprereq(char *pkg, char *name, int *errc)
+installprereq(const char *name, int *errc)
{
int ret;
-
ret = 0;
- if (!IS_URL(pkg) && !getenv("PKG_ADD_BASE")) {
- /* install depending pkg from local disk */
-
- char path[FILENAME_MAX], *cp = NULL;
-
- /* is there a .tbz file? */
- (void) snprintf(path, sizeof(path), "%s/%s.tbz", Home, name);
- if (fexists(path))
- cp = path;
- else {
- /* no, maybe .tgz? */
- (void) snprintf(path, sizeof(path), "%s/%s.tgz", Home, name);
- if (fexists(path)) {
- cp = path;
- } else {
- /* neither - let's do some digging! */
- cp = fileFindByPath(pkg, name); /* files & wildcards */
- }
- }
- if (cp == NULL) {
- warnx("<%s> (1) add of dependency `%s' failed%s",
- pkg ? pkg : "stdin", name, Force ? " (proceeding anyway)" : "!");
- if (!Force)
- ++errc;
- } else {
- if (Verbose)
- printf("Loading it from %s.\n", cp);
- if (vsystem("%s/pkg_add -s %s %s%s%s %s%s",
- BINDIR,
- get_verification(),
- Force ? "-f " : "",
- Prefix ? "-p " : "",
- Prefix ? Prefix : "",
- Verbose ? "-v " : "",
- cp)) {
- warnx("autoload of dependency `%s' failed%s",
- cp, Force ? " (proceeding anyway)" : "!");
- if (!Force)
- ++errc;
- } else {
- ret = 1;
- }
- }
- } else {
- /* pkg is url -> install depending pkg via FTP */
-
- char *saved_Current; /* allocated/set by save_dirs(), */
- char *saved_Previous; /* freed by restore_dirs() */
- char *cp, *new_pkg, *new_name;
- char *vertype;
- if (strcmp(vertype = get_verification(), "none") != 0) {
- (void) fprintf(stderr, "Warning: %s verification requested for a URL package\n", vertype);
- }
-
- new_pkg = pkg;
- new_name = name;
-
- if (ispkgpattern(name)) {
- /* Handle wildcard depends here */
-
- char *s;
- s=fileFindByPath(pkg, name);
-
- /* adjust new_pkg and new_name */
- new_pkg = NULL;
- new_name = s;
- }
-
- /* makeplaypen() and leave_playpen() clobber Current and
- * Previous, save them! */
- save_dirs(&saved_Current, &saved_Previous);
-
- if ((cp = fileGetURL(new_pkg, new_name)) != NULL) {
- if (Verbose)
- printf("Finished loading %s over FTP.\n", new_name);
- if (!fexists(CONTENTS_FNAME)) {
- warnx("autoloaded package %s has no %s file?",
- name, CONTENTS_FNAME);
- if (!Force)
- ++errc;
- } else {
- if (vsystem("(pwd; cat %s) | pkg_add %s%s%s %s-S",
- CONTENTS_FNAME,
- Force ? "-f " : "",
- Prefix ? "-p " : "",
- Prefix ? Prefix : "",
- Verbose ? "-v " : "")) {
- warnx("<%s> (2) add of dependency `%s' failed%s",
- pkg ? pkg : "stdin", name, Force ? " (proceeding anyway)" : "!");
- if (!Force)
- ++errc;
- } else {
- ret = 1;
- if (Verbose) {
- printf("\t`%s' loaded successfully as `%s'.\n", name, new_name);
- }
- }
- }
- /* Nuke the temporary playpen */
- leave_playpen(cp);
-
- } else {
- if (Verbose)
- warnx("fileGetURL('%s', '%s') failed", new_pkg, new_name);
- if (!Force)
- errc++;
- }
-
- restore_dirs(saved_Current, saved_Previous);
+ if (Verbose)
+ printf("Loading it from %s.\n", name);
+ path_setenv("PKG_PATH");
+ if (vsystem("%s/pkg_add -s %s %s%s%s %s%s",
+ BINDIR,
+ get_verification(),
+ Force ? "-f " : "",
+ Prefix ? "-p " : "",
+ Prefix ? Prefix : "",
Home |
Main Index |
Thread Index |
Old Index