diff --git a/usr.sbin/pkg_manage/Makefile b/usr.sbin/pkg_manage/Makefile index 21017dac474c..be38a2b0e743 100644 --- a/usr.sbin/pkg_manage/Makefile +++ b/usr.sbin/pkg_manage/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.2 1995/04/21 10:05:36 jkh Exp $ +# $Id: Makefile,v 1.3 1995/04/21 10:23:23 jkh Exp $ PROG= pkg_manage SRCS= pkg_main.c pkg_manage.c pkg_ui.c version.c @@ -10,8 +10,9 @@ CFLAGS+= -Wall -Wstrict-prototypes -DHELP_PATH=\"${HELPDIR}/\" \ HELPDIR = /usr/share/misc/pkg_manage -HELPS= pkg_view-inst.hlp pkg_del-inst.hlp pkg_preview.hlp \ - pkg_install.hlp pkg_main.hlp +HELPS= pkg_del-inst.hlp pkg_install.hlp pkg_preview_fs.hlp \ + pkg_del_inst.hlp pkg_main.hlp pkg_view-inst.hlp \ + pkg_ds_install.hlp pkg_preview.hlp pkg_view_inst.hlp afterinstall: @if [ ! -d ${HELPDIR} ]; then rm -f ${HELPDIR}; mkdir -p ${HELPDIR}; fi diff --git a/usr.sbin/pkg_manage/TODO b/usr.sbin/pkg_manage/TODO index 77552b04c1b4..85261517bed9 100644 --- a/usr.sbin/pkg_manage/TODO +++ b/usr.sbin/pkg_manage/TODO @@ -75,6 +75,7 @@ done 6Apr95 Low priority, because something fishy is going on then anyway - use $TMPDIR to create tmp directory into +done 18Apr95 - make sure that when calling help, the helplines are disabled. done 11Apr95, also implemented a different mechanism to save and @@ -84,4 +85,4 @@ restore helplines done 11Apr95 - (next version?) implement exec_catch_errors with popen(), I think - this will speed up things quite a bit. + this will speed up things quite a bit. (not sure about it) diff --git a/usr.sbin/pkg_manage/pkg_del_inst.hlp b/usr.sbin/pkg_manage/pkg_del_inst.hlp new file mode 100644 index 000000000000..f33813d2ecdb --- /dev/null +++ b/usr.sbin/pkg_manage/pkg_del_inst.hlp @@ -0,0 +1,14 @@ + + Choose a package from the list of installed packages to delete. + Move the cursor to the package to be deleted and press enter. + + You may now select to either: + + 1. Simulate delete Only display the commands that will + be executed to delete the package, + without actually executing them. + 2. Delete This will actually delete the + package. + 3. Cancel Return to the package selection menu. + + (use arrow-keys or digit to choose option and press enter) diff --git a/usr.sbin/pkg_manage/pkg_ds_install.hlp b/usr.sbin/pkg_manage/pkg_ds_install.hlp new file mode 100644 index 000000000000..474ed9c4d9a0 --- /dev/null +++ b/usr.sbin/pkg_manage/pkg_ds_install.hlp @@ -0,0 +1,9 @@ + + Select the directory where your packages are stored. + + Use TAB, SHIFT-TAB to move from one field to another. + When in the directory list, pressing enter over a + directory will move you into that directory. + + Select the button and press enter to continue, + Select the button to return. diff --git a/usr.sbin/pkg_manage/pkg_install.hlp b/usr.sbin/pkg_manage/pkg_install.hlp index 6cb1afeaee16..af030845f0ac 100644 --- a/usr.sbin/pkg_manage/pkg_install.hlp +++ b/usr.sbin/pkg_manage/pkg_install.hlp @@ -1,19 +1,21 @@ - *********************************** - * Help for '4. Install pkg files' * - *********************************** + There are several fields in the current window, you can move from + one to the other by pressing 'TAB' and 'SHIFT-TAB'. -Use the 'File Select' dialog to pick a filename. Use the TAB key to -move from field to field and press enter to commit changes or select -items. In the "Directories:"-list and the "Files:"-list use the -arrow-keys and PgUp and PgDn to move through the list. + In the left selection list, mark the packages you wish to install. + Pressing space will mark the current package, '*' will mark all + packages, '-' will unmark all packages. + To view information about a package press either 'ENTER' for + a one line description, or 'F2' for a longer description. -After having chosen a package, you can choose to either: + The right selection list lists the already installed packages. + Here you can also view information about these by using the same + keys as described above. -1. Simulate install Display the commands, necessary to install - the package, without actually executing them. -2. Install Install a package. -3. Cancel Don't install the package and return to the - previous menu. + After having marked the packages of your choice, move to the + button with 'TAB' or 'SHIFT-TAB' and press + 'ENTER' to actually install them. Before installation a check + will be made if a selected package is already installed. If so, + you will be given the choice to delete that package, or skip + the selected package. -(use arrow-keys or digit to choose option and press enter) diff --git a/usr.sbin/pkg_manage/pkg_main.hlp b/usr.sbin/pkg_manage/pkg_main.hlp index b0ac7db2675f..db671a94983a 100644 --- a/usr.sbin/pkg_manage/pkg_main.hlp +++ b/usr.sbin/pkg_manage/pkg_main.hlp @@ -1,8 +1,7 @@ - ********************** - * Help for Main menu * - ********************** + This is the main menu for pkg_manage: -Use the arrow-keys or a digit to select an option and press enter. + Select one of the options using the arrow-keys or press the + corresponding digit, and press enter diff --git a/usr.sbin/pkg_manage/pkg_manage.1 b/usr.sbin/pkg_manage/pkg_manage.1 index 3cd861415970..8a148455aeee 100644 --- a/usr.sbin/pkg_manage/pkg_manage.1 +++ b/usr.sbin/pkg_manage/pkg_manage.1 @@ -6,47 +6,45 @@ .TP .B pkg_manage .SH DESCRIPTION -Pkg_manage is an interactive tool with which you can install, -delete and view packages. It is essentially a -front-end to the pkg_add(1), pkg_info(1) and pkg_delete(1) programs -which uses the new libdialog extensions for the GUI. +Pkg_manage is an interactive tool with wich you can install, +delete and view packages. It is a +front-end to the pkg_add(1), pkg_info(1) and pkg_delete(1) programs. -Pressing F1 (or '?') at any time during the program will bring up -on-line help. (Pressing '?' will not invoke help when in character -input fields). +Pressing F1 (or '?') at anytime during the program will bring up +online-help. (Pressing '?' will not invoke help when in character +input fields) .SH NAVIGATING THE MENU -At start time, pkg_manage will present a menu with the following choices: +When starting pkg_manage you will be put in a menu with the following +choices: .TP .B 1. View installed. You will be offered an overview of the installed -packages. Moving the cursor to a package name and pressing the -.B Enter -key will show additional information for the package. Use the +packages. Moving the cursor to a packagename and pressing 'enter' +will show additional information for the package. Use the .B PgUp and .B PgDn -keys to page through the information. Press the +keys to page through the information. Press .B Enter -key (this selects the +(this selects the .B -button) to return to the `View installed Packages' menu. +button) to return to the 'View installed Packages' menu. -When done viewing packages, move the cursor to the +When done viewing packages move the cursor to the .B button with the right-arrow key (or left-arrow key) -and press Enter. This will return you to the main menu. +and press enter. This will return you to the main-menu. .TP .B 2. Delete installed -You can select a package from the list of installed packages for deletion. -Move the cursor to the package you wish to delete and press Enter. This will +You can choose a package from the installed ones to delete. Move the +cursor to the package you wish to delete and press enter. This will bring up another menu from which you can choose to either: .B 1. Simulate delete: -Have a look at the commands that are going to be executed rather than -executing them (recommended). +Have a look at the commands that are going to be executed (recommended). .B 2. Delete: Execute the commands to delete the package. .B 3. Cancel: @@ -58,90 +56,106 @@ previous menu. Choose the .B button if you don't want to delete any packages -and return to the main menu. +and return to the main-menu. .TP -.B 3. View pkg files -Take a look at the descriptions of not-yet-installed packages and see if you -want any of them or not. -For this option, you'll be asked to chose a package file name using the new -file selector object. See below for a description of the usage of the -file selector. +.B 3. Preview package +Take a look at the commands that will be executed upon installation +of a package. +Choose a package with the fileselector. See below for a description of +the usage of the fileselector. .TP -.B 4. Install pkg files -Install packages of your choice. Use the file selector to select a -package. +.B 4. Install packages +Install packages of your choice. Use the directoryselector to select a +directory containing your packages. Move the cursor to +.B +to continue, +.B +to back out. +Once a directory has been chosen, it will be scanned for packages files, +tpically files ending in '.tgz'. These will be listed in +a listbox (the one on the left) as well as the already installed +packages, that will be listed in a similar box (on the right side). +Use TAB or SHIFT-TAB to move from field to field. +Packages can be selected in the left listbox, using either the +space bar, to mark/unmark a single package at a time, or by using +\'*', '-' to mark/unmark all packages at once. +Once the packages have been selected move to the +.B +button and press enter. If you want to back out, press either ESC +or move to the +.B +button and press enter. +Under the left listbox, the number of kilobytes that the packages will +consume once installed, are indicated. .TP .B 5. Quit -Well, just try this one if you get fed up fiddling with your packages. +Well just try this one if you get fed up fiddling with your packages. -.SH USING THE FILE SELECTOR +.SH USING THE FILESELECTOR -Using the file selector is really quite simple, with a typical file selector -dialog looking something like this: +Using the fileselector is really very simple. -.nf -+----------------------------------------------------------+ -| Filemask: Directory: | -| +-----------------+ +----------------------------------+ | -| |*.tgz | |/seperate/home/marc/src/pkg_manage| | -| +-----------------+ +----------------------------------+ | -| | Directories: Files: | -| +--------------------------+ +-------------------------+ | -| |.. | |mlist-1.2_bin.tgz | | -| |libdialog | | | | -| | | | | | -| | | | | | -| | | | | | -| | | | | | -| | | | | | -| +-------------------(100%)-+ +------------------(100%)-+ | -| Selection: | -| +------------------------------------------------------+ | -| | | | -| +------------------------------------------------------+ | -| +------+ +----------+ | -| | | | | | -| +------+ +----------+ | -+----------------------------------------------------------+ - -.fi -You may use the +.\" +.\" Does anyone know how I can enter this into the manpage? +.\" +.\"+----------------------------------------------------------+ +.\"| Filemask: Directory: | +.\"| +-----------------+ +----------------------------------+ | +.\"| |*.tgz | |/seperate/home/marc/src/pkg_manage| | +.\"| +-----------------+ +----------------------------------+ | +.\"| | Directories: Files: | +.\"| +--------------------------+ +-------------------------+ | +.\"| |.. | |mlist-1.2_bin.tgz | | +.\"| |libdialog | | | | +.\"| | | | | | +.\"| | | | | | +.\"| | | | | | +.\"| | | | | | +.\"| | | | | | +.\"| +-------------------(100%)-+ +------------------(100%)-+ | +.\"| Selection: | +.\"| +------------------------------------------------------+ | +.\"| | | | +.\"| +------------------------------------------------------+ | +.\"| +------+ +----------+ | +.\"| | | | | | +.\"| +------+ +----------+ | +.\"+----------------------------------------------------------+ +.\" +Use the .B TAB -key to move forward from one input or display field to -the next. If enabled in the termcap file, +key to move forwards from one input/display field to +the next. If enabled in the termcap, .B Shift-TAB -will also move backwards. -Pressing the -.B Enter -key in a field will commit any changes you may have made and -move to the next field. Pressing the +will move backwards. +Pressing enter in a field will perform the changes you may have made and +move to the next field. Pressing .B TAB -key will discard any changes and move to the next field. +will discard the changes and move to the next field. The .B "Filemask:" -field controls what kind of files will be displayed in the +controls what kind of files will be displayed in the .B "Files:" -list. The expression follows the same globbing rules that your shell -does, e.g. \'*.tgz' will only show files having names ending with '.tgz'. +list. The expression follows the same rules as your shell does, i.e. +\'*.tgz' will only show files having names ending with '.tgz'. -The .B "Directory:" -field displays the current directory. You can also type another directory -name into this field. +displays the current directory. You can also type in another directory +in this field. The .B "Directories:" list enables you to browse the filesystem. Select .B '..' -and press Enter to -go up the directory tree, select any other directory listed to descend +and press enter to +go up the directory tree, select any other directory listed to descent into that directory. -Finally, there three more fields: The +Finally there three more fields: The .B Selection: , the .B @@ -149,22 +163,28 @@ button and the .B button. The file chosen in the .B Files: -field, assuming you pressed Enter, will be displayed in the +field, assuming you pressed enter, will be displayed in the .B Selection: field. You can also change this value directly by editing the field. When you are satisfied with the current selection you can move the cursor to the .B -button and press Enter. If you want to back out, move the cursor to the +button and press enter. If you want to back out, move the cursor to the .B -button and press Enter. +button and press enter. + +.SH USING THE DIRECTORYSELECTOR + +This is basically the same as using the fileselector. There are just no +files to select. Once the directory has been chosen, choose +.B .SH SEE ALSO pkg_add(1), pkg_info(1), pkg_delete(1), pkg_create(1). .SH BUGS -Haven't met them yet. +Sure. .SH AUTHORS Marc van Kempen (wmbfmk@urc.tue.nl) diff --git a/usr.sbin/pkg_manage/pkg_manage.c b/usr.sbin/pkg_manage/pkg_manage.c index 58cbed851b33..3a1a0b460a4c 100644 --- a/usr.sbin/pkg_manage/pkg_manage.c +++ b/usr.sbin/pkg_manage/pkg_manage.c @@ -1,6 +1,6 @@ /*************************************************************** * - * Program: pkg_manage + * Program: pkg_manage.c * Author: Marc van Kempen * Desc: Add, delete packages with the pkg_* binaries * Get info about installed packages @@ -8,7 +8,8 @@ * * 1. View installed packages * 2. Delete installed packages - * 3. Install packages + * 3. Preview package install + * 4. Install packages * * Copyright (c) 1995, Marc van Kempen * @@ -51,32 +52,21 @@ FreeInfo(void) * Desc: free the space allocated to p_inf */ { + int i; + free(p_inf.buf); free(p_inf.name); free(p_inf.comment); free(p_inf.description); p_inf.Nitems = 0; - FreeMnu(p_inf.mnu, 2*p_inf.Nitems); + for (i=0; i<2*p_inf.Nitems; i++) { + free(p_inf.mnu[i]); + } + free(p_inf.mnu); return; } /* FreeInfo() */ -void -FreeMnu(unsigned char **mnu, int n) -/* - * Desc: free mnu array - */ -{ - int i; - - for (i=0; i", fname); + dialog_textbox(title, tmp_file, LINES, COLS); + } + unlink(tmp_file); + free(fname); + free(tmp_file); + use_helpfile(PREVIEW_FS_HLP); + fname = dialog_fselect(".", "*.tgz"); + } + if (fname) free(fname); + use_helpfile(NULL); + use_helpline(NULL); + + return; +} /* preview_pkg() */ + void install_batch(void) /* @@ -209,9 +248,25 @@ install_batch(void) } names = (char **) malloc( sizeof(char *) * nf); + if (!names) { + fprintf(stderr, "install_batch(): Error mallocing space for names\n"); + exit(-1); + } comment = (char **) malloc( sizeof(char *) * nf ); + if (!comment) { + fprintf(stderr, "install_batch(): Error malloc'ing space for comment\n"); + exit(-1); + } desc = (char **) malloc( sizeof(char *) * nf ); + if (!desc) { + fprintf(stderr, "install_batch(): Error malloc'ing space for desc\n"); + exit(-1); + } sizes = (long *) malloc( sizeof(long) * nf ); + if (!sizes) { + fprintf(stderr, "install_batch(): Error malloc'ing space for desc\n"); + exit(-1); + } /* get_desc extracts the info from the file names[i] and puts the */ /* comment in comment[i] and the description in desc[i], space is */ @@ -227,7 +282,11 @@ install_batch(void) fprintf(stderr, "install_batch(): Error malloc'ing space for tmpfile\n"); exit(1); } - sprintf(tmp_dir, "/tmp/%s", tmp_file); + if (getenv("TMPDIR")) { + sprintf(tmp_dir, "%s/%s", getenv("TMP_DIR"), tmp_file); + } else { + sprintf(tmp_dir, "/tmp/%s", tmp_file); + } free(tmp_file); if (mkdir(tmp_dir, S_IRWXU)) { dialog_notify("Could not create temporary directory in /tmp, exiting"); @@ -242,6 +301,10 @@ install_batch(void) w = dupwin(curscr); + if (!w) { + fprintf(stderr, "install_batch(): Error malloc'ing new window\n"); + exit(-1); + } a = (int *) malloc( nf * sizeof(int) ); j = 0; for (i=0; iseld[i]) && (already_installed(names[i+p]))) { + if ((pkg_obj->seld[i]) && (already_installed(names[i]))) { /* popup a warning and remove the package from the */ /* packages that are going to be installed */ - sprintf(msg, " The following package is already installed:\n %s (%s)\n", + sprintf(msg, " The following package is already installed:\n\n %s (%s)\n\n", names[i], fnames[i]); strcat(msg, " This package will be skipped\n"); strcat(msg, " If you want to install it anyway, remove it first"); @@ -424,7 +487,7 @@ install_batch(void) for (i=0; iseld[i]) { dialog_gauge("Installing packages:", names[i], LINES/2-3, - COLS/2-30, 7, 60, (int) ((float) i/n*100)); + COLS/2-30, 7, 60, (int) ((float) (i+1)/n*100)); install_package(fnames[i]); } } @@ -462,8 +525,9 @@ run_menu(void) unsigned char *pkg_menu[] = { "1. View installed", "Overview of the installed packages", "2. Delete installed", "Delete an installed package", - "3. Install packages", "Install one or more packages", - "4. Quit", "Leave the program", + "3. Preview package", "Preview commands executed on installation", + "4. Install packages", "Install one or more packages", + "5. Quit", "Leave the program", }; quit_pkg = FALSE; @@ -471,7 +535,7 @@ run_menu(void) use_helpline("F1=help, use arrow-keys or digit to select option and press enter"); use_helpfile(MAIN_HLP); if (dialog_menu("Package Manager", "Choose one of the options", - LINES, COLS, 4, 4, pkg_menu, selection, &ch, &sc)) { + LINES, COLS, 5, 5, pkg_menu, selection, &ch, &sc)) { quit_pkg = TRUE; } else { sel = atoi(selection); @@ -482,10 +546,13 @@ run_menu(void) case 2: /* Delete installed package */ delete_installed(); break; - case 3: /* Install multiple packages */ + case 3: /* Preview install */ + preview_pkg(); + break; + case 4: /* Install multiple packages */ install_batch(); break; - case 4: /* Quit */ + case 5: /* Quit */ quit_pkg = TRUE; break; } diff --git a/usr.sbin/pkg_manage/pkg_view_inst.hlp b/usr.sbin/pkg_manage/pkg_view_inst.hlp new file mode 100644 index 000000000000..af01a662547b --- /dev/null +++ b/usr.sbin/pkg_manage/pkg_view_inst.hlp @@ -0,0 +1,8 @@ + + Choose a package from the list to see the description for the package. + + Move the cursor with the arrow-keys and PgUp and PgDn, press enter + when the cursor highlights the right package. + + When viewing the description use PgUp and PgDn and arrow-keys to move + through the text.