1995-10-15 12:41:09 +00:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last program in the `sysinstall' line - the next
|
|
|
|
* generation being essentially a complete rewrite.
|
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Jordan Hubbard. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
|
|
|
* point in the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
2004-01-02 09:19:13 +00:00
|
|
|
* $FreeBSD$
|
1995-10-15 12:41:09 +00:00
|
|
|
*/
|
|
|
|
|
1995-10-16 09:25:22 +00:00
|
|
|
#include <fcntl.h>
|
1995-10-07 11:55:37 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ncurses.h>
|
|
|
|
#include <dialog.h>
|
|
|
|
#include "sysinstall.h"
|
|
|
|
|
|
|
|
/* Macros and magic values */
|
1996-06-14 14:34:03 +00:00
|
|
|
#define MAX_MENU 12
|
1996-08-01 12:02:26 +00:00
|
|
|
#define _MAX_DESC 55
|
1995-10-07 11:55:37 +00:00
|
|
|
|
1999-02-02 15:57:14 +00:00
|
|
|
/* A structure holding the root, top and plist pointer at once */
|
|
|
|
struct ListPtrs
|
|
|
|
{
|
|
|
|
PkgNodePtr root; /* root of tree */
|
|
|
|
PkgNodePtr top; /* part of tree we handle */
|
|
|
|
PkgNodePtr plist; /* list of selected packages */
|
|
|
|
};
|
|
|
|
typedef struct ListPtrs* ListPtrsPtr;
|
|
|
|
|
|
|
|
static void index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie);
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1999-05-12 09:02:37 +00:00
|
|
|
/* Shared between index_initialize() and the various clients of it */
|
|
|
|
PkgNode Top, Plist;
|
|
|
|
|
1995-10-07 11:55:37 +00:00
|
|
|
/* Smarter strdup */
|
|
|
|
inline char *
|
|
|
|
_strdup(char *ptr)
|
|
|
|
{
|
1995-10-20 20:10:49 +00:00
|
|
|
return ptr ? strdup(ptr) : NULL;
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *descrs[] = {
|
1997-03-25 03:12:59 +00:00
|
|
|
"Package Selection", "To mark a package, move to it and press SPACE. If the package is\n"
|
|
|
|
"already marked, it will be unmarked or deleted (if installed).\n"
|
1999-05-15 14:34:22 +00:00
|
|
|
"Items marked with a `D' are dependencies which will be auto-loaded.\n"
|
1997-03-25 03:12:59 +00:00
|
|
|
"To search for a package by name, press ESC. To select a category,\n"
|
|
|
|
"press RETURN. NOTE: The All category selection creates a very large\n"
|
1999-05-14 12:15:34 +00:00
|
|
|
"submenu! If you select it, please be patient while it comes up.",
|
1995-10-14 19:13:35 +00:00
|
|
|
"Package Targets", "These are the packages you've selected for extraction.\n\n"
|
1995-11-12 20:47:15 +00:00
|
|
|
"If you're sure of these choices, select OK.\n"
|
|
|
|
"If not, select Cancel to go back to the package selection menu.\n",
|
1995-10-07 11:55:37 +00:00
|
|
|
"All", "All available packages in all categories.",
|
2002-11-18 09:33:56 +00:00
|
|
|
"accessibility", "Ports to help disabled users.",
|
1999-01-11 12:45:18 +00:00
|
|
|
"afterstep", "Ports to support the AfterStep window manager.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"applications", "User application software.",
|
2004-11-03 18:26:06 +00:00
|
|
|
"arabic", "Ported software for Arab countries.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"archivers", "Utilities for archiving and unarchiving data.",
|
2000-02-10 01:44:37 +00:00
|
|
|
"astro", "Applications related to astronomy.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"audio", "Audio utilities - most require a supported sound card.",
|
|
|
|
"benchmarks", "Utilities for measuring system performance.",
|
2000-02-10 01:44:37 +00:00
|
|
|
"biology", "Software related to biology.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"cad", "Computer Aided Design utilities.",
|
1996-12-31 14:37:06 +00:00
|
|
|
"chinese", "Ported software for the Chinese market.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"comms", "Communications utilities.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"converters", "Format conversion utilities.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"databases", "Database software.",
|
1998-10-13 07:31:37 +00:00
|
|
|
"deskutils", "Various Desktop utilities.",
|
2000-02-10 01:44:37 +00:00
|
|
|
"devel", "Software development utilities and libraries.",
|
2004-11-03 18:26:06 +00:00
|
|
|
"dns", "Domain Name Service tools.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"documentation", "Document preparation utilities.",
|
|
|
|
"editors", "Common text editors.",
|
1998-12-22 12:31:26 +00:00
|
|
|
"elisp", "Things related to Emacs Lisp.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"emulators", "Utilities for emulating other OS types.",
|
2002-11-18 09:33:56 +00:00
|
|
|
"finance", "Monetary, financial and related applications.",
|
2000-09-22 06:32:55 +00:00
|
|
|
"french", "Ported software for French countries.",
|
1999-11-08 16:23:34 +00:00
|
|
|
"ftp", "FTP client and server utilities.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"games", "Various and sundry amusements.",
|
1998-03-23 05:59:18 +00:00
|
|
|
"german", "Ported software for Germanic countries.",
|
1999-02-15 04:57:07 +00:00
|
|
|
"gnome", "Components of the Gnome Desktop environment.",
|
2000-02-10 01:44:37 +00:00
|
|
|
"graphics", "Graphics libraries and utilities.",
|
2002-11-18 09:33:56 +00:00
|
|
|
"haskell", "Software related to the Haskell language.",
|
2000-07-31 00:16:28 +00:00
|
|
|
"hebrew", "Ported software for Hebrew language.",
|
2002-11-18 09:33:56 +00:00
|
|
|
"hungarian", "Ported software for the Hungarian market.",
|
|
|
|
"ipv6", "IPv6 related software.",
|
1999-09-02 00:51:16 +00:00
|
|
|
"irc", "Internet Relay Chat utilities.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"japanese", "Ported software for the Japanese market.",
|
1999-09-02 00:51:16 +00:00
|
|
|
"java", "Java language support.",
|
1998-03-24 09:51:58 +00:00
|
|
|
"kde", "Software for the K Desktop Environment.",
|
1997-03-25 03:12:59 +00:00
|
|
|
"korean", "Ported software for the Korean market.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"lang", "Computer languages.",
|
|
|
|
"languages", "Computer languages.",
|
|
|
|
"libraries", "Software development libraries.",
|
2000-08-16 18:44:40 +00:00
|
|
|
"linux", "Linux programs that can be run under binary compatibility.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"mail", "Electronic mail packages and utilities.",
|
|
|
|
"math", "Mathematical computation software.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"mbone", "Applications and utilities for the MBONE.",
|
1996-03-18 15:28:10 +00:00
|
|
|
"misc", "Miscellaneous utilities.",
|
2002-11-18 09:33:56 +00:00
|
|
|
"multimedia", "Multimedia software.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"net", "Networking utilities.",
|
2004-11-03 18:26:06 +00:00
|
|
|
"net-mgmt", "Network Management",
|
1995-10-07 11:55:37 +00:00
|
|
|
"news", "USENET News support software.",
|
|
|
|
"numeric", "Mathematical computation software.",
|
1998-09-23 12:13:51 +00:00
|
|
|
"offix", "An office automation suite of sorts.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"orphans", "Packages without a home elsewhere.",
|
2002-11-18 09:33:56 +00:00
|
|
|
"palm", "Software support for the Palm(tm) series.",
|
|
|
|
"parallel", "Applications dealing with parallelism in computing.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"perl5", "Utilities/modules for the PERL5 language.",
|
2001-04-22 16:55:11 +00:00
|
|
|
"picobsd", "Ports to support PicoBSD.",
|
2000-02-10 01:44:37 +00:00
|
|
|
"pilot", "Software support for the 3Com Palm Pilot(tm) series.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"plan9", "Software from the Plan9 operating system.",
|
2004-11-03 18:26:06 +00:00
|
|
|
"polish", "Ported software for the Polish market.",
|
2002-11-18 09:33:56 +00:00
|
|
|
"portuguese", "Ported software for the Portuguese market.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"print", "Utilities for dealing with printing.",
|
|
|
|
"printing", "Utilities for dealing with printing.",
|
|
|
|
"programming", "Software development utilities and libraries.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"python", "Software related to the Python language.",
|
2000-08-16 17:44:35 +00:00
|
|
|
"ruby", "Software related to the Ruby language.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"russian", "Ported software for the Russian market.",
|
2001-03-24 21:52:25 +00:00
|
|
|
"science", "Scientific software.",
|
2004-11-03 18:26:06 +00:00
|
|
|
"scheme", "Software related to the Scheme language.",
|
1995-10-07 11:55:37 +00:00
|
|
|
"security", "System security software.",
|
|
|
|
"shells", "Various shells (tcsh, bash, etc).",
|
|
|
|
"sysutils", "Various system utilities.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"tcl75", "TCL v7.5 and packages that depend on it.",
|
|
|
|
"tcl76", "TCL v7.6 and packages that depend on it.",
|
|
|
|
"tcl80", "TCL v8.0 and packages that depend on it.",
|
2002-09-09 17:53:41 +00:00
|
|
|
"tcl81", "TCL v8.1 and packages that depend on it.",
|
1999-11-08 16:23:34 +00:00
|
|
|
"tcl82", "TCL v8.2 and packages that depend on it.",
|
2000-08-16 18:44:40 +00:00
|
|
|
"tcl83", "TCL v8.3 and packages that depend on it.",
|
2004-11-03 18:26:06 +00:00
|
|
|
"tcl84", "TCL v8.4 and packages that depend on it.",
|
2000-02-10 01:44:37 +00:00
|
|
|
"textproc", "Text processing/search utilities.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"tk41", "Tk4.1 and packages that depend on it.",
|
|
|
|
"tk42", "Tk4.2 and packages that depend on it.",
|
|
|
|
"tk80", "Tk8.0 and packages that depend on it.",
|
|
|
|
"tk81", "Tk8.1 and packages that depend on it.",
|
1999-11-08 16:23:34 +00:00
|
|
|
"tk82", "Tk8.2 and packages that depend on it.",
|
2000-08-16 18:44:40 +00:00
|
|
|
"tk83", "Tk8.3 and packages that depend on it.",
|
1999-11-08 16:23:34 +00:00
|
|
|
"tkstep80", "tkstep wm and packages that depend on it.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"troff", "TROFF text formatting utilities.",
|
2001-03-24 21:52:25 +00:00
|
|
|
"ukrainian", "Ported software for the Ukrainian market.",
|
1996-12-31 14:37:06 +00:00
|
|
|
"vietnamese", "Ported software for the Vietnamese market.",
|
1999-01-11 12:45:18 +00:00
|
|
|
"windowmaker", "Ports to support the WindowMaker window manager.",
|
1997-05-05 08:38:12 +00:00
|
|
|
"www", "WEB utilities (browers, HTTP servers, etc).",
|
1995-10-07 11:55:37 +00:00
|
|
|
"x11", "X Window System based utilities.",
|
1998-10-13 07:31:37 +00:00
|
|
|
"x11-clocks", "X Window System based clocks.",
|
|
|
|
"x11-fm", "X Window System based file managers.",
|
1999-01-11 12:45:18 +00:00
|
|
|
"x11-fonts", "X Window System fonts and font utilities.",
|
1999-09-02 00:51:16 +00:00
|
|
|
"x11-servers", "X Window System servers.",
|
2004-11-03 18:26:06 +00:00
|
|
|
"x11-themes", "X Window System themes.",
|
1998-10-13 07:31:37 +00:00
|
|
|
"x11-toolkits", "X Window System based development toolkits.",
|
1998-12-13 23:37:33 +00:00
|
|
|
"x11-wm", "X Window System window managers.",
|
2000-09-22 06:53:44 +00:00
|
|
|
"zope", "Software related to the Zope platform.",
|
1995-10-07 11:55:37 +00:00
|
|
|
NULL, NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *
|
|
|
|
fetch_desc(char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; descrs[i]; i += 2) {
|
|
|
|
if (!strcmp(descrs[i], name))
|
|
|
|
return descrs[i + 1];
|
|
|
|
}
|
|
|
|
return "No description provided";
|
|
|
|
}
|
|
|
|
|
|
|
|
static PkgNodePtr
|
|
|
|
new_pkg_node(char *name, node_type type)
|
|
|
|
{
|
1995-10-20 07:02:53 +00:00
|
|
|
PkgNodePtr tmp = safe_malloc(sizeof(PkgNode));
|
1995-10-07 11:55:37 +00:00
|
|
|
|
|
|
|
tmp->name = _strdup(name);
|
|
|
|
tmp->type = type;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
1996-06-25 04:28:23 +00:00
|
|
|
static char *
|
|
|
|
strip(char *buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; buf[i]; i++)
|
|
|
|
if (buf[i] == '\t' || buf[i] == '\n')
|
|
|
|
buf[i] = ' ';
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
1995-10-07 11:55:37 +00:00
|
|
|
static IndexEntryPtr
|
2002-04-13 13:00:42 +00:00
|
|
|
new_index(char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *deps, int volume)
|
1995-10-07 11:55:37 +00:00
|
|
|
{
|
1995-10-20 07:02:53 +00:00
|
|
|
IndexEntryPtr tmp = safe_malloc(sizeof(IndexEntry));
|
1995-10-07 11:55:37 +00:00
|
|
|
|
|
|
|
tmp->name = _strdup(name);
|
|
|
|
tmp->path = _strdup(pathto);
|
|
|
|
tmp->prefix = _strdup(prefix);
|
|
|
|
tmp->comment = _strdup(comment);
|
1996-06-25 04:28:23 +00:00
|
|
|
tmp->descrfile = strip(_strdup(descr));
|
1995-10-07 11:55:37 +00:00
|
|
|
tmp->maintainer = _strdup(maint);
|
1996-03-18 15:28:10 +00:00
|
|
|
tmp->deps = _strdup(deps);
|
1999-02-02 15:57:14 +00:00
|
|
|
tmp->depc = 0;
|
2004-01-02 09:19:13 +00:00
|
|
|
tmp->installed = package_installed(name);
|
2002-04-13 13:00:42 +00:00
|
|
|
tmp->volume = volume;
|
1995-10-07 11:55:37 +00:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
index_register(PkgNodePtr top, char *where, IndexEntryPtr ptr)
|
|
|
|
{
|
|
|
|
PkgNodePtr p, q;
|
|
|
|
|
1995-10-20 20:10:49 +00:00
|
|
|
for (q = NULL, p = top->kids; p; p = p->next) {
|
1995-10-07 11:55:37 +00:00
|
|
|
if (!strcmp(p->name, where)) {
|
|
|
|
q = p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!p) {
|
|
|
|
/* Add new category */
|
|
|
|
q = new_pkg_node(where, PLACE);
|
|
|
|
q->desc = fetch_desc(where);
|
|
|
|
q->next = top->kids;
|
|
|
|
top->kids = q;
|
|
|
|
}
|
|
|
|
p = new_pkg_node(ptr->name, PACKAGE);
|
1995-10-16 07:31:11 +00:00
|
|
|
p->desc = ptr->comment;
|
1995-10-07 11:55:37 +00:00
|
|
|
p->data = ptr;
|
|
|
|
p->next = q->kids;
|
|
|
|
q->kids = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
copy_to_sep(char *to, char *from, int sep)
|
|
|
|
{
|
|
|
|
char *tok;
|
|
|
|
|
|
|
|
tok = strchr(from, sep);
|
|
|
|
if (!tok) {
|
|
|
|
*to = '\0';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*tok = '\0';
|
|
|
|
strcpy(to, from);
|
|
|
|
return tok + 1 - from;
|
|
|
|
}
|
|
|
|
|
1995-10-16 09:25:22 +00:00
|
|
|
static int
|
1996-12-11 09:35:06 +00:00
|
|
|
readline(FILE *fp, char *buf, int max)
|
1995-10-16 09:25:22 +00:00
|
|
|
{
|
|
|
|
int rv, i = 0;
|
|
|
|
char ch;
|
|
|
|
|
1996-12-11 09:35:06 +00:00
|
|
|
while ((rv = fread(&ch, 1, 1, fp)) == 1 && ch != '\n' && i < max)
|
1995-10-16 09:25:22 +00:00
|
|
|
buf[i++] = ch;
|
|
|
|
if (i < max)
|
|
|
|
buf[i] = '\0';
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2002-04-13 13:00:42 +00:00
|
|
|
/*
|
|
|
|
* XXX - this function should do error checking, and skip corrupted INDEX
|
|
|
|
* lines without a set number of '|' delimited fields.
|
|
|
|
*/
|
|
|
|
|
1995-10-07 11:55:37 +00:00
|
|
|
int
|
2002-04-13 13:00:42 +00:00
|
|
|
index_parse(FILE *fp, char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *cats, char *rdeps, int *volume)
|
1995-10-07 11:55:37 +00:00
|
|
|
{
|
2003-02-27 20:43:52 +00:00
|
|
|
char line[10240 + 2048 * 7];
|
2001-06-22 21:47:55 +00:00
|
|
|
char junk[2048];
|
2002-04-13 13:00:42 +00:00
|
|
|
char volstr[2048];
|
1995-10-07 11:55:37 +00:00
|
|
|
char *cp;
|
1995-10-16 09:25:22 +00:00
|
|
|
int i;
|
1995-10-07 11:55:37 +00:00
|
|
|
|
2000-02-13 21:11:28 +00:00
|
|
|
i = readline(fp, line, sizeof line);
|
1995-10-16 09:25:22 +00:00
|
|
|
if (i <= 0)
|
|
|
|
return EOF;
|
1995-10-07 11:55:37 +00:00
|
|
|
cp = line;
|
|
|
|
cp += copy_to_sep(name, cp, '|');
|
|
|
|
cp += copy_to_sep(pathto, cp, '|');
|
|
|
|
cp += copy_to_sep(prefix, cp, '|');
|
|
|
|
cp += copy_to_sep(comment, cp, '|');
|
|
|
|
cp += copy_to_sep(descr, cp, '|');
|
|
|
|
cp += copy_to_sep(maint, cp, '|');
|
|
|
|
cp += copy_to_sep(cats, cp, '|');
|
1997-03-29 06:44:57 +00:00
|
|
|
cp += copy_to_sep(junk, cp, '|'); /* build deps - not used */
|
2002-04-13 13:00:42 +00:00
|
|
|
cp += copy_to_sep(rdeps, cp, '|');
|
|
|
|
if (index(cp, '|'))
|
|
|
|
cp += copy_to_sep(junk, cp, '|'); /* url - not used */
|
|
|
|
else {
|
|
|
|
strncpy(junk, cp, 1023);
|
|
|
|
*volume = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
1997-04-05 07:08:14 +00:00
|
|
|
if (index(cp, '|'))
|
2002-04-13 13:00:42 +00:00
|
|
|
cp += copy_to_sep(volstr, cp, '|'); /* media volume */
|
|
|
|
else {
|
|
|
|
strncpy(volstr, cp, 1023);
|
|
|
|
}
|
|
|
|
*volume = atoi(volstr);
|
1995-10-07 11:55:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-12-11 09:35:06 +00:00
|
|
|
index_read(FILE *fp, PkgNodePtr papa)
|
1995-10-07 11:55:37 +00:00
|
|
|
{
|
2003-02-27 20:43:52 +00:00
|
|
|
char name[127], pathto[255], prefix[255], comment[255], descr[127], maint[127], cats[511], deps[2048 * 8];
|
2002-04-13 13:00:42 +00:00
|
|
|
int volume;
|
1999-02-02 15:57:14 +00:00
|
|
|
PkgNodePtr i;
|
1995-10-07 11:55:37 +00:00
|
|
|
|
2002-04-13 13:00:42 +00:00
|
|
|
while (index_parse(fp, name, pathto, prefix, comment, descr, maint, cats, deps, &volume) != EOF) {
|
2000-02-13 21:11:28 +00:00
|
|
|
char *cp, *cp2, tmp[1024];
|
1995-10-07 11:55:37 +00:00
|
|
|
IndexEntryPtr idx;
|
|
|
|
|
2002-04-13 13:00:42 +00:00
|
|
|
idx = new_index(name, pathto, prefix, comment, descr, maint, deps, volume);
|
1995-10-07 11:55:37 +00:00
|
|
|
/* For now, we only add things to menus if they're in categories. Keywords are ignored */
|
1995-10-20 20:10:49 +00:00
|
|
|
for (cp = strcpy(tmp, cats); (cp2 = strchr(cp, ' ')) != NULL; cp = cp2 + 1) {
|
1995-10-07 11:55:37 +00:00
|
|
|
*cp2 = '\0';
|
|
|
|
index_register(papa, cp, idx);
|
|
|
|
}
|
|
|
|
index_register(papa, cp, idx);
|
|
|
|
|
|
|
|
/* Add to special "All" category */
|
|
|
|
index_register(papa, "All", idx);
|
|
|
|
}
|
1999-02-02 15:57:14 +00:00
|
|
|
|
|
|
|
/* Adjust dependency counts */
|
|
|
|
for (i = papa->kids; i != NULL; i = i->next)
|
|
|
|
if (strcmp(i->name, "All") == 0)
|
|
|
|
break;
|
|
|
|
for (i = i->kids; i != NULL; i = i->next)
|
|
|
|
if (((IndexEntryPtr)i->data)->installed)
|
|
|
|
index_recorddeps(TRUE, papa, i->data);
|
|
|
|
|
1995-10-07 11:55:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
index_init(PkgNodePtr top, PkgNodePtr plist)
|
|
|
|
{
|
1996-03-21 09:30:18 +00:00
|
|
|
if (top) {
|
|
|
|
top->next = top->kids = NULL;
|
|
|
|
top->name = "Package Selection";
|
|
|
|
top->type = PLACE;
|
|
|
|
top->desc = fetch_desc(top->name);
|
|
|
|
top->data = NULL;
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
1996-03-21 09:30:18 +00:00
|
|
|
if (plist) {
|
|
|
|
plist->next = plist->kids = NULL;
|
|
|
|
plist->name = "Package Targets";
|
|
|
|
plist->type = PLACE;
|
|
|
|
plist->desc = fetch_desc(plist->name);
|
|
|
|
plist->data = NULL;
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
|
|
|
}
|
1996-03-21 09:30:18 +00:00
|
|
|
|
1995-10-07 11:55:37 +00:00
|
|
|
void
|
|
|
|
index_print(PkgNodePtr top, int level)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
while (top) {
|
|
|
|
for (i = 0; i < level; i++) putchar('\t');
|
|
|
|
printf("name [%s]: %s\n", top->type == PLACE ? "place" : "package", top->name);
|
|
|
|
for (i = 0; i < level; i++) putchar('\t');
|
|
|
|
printf("desc: %s\n", top->desc);
|
|
|
|
if (top->kids)
|
|
|
|
index_print(top->kids, level + 1);
|
|
|
|
top = top->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Swap one node for another */
|
|
|
|
static void
|
|
|
|
swap_nodes(PkgNodePtr a, PkgNodePtr b)
|
|
|
|
{
|
|
|
|
PkgNode tmp;
|
|
|
|
|
|
|
|
tmp = *a;
|
|
|
|
*a = *b;
|
|
|
|
a->next = tmp.next;
|
|
|
|
tmp.next = b->next;
|
|
|
|
*b = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use a disgustingly simplistic bubble sort to put our lists in order */
|
|
|
|
void
|
|
|
|
index_sort(PkgNodePtr top)
|
|
|
|
{
|
|
|
|
PkgNodePtr p, q;
|
|
|
|
|
|
|
|
/* Sort everything at the top level */
|
1995-10-20 20:10:49 +00:00
|
|
|
for (p = top->kids; p; p = p->next) {
|
|
|
|
for (q = top->kids; q; q = q->next) {
|
1995-10-07 11:55:37 +00:00
|
|
|
if (q->next && strcmp(q->name, q->next->name) > 0)
|
|
|
|
swap_nodes(q, q->next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-15 14:34:22 +00:00
|
|
|
/* Now sub-sort everything n levels down */
|
1995-10-20 20:10:49 +00:00
|
|
|
for (p = top->kids; p; p = p->next) {
|
1995-10-07 11:55:37 +00:00
|
|
|
if (p->kids)
|
|
|
|
index_sort(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-05-16 11:47:46 +00:00
|
|
|
/* Delete an entry out of the list it's in (only the plist, at present) */
|
1995-10-07 11:55:37 +00:00
|
|
|
void
|
|
|
|
index_delete(PkgNodePtr n)
|
|
|
|
{
|
1996-05-16 11:47:46 +00:00
|
|
|
if (n->next) {
|
|
|
|
PkgNodePtr p = n->next;
|
|
|
|
|
1995-10-07 11:55:37 +00:00
|
|
|
*n = *(n->next);
|
1996-05-16 11:47:46 +00:00
|
|
|
safe_free(p);
|
|
|
|
}
|
1995-10-07 11:55:37 +00:00
|
|
|
else /* Kludgy end sentinal */
|
|
|
|
n->name = NULL;
|
|
|
|
}
|
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
/*
|
|
|
|
* Search for a given node by name, returning the category in if
|
|
|
|
* tp is non-NULL.
|
|
|
|
*/
|
1995-10-07 11:55:37 +00:00
|
|
|
PkgNodePtr
|
|
|
|
index_search(PkgNodePtr top, char *str, PkgNodePtr *tp)
|
|
|
|
{
|
|
|
|
PkgNodePtr p, sp;
|
|
|
|
|
|
|
|
for (p = top->kids; p && p->name; p = p->next) {
|
1999-05-15 14:34:22 +00:00
|
|
|
if (p->type == PACKAGE) {
|
|
|
|
/* If tp == NULL, we're looking for an exact package match */
|
|
|
|
if (!tp && !strcmp(p->name, str))
|
|
|
|
return p;
|
|
|
|
|
|
|
|
/* If tp, we're looking for both a package and a pointer to the place it's in */
|
|
|
|
if (tp && !strncmp(p->name, str, strlen(str))) {
|
|
|
|
*tp = top;
|
|
|
|
return p;
|
|
|
|
}
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
1999-05-15 14:34:22 +00:00
|
|
|
else if (p->kids) {
|
|
|
|
/* The usual recursion-out-of-laziness ploy */
|
1995-10-07 11:55:37 +00:00
|
|
|
if ((sp = index_search(p, str, tp)) != NULL)
|
|
|
|
return sp;
|
1999-05-15 14:34:22 +00:00
|
|
|
}
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
|
|
|
if (p && !p->name)
|
|
|
|
p = NULL;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
int
|
|
|
|
pkg_checked(dialogMenuItem *self)
|
1995-10-14 19:13:35 +00:00
|
|
|
{
|
1999-02-02 15:57:14 +00:00
|
|
|
ListPtrsPtr lists = (ListPtrsPtr)self->aux;
|
|
|
|
PkgNodePtr kp = self->data, plist = lists->plist;
|
1996-06-08 08:01:52 +00:00
|
|
|
int i;
|
1995-10-15 17:22:24 +00:00
|
|
|
|
1996-06-08 08:01:52 +00:00
|
|
|
i = index_search(plist, kp->name, NULL) ? TRUE : FALSE;
|
1999-02-02 15:57:14 +00:00
|
|
|
if (kp->type == PACKAGE && plist) {
|
|
|
|
IndexEntryPtr ie = kp->data;
|
|
|
|
int markD, markX;
|
|
|
|
|
|
|
|
markD = ie->depc > 0; /* needed as dependency */
|
|
|
|
markX = i || ie->installed; /* selected or installed */
|
|
|
|
self->mark = markX ? 'X' : 'D';
|
|
|
|
return markD || markX;
|
|
|
|
} else
|
1996-04-13 13:32:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
1995-10-14 19:13:35 +00:00
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
int
|
|
|
|
pkg_fire(dialogMenuItem *self)
|
|
|
|
{
|
1996-04-30 21:22:29 +00:00
|
|
|
int ret;
|
1999-02-02 15:57:14 +00:00
|
|
|
ListPtrsPtr lists = (ListPtrsPtr)self->aux;
|
|
|
|
PkgNodePtr sp, kp = self->data, plist = lists->plist;
|
1996-04-13 13:32:15 +00:00
|
|
|
|
|
|
|
if (!plist)
|
1996-04-30 21:22:29 +00:00
|
|
|
ret = DITEM_FAILURE;
|
|
|
|
else if (kp->type == PACKAGE) {
|
1999-02-02 15:57:14 +00:00
|
|
|
IndexEntryPtr ie = kp->data;
|
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
sp = index_search(plist, kp->name, NULL);
|
|
|
|
/* Not already selected? */
|
|
|
|
if (!sp) {
|
1999-02-02 15:57:14 +00:00
|
|
|
if (!ie->installed) {
|
1996-06-08 08:01:52 +00:00
|
|
|
PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode));
|
|
|
|
|
|
|
|
*np = *kp;
|
|
|
|
np->next = plist->kids;
|
|
|
|
plist->kids = np;
|
1999-02-02 15:57:14 +00:00
|
|
|
index_recorddeps(TRUE, lists->root, ie);
|
1996-06-08 08:01:52 +00:00
|
|
|
msgInfo("Added %s to selection list", kp->name);
|
|
|
|
}
|
1999-02-02 15:57:14 +00:00
|
|
|
else if (ie->depc == 0) {
|
2000-12-14 02:49:02 +00:00
|
|
|
if (!msgNoYes("Do you really want to delete %s from the system?", kp->name)) {
|
1999-04-06 08:25:53 +00:00
|
|
|
if (vsystem("pkg_delete %s %s", isDebug() ? "-v" : "", kp->name)) {
|
1997-01-29 22:35:05 +00:00
|
|
|
msgConfirm("Warning: pkg_delete of %s failed.\n Check debug output for details.", kp->name);
|
1999-04-06 08:25:53 +00:00
|
|
|
}
|
1999-02-02 15:57:14 +00:00
|
|
|
else {
|
|
|
|
ie->installed = 0;
|
|
|
|
index_recorddeps(FALSE, lists->root, ie);
|
|
|
|
}
|
1999-04-06 08:25:53 +00:00
|
|
|
}
|
1997-01-29 22:35:05 +00:00
|
|
|
}
|
1999-02-02 15:57:14 +00:00
|
|
|
else
|
|
|
|
msgConfirm("Warning: Package %s is needed by\n %d other installed package%s.",
|
|
|
|
kp->name, ie->depc, (ie->depc != 1) ? "s" : "");
|
1995-10-15 17:22:24 +00:00
|
|
|
}
|
1997-01-29 21:45:30 +00:00
|
|
|
else {
|
1999-02-02 15:57:14 +00:00
|
|
|
index_recorddeps(FALSE, lists->root, ie);
|
1996-04-30 06:00:06 +00:00
|
|
|
msgInfo("Removed %s from selection list", kp->name);
|
1996-04-13 13:32:15 +00:00
|
|
|
index_delete(sp);
|
1995-10-15 17:22:24 +00:00
|
|
|
}
|
1996-04-30 21:22:29 +00:00
|
|
|
ret = DITEM_SUCCESS;
|
1999-02-02 15:57:14 +00:00
|
|
|
/* Mark menu for redraw if we had dependencies */
|
|
|
|
if (strlen(ie->deps) > 0)
|
|
|
|
ret |= DITEM_REDRAW;
|
1995-10-14 19:13:35 +00:00
|
|
|
}
|
1996-04-13 13:32:15 +00:00
|
|
|
else { /* Not a package, must be a directory */
|
|
|
|
int p, s;
|
|
|
|
|
|
|
|
p = s = 0;
|
1999-02-02 15:57:14 +00:00
|
|
|
index_menu(lists->root, kp, plist, &p, &s);
|
1996-04-30 21:22:29 +00:00
|
|
|
ret = DITEM_SUCCESS | DITEM_CONTINUE;
|
1996-04-13 13:32:15 +00:00
|
|
|
}
|
1996-04-30 21:22:29 +00:00
|
|
|
return ret;
|
1996-04-13 13:32:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pkg_selected(dialogMenuItem *self, int is_selected)
|
|
|
|
{
|
1996-06-25 04:28:23 +00:00
|
|
|
PkgNodePtr kp = self->data;
|
|
|
|
|
|
|
|
if (!is_selected || kp->type != PACKAGE)
|
|
|
|
return;
|
2001-07-05 09:51:09 +00:00
|
|
|
msgInfo("%s", kp->desc);
|
1995-10-14 19:13:35 +00:00
|
|
|
}
|
|
|
|
|
1995-10-07 11:55:37 +00:00
|
|
|
int
|
1999-02-02 15:57:14 +00:00
|
|
|
index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll)
|
1995-10-07 11:55:37 +00:00
|
|
|
{
|
1999-02-02 15:57:14 +00:00
|
|
|
struct ListPtrs lists;
|
1995-10-20 20:10:49 +00:00
|
|
|
int n, rval, maxname;
|
1995-10-07 11:55:37 +00:00
|
|
|
int curr, max;
|
1996-04-13 13:32:15 +00:00
|
|
|
PkgNodePtr kp;
|
|
|
|
dialogMenuItem *nitems;
|
1995-10-14 19:13:35 +00:00
|
|
|
Boolean hasPackages;
|
1996-04-23 01:29:35 +00:00
|
|
|
WINDOW *w;
|
1999-12-14 04:25:29 +00:00
|
|
|
|
1999-02-02 15:57:14 +00:00
|
|
|
lists.root = root;
|
|
|
|
lists.top = top;
|
|
|
|
lists.plist = plist;
|
|
|
|
|
1995-10-14 19:13:35 +00:00
|
|
|
hasPackages = FALSE;
|
1995-10-07 11:55:37 +00:00
|
|
|
nitems = NULL;
|
1995-10-20 20:10:49 +00:00
|
|
|
n = maxname = 0;
|
1999-12-14 04:25:29 +00:00
|
|
|
|
1995-10-14 19:13:35 +00:00
|
|
|
/* Figure out if this menu is full of "leaves" or "branches" */
|
1995-10-20 20:10:49 +00:00
|
|
|
for (kp = top->kids; kp && kp->name; kp = kp->next) {
|
|
|
|
int len;
|
1996-06-25 04:28:23 +00:00
|
|
|
|
1995-10-07 11:55:37 +00:00
|
|
|
++n;
|
1995-10-20 20:10:49 +00:00
|
|
|
if (kp->type == PACKAGE && plist) {
|
1995-10-14 19:13:35 +00:00
|
|
|
hasPackages = TRUE;
|
1995-10-20 20:10:49 +00:00
|
|
|
if ((len = strlen(kp->name)) > maxname)
|
|
|
|
maxname = len;
|
1995-10-14 19:13:35 +00:00
|
|
|
}
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
1995-10-20 20:10:49 +00:00
|
|
|
if (!n && plist) {
|
1995-10-07 11:55:37 +00:00
|
|
|
msgConfirm("The %s menu is empty.", top->name);
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_LEAVE_MENU;
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
1995-10-14 19:13:35 +00:00
|
|
|
|
1999-12-14 04:25:29 +00:00
|
|
|
w = savescr();
|
1995-10-07 11:55:37 +00:00
|
|
|
while (1) {
|
1995-10-14 19:13:35 +00:00
|
|
|
n = 0;
|
1995-11-06 12:49:27 +00:00
|
|
|
curr = max = 0;
|
1997-03-25 03:12:59 +00:00
|
|
|
use_helpline(NULL);
|
|
|
|
use_helpfile(NULL);
|
1995-10-14 19:13:35 +00:00
|
|
|
kp = top->kids;
|
1997-03-25 03:12:59 +00:00
|
|
|
if (!hasPackages && plist) {
|
2001-09-22 22:21:01 +00:00
|
|
|
nitems = item_add(nitems, "OK", NULL, NULL, NULL, NULL, NULL, NULL, &curr, &max);
|
|
|
|
nitems = item_add(nitems, "Install", NULL, NULL, NULL, NULL, NULL, NULL, &curr, &max);
|
1997-03-25 03:12:59 +00:00
|
|
|
}
|
1995-10-14 19:13:35 +00:00
|
|
|
while (kp && kp->name) {
|
1996-04-13 13:32:15 +00:00
|
|
|
char buf[256];
|
1997-03-25 03:12:59 +00:00
|
|
|
IndexEntryPtr ie = kp->data;
|
1996-04-13 13:32:15 +00:00
|
|
|
|
1995-10-20 20:10:49 +00:00
|
|
|
/* Brutally adjust description to fit in menu */
|
1997-03-25 03:12:59 +00:00
|
|
|
if (kp->type == PACKAGE)
|
|
|
|
snprintf(buf, sizeof buf, "[%s]", ie->path ? ie->path : "External vendor");
|
|
|
|
else
|
|
|
|
SAFE_STRCPY(buf, kp->desc);
|
1996-04-13 13:32:15 +00:00
|
|
|
if (strlen(buf) > (_MAX_DESC - maxname))
|
|
|
|
buf[_MAX_DESC - maxname] = '\0';
|
2001-09-22 22:21:01 +00:00
|
|
|
nitems = item_add(nitems, kp->name, (char *)buf, pkg_checked,
|
|
|
|
pkg_fire, pkg_selected, kp, (int *)(&lists),
|
|
|
|
&curr, &max);
|
1995-10-14 19:13:35 +00:00
|
|
|
++n;
|
|
|
|
kp = kp->next;
|
|
|
|
}
|
1996-04-13 13:32:15 +00:00
|
|
|
/* NULL delimiter so item_free() knows when to stop later */
|
2001-09-22 22:21:01 +00:00
|
|
|
nitems = item_add(nitems, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
&curr, &max);
|
1995-10-14 19:13:35 +00:00
|
|
|
|
1996-06-14 14:34:03 +00:00
|
|
|
recycle:
|
1996-08-03 10:11:56 +00:00
|
|
|
dialog_clear_norefresh();
|
1995-10-14 19:13:35 +00:00
|
|
|
if (hasPackages)
|
1996-04-13 13:32:15 +00:00
|
|
|
rval = dialog_checklist(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems, NULL);
|
1997-03-25 03:12:59 +00:00
|
|
|
else
|
|
|
|
rval = dialog_menu(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems + (plist ? 2 : 0), (char *)plist, pos, scroll);
|
1996-04-13 13:32:15 +00:00
|
|
|
if (rval == -1 && plist) {
|
1995-10-07 11:55:37 +00:00
|
|
|
static char *cp;
|
|
|
|
PkgNodePtr menu;
|
|
|
|
|
|
|
|
/* Search */
|
|
|
|
if ((cp = msgGetInput(cp, "Search by package name. Please enter search string:")) != NULL) {
|
|
|
|
PkgNodePtr p = index_search(top, cp, &menu);
|
|
|
|
|
|
|
|
if (p) {
|
|
|
|
int pos, scroll;
|
|
|
|
|
|
|
|
/* These need to be set to point at the found item, actually. Hmmm! */
|
|
|
|
pos = scroll = 0;
|
1999-02-02 15:57:14 +00:00
|
|
|
index_menu(root, menu, plist, &pos, &scroll);
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
1996-04-23 01:29:35 +00:00
|
|
|
else
|
1995-10-07 11:55:37 +00:00
|
|
|
msgConfirm("Search string: %s yielded no hits.", cp);
|
|
|
|
}
|
1996-06-14 14:34:03 +00:00
|
|
|
goto recycle;
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
1996-05-01 09:31:50 +00:00
|
|
|
items_free(nitems, &curr, &max);
|
|
|
|
restorescr(w);
|
|
|
|
return rval ? DITEM_FAILURE : DITEM_SUCCESS;
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-10-15 04:37:07 +00:00
|
|
|
int
|
1999-05-15 14:34:22 +00:00
|
|
|
index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended)
|
1996-03-18 15:28:10 +00:00
|
|
|
{
|
1996-04-13 13:32:15 +00:00
|
|
|
int status = DITEM_SUCCESS;
|
1996-03-18 15:28:10 +00:00
|
|
|
PkgNodePtr tmp2;
|
1996-03-21 09:30:18 +00:00
|
|
|
IndexEntryPtr id = who->data;
|
1999-12-18 03:13:19 +00:00
|
|
|
WINDOW *w = savescr();
|
1996-03-18 15:28:10 +00:00
|
|
|
|
2002-01-29 21:41:08 +00:00
|
|
|
/*
|
|
|
|
* Short-circuit the package dependency checks. We're already
|
|
|
|
* maintaining a data structure of installed packages, so if a
|
|
|
|
* package is already installed, don't try to check to make sure
|
|
|
|
* that all of its dependencies are installed. At best this
|
|
|
|
* wastes a ton of cycles and can cause minor delays between
|
|
|
|
* package extraction. At worst it can cause an infinite loop with
|
|
|
|
* a certain faulty INDEX file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (id->installed == 1)
|
2002-04-13 13:00:42 +00:00
|
|
|
return DITEM_SUCCESS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* What if the package is not available on the current media volume?
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
if (id->volume != dev->volume) {
|
|
|
|
if (!msgYesNo("This is disc #%d. Package %s is on disc #%d\n"
|
|
|
|
"Would you like to switch discs now?\n", dev->volume,
|
|
|
|
id->name, id->volume)) {
|
|
|
|
DEVICE_SHUTDOWN(mediaDevice);
|
|
|
|
msgConfirm("Please remove disc #%d from your drive, and add disc #%d\n",
|
|
|
|
dev->volume, id->volume);
|
|
|
|
DEVICE_INIT(mediaDevice);
|
|
|
|
/* XXX, at this point we check to see if this is the
|
|
|
|
* correct disc, and if not, we loop */
|
|
|
|
} else {
|
|
|
|
return DITEM_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2002-01-29 21:41:08 +00:00
|
|
|
|
1996-03-21 09:30:18 +00:00
|
|
|
if (id && id->deps && strlen(id->deps)) {
|
2003-02-27 20:43:52 +00:00
|
|
|
char t[2048 * 8], *cp, *cp2;
|
1996-03-18 15:28:10 +00:00
|
|
|
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(t, id->deps);
|
1996-03-18 15:28:10 +00:00
|
|
|
cp = t;
|
1996-04-28 03:27:26 +00:00
|
|
|
while (cp && DITEM_STATUS(status) == DITEM_SUCCESS) {
|
1996-03-18 15:28:10 +00:00
|
|
|
if ((cp2 = index(cp, ' ')) != NULL)
|
|
|
|
*cp2 = '\0';
|
1996-03-21 09:30:18 +00:00
|
|
|
if ((tmp2 = index_search(top, cp, NULL)) != NULL) {
|
1999-05-15 14:34:22 +00:00
|
|
|
status = index_extract(dev, top, tmp2, TRUE);
|
1999-07-02 22:36:14 +00:00
|
|
|
if (DITEM_STATUS(status) != DITEM_SUCCESS) {
|
|
|
|
if (variable_get(VAR_NO_CONFIRM))
|
2001-03-24 01:26:51 +00:00
|
|
|
msgNotify("Loading of dependent package %s failed", cp);
|
1999-07-02 22:36:14 +00:00
|
|
|
else
|
2001-03-24 01:26:51 +00:00
|
|
|
msgConfirm("Loading of dependent package %s failed", cp);
|
1999-07-02 22:36:14 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-02 09:52:49 +00:00
|
|
|
else if (!package_installed(cp)) {
|
1999-07-02 22:36:14 +00:00
|
|
|
if (variable_get(VAR_NO_CONFIRM))
|
|
|
|
msgNotify("Warning: %s is a required package but was not found.", cp);
|
|
|
|
else
|
|
|
|
msgConfirm("Warning: %s is a required package but was not found.", cp);
|
1997-11-13 11:44:42 +00:00
|
|
|
}
|
1997-05-05 08:38:12 +00:00
|
|
|
if (cp2)
|
|
|
|
cp = cp2 + 1;
|
|
|
|
else
|
|
|
|
cp = NULL;
|
1996-03-18 15:28:10 +00:00
|
|
|
}
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
1996-03-18 15:28:10 +00:00
|
|
|
/* Done with the deps? Load the real m'coy */
|
1999-02-02 15:57:14 +00:00
|
|
|
if (DITEM_STATUS(status) == DITEM_SUCCESS) {
|
1996-03-21 09:30:18 +00:00
|
|
|
status = package_extract(dev, who->name, depended);
|
1999-02-02 15:57:14 +00:00
|
|
|
if (DITEM_STATUS(status) == DITEM_SUCCESS)
|
|
|
|
id->installed = 1;
|
|
|
|
}
|
1999-12-18 03:13:19 +00:00
|
|
|
restorescr(w);
|
1995-10-20 20:10:49 +00:00
|
|
|
return status;
|
1995-10-07 11:55:37 +00:00
|
|
|
}
|
1999-02-02 15:57:14 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie)
|
|
|
|
{
|
2003-02-27 20:43:52 +00:00
|
|
|
char depends[1024 * 16], *space, *todo;
|
1999-02-02 15:57:14 +00:00
|
|
|
PkgNodePtr found;
|
|
|
|
IndexEntryPtr found_ie;
|
|
|
|
|
|
|
|
SAFE_STRCPY(depends, ie->deps);
|
|
|
|
for (todo = depends; todo != NULL; ) {
|
|
|
|
space = index(todo, ' ');
|
|
|
|
if (space != NULL)
|
|
|
|
*space = '\0';
|
|
|
|
|
|
|
|
if (strlen(todo) > 0) { /* only non-empty dependencies */
|
|
|
|
found = index_search(root, todo, NULL);
|
|
|
|
if (found != NULL) {
|
|
|
|
found_ie = found->data;
|
|
|
|
if (add)
|
|
|
|
++found_ie->depc;
|
|
|
|
else
|
|
|
|
--found_ie->depc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (space != NULL)
|
|
|
|
todo = space + 1;
|
|
|
|
else
|
|
|
|
todo = NULL;
|
|
|
|
}
|
|
|
|
}
|
1999-05-12 09:02:37 +00:00
|
|
|
|
|
|
|
static Boolean index_initted;
|
|
|
|
|
|
|
|
/* Read and initialize global index */
|
|
|
|
int
|
|
|
|
index_initialize(char *path)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
1999-12-14 04:25:29 +00:00
|
|
|
WINDOW *w = NULL;
|
1999-05-12 09:02:37 +00:00
|
|
|
|
|
|
|
if (!index_initted) {
|
1999-12-14 04:25:29 +00:00
|
|
|
w = savescr();
|
|
|
|
dialog_clear_norefresh();
|
|
|
|
|
1999-05-12 09:02:37 +00:00
|
|
|
/* Got any media? */
|
1999-12-14 04:25:29 +00:00
|
|
|
if (!mediaVerify()) {
|
|
|
|
restorescr(w);
|
1999-05-12 09:02:37 +00:00
|
|
|
return DITEM_FAILURE;
|
1999-12-14 04:25:29 +00:00
|
|
|
}
|
1999-05-12 09:02:37 +00:00
|
|
|
|
|
|
|
/* Does it move when you kick it? */
|
2001-07-02 00:18:04 +00:00
|
|
|
if (!DEVICE_INIT(mediaDevice)) {
|
1999-12-14 04:25:29 +00:00
|
|
|
restorescr(w);
|
1999-05-12 09:02:37 +00:00
|
|
|
return DITEM_FAILURE;
|
1999-12-14 04:25:29 +00:00
|
|
|
}
|
1999-05-12 09:02:37 +00:00
|
|
|
|
1999-12-18 03:13:19 +00:00
|
|
|
dialog_clear_norefresh();
|
1999-05-12 09:02:37 +00:00
|
|
|
msgNotify("Attempting to fetch %s file from selected media.", path);
|
2001-07-02 00:18:04 +00:00
|
|
|
fp = DEVICE_GET(mediaDevice, path, TRUE);
|
1999-05-12 09:02:37 +00:00
|
|
|
if (!fp) {
|
2000-12-16 05:36:10 +00:00
|
|
|
msgConfirm("Unable to get packages/INDEX file from selected media.\n\n"
|
|
|
|
"This may be because the packages collection is not available\n"
|
|
|
|
"on the distribution media you've chosen, most likely an FTP site\n"
|
|
|
|
"without the packages collection mirrored. Please verify that\n"
|
|
|
|
"your media, or your path to the media, is correct and try again.");
|
2001-07-02 00:18:04 +00:00
|
|
|
DEVICE_SHUTDOWN(mediaDevice);
|
1999-12-14 04:25:29 +00:00
|
|
|
restorescr(w);
|
|
|
|
return DITEM_FAILURE;
|
1999-05-12 09:02:37 +00:00
|
|
|
}
|
1999-12-18 03:13:19 +00:00
|
|
|
dialog_clear_norefresh();
|
1999-05-12 09:02:37 +00:00
|
|
|
msgNotify("Located INDEX, now reading package data from it...");
|
|
|
|
index_init(&Top, &Plist);
|
|
|
|
if (index_read(fp, &Top)) {
|
|
|
|
msgConfirm("I/O or format error on packages/INDEX file.\n"
|
|
|
|
"Please verify media (or path to media) and try again.");
|
|
|
|
fclose(fp);
|
1999-12-14 04:25:29 +00:00
|
|
|
restorescr(w);
|
|
|
|
return DITEM_FAILURE;
|
1999-05-12 09:02:37 +00:00
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
index_sort(&Top);
|
|
|
|
index_initted = TRUE;
|
1999-12-19 06:34:22 +00:00
|
|
|
restorescr(w);
|
1999-05-12 09:02:37 +00:00
|
|
|
}
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_SUCCESS;
|
1999-05-12 09:02:37 +00:00
|
|
|
}
|