summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-02-15 20:47:56 +0000
committerache <ache@FreeBSD.org>1995-02-15 20:47:56 +0000
commit85e70fdb05873198e16b8dc9ed4449c556578083 (patch)
tree1b396881e2f02f7197086453f07809af4f167441 /usr.sbin
downloadFreeBSD-src-85e70fdb05873198e16b8dc9ed4449c556578083.zip
FreeBSD-src-85e70fdb05873198e16b8dc9ed4449c556578083.tar.gz
pkg_manage utility, using file selector
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_manage/Makefile22
-rw-r--r--usr.sbin/pkg_manage/pkg_del-inst.hlp18
-rw-r--r--usr.sbin/pkg_manage/pkg_install.hlp19
-rw-r--r--usr.sbin/pkg_manage/pkg_main.hlp8
-rw-r--r--usr.sbin/pkg_manage/pkg_manage.1163
-rw-r--r--usr.sbin/pkg_manage/pkg_manage.c542
-rw-r--r--usr.sbin/pkg_manage/pkg_manage.h62
-rw-r--r--usr.sbin/pkg_manage/pkg_preview.hlp12
-rw-r--r--usr.sbin/pkg_manage/pkg_view-inst.hlp12
9 files changed, 858 insertions, 0 deletions
diff --git a/usr.sbin/pkg_manage/Makefile b/usr.sbin/pkg_manage/Makefile
new file mode 100644
index 0000000..49691bf
--- /dev/null
+++ b/usr.sbin/pkg_manage/Makefile
@@ -0,0 +1,22 @@
+# $Id$
+
+PROG= pkg_manage
+LDADD+= -ldialog -lncurses -lmytinfo
+DPADD+= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO}
+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
+
+afterinstall:
+ cd ${.CURDIR}; \
+ for m in ${HELPS} ; do \
+ cmp -s $$m ${DESTDIR}${HELPDIR}/$$m || \
+ install -c -o ${BINOWN} -g ${BINGRP} -m 444 \
+ $$m ${DESTDIR}${HELPDIR} ; \
+ done
+
+.include <bsd.prog.mk>
+
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 0000000..5d0b208
--- /dev/null
+++ b/usr.sbin/pkg_manage/pkg_del-inst.hlp
@@ -0,0 +1,18 @@
+
+ *********************************************
+ * Help for '2. DELETE an installed package' *
+ *********************************************
+
+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_install.hlp b/usr.sbin/pkg_manage/pkg_install.hlp
new file mode 100644
index 0000000..6cb1afe
--- /dev/null
+++ b/usr.sbin/pkg_manage/pkg_install.hlp
@@ -0,0 +1,19 @@
+
+ ***********************************
+ * Help for '4. Install pkg files' *
+ ***********************************
+
+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.
+
+After having chosen a package, you can choose to either:
+
+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.
+
+(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
new file mode 100644
index 0000000..b0ac7db
--- /dev/null
+++ b/usr.sbin/pkg_manage/pkg_main.hlp
@@ -0,0 +1,8 @@
+
+ **********************
+ * Help for Main menu *
+ **********************
+
+Use the arrow-keys or a digit to select an option and press enter.
+
+
diff --git a/usr.sbin/pkg_manage/pkg_manage.1 b/usr.sbin/pkg_manage/pkg_manage.1
new file mode 100644
index 0000000..76f67fb
--- /dev/null
+++ b/usr.sbin/pkg_manage/pkg_manage.1
@@ -0,0 +1,163 @@
+.TH pkg_manage 1 "6 November 1994" "pkg_manage (1)" "FreeBSD"
+.SH NAME
+.B pkg_manage
+\- Package manager
+.SH SYNOPSIS
+.TP
+.B pkg_manage
+.SH DESCRIPTION
+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 anytime during the program will bring up
+online-help. (Pressing '?' will not work in character input fields)
+
+.SH NAVIGATING THE MENU
+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 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
+.B Enter
+(this selects the
+.B <EXIT>
+button) to return to the 'View installed Packages' menu.
+
+When done viewing packages move the cursor to the
+.B <Cancel>
+button with the right-arrow key (or left-arrow key)
+and press enter. This will return you to the main-menu.
+
+.TP
+.B 2. Delete installed
+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 (recommended).
+.B 2. Delete:
+Execute the commands to delete the package.
+.B 3. Cancel:
+Do
+.B NOT
+execute the commands to delete the package and return to the
+previous menu.
+
+Choose the
+.B <Cancel>
+button if you don't want to delete any packages
+and return to the main-menu.
+
+.TP
+.B 3. View pkg files
+Take a look at the description of not yet installed packages and see if you
+want it or not.
+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 fileselector to select a
+package.
+
+.TP
+.B 5. Quit
+Well just try this one if you get fed up fiddling with your packages.
+
+.SH USING THE FILESELECTOR
+
+Using the fileselector is really very simple.
+
+.\"
+.\" 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: |
+.\"| +------------------------------------------------------+ |
+.\"| | | |
+.\"| +------------------------------------------------------+ |
+.\"| +------+ +----------+ |
+.\"| | <Ok> | | <Cancel> | |
+.\"| +------+ +----------+ |
+.\"+----------------------------------------------------------+
+.\"
+Use the
+.B TAB
+key to move forwards from one input/display field to
+the next. If enabled in the termcap,
+.B Shift-TAB
+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
+will discard the changes and move to the next field.
+
+The
+.B "Filemask:"
+controls what kind of files will be displayed in the
+.B "Files:"
+list. The expression follows the same rules as your shell does, i.e.
+\'*.tgz' will only show files having names ending with '.tgz'.
+
+.B "Directory:"
+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 descent
+into that directory.
+
+Finally there three more fields: The
+.B Selection:
+, the
+.B <Ok>
+button and the
+.B <Cancel>
+button. The file chosen in the
+.B Files:
+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 <Ok>
+button and press enter. If you want to back out, move the cursor to the
+.B <Cancel>
+button and press enter.
+
+.SH SEE ALSO
+pkg_add(1), pkg_info(1), pkg_delete(1), pkg_create.
+
+.SH BUGS
+Haven't met them yet.
+
+.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
new file mode 100644
index 0000000..eb0bab0
--- /dev/null
+++ b/usr.sbin/pkg_manage/pkg_manage.c
@@ -0,0 +1,542 @@
+/***************************************************************
+ *
+ * Program: pkg_manage
+ * Author: Marc van Kempen
+ * Desc: Add, delete packages with the pkg_* binaries
+ * Get info about installed packages
+ * Review about to be installed packages
+ *
+ * 1. View installed packages
+ * 2. Delete installed packages
+ * 3. View package files
+ * 4. Install packages files.
+ *
+ * Installation and deletion of packages should be previewable
+ *
+ *
+ * Copyright (c) 1995, Marc van Kempen
+ *
+ * All rights reserved.
+ *
+ * This software may be used, modified, copied, distributed, and
+ * sold, in both source and binary form provided that the above
+ * copyright and these terms are retained, verbatim, as the first
+ * lines of this file. Under no circumstances is the author
+ * responsible for the proper functioning of this software, nor does
+ * the author assume any responsibility for damages incurred with
+ * its use.
+ *
+ ***************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+
+#include "pkg_manage.h"
+
+static PKG_info p_inf;
+static int got_info;
+
+/*
+ * Local prototypes
+ */
+
+void run_menu(void);
+void get_pkginfo(void);
+void FreeMnu(unsigned char **mnu, int n);
+void FreeInfo(void);
+
+/*
+ * Main
+ */
+
+void
+main(void)
+{
+ init_dialog();
+
+ get_pkginfo();
+ run_menu();
+
+ if (got_info)
+ FreeInfo();
+
+ clear();
+ dialog_update();
+ end_dialog();
+
+ return;
+} /* main() */
+
+void FreeInfo(void)
+{
+ free(p_inf.buf);
+ free(p_inf.name);
+ free(p_inf.comment);
+ free(p_inf.description);
+ FreeMnu(p_inf.mnu, 2*p_inf.Nitems);
+ got_info = FALSE;
+}
+
+void
+FreeMnu(unsigned char **mnu, int n)
+/*
+ * Desc: free mnu array
+ */
+{
+ int i;
+
+ for (i=0; i<n; i++) {
+ free(mnu[i]);
+ }
+ free(mnu);
+
+ return;
+} /* FreeMnu() */
+
+int
+file_exists(char *fname)
+/*
+ * Desc: check if the file <fname> exists (and is readable)
+ */
+{
+ FILE *f;
+
+ if (strlen(fname) == 0) return(FALSE); /* apparently opening an empty */
+ /* file for reading succeeds always */
+ f = fopen(fname, "r");
+ if (f) {
+ fclose(f);
+ return(TRUE);
+ } else {
+ return(FALSE);
+ }
+} /* file_exists() */
+
+
+void
+get_pkginfo(void)
+{
+ FILE *f;
+ char *p;
+ char prog[512];
+ struct stat sb;
+ int i, j, n, lsize;
+ int newline;
+ int state;
+ char *tmp_file;
+#define R_NAME 1
+#define R_COMMENT 2
+#define R_DESC 3
+
+ if (got_info)
+ FreeInfo();
+
+ dialog_msgbox("PKG INFO", "Reading info, please wait ...", 4, 35, FALSE);
+
+ tmp_file = tempnam(NULL, "pkg.");
+
+ sprintf(prog, "%s -a > %s", PKG_INFO, tmp_file);
+ system(prog);
+ dialog_clear_norefresh();
+
+ f = fopen(tmp_file, "r");
+ if (!f) {
+ dialog_notify("Could not open temporary file");
+ goto err1;
+ }
+
+ if (stat(tmp_file, &sb)) { /* stat file to get filesize */
+ dialog_notify("Could not stat temporary file");
+ goto err2;
+ }
+
+ if (sb.st_size == 0) {
+ dialog_notify("No packages info available");
+ goto err2;
+ }
+
+ /* Allocate a buffer with sufficient space to hold the entire file */
+ p_inf.buf = (char *) malloc( sb.st_size );
+ p_inf.N = sb.st_size;
+ if (fread(p_inf.buf, 1, p_inf.N, f) != p_inf.N) {
+ dialog_notify("Could not read from temporary file");
+ free(p_inf.buf);
+err2:
+ fclose(f);
+err1:
+ got_info = FALSE;
+ unlink(tmp_file);
+ free(tmp_file);
+ return;
+ }
+ fclose(f);
+ unlink(tmp_file);
+ free(tmp_file);
+ /* make one sweep through the buffer to determine the # of entries */
+ /* Look for "Information for" in the first column */
+
+ i = p_inf.N - strlen("Information for") - 1;
+ p = p_inf.buf;
+ if (strncmp(p_inf.buf, "Information for", 15) == 0) {
+ n = 1;
+ } else {
+ n = 0;
+ }
+ while (i--) {
+ if (*p == '\n') {
+ if (strncmp(p+1, "Information for", 15) == 0) {
+ n++;
+ }
+ }
+ p++;
+ }
+
+ /* malloc space for PKG_info */
+ p_inf.name = (char **) malloc( n * sizeof(char *) );
+ p_inf.comment = (char **) malloc( n * sizeof(char *) );
+ p_inf.description = (char **) malloc( n * sizeof(char *) );
+ p_inf.Nitems = n;
+
+ /* parse pkg_info output */
+ /* use a finite state automate to parse the file */
+
+ i = 0;
+ p = p_inf.buf;
+ newline = TRUE;
+ state = R_NAME;
+ while (*p) {
+ if (newline) {
+ switch(state) {
+ case R_NAME:
+ if (strncmp(p, "Information for", 15) == 0) {
+ if (p>p_inf.buf) *(p-1) = '\0';
+ p_inf.name[i] = (char *) p+16;
+ while (*p && *p != ':') p++;
+ if (*p) *p = '\0';
+ state = R_COMMENT;
+ }
+ break;
+ case R_COMMENT:
+ if (strncmp(p, "Comment:", 8) == 0) {
+ while (*p && *p != '\n') p++;
+ if (*p) p_inf.comment[i] = (char *) p+1;
+ p++;
+ while (*p && *p != '\n') p++;
+ if (*p) *p = '\0';
+ p++;
+ state = R_DESC;
+ }
+ break;
+ case R_DESC:
+ if (strncmp(p, "Description:", 12) == 0) {
+ while (*p && *p != '\n') p++;
+ if (*p) p_inf.description[i] = (char *) p+1;
+ state = R_NAME;
+ i++;
+ }
+ break;
+ }
+ newline = FALSE;
+ }
+ if (*p == '\n') newline = TRUE;
+ p++;
+ }
+
+ /* build menu entries */
+ p_inf.mnu = (unsigned char **) malloc( 2 * p_inf.Nitems * sizeof(char *) );
+
+ lsize = COLS-30;
+ j=0;
+ for (i=0; i<p_inf.Nitems; i++) {
+ /* tag */
+ p_inf.mnu[j] = (char *) malloc( lsize );
+ strncpy(p_inf.mnu[j], p_inf.name[i], lsize-1);
+ p_inf.mnu[j++][lsize-1] = 0;
+
+ /* description */
+ p_inf.mnu[j] = (char *) malloc( lsize );
+ strncpy(p_inf.mnu[j], p_inf.comment[i], lsize-1);
+ p_inf.mnu[j++][lsize-1] = 0;
+ }
+
+ got_info = TRUE;
+ return;
+} /* get_pkginfo() */
+
+int
+get_pkg_index(char *selection)
+/*
+ * desc: get the index i, for which p_inf.name[i] == selection
+ */
+{
+ int i, found = FALSE, index = -1;
+
+ if (got_info)
+ for (i=0; i<p_inf.Nitems && !found; i++) {
+ if (strcmp(selection, p_inf.name[i]) == 0) {
+ found = TRUE;
+ index = i;
+ }
+ }
+
+ return(index);
+} /* get_pkg_index() */
+
+void
+view_installed(void)
+/*
+ * Desc: View the installed packages
+ */
+{
+ int i, quit_view, sc=0, ch=0;
+ char selection[1024];
+
+ if (!got_info) {
+ use_helpfile(NULL);
+ use_helpline(NULL);
+ dialog_notify("No packages info available");
+ return;
+ }
+ use_helpfile(VIEW_INST_HLP);
+ quit_view = FALSE;
+ while (!quit_view) {
+ use_helpline("use arrow-keys or character to select option and press enter");
+ if (dialog_menu("View installed packages",
+ "Press enter to see the package descriptions",
+ LINES, COLS, LINES-5, p_inf.Nitems,
+ p_inf.mnu, selection, &ch, &sc )) {
+ quit_view = TRUE;
+ } else {
+ i = get_pkg_index(selection);
+ use_helpline("use PgUp and PgDn and arrow-keys to move throught the text");
+ dialog_mesgbox(p_inf.comment[i], p_inf.description[i], LINES, COLS);
+ }
+ }
+ use_helpfile(NULL);
+ use_helpline(NULL);
+
+ return;
+} /* view_installed() */
+
+void
+delete_installed(void)
+/*
+ * Desc: Delete an installed package
+ */
+{
+ unsigned char *mnu[] = {
+ "1. Simulate delete", "Display commands that are going to be executed",
+ "2. Delete", "Execute commands to delete the package",
+ "3. Cancel", "Do NOT delete the package"
+ };
+ char tmp[512], selection[512], *tmp_file;
+ int quit_view, quit_del;
+ int i, sel, ch=0, sc=0, ch0=0, sc0=0;
+
+ if (!got_info) {
+ use_helpfile(NULL);
+ use_helpline(NULL);
+ dialog_notify("No packages info available");
+ return;
+ }
+ quit_view = FALSE;
+ while (!quit_view) {
+ use_helpline("use arrow-keys or character to select option and press enter");
+ use_helpfile(DEL_INST_HLP);
+ if (dialog_menu("DELETE an installed package",
+ "Press enter to select a package",
+ LINES, COLS, LINES-5, p_inf.Nitems,
+ p_inf.mnu, selection, &ch, &sc)) {
+ quit_view = TRUE;
+ } else {
+ quit_del = FALSE;
+ i = get_pkg_index(selection);
+ while (!quit_del) {
+ sprintf(tmp, "Delete <%s>", p_inf.name[i]);
+ use_helpline("use arrow-keys or digit to select option and press enter");
+ if (dialog_menu("Delete a package", tmp, 10, COLS-6,
+ 3, 3, mnu, selection, &ch0, &sc0)) {
+ quit_del = TRUE;
+ } else {
+ sel = atoi(selection);
+ switch(sel) {
+ case 1:
+ tmp_file = tempnam(NULL, "pkg.");
+ sprintf(tmp, "%s -n %s > %s",
+ PKG_DELETE, p_inf.name[i], tmp_file);
+ system(tmp);
+ dialog_textbox("Package deletion commands",
+ tmp_file, LINES, COLS);
+ unlink(tmp_file);
+ free(tmp_file);
+ break;
+ case 2:
+ sprintf(tmp, "%s %s", PKG_DELETE, p_inf.name[i]);
+ system(tmp);
+ get_pkginfo();
+ quit_del = TRUE;
+ break;
+ case 3:
+ quit_del = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ }
+ use_helpfile(NULL);
+ use_helpline(NULL);
+
+ return;
+} /* delete_installed() */
+
+void
+preview_pkg(void)
+/*
+ * Desc: View the package description and comment before installation
+ */
+{
+ char *fname;
+ char *tmp_file;
+ char prog[512], title[512];
+
+ use_helpfile(PREVIEW_HLP);
+ fname = dialog_fselect(".", "*.tgz");
+ while (fname) {
+ use_helpfile(PREVIEW_HLP);
+ use_helpline("use PgUp and PgDn and arrow-keys to move through the text");
+ tmp_file = tempnam(NULL, "pkg.");
+ sprintf(prog, "%s zxOf %s +COMMENT +DESC > %s", TAR, fname, tmp_file);
+ system(prog);
+ sprintf(title, "Preview package <%s>", fname);
+ dialog_textbox(title, tmp_file, LINES, COLS);
+ unlink(tmp_file);
+ free(fname);
+ free(tmp_file);
+ fname = dialog_fselect(".", "*.tgz");
+ }
+ if (fname) free(fname);
+ use_helpfile(NULL);
+ use_helpline(NULL);
+
+ return;
+} /* preview_pkg() */
+
+void
+install_new(void)
+/*
+ * Desc: Install a new package
+ */
+{
+ char *fname;
+ char *tmp_file;
+ char tmp[512], selection[40];
+ unsigned char *mnu[] = {
+ "1. Simulate install", "Display commands that are going to be executed",
+ "2. Install", "Execute commands to install the package",
+ "3. Cancel", "Do NOT install the package"
+ };
+ int sel, quit_inst, ch=0, sc=0;
+
+ use_helpfile(INSTALL_HLP);
+ fname = dialog_fselect(".", "*.tgz");
+ if (!fname) {
+ quit_inst = TRUE;
+ } else {
+ quit_inst = FALSE;
+ }
+ while (!quit_inst) {
+ use_helpfile(INSTALL_HLP);
+ use_helpline("use arrow-keys or digit to select option and press enter");
+ sprintf(tmp, "Install package <%s>", fname);
+ if (dialog_menu("Install a package", tmp, 10, COLS-5,
+ 3, 3, mnu, selection, &ch, &sc)) {
+ quit_inst = TRUE;
+ } else {
+ sel = atoi(selection);
+ switch(sel) {
+ case 1:
+ tmp_file = tempnam(NULL, "*.pkg");
+ sprintf(tmp, "%s -n %s 2>&1 | cat > %s", PKG_ADD, fname, tmp_file);
+ system(tmp);
+ dialog_textbox("Package installation commands",
+ tmp_file, LINES, COLS);
+ unlink(tmp_file);
+ free(tmp_file);
+ break;
+ case 2:
+ sprintf(tmp, "%s %s", PKG_ADD, fname);
+ system(tmp);
+ get_pkginfo();
+ quit_inst = TRUE;
+ break;
+ case 3:
+ quit_inst = TRUE;
+ break;
+ }
+ }
+ }
+ if (fname) free(fname);
+ use_helpfile(NULL);
+ use_helpline(NULL);
+
+ return;
+} /* install_new() */
+
+void
+run_menu(void)
+/*
+ * Desc: display/choose from menu
+ */
+{
+ int quit_pkg, sel, ch=0, sc=0;
+ char selection[30];
+ unsigned char *pkg_menu[] = {
+ "1. View installed", "Overview of the installed packages",
+ "2. Delete installed", "Delete an installed package",
+ "3. View pkg files", "Preview about to be installed packages",
+ "4. Install pkg files", "Install new packages",
+ "5. Quit", "Leave the program",
+ };
+
+ quit_pkg = FALSE;
+ while (!quit_pkg) {
+ use_helpline("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, 5, 5, pkg_menu, selection, &ch, &sc)) {
+ sel = 0;
+ quit_pkg = TRUE;
+ } else {
+ sel = atoi(selection);
+ }
+
+ switch(sel) {
+ case 0: /* Quit */
+ break;
+ case 1: /* View installed packages */
+ view_installed();
+ break;
+ case 2: /* Delete installed package */
+ delete_installed();
+ break;
+ case 3: /* Preview new package file */
+ preview_pkg();
+ break;
+ case 4: /* Install new package */
+ install_new();
+ break;
+ case 5: /* Quit */
+ quit_pkg = TRUE;
+ break;
+ }
+ }
+
+ return;
+} /* run_menu() */
+
+
diff --git a/usr.sbin/pkg_manage/pkg_manage.h b/usr.sbin/pkg_manage/pkg_manage.h
new file mode 100644
index 0000000..da5bdfa
--- /dev/null
+++ b/usr.sbin/pkg_manage/pkg_manage.h
@@ -0,0 +1,62 @@
+/*
+ * include file for pkg.c
+ *
+ *
+ * Copyright (c) 1995, Marc van Kempen
+ *
+ * All rights reserved.
+ *
+ * This software may be used, modified, copied, distributed, and
+ * sold, in both source and binary form provided that the above
+ * copyright and these terms are retained, verbatim, as the first
+ * lines of this file. Under no circumstances is the author
+ * responsible for the proper functioning of this software, nor does
+ * the author assume any responsibility for damages incurred with
+ * its use.
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/dirent.h>
+#include <ncurses.h>
+#include <dialog.h>
+
+#ifndef TRUE
+#define TRUE (1)
+#endif
+#ifndef FALSE
+#define FALSE (0)
+#endif
+
+typedef struct {
+ int N; /* size of buf in bytes */
+ int Nitems; /* # of packages */
+ char *buf; /* buffer to hold package info */
+ char **name; /* array of char pointer to locations in buf */
+ char **comment; /* idem */
+ char **description; /* idem */
+ unsigned char **mnu; /* pointers to be used with dialog_menu() */
+} PKG_info;
+
+typedef struct DirList { /* structure to hold the directory entries */
+ char filename[MAXNAMLEN]; /* together with the stat-info per file */
+ struct stat filestatus; /* filename, or the name to which it points */
+ int link; /* is it a link ? */
+ char *linkname; /* the name of the file the link points to */
+} DirList;
+
+#define PKG_DELETE "/usr/sbin/pkg_delete"
+#define PKG_INFO "/usr/sbin/pkg_info"
+#define PKG_ADD "/usr/sbin/pkg_add"
+#define TAR "/usr/bin/tar"
+
+/* HELP_PATH must have a trailing '/' */
+#ifndef HELP_PATH
+#define HELP_PATH "/home/marc/src/pkg_manage/"
+#endif
+#define VIEW_INST_HLP HELP_PATH##"pkg_view-inst.hlp"
+#define DEL_INST_HLP HELP_PATH##"pkg_del-inst.hlp"
+#define PREVIEW_HLP HELP_PATH##"pkg_preview.hlp"
+#define INSTALL_HLP HELP_PATH##"pkg_install.hlp"
+#define MAIN_HLP HELP_PATH##"pkg_main.hlp"
diff --git a/usr.sbin/pkg_manage/pkg_preview.hlp b/usr.sbin/pkg_manage/pkg_preview.hlp
new file mode 100644
index 0000000..42a6711
--- /dev/null
+++ b/usr.sbin/pkg_manage/pkg_preview.hlp
@@ -0,0 +1,12 @@
+
+ ********************************
+ * Help for '3. View pkg files' *
+ ********************************
+
+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.
+
+After having chosen a package use the arrow-keys and PgUp and PgDn
+to move through the text.
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 0000000..c74d400
--- /dev/null
+++ b/usr.sbin/pkg_manage/pkg_view-inst.hlp
@@ -0,0 +1,12 @@
+
+ ********************************
+ * Help for '1. View installed' *
+ ********************************
+
+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.
OpenPOWER on IntegriCloud