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.69 (request...
details: https://anonhg.NetBSD.org/src/rev/762a75cc8df0
branches: netbsd-1-6
changeset: 528502:762a75cc8df0
user: lukem <lukem%NetBSD.org@localhost>
date: Sun Jul 21 04:41:22 2002 +0000
description:
Pull up revision 1.69 (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/perform.c | 302 +++++++++---------------------------
1 files changed, 76 insertions(+), 226 deletions(-)
diffs (truncated from 439 to 300 lines):
diff -r ebaac363e4e4 -r 762a75cc8df0 usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c Sun Jul 21 04:41:13 2002 +0000
+++ b/usr.sbin/pkg_install/add/perform.c Sun Jul 21 04:41:22 2002 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: perform.c,v 1.63.2.3 2002/07/21 04:37:11 lukem Exp $ */
+/* $NetBSD: perform.c,v 1.63.2.4 2002/07/21 04:41:22 lukem 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.63.2.3 2002/07/21 04:37:11 lukem Exp $");
+__RCSID("$NetBSD: perform.c,v 1.63.2.4 2002/07/21 04:41:22 lukem 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 : "",
+ Verbose ? "-v " : "",
+ name)) {
+ warnx("autoload of dependency `%s' failed%s",
+ name, Force ? " (proceeding anyway)" : "!");
+ if (!Force)
+ ++(*errc);
+ } else {
+ ret = 1;
}
return ret;
@@ -191,9 +98,8 @@
* to be hacked, I guess.. :) -jkh]
*/
static int
-pkg_do(char *pkg)
+pkg_do(const char *pkg)
{
- char pkg_fullname[FILENAME_MAX];
char playpen[FILENAME_MAX];
char extract_contents[FILENAME_MAX];
char upgrade_from[FILENAME_MAX];
@@ -202,7 +108,7 @@
int upgrading = 0;
char *where_to, *tmp, *extract;
char *dbdir;
- char *exact;
+ const char *exact;
FILE *cfile;
int errc;
plist_t *p;
@@ -239,100 +145,40 @@
}
/* Nope - do it now */
else {
- /*
- * Is it an ftp://foo.bar.baz/file.tgz or http://foo.bar.baz/file.tgz
- * specification?
- */
- if (IS_URL(pkg)) {
- char buf[FILENAME_MAX];
- char *tmppkg = pkg;
-
- if (ispkgpattern(pkg)) {
- /* Handle wildcard depends */
-
- char *s;
- s=fileFindByPath(NULL, pkg);
- if (s == NULL) {
- warnx("no pkg found for '%s', sorry.", pkg);
- return 1;
- }
- strcpy(buf, s);
- tmppkg = buf;
- }
-
- Home = fileGetURL(NULL, tmppkg);
- if (Home == NULL) {
- warnx("unable to fetch `%s' by URL", tmppkg);
- if (ispkgpattern(pkg))
- /*
- * Seems we were not able to expand the pattern
- * to something useful - bail out
- */
- return 1;
+ const char *tmppkg;
- if ((strstr(pkg, ".tgz") != NULL) || (strstr(pkg, ".tbz") != NULL)) {
- /* There already is a ".t[bg]z" - give up
- * (We don't want to pretend to be exceedingly
- * clever - the user should give something sane!)
- */
- return 1;
- }
-
-
- /* Second chance - maybe just a package name was given,
- * without even a wildcard as a version. Tack on
- * the same pattern as we do for local packages: "-[0-9]*",
- * plus a ".t[bg]z" as we're talking binary pkgs here.
- * Then retry.
- */
- {
- char *s;
- char buf2[FILENAME_MAX];
-
- snprintf(buf2, sizeof(buf2), "%s-[0-9]*.t[bg]z", tmppkg);
- s=fileFindByPath(NULL, buf2);
- if (s == NULL) {
- warnx("no pkg found for '%s' on 2nd try, sorry.", buf2);
- return 1;
- }
- strcpy(buf, s);
- tmppkg = buf;
- Home = fileGetURL(NULL, tmppkg);
- if (Home == NULL) {
- warnx("unable to fetch `%s' by URL", tmppkg);
- return 1;
- }
- }
+ tmppkg = fileFindByPath(pkg);
+ if (tmppkg == NULL) {
+ warnx("no pkg found for '%s', sorry.", pkg);
+ return 1;
+ }
+
+ pkg = tmppkg;
+
+ if (IS_URL(pkg)) {
+ Home = fileGetURL(pkg);
+ if (Home == NULL) {
+ warnx("unable to fetch `%s' by URL", pkg);
}
where_to = Home;
- strcpy(pkg_fullname, tmppkg);
/* make sure the pkg is verified */
- if (!verify(tmppkg)) {
- warnx("Package %s will not be extracted", tmppkg);
+ if (!verify(pkg)) {
+ warnx("Package %s will not be extracted", pkg);
goto bomb;
}
-
- cfile = fopen(CONTENTS_FNAME, "r");
- if (!cfile) {
- warnx("unable to open table of contents file `%s' - not a package?",
- CONTENTS_FNAME);
- goto bomb;
- }
- read_plist(&Plist, cfile);
- fclose(cfile);
- } else { /* no URL */
- strcpy(pkg_fullname, pkg); /* copy for sanity's sake, could remove pkg_fullname */
- if (strcmp(pkg, "-")) {
+ }
+ else { /* local */
+ if (!IS_STDIN(pkg)) {
/* not stdin */
- if (!ispkgpattern(pkg_fullname)) {
- if (stat(pkg_fullname, &sb) == FAIL) {
- warnx("can't stat package file '%s'", pkg_fullname);
+ if (!ispkgpattern(pkg)) {
+ if (stat(pkg, &sb) == FAIL) {
+ warnx("can't stat package file '%s'", pkg);
Home |
Main Index |
Thread Index |
Old Index