summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1995-11-10 06:44:53 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1995-11-10 06:44:53 +0000
commit59b6334caf1db16832ef7b06c02291e19103f3b2 (patch)
tree01b66ddc21214874938ed71735d42e894f1c1f5c /usr.sbin/pkg_install
parentf202e841d1ee3319b0ac08e6878676a4612410bf (diff)
Notes
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/add/main.c53
-rw-r--r--usr.sbin/pkg_install/add/perform.c23
-rw-r--r--usr.sbin/pkg_install/delete/perform.c15
-rw-r--r--usr.sbin/pkg_install/lib/file.c79
-rw-r--r--usr.sbin/pkg_install/lib/plist.c34
5 files changed, 100 insertions, 104 deletions
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index f0a95d0ac140..87252cbb81bc 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -1,5 +1,5 @@
#ifndef lint
-static char *rcsid = "$Id: main.c,v 1.7.4.2 1995/10/14 19:11:01 jkh Exp $";
+static char *rcsid = "$Id: main.c,v 1.7.4.3 1995/11/03 02:54:56 jkh Exp $";
#endif
/*
@@ -42,7 +42,7 @@ char *Directory = NULL;
char FirstPen[FILENAME_MAX];
add_mode_t AddMode = NORMAL;
-#define MAX_PKGS 10
+#define MAX_PKGS 20
char pkgnames[MAX_PKGS][MAXPATHLEN];
char *pkgs[MAX_PKGS];
@@ -54,7 +54,7 @@ main(int argc, char **argv)
char *prog_name = argv[0], *cp;
start = argv;
- while ((ch = getopt(argc, argv, Options)) != EOF)
+ while ((ch = getopt(argc, argv, Options)) != EOF) {
switch(ch) {
case 'v':
Verbose = TRUE;
@@ -99,46 +99,39 @@ main(int argc, char **argv)
usage(prog_name, NULL);
break;
}
-
+ }
argc -= optind;
argv += optind;
- if (argc > MAX_PKGS)
- {
- whinge("Too many packages (max 10).");
+ if (argc > MAX_PKGS) {
+ whinge("Too many packages (max %d).", MAX_PKGS);
return(1);
}
- for (ch = 0; ch < MAX_PKGS; pkgs[ch++] = NULL)
- ;
- /* Get all the remaining package names, if any */
- for (ch = 0; *argv; ch++,argv++)
- {
- if (isURL(*argv)) /* preserve URLs */
- {
- pkgs[ch] = strcpy(pkgnames[ch],*argv);
- }else{ /* expand all pathnames to fullnames */
- if (fexists(*argv)) /* refers to a file directly */
- {
- pkgs[ch] = realpath(*argv,pkgnames[ch]);
- }else{ /* look for the file in the expected places */
- if (!(cp = fileFindByPath(NULL,*argv)))
- {
- whinge("Can't find package '%s'.",*argv);
- return(1);
+ if (AddMode != SLAVE) {
+ for (ch = 0; ch < MAX_PKGS; pkgs[ch++] = NULL) ;
+
+ /* Get all the remaining package names, if any */
+ for (ch = 0; *argv; ch++, argv++) {
+ if (isURL(*argv)) /* preserve URLs */
+ pkgs[ch] = strcpy(pkgnames[ch], *argv);
+ else { /* expand all pathnames to fullnames */
+ if (fexists(*argv)) /* refers to a file directly */
+ pkgs[ch] = realpath(*argv, pkgnames[ch]);
+ else { /* look for the file in the expected places */
+ if (!(cp = fileFindByPath(NULL, *argv)))
+ whinge("Can't find package '%s'.", *argv);
+ else
+ pkgs[ch] = strcpy(pkgnames[ch], cp);
}
- pkgs[ch] = strcpy(pkgnames[ch],cp);
}
}
}
-
/* If no packages, yelp */
- if (!ch && AddMode != SLAVE)
+ else if (!ch)
usage(prog_name, "Missing package name(s)");
- else if ((ch > 1) && AddMode == MASTER)
+ else if (ch > 1 && AddMode == MASTER)
usage(prog_name, "Only one package name may be specified with master mode");
- else if (ch && AddMode == SLAVE)
- whinge("Package names ignored in slave mode.");
if ((err = pkg_perform(pkgs)) != NULL) {
if (Verbose)
fprintf(stderr, "%d package addition(s) failed.\n", err);
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index b557ee50b9c8..658f245ee39d 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: perform.c,v 1.26.2.6 1995/10/31 20:35:16 jkh Exp $";
+static const char *rcsid = "$Id: perform.c,v 1.26.2.7 1995/11/03 02:54:57 jkh Exp $";
#endif
/*
@@ -223,7 +223,7 @@ pkg_do(char *pkg)
if (!Fake && vsystem("pkg_info -e %s", p->name)) {
char path[FILENAME_MAX], *cp = NULL;
- if (!Fake && !isURL(pkg)) {
+ if (!Fake && !isURL(pkg) && !getenv("PKG_ADD_BASE")) {
snprintf(path, FILENAME_MAX, "%s/%s.tgz", Home, p->name);
if (fexists(path))
cp = path;
@@ -242,14 +242,19 @@ pkg_do(char *pkg)
else if (!Fake && (cp = fileGetURL(pkg, p->name)) != NULL) {
if (Verbose)
printf("Finished loading %s over FTP.\n", p->name);
- if (!Fake && (!fexists("+CONTENTS") || vsystem("(pwd; cat +CONTENTS) | pkg_add %s-S"),
- Verbose ? "-v " : "")) {
- whinge("Autoload of dependency `%s' failed%s", p->name, Force ? " (proceeding anyway)" : "!");
- if (!Force)
- ++code;
+ if (!Fake) {
+ if (!fexists("+CONTENTS"))
+ whinge("Autoloaded package %s has no +CONTENTS file?", p->name);
+ else
+ if (vsystem("(pwd; cat +CONTENTS) | pkg_add %s-S", Verbose ? "-v " : "")) {
+ whinge("pkg_add of dependency `%s' failed%s",
+ p->name, Force ? " (proceeding anyway)" : "!");
+ if (!Force)
+ ++code;
+ }
+ else if (Verbose)
+ printf("\t`%s' loaded successfully.\n", p->name);
}
- else if (Verbose)
- printf("\t`%s' loaded successfully.\n", p->name);
/* Nuke the temporary playpen */
leave_playpen(cp);
}
diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c
index 6449fd49b8f4..19b9f2e5031c 100644
--- a/usr.sbin/pkg_install/delete/perform.c
+++ b/usr.sbin/pkg_install/delete/perform.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: perform.c,v 1.6 1994/12/06 00:51:40 jkh Exp $";
+static const char *rcsid = "$Id: perform.c,v 1.7 1995/04/19 14:01:58 jkh Exp $";
#endif
/*
@@ -120,10 +120,15 @@ pkg_do(char *pkg)
}
if (chdir(home) == FAIL)
barf("Toto! This doesn't look like Kansas anymore!");
- if (!Fake && delete_package(FALSE, CleanDirs, &Plist) != FAIL &&
- vsystem("%s -r %s", REMOVE_CMD, LogDir)) {
- whinge("Couldn't remove log entry in %s, de-install failed.", LogDir);
- return 1;
+ if (!Fake) {
+ /* Some packages aren't packed right, so we need to just ignore delete_package()'s status. Ugh! :-( */
+ if (delete_package(FALSE, CleanDirs, &Plist) == FAIL)
+ warn("Couldn't entirely delete package (perhaps the packing list is\n"
+ "incorrectly specified?)\n");
+ if (vsystem("%s -r %s", REMOVE_CMD, LogDir)) {
+ whinge("Couldn't remove log entry in %s, de-install failed.", LogDir);
+ return 1;
+ }
}
for (p = Plist.head; p ; p = p->next) {
if (p->type != PLIST_PKGDEP)
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
index 9e9ca7d5e027..25447069b227 100644
--- a/usr.sbin/pkg_install/lib/file.c
+++ b/usr.sbin/pkg_install/lib/file.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: file.c,v 1.10.4.6 1995/10/15 14:08:40 jkh Exp $";
+static const char *rcsid = "$Id: file.c,v 1.10.4.7 1995/10/31 20:35:20 jkh Exp $";
#endif
/*
@@ -174,7 +174,7 @@ fileGetURL(char *base, char *spec)
{
char host[HOSTNAME_MAX], file[FILENAME_MAX], dir[FILENAME_MAX];
char pword[HOSTNAME_MAX + 40], *uname, *cp, *rp, *tmp;
- char fname[511];
+ char fname[FILENAME_MAX];
char pen[FILENAME_MAX];
struct passwd *pw;
FTP_t ftp;
@@ -182,39 +182,40 @@ fileGetURL(char *base, char *spec)
int fd, fd2, i, len = 0;
char ch;
time_t start, stop;
+ char *hint;
rp = NULL;
+ /* Special tip that sysinstall left for us */
+ hint = getenv("PKG_ADD_BASE");
if (!isURL(spec)) {
int len;
- if (!base)
+ if (!base && !hint)
return NULL;
/* We've been given an existing URL (that's known-good) and now we need
to construct a composite one out of that and the basename we were
handed as a dependency. */
- strncpy(fname, base, 511);
- fname[511] = '\0';
- cp = strrchr(fname, '/');
- if (cp) {
- *cp = '\0'; /* Eliminate the filename portion */
- len = strlen(fname);
- /* Special case for the all category */
- if (len > 3 && !strcmp(cp - 3, "All"))
- sprintf(cp, "/%s", spec);
- else {
- /* Replace category with All */
- if ((cp = strrchr(fname, '/')) != NULL) {
- strcat(cp + 1, "All/");
- strcat(cp + 4, spec);
- }
- else {
- strcat(fname, "All/");
- strcat(fname, spec);
- }
+ if (base) {
+ strcpy(fname, base);
+ /* Advance back two slashes to get to the root of the package hierarchy */
+ cp = strrchr(fname, '/');
+ if (cp) {
+ *cp = '\0'; /* chop name */
+ cp = strrchr(fname, '/');
+ }
+ if (cp) {
+ *(cp + 1) = '\0';
+ strcat(cp, "All/");
+ strcat(cp, spec);
}
+ else
+ return NULL;
+ }
+ else {
+ /* Otherwise, we've been given an environment variable hinting at the right location from sysinstall */
+ strcpy(fname, hint);
+ strcat(fname, spec);
}
- else
- return NULL;
}
else
strcpy(fname, spec);
@@ -298,7 +299,6 @@ fileFindByPath(char *base, char *fname)
{
static char tmp[FILENAME_MAX];
char *cp;
- int len;
if (fexists(fname) && isfile(fname)) {
strcpy(tmp, fname);
@@ -306,28 +306,19 @@ fileFindByPath(char *base, char *fname)
}
if (base) {
strcpy(tmp, base);
- cp = strchr(tmp, '/');
- len = strlen(tmp);
+ cp = strrchr(fname, '/');
if (cp) {
- /* Special case for the all category */
- if (len > 3 && !strncmp(cp - 3, "All/", 4))
- strcat(cp + 1, fname);
- else {
- *cp = '\0';
- /* Replace category with All */
- if ((cp = strrchr(tmp, '/')) != NULL) {
- strcat(cp + 1, "All/");
- strcat(cp, fname);
- }
- else {
- strcat(tmp, "All/");
- strcat(tmp, fname);
- }
- }
+ *cp = '\0'; /* chop name */
+ cp = strrchr(fname, '/');
+ }
+ if (cp) {
+ *(cp + 1) = '\0';
+ strcat(cp, "All/");
+ strcat(cp, fname);
+ if (fexists(tmp))
+ return tmp;
}
- if (fexists(tmp))
- return tmp;
}
cp = getenv("PKG_PATH");
diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c
index 36a016ccd751..9a0124b01f4f 100644
--- a/usr.sbin/pkg_install/lib/plist.c
+++ b/usr.sbin/pkg_install/lib/plist.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: plist.c,v 1.14 1995/07/28 01:50:35 ache Exp $";
+static const char *rcsid = "$Id: plist.c,v 1.13.4.1 1995/08/30 07:50:02 jkh Exp $";
#endif
/*
@@ -287,18 +287,15 @@ write_plist(Package *pkg, FILE *fp)
break;
case PLIST_CHMOD:
- fprintf(fp, "%cmode %s\n", CMD_CHAR,
- plist->name ? plist->name : "");
+ fprintf(fp, "%cmode %s\n", CMD_CHAR, plist->name ? plist->name : "");
break;
case PLIST_CHOWN:
- fprintf(fp, "%cowner %s\n", CMD_CHAR,
- plist->name ? plist->name : "");
+ fprintf(fp, "%cowner %s\n", CMD_CHAR, plist->name ? plist->name : "");
break;
case PLIST_CHGRP:
- fprintf(fp, "%cgroup %s\n", CMD_CHAR,
- plist->name ? plist->name : "");
+ fprintf(fp, "%cgroup %s\n", CMD_CHAR, plist->name ? plist->name : "");
break;
case PLIST_COMMENT:
@@ -355,6 +352,8 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
char *Where = ".", *last_file = "";
Boolean fail = SUCCESS;
+ if (!p)
+ return FAIL;
while (p) {
if (p->type == PLIST_CWD) {
Where = p->name;
@@ -378,14 +377,18 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
char full_name[FILENAME_MAX];
sprintf(full_name, "%s/%s", Where, p->name);
- if (Verbose)
- printf("Delete%s %s\n",
- p->type == PLIST_FILE ? "" : " directory", full_name);
+ if (isdir(full_name) && p->type == PLIST_FILE) {
+ warn("Attempting to delete directory `%s' as a file\n"
+ "This packing list is incorrect - ignoring delete request.\n", full_name);
+ }
+ else {
+ if (Verbose)
+ printf("Delete %s %s\n", !isdir(full_name) ? "file" : " directory", full_name);
- if (!Fake && delete_hierarchy(full_name, ign_err,
- p->type == PLIST_DIR_RM ? FALSE : nukedirs)) {
- whinge("Unable to completely remove file '%s'", full_name);
- fail = FAIL;
+ if (!Fake && delete_hierarchy(full_name, ign_err, p->type == PLIST_DIR_RM ? FALSE : nukedirs)) {
+ whinge("Unable to completely remove file '%s'", full_name);
+ fail = FAIL;
+ }
}
last_file = p->name;
}
@@ -411,8 +414,7 @@ delete_hierarchy(char *dir, Boolean ign_err, Boolean nukedirs)
cp1 = cp2 = dir;
if (!fexists(dir)) {
if (!ign_err)
- whinge("%s `%s' doesn't really exist.",
- isdir(dir) ? "Directory" : "File", dir);
+ whinge("%s `%s' doesn't really exist.", isdir(dir) ? "Directory" : "File", dir);
} else if (nukedirs) {
if (vsystem("%s -r%s %s", REMOVE_CMD, (ign_err ? "f" : ""), dir))
return 1;