diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1995-11-10 06:44:53 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1995-11-10 06:44:53 +0000 |
| commit | 59b6334caf1db16832ef7b06c02291e19103f3b2 (patch) | |
| tree | 01b66ddc21214874938ed71735d42e894f1c1f5c /usr.sbin/pkg_install/lib | |
| parent | f202e841d1ee3319b0ac08e6878676a4612410bf (diff) | |
Notes
Diffstat (limited to 'usr.sbin/pkg_install/lib')
| -rw-r--r-- | usr.sbin/pkg_install/lib/file.c | 79 | ||||
| -rw-r--r-- | usr.sbin/pkg_install/lib/plist.c | 34 |
2 files changed, 53 insertions, 60 deletions
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; |
