Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/usr.sbin/pkg_install/add Pull up revisions 1.37-1.39:
details: https://anonhg.NetBSD.org/src/rev/5acc0d9404c2
branches: netbsd-1-4
changeset: 469375:5acc0d9404c2
user: he <he%NetBSD.org@localhost>
date: Mon Sep 13 21:57:36 1999 +0000
description:
Pull up revisions 1.37-1.39:
Provide full pathnames for chgrp and chown, fixing PR#8250.
Hide test for URLlength()>0 behind a macro (IS_URL()).
Bring closer to /usr/share/misc/style with the aid of indent(1).
(hubertf)
diffstat:
usr.sbin/pkg_install/add/perform.c | 1022 +++++++++++++++++------------------
1 files changed, 509 insertions(+), 513 deletions(-)
diffs (truncated from 1112 to 300 lines):
diff -r 8bc0621825ff -r 5acc0d9404c2 usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c Mon Sep 13 21:36:28 1999 +0000
+++ b/usr.sbin/pkg_install/add/perform.c Mon Sep 13 21:57:36 1999 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: perform.c,v 1.29.2.2 1999/08/25 10:26:10 he Exp $ */
+/* $NetBSD: perform.c,v 1.29.2.3 1999/09/13 21:57:36 he 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.29.2.2 1999/08/25 10:26:10 he Exp $");
+__RCSID("$NetBSD: perform.c,v 1.29.2.3 1999/09/13 21:57:36 he Exp $");
#endif
#endif
@@ -37,13 +37,15 @@
#include <sys/wait.h>
static char LogDir[FILENAME_MAX];
-static int zapLogDir; /* Should we delete LogDir? */
+static int zapLogDir; /* Should we delete LogDir? */
static package_t Plist;
static char *Home;
-/* called to see if pkg is already installed as some other version */
-/* note found version in "note" */
+/*
+ * Called to see if pkg is already installed as some other version,
+ * note found version in "note".
+ */
static int
check_if_installed(const char *found, char *note)
{
@@ -54,19 +56,19 @@
static int
sanity_check(char *pkg)
{
- int code = 0;
+ int code = 0;
- if (!fexists(CONTENTS_FNAME)) {
- warnx("package %s has no CONTENTS file!", pkg);
- code = 1;
- } else if (!fexists(COMMENT_FNAME)) {
- warnx("package %s has no COMMENT file!", pkg);
- code = 1;
- } else if (!fexists(DESC_FNAME)) {
- warnx("package %s has no DESC file!", pkg);
- code = 1;
- }
- return code;
+ if (!fexists(CONTENTS_FNAME)) {
+ warnx("package %s has no CONTENTS file!", pkg);
+ code = 1;
+ } else if (!fexists(COMMENT_FNAME)) {
+ warnx("package %s has no COMMENT file!", pkg);
+ code = 1;
+ } else if (!fexists(DESC_FNAME)) {
+ warnx("package %s has no DESC file!", pkg);
+ code = 1;
+ }
+ return code;
}
/*
@@ -77,553 +79,547 @@
static int
pkg_do(char *pkg)
{
- char pkg_fullname[FILENAME_MAX];
- char playpen[FILENAME_MAX];
- char extract_contents[FILENAME_MAX];
- char *where_to, *tmp, *extract;
- char *dbdir;
- FILE *cfile;
- int code;
- plist_t *p;
- struct stat sb;
- int inPlace;
+ char pkg_fullname[FILENAME_MAX];
+ char playpen[FILENAME_MAX];
+ char extract_contents[FILENAME_MAX];
+ char *where_to, *tmp, *extract;
+ char *dbdir;
+ FILE *cfile;
+ int code;
+ plist_t *p;
+ struct stat sb;
+ int inPlace;
- code = 0;
- zapLogDir = 0;
- LogDir[0] = '\0';
- strcpy(playpen, FirstPen);
- inPlace = 0;
- dbdir = (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR;
+ code = 0;
+ zapLogDir = 0;
+ LogDir[0] = '\0';
+ strcpy(playpen, FirstPen);
+ inPlace = 0;
+ dbdir = (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR;
- /* make sure dbdir actually exists! */
- if (!(isdir(dbdir) || islinktodir(dbdir))) {
- if (vsystem("/bin/mkdir -p -m 755 %s", dbdir)) {
- errx(1, "Database-dir %s cannot be generated, aborting.",
- dbdir);
- }
- }
-
- /* Are we coming in for a second pass, everything already extracted? */
- /* (Slave mode) */
- if (!pkg) {
- fgets(playpen, FILENAME_MAX, stdin);
- playpen[strlen(playpen) - 1] = '\0'; /* pesky newline! */
- if (chdir(playpen) == FAIL) {
- warnx("add in SLAVE mode can't chdir to %s", playpen);
- return 1;
+ /* make sure dbdir actually exists! */
+ if (!(isdir(dbdir) || islinktodir(dbdir))) {
+ if (vsystem("/bin/mkdir -p -m 755 %s", dbdir)) {
+ errx(1, "Database-dir %s cannot be generated, aborting.",
+ dbdir);
+ }
}
- read_plist(&Plist, stdin);
- where_to = playpen;
- }
- /* Nope - do it now */
- else {
- /*
- * Is it an ftp://foo.bar.baz/file.tgz or http://foo.bar.baz/file.tgz
- * specification?
- */
- if (URLlength(pkg) > 0) {
- if (ispkgpattern(pkg)) {
- warnx("patterns not allowed in URLs, "
- "please install manually!");
- /* ... until we come up with a better solution :-/ - HF */
- goto bomb;
- }
-
- if (!(Home = fileGetURL(NULL, pkg))) {
- warnx("unable to fetch `%s' by URL", pkg);
- return 1;
- }
- where_to = Home;
- strcpy(pkg_fullname, pkg);
- 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 {
- strcpy(pkg_fullname, pkg); /* copy for sanity's sake, could remove pkg_fullname */
- if (strcmp(pkg, "-")) {
- if (!ispkgpattern(pkg_fullname)
- && stat(pkg_fullname, &sb) == FAIL) {
- warnx("can't stat package file '%s'", pkg_fullname);
- goto bomb;
+
+ /* Are we coming in for a second pass, everything already extracted?
+ * (Slave mode) */
+ if (!pkg) {
+ fgets(playpen, FILENAME_MAX, stdin);
+ playpen[strlen(playpen) - 1] = '\0'; /* pesky newline! */
+ if (chdir(playpen) == FAIL) {
+ warnx("add in SLAVE mode can't chdir to %s", playpen);
+ return 1;
}
- (void) snprintf(extract_contents, sizeof(extract_contents), "--fast-read %s", CONTENTS_FNAME);
- extract = extract_contents;
- }
- else {
- extract = NULL;
- sb.st_size = 100000; /* Make up a plausible average size */
- }
- Home = make_playpen(playpen, sizeof(playpen), sb.st_size * 4);
- if (!Home)
- warnx("unable to make playpen for %ld bytes",
- (long)(sb.st_size * 4));
- where_to = Home;
- if (unpack(pkg_fullname, extract)) {
- warnx(
- "unable to extract table of contents file from `%s' - not a package?",
- pkg_fullname);
- 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);
+ read_plist(&Plist, stdin);
+ where_to = playpen;
+ }
+ /* 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)) {
+ if (ispkgpattern(pkg)) {
+ warnx("patterns not allowed in URLs, "
+ "please install manually!");
+ /* ... until we come up with a better solution :-/ - HF */
+ goto bomb;
+ }
+
+ if (!(Home = fileGetURL(NULL, pkg))) {
+ warnx("unable to fetch `%s' by URL", pkg);
+ return 1;
+ }
+ where_to = Home;
+ strcpy(pkg_fullname, pkg);
+ 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 {
+ strcpy(pkg_fullname, pkg); /* copy for sanity's sake, could remove pkg_fullname */
+ if (strcmp(pkg, "-")) {
+ if (!ispkgpattern(pkg_fullname)
+ && stat(pkg_fullname, &sb) == FAIL) {
+ warnx("can't stat package file '%s'", pkg_fullname);
+ goto bomb;
+ }
+ (void) snprintf(extract_contents, sizeof(extract_contents), "--fast-read %s", CONTENTS_FNAME);
+ extract = extract_contents;
+ } else {
+ extract = NULL;
+ sb.st_size = 100000; /* Make up a plausible average size */
+ }
+ Home = make_playpen(playpen, sizeof(playpen), sb.st_size * 4);
+ if (!Home)
+ warnx("unable to make playpen for %ld bytes",
+ (long) (sb.st_size * 4));
+ where_to = Home;
+ if (unpack(pkg_fullname, extract)) {
+ warnx(
+ "unable to extract table of contents file from `%s' - not a package?",
+ pkg_fullname);
+ 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);
- /* Extract directly rather than moving? Oh goodie! */
- if (find_plist_option(&Plist, "extract-in-place")) {
- if (Verbose)
- printf("Doing in-place extraction for %s\n", pkg_fullname);
- p = find_plist(&Plist, PLIST_CWD);
- if (p) {
- if (!(isdir(p->name) || islinktodir(p->name)) && !Fake) {
- if (Verbose)
- printf("Desired prefix of %s does not exist, creating.\n", p->name);
- (void)vsystem("mkdir -p %s", p->name);
- }
- if (chdir(p->name) == -1) {
- warn("unable to change directory to `%s'", p->name);
- goto bomb;
- }
- where_to = p->name;
- inPlace = 1;
- }
- else {
- warnx(
- "no prefix specified in `%s' - this is a bad package!",
- pkg_fullname);
- goto bomb;
+ /* Extract directly rather than moving? Oh goodie! */
+ if (find_plist_option(&Plist, "extract-in-place")) {
+ if (Verbose)
+ printf("Doing in-place extraction for %s\n", pkg_fullname);
+ p = find_plist(&Plist, PLIST_CWD);
Home |
Main Index |
Thread Index |
Old Index