From b44f3c89b739941ab25fa7f7b7c170d827c16288 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 25 Jul 2003 23:55:57 +0000 Subject: [PATCH] - Renamed Essential field to Key, to prevent confusion. - Implemented dropping of tasks that are missing key packages. - If a task is not in the task desc files, but is in the available file as a Task: line, do not display it. --- data.c | 49 ++++++++++++++++++++++++++++++++++++++++++------- data.h | 4 +++- tasksel.c | 4 +++- 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/data.c b/data.c index d3026d85..472fc330 100644 --- a/data.c +++ b/data.c @@ -1,4 +1,4 @@ -/* $Id: data.c,v 1.16 2003/07/25 18:06:28 joeyh Exp $ */ +/* $Id: data.c,v 1.17 2003/07/25 23:55:57 joeyh Rel $ */ /* data.c - encapsulates functions for reading a package listing like dpkg's available file * Internally, packages are stored in a binary tree format to faciliate search operations */ @@ -40,6 +40,7 @@ static void *_packages_root = NULL; static struct task_t **_tasks_enumbuf = NULL; static int _tasks_enumcount = 0; static void *_tasks_root = NULL; +int _tasks_count; /* private functions */ static int packagecompare(const void *p1, const void *p2) @@ -71,7 +72,6 @@ static void tasks_walk_enumerate(const void *nodep, const VISIT order, const int } } - static int taskcompare(const void *lp, const void *rp) { const struct task_t *l = (const struct task_t *)lp; @@ -96,6 +96,19 @@ static void tasks_walk_delete(const void *nodep, const VISIT order, const int de } } +static void tasks_walk_crop(const void *nodep, const VISIT order, const int depth) +{ + struct task_t *datap = *(struct task_t **)nodep; + + if (order == leaf || order == endorder) { + if (! datap->task_pkg || ! datap->task_pkg->shortdesc) { + if (tdelete((void *)datap, &_tasks_root, taskcompare)) { + _tasks_count--; + } + } + } +} + static void packages_walk_delete(const void *nodep, const VISIT order, const int depth) { /* deletes memory associated with nodep */ @@ -149,6 +162,20 @@ static int splitlinkdesc(const char *desc, char ***array) return elts; } + +void deletetask(struct tasks_t *tasks, const char *taskname) { + struct task_t *task; + + task = tasks_find(tasks, taskname); + if (! task) + return; + + /* TODO: free structs */ + if (tdelete((void *)task, &tasks->tasks, taskcompare)) { + tasks->count--; + } +} + static struct task_t *addtask( struct tasks_t *tasks, const char *taskname, @@ -299,6 +326,13 @@ struct task_t **tasks_enumerate(const struct tasks_t *tasks) return _tasks_enumbuf; } +void tasks_crop(struct tasks_t *tasks) { + _tasks_root = tasks->tasks; + _tasks_count = tasks->count; + twalk(tasks->tasks, tasks_walk_crop); + tasks->count = _tasks_count; +} + static void walktasks(const void *t, const VISIT which, const int depth) { struct task_t *task = *(struct task_t**)t; @@ -392,10 +426,8 @@ dontmakemethink: } if (pkgname) { if (! packages_find(pkgs, pkgname)) { - DPRINTF("task %s is missing required package %s\n", task, pkgname); - if (! showempties) { - key_missing=1; - } + DPRINTF("task %s is missing key package %s", task, pkgname); + key_missing=1; } } } while (buf[0] != '\n' && !feof(f)); @@ -418,10 +450,13 @@ dontmakemethink: PRIORITY_UNKNOWN); p->section = STRDUP(section); p->pseudopackage = 1; - t = addtask(tasks, task, ""); t->task_pkg = p; } + else { + DPRINTF("skipping empty task %s", task); + deletetask(tasks, task); + } if (task != NULL) FREE(task); if (shortdesc != NULL) FREE(shortdesc); diff --git a/data.h b/data.h index 3eaed484..a5dccee1 100644 --- a/data.h +++ b/data.h @@ -1,4 +1,4 @@ -/* $Id: data.h,v 1.8 2003/07/25 18:06:28 joeyh Exp $ */ +/* $Id: data.h,v 1.9 2003/07/25 23:55:57 joeyh Rel $ */ #ifndef _DATA_H #define _DATA_H @@ -53,6 +53,8 @@ void packages_readlist(struct tasks_t *tasks, struct packages_t *packages); /* free memory allocated to store packages */ void packages_free(struct tasks_t *tasks, struct packages_t *packages); +void tasks_crop(struct tasks_t *tasks); + struct package_t *packages_find(const struct packages_t *packages, const char *name); struct task_t *tasks_find(const struct tasks_t *tasks, const char *name); struct package_t **packages_enumerate(const struct packages_t *packages); diff --git a/tasksel.c b/tasksel.c index 8e7a5345..6405b2ff 100644 --- a/tasksel.c +++ b/tasksel.c @@ -1,4 +1,4 @@ -/* $Id: tasksel.c,v 1.16 2003/07/25 17:33:24 joeyh Exp $ */ +/* $Id: tasksel.c,v 1.17 2003/07/25 23:55:57 joeyh Rel $ */ #include "tasksel.h" #include @@ -186,6 +186,8 @@ int main(int argc, char * const argv[]) } closedir(taskdir); + tasks_crop(&tasks); + if (tasks.count == 0) { fprintf(stderr, _("No tasks found on this system.\nDid you update your available file? Try running dselect update.\n")); return 255;