diff --git a/usr.sbin/pkg_install/add/Makefile b/usr.sbin/pkg_install/add/Makefile index 723ca45919b9..83a022ecfffb 100644 --- a/usr.sbin/pkg_install/add/Makefile +++ b/usr.sbin/pkg_install/add/Makefile @@ -10,8 +10,8 @@ LDADD+= -L${.CURDIR}/../lib -linstall DPADD+= ${.CURDIR}/../lib/libinstall.a .endif -LDADD+= -lftpio -DPADD+= ${LIBFTPIO} +LDADD+= -lftpio -lmd +DPADD+= ${LIBFTPIO} ${LIBMD} SRCS= main.c perform.c futil.c extract.c diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index 4dd91098e878..1d3099a51cb3 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.9 1995/11/12 04:55:19 jkh Exp $"; +static char *rcsid = "$Id: main.c,v 1.10 1996/03/12 06:12:36 jkh Exp $"; #endif /* @@ -32,7 +32,6 @@ static char Options[] = "hvIRfnp:SMt:"; char *Prefix = NULL; Boolean NoInstall = FALSE; Boolean NoRecord = FALSE; -Boolean Force = FALSE; char *Mode = NULL; char *Owner = NULL; diff --git a/usr.sbin/pkg_install/create/Makefile b/usr.sbin/pkg_install/create/Makefile index 26d57e4958fc..01048acdf548 100644 --- a/usr.sbin/pkg_install/create/Makefile +++ b/usr.sbin/pkg_install/create/Makefile @@ -10,8 +10,8 @@ LDADD+= -L${.CURDIR}/../lib -linstall DPADD+= ${.CURDIR}/../lib/libinstall.a .endif -LDADD+= -lftpio -DPADD+= ${LIBFTPIO} +LDADD+= -lftpio -lmd +DPADD+= ${LIBFTPIO} ${LIBMD} SRCS= main.c perform.c pl.c diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index c3004eec9868..ee89e1a3aabe 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: perform.c,v 1.30 1996/03/20 19:05:59 jdp Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.31 1996/06/20 18:33:36 jkh Exp $"; #endif /* @@ -156,11 +156,6 @@ pkg_perform(char **pkgs) add_plist(&plist, PLIST_MTREE, MTREE_FNAME); } - /* Run through the list again, picking up extra "local" items */ - /* check_list(".", &plist); */ - /* copy_plist(".", &plist); */ - /* mark_plist(&plist); */ - /* Finally, write out the packing list */ fp = fopen(CONTENTS_FNAME, "w"); if (!fp) diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c index 9eb98a38458e..80d8805ac12f 100644 --- a/usr.sbin/pkg_install/create/pl.c +++ b/usr.sbin/pkg_install/create/pl.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: pl.c,v 1.6 1994/12/06 00:51:38 jkh Exp $"; +static const char *rcsid = "$Id: pl.c,v 1.7 1995/05/30 03:49:56 rgrimes Exp $"; #endif /* @@ -25,13 +25,12 @@ static const char *rcsid = "$Id: pl.c,v 1.6 1994/12/06 00:51:38 jkh Exp $"; #include "lib.h" #include "create.h" #include +#include /* Check a list for files that require preconversion */ void check_list(char *home, Package *pkg) { - char cmd[FILENAME_MAX]; - char name[FILENAME_MAX]; char *where = home; char *there = NULL; PackingList p = pkg->head; @@ -45,15 +44,18 @@ check_list(char *home, Package *pkg) there = p->name; } else if (p->type == PLIST_FILE) { - cmd[0] = '\0'; - sprintf(name, "%s/%s", there ? there : where, p->name); + char *cp, name[FILENAME_MAX], buf[33]; - if (*cmd) { - if (Verbose) - printf("Uncompressing-> %s\n", cmd); - if (system(cmd)) - barf("%s failed!", cmd); - nuke_suffix(p->name); + sprintf(name, "%s/%s", there ? there : where, p->name); + if ((cp = MD5File(name, buf)) != NULL) { + PackingList tmp = new_plist_entry(); + + tmp->name = copy_string(strconcat("MD5:", cp)); + tmp->type = PLIST_COMMENT; + tmp->next = p->next; + tmp->prev = p; + p->next = tmp; + p = tmp; } } p = p->next; diff --git a/usr.sbin/pkg_install/delete/Makefile b/usr.sbin/pkg_install/delete/Makefile index 9fd098007d9a..20a57176a2c3 100644 --- a/usr.sbin/pkg_install/delete/Makefile +++ b/usr.sbin/pkg_install/delete/Makefile @@ -9,8 +9,8 @@ LDADD+= -L${.CURDIR}/../lib -linstall DPADD+= ${.CURDIR}/../lib/libinstall.a .endif -LDADD+= -lftpio -DPADD+= ${LIBFTPIO} +LDADD+= -lftpio -lmd +DPADD+= ${LIBFTPIO} ${LIBMD} SRCS= main.c perform.c diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index 10d0c187916a..646c42010ce1 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -1,5 +1,5 @@ #ifndef lint -static char *rcsid = "$Id: main.c,v 1.4 1995/05/30 03:49:57 rgrimes Exp $"; +static char *rcsid = "$Id: main.c,v 1.5 1996/06/20 18:33:43 jkh Exp $"; #endif /* @@ -32,7 +32,6 @@ static char Options[] = "hvDdnfp:"; char *Prefix = NULL; Boolean NoDeInstall = FALSE; Boolean CleanDirs = FALSE; -Boolean Force = FALSE; int main(int argc, char **argv) diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index dd3810ae75f1..dd548b2a76cb 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.8 1995/11/12 04:55:30 jkh Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.9 1996/06/20 18:33:44 jkh Exp $"; #endif /* @@ -127,15 +127,15 @@ pkg_do(char *pkg) "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; + if (!Force) + return 1; } } for (p = Plist.head; p ; p = p->next) { if (p->type != PLIST_PKGDEP) continue; if (Verbose) - printf("Attempting to remove dependency on package `%s'\n", - p->name); + printf("Attempting to remove dependency on package `%s'\n", p->name); if (!Fake) undepend(p, pkg); } diff --git a/usr.sbin/pkg_install/info/Makefile b/usr.sbin/pkg_install/info/Makefile index 9ab8dc38fce2..29f98d219cb6 100644 --- a/usr.sbin/pkg_install/info/Makefile +++ b/usr.sbin/pkg_install/info/Makefile @@ -9,8 +9,8 @@ LDADD+= -L${.CURDIR}/../lib -linstall DPADD+= ${.CURDIR}/../lib/libinstall.a .endif -LDADD+= -lftpio -DPADD+= ${LIBFTPIO} +LDADD+= -lftpio -lmd +DPADD+= ${LIBFTPIO} ${LIBMD} SRCS= main.c perform.c show.c diff --git a/usr.sbin/pkg_install/lib/global.c b/usr.sbin/pkg_install/lib/global.c index d411f5e28550..17d0026ca62a 100644 --- a/usr.sbin/pkg_install/lib/global.c +++ b/usr.sbin/pkg_install/lib/global.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: global.c,v 1.1.1.1 1993/08/26 01:19:55 jkh Exp $"; +static const char *rcsid = "$Id: global.c,v 1.2 1994/04/05 14:08:45 jkh Exp $"; #endif /* @@ -28,6 +28,7 @@ static const char *rcsid = "$Id: global.c,v 1.1.1.1 1993/08/26 01:19:55 jkh Exp /* These are global for all utils */ Boolean Verbose = FALSE; Boolean Fake = FALSE; +Boolean Force = FALSE; int AutoAnswer = FALSE; diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index 95ac9a1a034d..6abf95f7f392 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -1,4 +1,4 @@ -/* $Id: lib.h,v 1.20 1996/06/08 00:46:32 alex Exp $ */ +/* $Id: lib.h,v 1.21 1996/06/20 18:33:53 jkh Exp $ */ /* * FreeBSD install - a package for the installation and maintainance @@ -62,25 +62,25 @@ #define PKG_DBDIR "PKG_DBDIR" /* The names of our "special" files */ -#define CONTENTS_FNAME "+CONTENTS" -#define COMMENT_FNAME "+COMMENT" -#define DESC_FNAME "+DESC" -#define INSTALL_FNAME "+INSTALL" -#define DEINSTALL_FNAME "+DEINSTALL" -#define REQUIRE_FNAME "+REQUIRE" +#define CONTENTS_FNAME "+CONTENTS" +#define COMMENT_FNAME "+COMMENT" +#define DESC_FNAME "+DESC" +#define INSTALL_FNAME "+INSTALL" +#define DEINSTALL_FNAME "+DEINSTALL" +#define REQUIRE_FNAME "+REQUIRE" #define REQUIRED_BY_FNAME "+REQUIRED_BY" -#define DISPLAY_FNAME "+DISPLAY" -#define MTREE_FNAME "+MTREE_DIRS" +#define DISPLAY_FNAME "+DISPLAY" +#define MTREE_FNAME "+MTREE_DIRS" -#define CMD_CHAR '@' /* prefix for extended PLIST cmd */ +#define CMD_CHAR '@' /* prefix for extended PLIST cmd */ /* The name of the "prefix" environment variable given to scripts */ #define PKG_PREFIX_VNAME "PKG_PREFIX" enum _plist_t { PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD, - PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, - PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY, + PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE, + PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY, PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST, PLIST_OPTION }; @@ -171,6 +171,7 @@ int pkg_perform(char **); /* Externs */ extern Boolean Verbose; extern Boolean Fake; +extern Boolean Force; extern int AutoAnswer; #endif /* _INST_LIB_LIB_H_ */ diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c index 2a5c67460451..b9f3e1673e57 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.15 1995/11/12 04:55:40 jkh Exp $"; +static const char *rcsid = "$Id: plist.c,v 1.16 1996/06/20 18:33:55 jkh Exp $"; #endif /* @@ -23,6 +23,7 @@ static const char *rcsid = "$Id: plist.c,v 1.15 1995/11/12 04:55:40 jkh Exp $"; */ #include "lib.h" +#include /* Add an item to a packing list */ void @@ -238,11 +239,11 @@ read_plist(Package *pkg, FILE *fp) int cmd; while (fgets(pline, FILENAME_MAX, fp)) { - int len = strlen(pline) - 1; + int len = strlen(pline); - while (isspace(pline[len])) - pline[len--] = '\0'; - if (len <= 0) + while (len && isspace(pline[len - 1])) + pline[--len] = '\0'; + if (!len) continue; cp = pline; if (pline[0] == CMD_CHAR) { @@ -348,51 +349,84 @@ write_plist(Package *pkg, FILE *fp) int delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg) { - PackingList p = pkg->head; + PackingList p; char *Where = ".", *last_file = ""; Boolean fail = SUCCESS; + char tmp[FILENAME_MAX]; - if (!p) - return FAIL; - while (p) { - if (p->type == PLIST_CWD) { + for (p = pkg->head; p; p = p->next) { + switch (p->type) { + case PLIST_IGNORE: + p = p->next; + break; + + case PLIST_CWD: Where = p->name; if (Verbose) printf("Change working directory to %s\n", Where); - } - else if (p->type == PLIST_UNEXEC) { - char cmd[FILENAME_MAX]; + break; - format_cmd(cmd, p->name, Where, last_file); + case PLIST_UNEXEC: + format_cmd(tmp, p->name, Where, last_file); if (Verbose) - printf("Execute `%s'\n", cmd); - if (!Fake && system(cmd)) { - whinge("unexec command for `%s' failed.", cmd); + printf("Execute `%s'\n", tmp); + if (!Fake && system(tmp)) { + whinge("unexec command for `%s' failed.", tmp); fail = FAIL; } - } - else if (p->type == PLIST_IGNORE) - p = p->next; - else if (p->type == PLIST_FILE || p->type == PLIST_DIR_RM) { - char full_name[FILENAME_MAX]; + break; - sprintf(full_name, "%s/%s", Where, p->name); - if (isdir(full_name) && p->type == PLIST_FILE) { + case PLIST_FILE: + sprintf(tmp, "%s/%s", Where, p->name); + if (isdir(tmp)) { whinge("Attempting to delete directory `%s' as a file\n" - "This packing list is incorrect - ignoring delete request.\n", full_name); + "This packing list is incorrect - ignoring delete request.\n", tmp); } else { - if (Verbose) - printf("Delete %s %s\n", !isdir(full_name) ? "file" : " directory", full_name); + if (p->next && p->next->type == PLIST_COMMENT && !strncmp(p->next->name, "MD5:", 4)) { + char *cp, buf[33]; - if (!Fake && delete_hierarchy(full_name, ign_err, p->type == PLIST_DIR_RM ? FALSE : nukedirs)) { - whinge("Unable to completely remove file '%s'", full_name); + if ((cp = MD5File(tmp, buf)) != NULL) { + /* Mismatch? */ + if (strcmp(cp, p->next->name + 4)) { + if (Verbose) + printf("%s fails original MD5 checksum - %s\n", + tmp, Force ? "deleted anyway." : "not deleted."); + if (!Force) { + fail = FAIL; + continue; + } + } + } + } + if (Verbose) + printf("Delete file %s\n", tmp); + + if (!Fake && delete_hierarchy(tmp, ign_err, nukedirs)) { + whinge("Unable to completely remove file '%s'", tmp); fail = FAIL; } } last_file = p->name; + break; + + case PLIST_DIR_RM: + sprintf(tmp, "%s/%s", Where, p->name); + if (!isdir(tmp)) { + whinge("Attempting to delete file `%s' as a directory\n" + "This packing list is incorrect - ignoring delete request.\n", tmp); + } + else { + if (Verbose) + printf("Delete directory %s\n", tmp); + if (!Fake && delete_hierarchy(tmp, ign_err, FALSE)) { + whinge("Unable to completely remove directory '%s'", tmp); + fail = FAIL; + } + } + last_file = p->name; + break; } - p = p->next; } return fail; }