--- pkg_install/add/extract.c.orig Tue Sep 3 10:54:35 2002 +++ pkg_install/add/extract.c Tue Sep 3 14:17:12 2002 @@ -104,6 +104,9 @@ plist_t *p = pkg->head; char *last_file; char *where_args, *perm_args, *last_chdir; + char menufilename[FILENAME_MAX]; + char *PkgMenu = NULL; + FILE *mfile; int maxargs, where_count = 0, perm_count = 0, add_count; Boolean preserve; @@ -326,6 +329,39 @@ case PLIST_IGNORE: p = p->next; + break; + + case PLIST_MENU: + PkgMenu = p->name; + if (! PkgName) { + warnx("No package name for saving menu -- maybe corrupted PLIST"); + break; + } + (void) snprintf (menufilename, + sizeof(menufilename), + DEF_MENU_DIR "/"); + if (!(isdir(menufilename) || islinktodir(menufilename))) { + if (Verbose) + printf("menu directory %s does not exist, creating.\n", menufilename); + if (vsystem("/bin/mkdir -p -m 755 %s", menufilename)) { + errx(1, "Unable to make directory %s, aborting.", + menufilename); + } + + } + strcat(menufilename, PkgName); + mfile = fopen(menufilename, "a"); + if (! mfile) + warnx("can't append to menu file '%s'", + menufilename); + else { + fprintf(mfile, "%s\n", PkgMenu); + if (Verbose) + printf("extract: Package menu entry: %s to %s\n", PkgMenu, menufilename); + if (fclose(mfile) == EOF) + warnx("cannot properly close file %s", + menufilename); + } break; default: --- pkg_install/add/perform.c.orig Tue Sep 3 14:52:45 2002 +++ pkg_install/add/perform.c Tue Sep 3 14:53:25 2002 @@ -645,7 +645,7 @@ fail: /* Nuke the whole (installed) show, XXX but don't clean directories */ if (!Fake) - delete_package(FALSE, FALSE, &Plist); + delete_package(FALSE, FALSE, &Plist, PkgName); success: /* delete the packing list contents */ --- pkg_install/lib/lib.h.orig Tue Sep 3 13:07:07 2002 +++ pkg_install/lib/lib.h Tue Sep 3 14:47:22 2002 @@ -87,6 +87,11 @@ #define DEF_LOG_DIR "/var/db/pkg" #endif +/* Where the package menu entries are saved */ +#ifndef DEF_MENU_DIR +#define DEF_MENU_DIR "/usr/pkg/etc/menus" +#endif + /* just in case we change the environment variable name */ #define PKG_DBDIR "PKG_DBDIR" @@ -141,7 +146,8 @@ PLIST_IGNORE_INST, /* 15 */ PLIST_OPTION, /* 16 */ PLIST_PKGCFL, /* 17 */ - PLIST_BLDDEP /* 18 */ + PLIST_BLDDEP, /* 18 */ + PLIST_MENU /* 19 */ } pl_ent_t; /* Types */ @@ -265,7 +271,7 @@ void write_plist(package_t *, FILE *, char *); void read_plist(package_t *, FILE *); int plist_cmd(char *, char **); -int delete_package(Boolean, Boolean, package_t *); +int delete_package(Boolean, Boolean, package_t *, const char *); /* Package Database */ int pkgdb_open(int); --- pkg_install/lib/plist.c.orig Tue Sep 3 13:38:52 2002 +++ pkg_install/lib/plist.c Tue Sep 3 14:37:33 2002 @@ -63,6 +63,7 @@ {"dirrm", PLIST_DIR_RM, 1, 0}, {"option", PLIST_OPTION, 1, 0}, {"blddep", PLIST_BLDDEP, 1, 0}, + {"menu", PLIST_MENU, 1, 0}, {NULL, FAIL, 0, 0} }; @@ -323,12 +324,13 @@ * run it too in cases of failure. */ int -delete_package(Boolean ign_err, Boolean nukedirs, package_t *pkg) +delete_package(Boolean ign_err, Boolean nukedirs, package_t *pkg, const char *pkgname) { plist_t *p; char *Where = ".", *last_file = ""; int fail = SUCCESS; Boolean preserve; + Boolean removedmenu = FALSE; char tmp[FILENAME_MAX], *name = NULL; if (pkgdb_open(0) == -1) { @@ -350,6 +352,25 @@ Where = p->name; if (Verbose) printf("Change working directory to %s\n", Where); + break; + case PLIST_MENU: + (void) snprintf(tmp, sizeof(tmp), DEF_MENU_DIR "/%s", + pkgname); + /* it may be in multiple times, so only delete once */ + if (fexists(tmp)) { + if (delete_hierarchy(tmp, ign_err, FALSE)) { + warnx("unable to remove menu file '%s'", tmp); + fail = FAIL; + + } else { + removedmenu = TRUE; + if (Verbose) + printf("Menu file '%s' removed\n", tmp); + } + } else if (! removedmenu) + warnx("cannot remove non-existent menu file " + "'%s'", tmp); + last_file = p->name; break; case PLIST_UNEXEC: --- pkg_install/delete/perform.c.orig Tue Sep 3 14:25:44 2002 +++ pkg_install/delete/perform.c Tue Sep 3 14:26:17 2002 @@ -610,7 +610,7 @@ } 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) + if (delete_package(FALSE, CleanDirs, &Plist, pkg) == FAIL) warnx( "couldn't entirely delete package `%s'\n" "(perhaps the packing list is incorrectly specified?)", pkg);