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 - Comment code
details: https://anonhg.NetBSD.org/src/rev/91f1562e1ada
branches: trunk
changeset: 479003:91f1562e1ada
user: hubertf <hubertf%NetBSD.org@localhost>
date: Wed Dec 01 14:51:50 1999 +0000
description:
- 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 :-)
diffstat:
usr.sbin/pkg_install/add/perform.c | 76 +++++++++++++++++-----------------
usr.sbin/pkg_install/delete/perform.c | 54 +++++++++++++++++++++---
usr.sbin/pkg_install/info/show.c | 9 ++-
usr.sbin/pkg_install/lib/file.c | 9 ++-
usr.sbin/pkg_install/lib/lpkg.c | 4 +-
usr.sbin/pkg_install/lib/str.c | 8 ++-
6 files changed, 101 insertions(+), 59 deletions(-)
diffs (truncated from 450 to 300 lines):
diff -r 7a3999f835c7 -r 91f1562e1ada usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c Wed Dec 01 12:03:16 1999 +0000
+++ b/usr.sbin/pkg_install/add/perform.c Wed Dec 01 14:51:50 1999 +0000
@@ -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 @@
* 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 @@
* (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 @@
*/
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 @@
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 @@
(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 @@
}
}
- /* Check for sanity and dependencies */
+ /* Check for sanity */
if (sanity_check(pkg))
goto bomb;
@@ -257,7 +256,7 @@
/* 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 @@
(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 @@
/* 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 @@
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 @@
p->name, Force ? " (proceeding anyway)" : "!");
if (!Force)
++code;
- }
+ } /* cp */
} else {
/* install depending pkg via FTP */
@@ -386,16 +388,14 @@
}
}
} 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 @@
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 @@
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 @@
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)) {
diff -r 7a3999f835c7 -r 91f1562e1ada usr.sbin/pkg_install/delete/perform.c
--- a/usr.sbin/pkg_install/delete/perform.c Wed Dec 01 12:03:16 1999 +0000
+++ b/usr.sbin/pkg_install/delete/perform.c Wed Dec 01 14:51:50 1999 +0000
@@ -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 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 @@
}
/* 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 @@
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;
+ }
Home |
Main Index |
Thread Index |
Old Index