diff -ur ports-mgmt/pkg_cleanup.orig/Makefile ports-mgmt/pkg_cleanup/Makefile --- ports-mgmt/pkg_cleanup.orig/Makefile 2011-03-18 20:44:09.000000000 -0700 +++ ports-mgmt/pkg_cleanup/Makefile 2011-03-22 02:37:03.000000000 -0700 @@ -6,8 +6,7 @@ # PORTNAME= pkg_cleanup -PORTVERSION= 1.0 -PORTREVISION= 2 +PORTVERSION= 1.1 CATEGORIES= ports-mgmt DISTFILES= diff -ur ports-mgmt/pkg_cleanup.orig/files/Makefile ports-mgmt/pkg_cleanup/files/Makefile --- ports-mgmt/pkg_cleanup.orig/files/Makefile 2011-03-18 20:44:09.000000000 -0700 +++ ports-mgmt/pkg_cleanup/files/Makefile 2011-03-21 22:28:45.000000000 -0700 @@ -1,5 +1,6 @@ # $FreeBSD: ports/ports-mgmt/pkg_cleanup/files/Makefile,v 1.1 2008/01/04 13:28:51 pav Exp $ +LDLIBS += -lncursesw LDLIBS += -ldialog pkg_cleanup: pkg_cleanup.c diff -ur ports-mgmt/pkg_cleanup.orig/files/pkg_cleanup.c ports-mgmt/pkg_cleanup/files/pkg_cleanup.c --- ports-mgmt/pkg_cleanup.orig/files/pkg_cleanup.c 2011-03-18 20:44:09.000000000 -0700 +++ ports-mgmt/pkg_cleanup/files/pkg_cleanup.c 2011-03-22 02:32:21.000000000 -0700 @@ -15,8 +15,27 @@ #include #include +#if __FreeBSD_version < 900030 +#define OLD_DIALOG +#endif + static glob_t gl; /* A cached list of all files in /var/db/pkg */ -dialogMenuItem *menu=NULL; +#ifdef OLD_DIALOG +typedef dialogMenuItem ListItem; +#else +typedef DIALOG_LISTITEM ListItem; +#endif +ListItem *menu; +#ifdef OLD_DIALOG +#define ITEM_DATA data +#define ITEM_PROMPT prompt +#define ITEM_CHECKED aux +#else +#define ITEM_DATA help +#define ITEM_PROMPT name +#define ITEM_CHECKED state +#endif + int menulen=0; void free_menu(void) @@ -25,13 +44,13 @@ if(menu) { for(i=0; iaux) @@ -80,22 +100,23 @@ return(TRUE); return(FALSE); } +#endif /* Read +COMMENT, add to menu and blacklist */ int add_item(char *path) { - char *p; - char comment[80]; - FILE *comment_file; - char comment_path[MAXPATHLEN+1]; - dialogMenuItem *newmenu; + char *p; + char comment[80]; + FILE *file; + char newpath[MAXPATHLEN+1]; + ListItem *newmenu; if(blacklist(path,FIND)) return(0); blacklist(path,ENTER); comment[0]=0; - newmenu=(dialogMenuItem*)realloc(menu, sizeof(dialogMenuItem)*(menulen+1)); + newmenu=(ListItem *)realloc(menu, sizeof(ListItem)*(menulen+1)); if(newmenu==NULL) return(-1); menu=newmenu; @@ -104,7 +125,9 @@ if(p==NULL) /* Not possible */ return(-1); - menu[menulen].prompt=strdup(p+1); + menu[menulen].ITEM_PROMPT=strdup(p+1); + menu[menulen].ITEM_CHECKED=0; +#ifdef OLD_DIALOG menu[menulen].title=""; menu[menulen].checked=checked; menu[menulen].fire=fire; @@ -112,14 +135,16 @@ menu[menulen].lbra='['; menu[menulen].mark='X'; menu[menulen].rbra=']'; - menu[menulen].aux=0; +#else + menu[menulen].text=""; +#endif /* Read +COMMENT */ - sprintf(comment_path,"%s/+COMMENT",path); - comment_file=fopen(comment_path,"r"); - if(comment_file) { - fgets(comment, sizeof(comment), comment_file); - fclose(comment_file); + sprintf(newpath,"%s/+COMMENT",path); + file=fopen(newpath,"r"); + if(file) { + fgets(comment, sizeof(comment), file); + fclose(file); /* Remove trailing whitespace */ for(p=strchr(comment,0)-1; p>=comment; p--) { if(isspace(*p)) @@ -128,22 +153,75 @@ break; } } - menu[menulen].data=strdup(comment); + menu[menulen].ITEM_DATA=strdup(comment); menulen++; return(0); } +void do_init_dialog(void) +{ +#ifdef OLD_DIALOG + init_dialog(); + use_shadow=FALSE; +#else + init_dialog(stdin, stdout); + dialog_state.use_shadow=FALSE; +#endif +} + int display_menu(void) { int ret=0; - int maxx,maxy; + int maxx,maxy; + int curr; - init_dialog(); - use_shadow=FALSE; + do_init_dialog(); getmaxyx(stdscr, maxy, maxx); +#ifdef OLD_DIALOG if(dialog_checklist("Welcome to pkg_cleanup.", "These are the leaf packages installed on your system\nChose the packages to deinstall. F1 will display the package description.\n\n\n", maxy, maxx, maxy-11, 0-menulen, menu, NULL)) ret=-1; +#else + dialog_vars.help_button=1; + dialog_vars.item_help=1; +loop: + switch(ret=dlg_checklist("Welcome to pkg_cleanup.", "These are the leaf packages installed on your system\nChose the packages to deinstall. Help will display the package description.", maxy-1, maxx, maxy-9, menulen, menu, " X", FLAG_CHECK, &curr)) { + case DLG_EXIT_HELP: { + char *p; + char newpath[MAXPATHLEN+1]; + FILE *file; + struct stat sb; + + /* READ +DESC */ + sprintf(newpath,"/var/db/pkg/%s/+DESC",menu[curr].ITEM_PROMPT); + file=fopen(newpath, "r"); + if(file) { + if(fstat(fileno(file), &sb)==0) { + p=(char *)malloc(sb.st_size+1); + if(p) { + if(fread(p, sb.st_size, 1, file)==1) { + p[sb.st_size]=0; + dialog_vars.help_button=0; + dialog_msgbox(menu[curr].ITEM_DATA, p, maxy-4, maxx-4, TRUE); + dialog_vars.help_button=1; + } + free(p); + } + } + fclose(file); + } + goto loop; + } + case 0: + ret=0; + break; + default: + ret=-1; + break; + } + dialog_vars.help_button=0; + dialog_vars.item_help=0; +#endif end_dialog(); return(ret); } @@ -157,13 +235,38 @@ int maxx,maxy; int lastgauge=-1; int gauge; +#ifndef OLD_DIALOG + int pipepair[2]; + FILE *read_pipe; + FILE *write_pipe; +#endif - init_dialog(); + do_init_dialog(); getmaxyx(stdscr, maxy, maxx); for(p=0;p