Browse Source

- 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.
keep-around/43e990ab3f4cc50982f8dbc32e3465ca7c827876
Joey Hess 20 years ago
parent
commit
b44f3c89b7
  1. 49
      data.c
  2. 4
      data.h
  3. 4
      tasksel.c

49
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);

4
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);

4
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 <stdio.h>
@ -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;

Loading…
Cancel
Save