- Comment code

- Minor re-indenting
 - Fix printing of @ignore in pkg_info (did this ever work?)
 - Fix installing of local wildcard dependencies (unused in main system)
 - Fix deleting of packages that depend on wildcard dependencies
   (fexist() is not enough there :-)
This commit is contained in:
hubertf 1999-12-01 14:51:50 +00:00
parent 0826be2b88
commit 402f80b9da
6 changed files with 101 additions and 59 deletions

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.40 1999/10/04 17:16:59 proff Exp $ */
/* $NetBSD: perform.c,v 1.41 1999/12/01 14:51:50 hubertf 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.40 1999/10/04 17:16:59 proff Exp $");
__RCSID("$NetBSD: perform.c,v 1.41 1999/12/01 14:51:50 hubertf Exp $");
#endif
#endif
@ -47,7 +47,7 @@ static char *Home;
* note found version in "note".
*/
static int
check_if_installed(const char *found, char *note)
note_whats_installed(const char *found, char *note)
{
(void) strcpy(note, found);
return 0;
@ -109,7 +109,7 @@ pkg_do(char *pkg)
* (Slave mode) */
if (!pkg) {
fgets(playpen, FILENAME_MAX, stdin);
playpen[strlen(playpen) - 1] = '\0'; /* pesky newline! */
playpen[strlen(playpen) - 1] = '\0'; /* remove newline! */
if (chdir(playpen) == FAIL) {
warnx("add in SLAVE mode can't chdir to %s", playpen);
return 1;
@ -125,7 +125,7 @@ pkg_do(char *pkg)
*/
if (IS_URL(pkg)) {
if (ispkgpattern(pkg)) {
warnx("patterns not allowed in URLs, "
warnx("patterns not supported in URLs, "
"please install manually!");
/* ... until we come up with a better solution :-/ - HF */
goto bomb;
@ -139,16 +139,16 @@ pkg_do(char *pkg)
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);
warnx("unable to open table of contents file `%s' - not a package?",
CONTENTS_FNAME);
goto bomb;
}
read_plist(&Plist, cfile);
fclose(cfile);
} else {
} else { /* no URL */
strcpy(pkg_fullname, pkg); /* copy for sanity's sake, could remove pkg_fullname */
if (strcmp(pkg, "-")) {
/* not stdin */
if (!ispkgpattern(pkg_fullname)
&& stat(pkg_fullname, &sb) == FAIL) {
warnx("can't stat package file '%s'", pkg_fullname);
@ -157,25 +157,24 @@ pkg_do(char *pkg)
(void) snprintf(extract_contents, sizeof(extract_contents), "--fast-read %s", CONTENTS_FNAME);
extract = extract_contents;
} else {
/* some values for stdin */
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));
(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);
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);
warnx("unable to open table of contents file `%s' - not a package?",
CONTENTS_FNAME);
goto bomb;
}
read_plist(&Plist, cfile);
@ -232,7 +231,7 @@ pkg_do(char *pkg)
}
}
/* Check for sanity and dependencies */
/* Check for sanity */
if (sanity_check(pkg))
goto bomb;
@ -257,7 +256,7 @@ pkg_do(char *pkg)
/* Protect against old packages with bogus @name fields */
PkgName = (p = find_plist(&Plist, PLIST_NAME)) ? p->name : "anonymous";
/* See if we're already registered */
/* See if this package (exact version) is already registered */
(void) snprintf(LogDir, sizeof(LogDir), "%s/%s", dbdir, PkgName);
if ((isdir(LogDir) || islinktodir(LogDir)) && !Force) {
warnx("package `%s' already recorded as installed", PkgName);
@ -278,7 +277,7 @@ pkg_do(char *pkg)
(void) memcpy(buf, PkgName, l);
(void) strcpy(&buf[l], "[0-9]*");
if (findmatchingname(dbdir, buf, check_if_installed, installed) > 0) {
if (findmatchingname(dbdir, buf, note_whats_installed, installed) > 0) {
warnx("other version '%s' already installed", installed);
code = 1;
goto success; /* close enough for government work */
@ -297,7 +296,7 @@ pkg_do(char *pkg)
/* was: */
/* if (!vsystem("/usr/sbin/pkg_info -qe '%s'", p->name)) { */
if (findmatchingname(dbdir, p->name, check_if_installed, installed) > 0) {
if (findmatchingname(dbdir, p->name, note_whats_installed, installed) > 0) {
warnx("Conflicting package installed, please use\n\t\"pkg_delete %s\" first to remove it!\n", installed);
++code;
}
@ -312,27 +311,30 @@ pkg_do(char *pkg)
if (Verbose)
printf("Package `%s' depends on `%s'.\n", PkgName, p->name);
/* if (vsystem("/usr/sbin/pkg_info -qe '%s'", p->name)) { */
if (findmatchingname(dbdir, p->name, check_if_installed, installed) != 1) {
char path[FILENAME_MAX], *cp = NULL;
if (findmatchingname(dbdir, p->name, note_whats_installed, installed) != 1) {
/* required pkg not found - need to pull in */
if (!Fake) {
if (!IS_URL(pkg) && !getenv("PKG_ADD_BASE")) {
/* install depending pkg from local disk */
char path[FILENAME_MAX], *cp = NULL;
(void) snprintf(path, sizeof(path), "%s/%s.tgz", Home, p->name);
if (fexists(path))
cp = path;
else
cp = fileFindByPath(pkg, p->name);
cp = fileFindByPath(pkg, p->name); /* files & wildcards */
if (cp) {
if (Verbose)
printf("Loading it from %s.\n", cp);
if (vsystem("%s/pkg_add %s%s%s %s%s",
BINDIR,
Force ? "-f " : "",
Prefix ? "-p " : "",
Prefix ? Prefix : "",
Verbose ? "-v " : "", cp)) {
BINDIR,
Force ? "-f " : "",
Prefix ? "-p " : "",
Prefix ? Prefix : "",
Verbose ? "-v " : "",
cp)) {
warnx("autoload of dependency `%s' failed%s",
cp, Force ? " (proceeding anyway)" : "!");
if (!Force)
@ -343,7 +345,7 @@ pkg_do(char *pkg)
p->name, Force ? " (proceeding anyway)" : "!");
if (!Force)
++code;
}
} /* cp */
} else {
/* install depending pkg via FTP */
@ -386,16 +388,14 @@ pkg_do(char *pkg)
}
}
} else {
/* fake install (???) */
if (Verbose)
printf("and was not found%s.\n", Force ? " (proceeding anyway)" : "");
else
printf("Package dependency %s for %s not found%s\n", p->name, pkg,
printf("Package dependency %s for %s not installed%s\n", p->name, pkg,
Force ? " (proceeding anyway)" : "!");
if (!Force)
++code;
}
} else if (Verbose)
} else if (Verbose) {
printf(" - %s already installed.\n", installed);
}
}
if (code != 0)
@ -443,7 +443,7 @@ pkg_do(char *pkg)
if (vsystem("%s/mtree -U -f %s -d -e -p %s", BINDIR, MTREE_FNAME, p ? p->name : "/"))
warnx("mtree returned a non-zero status - continuing");
}
unlink(MTREE_FNAME);
unlink(MTREE_FNAME); /* remove this line to tar up pkg later - HF */
}
/* Run the installation script one last time? */
@ -456,7 +456,7 @@ pkg_do(char *pkg)
code = 1;
goto fail;
}
unlink(INSTALL_FNAME);
unlink(INSTALL_FNAME); /* remove this line to tar up pkg later - HF */
}
/* Time to record the deed? */
@ -473,7 +473,7 @@ pkg_do(char *pkg)
goto success; /* well, partial anyway */
}
(void) snprintf(LogDir, sizeof(LogDir), "%s/%s", dbdir, PkgName);
zapLogDir = 1;
zapLogDir = 1; /* LogDir contains something valid now */
if (Verbose)
printf("Attempting to record package into %s.\n", LogDir);
if (make_hierarchy(LogDir)) {

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.28 1999/09/09 01:36:30 hubertf Exp $ */
/* $NetBSD: perform.c,v 1.29 1999/12/01 14:51:52 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.28 1999/09/09 01:36:30 hubertf Exp $");
__RCSID("$NetBSD: perform.c,v 1.29 1999/12/01 14:51:52 hubertf Exp $");
#endif
#endif
@ -84,6 +84,17 @@ static package_t Plist;
static lpkg_head_t lpfindq;
static lpkg_head_t lpdelq;
/*
* Called to see if pkg is already installed as some other version,
* note found version in "note".
*/
static int
note_whats_installed(const char *found, char *note)
{
(void) strcpy(note, found);
return 0;
}
static void
sanity_check(char *pkg)
{
@ -197,9 +208,17 @@ require_delete(char *home, int tryall)
}
/* look to see if package was already deleted */
if (!fexists(lpp->lp_name)) {
warnx("%s appears to have been deleted", lpp->lp_name);
continue;
if (ispkgpattern(lpp->lp_name)) {
char installed[FILENAME_MAX];
if (findmatchingname(".", lpp->lp_name, note_whats_installed, installed) != 1) {
warnx("%s appears to have been deleted", lpp->lp_name);
continue;
}
} else {
if (!fexists(lpp->lp_name)) {
warnx("%s appears to have been deleted", lpp->lp_name);
continue;
}
}
/* return home for execution of command */
@ -385,9 +404,28 @@ require_find_recursive_down(lpkg_t *thislpp, package_t *plist)
rPlist.tail = NULL;
/* prepare for recursion */
chdir((tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR);
chdir(lpp->lp_name);
sanity_check(lpp->lp_name);
chdir ((tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR);
if (ispkgpattern(lpp->lp_name)) {
char installed[FILENAME_MAX];
if (findmatchingname(".", lpp->lp_name, note_whats_installed, installed) != 1) {
warnx("cannot remove dependency for pkg-pattern %s", lpp->lp_name);
fail = 1;
goto fail;
}
if (chdir(installed) == -1) {
warnx("can't chdir to %s", installed);
fail = 1;
goto fail;
}
sanity_check(installed);
} else {
if (chdir(lpp->lp_name) == -1) {
warnx("cannot remove dependency from %s", lpp->lp_name);
fail = 1;
goto fail;
}
sanity_check(lpp->lp_name);
}
cfile = fopen(CONTENTS_FNAME, "r");
if (!cfile) {

View File

@ -1,11 +1,11 @@
/* $NetBSD: show.c,v 1.18 1999/11/29 20:09:55 hubertf Exp $ */
/* $NetBSD: show.c,v 1.19 1999/12/01 14:51:52 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: show.c,v 1.11 1997/10/08 07:47:38 charnier Exp";
#else
__RCSID("$NetBSD: show.c,v 1.18 1999/11/29 20:09:55 hubertf Exp $");
__RCSID("$NetBSD: show.c,v 1.19 1999/12/01 14:51:52 hubertf Exp $");
#endif
#endif
@ -74,14 +74,14 @@ typedef struct show_t {
* pl_ent_t constants
*/
static show_t showv[] = {
{PLIST_FILE, "%s", "File: %s"},
{PLIST_FILE, "%s", "\tFile: %s"},
{PLIST_CWD, "@cwd %s", "\tCWD to: %s"},
{PLIST_CMD, "@exec %s", "\tEXEC '%s'"},
{PLIST_CHMOD, "@chmod %s", "\tCHMOD to %s"},
{PLIST_CHOWN, "@chown %s", "\tCHOWN to %s"},
{PLIST_CHGRP, "@chgrp %s", "\tCHGRP to %s"},
{PLIST_COMMENT, "@comment %s", "\tComment: %s"},
{PLIST_IGNORE, NULL, NULL},
{PLIST_IGNORE, "@ignore", "Ignore next file:"},
{PLIST_NAME, "@name %s", "\tPackage name: %s"},
{PLIST_UNEXEC, "@unexec %s", "\tUNEXEC '%s'"},
{PLIST_SRC, "@src: %s", "\tSRC to: %s"},
@ -175,6 +175,7 @@ show_plist(char *title, package_t *plist, pl_ent_t type)
p->name ? p->name : "(clear default)");
break;
case PLIST_IGNORE:
printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose);
ign = TRUE;
break;
case PLIST_IGNORE_INST:

View File

@ -1,11 +1,11 @@
/* $NetBSD: file.c,v 1.34 1999/12/01 05:08:10 hubertf Exp $ */
/* $NetBSD: file.c,v 1.35 1999/12/01 14:51:53 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: file.c,v 1.29 1997/10/08 07:47:54 charnier Exp";
#else
__RCSID("$NetBSD: file.c,v 1.34 1999/12/01 05:08:10 hubertf Exp $");
__RCSID("$NetBSD: file.c,v 1.35 1999/12/01 14:51:53 hubertf Exp $");
#endif
#endif
@ -86,7 +86,7 @@ ftpGetURL(char *url, int *retcode)
}
/*
* Quick check to see if a file exists
* Quick check to see if a file (or dir ...) exists
*/
Boolean
fexists(char *fname)
@ -317,6 +317,7 @@ fileGetURL(char *base, char *spec)
/* Otherwise, we've been given an environment variable hinting at the right location from sysinstall */
strcpy(fname, hint);
strcat(fname, spec);
strcat(fname, ".tgz");
}
} else
strcpy(fname, spec);
@ -444,7 +445,7 @@ fileFindByPath(char *base, char *fname)
}
/*
* Expect "fname" to point at a +CONTENTS file, and read it into
* Expect "fname" to point at a file, and read it into
* the buffer returned.
*/
char *

View File

@ -1,4 +1,4 @@
/* $NetBSD: lpkg.c,v 1.2 1999/08/24 00:48:39 hubertf Exp $ */
/* $NetBSD: lpkg.c,v 1.3 1999/12/01 14:51:53 hubertf Exp $ */
/*
* Copyright (c) 1999 Christian E. Hopps
@ -33,7 +33,7 @@
#include "lib.h"
/*
* Add a package to the recursive delete list
* Add a package to the (add/recursive delete) list
*/
lpkg_t *
alloc_lpkg(const char *pkgname)

View File

@ -1,11 +1,11 @@
/* $NetBSD: str.c,v 1.17 1999/08/24 00:48:40 hubertf Exp $ */
/* $NetBSD: str.c,v 1.18 1999/12/01 14:51:53 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
#else
__RCSID("$NetBSD: str.c,v 1.17 1999/08/24 00:48:40 hubertf Exp $");
__RCSID("$NetBSD: str.c,v 1.18 1999/12/01 14:51:53 hubertf Exp $");
#endif
#endif
@ -277,9 +277,11 @@ findmatchingname(const char *dir, const char *pattern, matchfn match, char *data
continue;
(void) snprintf(tmp, sizeof(tmp), "%s/%s", dir, dp->d_name);
#if 0 /* This code breaks a LOT ... */
if (isfile(tmp))/* pkgdb, ... */
continue;
#endif
if (pmatch(pattern, dp->d_name)) {
if (match) {
match(dp->d_name, data);