~ubuntu-branches/debian/experimental/sysvinit/experimental

« back to all changes in this revision

Viewing changes to .pc/75_pri_kdm_gdm.patch/startpar/makeboot.c

  • Committer: Package Import Robot
  • Author(s): Roger Leigh, Roger Leigh, Steve Langasek
  • Date: 2012-04-21 12:11:45 UTC
  • mfrom: (9.1.33 sid)
  • Revision ID: package-import@ubuntu.com-20120421121145-tcyy57v1j6gx946d
Tags: 2.88dsf-23
[ Roger Leigh ]
* Acknowledge NMU for translation updates.  Thanks to Christian
  Perrier.
* debian/control:
  - Upgrade to Standards-Version 3.9.3.
  - Build-Depend on debhelper v9.
  - Correct Vcs-Git URL.
* debian/rules:
  - Use DEB_HOST_ARCH_OS = hurd rather than
    DEB_HOST_ARCH = hurd-i386.   Thanks to Pino Toscano.
* debian/patches:
  - 11_lfs_cflags.patch: Add patch for enabling large file support,
    needed on GNU/Hurd, but useful for all platforms.
  - 73_lfs_cflags.patch: Add patch for enabling large file support
    in startpar.
* initscripts:
  - Moved RAM* settings from /etc/default/rcS to /etc/default/tmpfs.
    This ensures that the settings are equivalent for upgrades and
    new installations, but will require manual configuration of the
    settings for upgrades (no migration from /etc/default/rcS to
    /etc/default/tmpfs will take place, due to tmpfs being a
    conffile).  tmpf(5) manual page added to document all aspects
    of tmpfs configuration, including the existing documentation in
    rcS(5).
  - Drop the use of .ramfs dotfiles in /run and /run/lock.  These
    were a legacy of /lib/init/rw and were not actually used by
    anything.  Closes: #403863.
  - Drop /etc/init.d/mountoverflowtmp.  This has been merged into
    the general tmpfs on /tmp handling functions.  This means the
    generic RAMTMP configuration is used for the overflowtmp.
    Closes: #567539.
  - It is now possible to configure a tmpfs mount size limit as a
    percentage of the total VM size (%VM) as well as a percentage
    of the RAM size (%).  This is computed by tmpfs.sh and the
    tmpfs mounts are remounted with the updated size limit after
    swap becomes available.
  - An fstab entry for /tmp overrides RAMTMP.  Document tmpfs
    override and tmpfs defaults in tmpfs(5), also undeprecating the
    tmpfs settings.  Closes: #585540, #665995.
  - An fstab entry for /run/lock or /run/shm overrides RAMLOCK and
    RAMSHM.
  - bootclean cleans /tmp, /run and /run/lock before any filesystems
    are mounted as well as after local and network mounts.  This
    permits cleaning of directories which would otherwise be hidden
    by mountpoints later in the boot process.
    Closes: #55707, #558000, #666871.  Additionally clean up
    /lib/init/rw in case any files were hidden by the (now removed)
    tmpfs mount at this location.  Closes: #652625.
  - Removed last trace of the long-removed EDITMOTD from the
    postinst.  Closes: #438895.
  - Removed documentation of #346342 in rcS(5).  This is no longer
    an issue now tzdata keeps a copy of the data on the rootfs.
    Closes: #385172.
  - Correct description of TMPTIME in rcS(5).  Thanks to Alan J.
    Greenberger.  Closes: #562500.
  - urandom: Applied a series of patches from John Denker to
    improve the integrity of random number generation.  Many thanks.
    Closes: #596479, #596480, #596481, #596482, #596483.
* sysv-rc:
  - Remove old upgrade logic from maintainer scripts not required
    for wheezy.
  - Migrate users of obsolete static boot ordering to dynamic boot
    ordering.
  - Remove use of /etc/init.d/.legacy-bootordering.  Closes: #668312.
  - Improve help text of debconf message when it is not possible to
    automatically enable dynamic boot ordering.  Provide explicit
    instructions for how to purge obsolete init scripts.
    Closes: #550425.
  - etc/init.d/rc: Ensure linprocfs is mounted on kFreeBSD.  Thanks
    to Robert Millan.  Closes: #659480.
  - Drop undocumented CONCURRENCY setting from /etc/init.d/rc.
    Closes: #518249, #540448, #539261.  Note that this still contains
    internal fallbacks to support non-insserv booting, which may be
    removed at a later date.
  - invoke-rc.d:
    + Minor manual page corrections.  Thanks to Anthony Fiumara.
      Closes: #664816.
    + Remove mention of the "dpkg Programmers' Manual" and replace
      with references to Debian Policy.  Closes: #543793.
  - update-rc.d:
    + Correctly warn about non-LSB standard runlevels.  Thanks to
      Chris Hiestand for this patch.  Closes: #614895.
    + Remove obsolete documentation of
      /var/lib/sysv-rc/legacy-bootsequence.  Thanks to Thomas Hood.
      Closes: #623051.
* sysvinit:
  - Minor corrections for halt(8) manual page.  Thanks to
    Christoph Anton Mitterer.  Closes: #587923.
  - Installation with debootstrap --variant=fakechroot now works, due
    to only migrating the old control channel when it is still
    present.  Thanks to Michael Gilbert.  Closes: #596284.
* sysvinit-utils:
  - Recommend bootlogd.  Closes: #659490.  This means that booklogd
    will be installed by default, but will be removable.
    Closes: #232569.
  - Correct documentation of the startpar -i option.  Closes: #545438.
  - Correct startpar(8) SEE ALSO section.  Closes: #634146.
  - Correct wording in service(8).  Thanks to Joey Hess and Regid
    Ichira.  Closes: #545401, #667745.

[ Steve Langasek ]
* debian/service/service: fix upstart compatibility to not try to use the
  upstart commands when init isn't upstart.  Closes: #636054.
* debian/rules: pass CFLAGS when building startpar.
* Fix startpar to not run init scripts that have matching upstart jobs,
  instead waiting for a signal from upstart.  Closes: #660824.
    to Robert Millan.  (Closes: #659480)
* sysvinit:
  - Don't restart or perform initctl migration if systemd is
    running.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * very very simple makefile parser
3
 
 */
4
 
 
5
 
#include <stdio.h>
6
 
#include <string.h>
7
 
#include <malloc.h>
8
 
#include <ctype.h>
9
 
#include <stdlib.h>
10
 
#include <dirent.h>
11
 
#include <unistd.h>
12
 
#include <stdarg.h>
13
 
#include <errno.h>
14
 
#include <limits.h>
15
 
#include "makeboot.h"
16
 
#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
17
 
# include <sys/types.h>
18
 
# include <sys/stat.h>
19
 
# include <fcntl.h>
20
 
#ifndef POSIX_FADV_SEQUENTIAL
21
 
#define posix_fadvise(fd, off, len, adv)        (-1)
22
 
#endif
23
 
#ifndef O_DIRECT
24
 
#define O_DIRECT 0
25
 
#endif
26
 
static int o_flags = O_RDONLY;
27
 
#endif
28
 
 
29
 
 
30
 
int tree_entries = 0;
31
 
struct makenode *tree_list = NULL;
32
 
 
33
 
/*
34
 
 * search for the node with the given name
35
 
 * returns the node pointer or NULL if not found.
36
 
 *
37
 
 * FIXME: we should use hash for the effective search.
38
 
 */
39
 
static struct makenode *lookup_target(const char *name)
40
 
{
41
 
        struct makenode *t;
42
 
 
43
 
        for (t = tree_list; t; t = t->next)
44
 
                if (! strcmp(t->name, name))
45
 
                        return t;
46
 
        return NULL;
47
 
}
48
 
 
49
 
/*
50
 
 * look for the node with the given name.  if not exist,
51
 
 * create a new one and append to the node list.
52
 
 */
53
 
static struct makenode *add_target(const char *name)
54
 
{
55
 
        struct makenode *__restrict node;
56
 
        struct makenode *prev, *t;
57
 
 
58
 
        node = lookup_target(name);
59
 
        if (node)
60
 
                return node;
61
 
        if (posix_memalign((void*)&node, sizeof(void*), alignof(struct makenode)+strsize(name)) < 0) {
62
 
                fprintf(stderr, "Can't malloc: %s\n", strerror(errno));
63
 
                exit(1);
64
 
        }
65
 
        memset(node, 0, alignof(struct makenode)+strsize(name));
66
 
        node->name = ((char*)node)+alignof(struct makenode);
67
 
        strcpy(node->name, name);
68
 
 
69
 
        /* append to the list in alphabetical order */
70
 
        prev = NULL;
71
 
        for (t = tree_list; t; prev = t, t = t->next)
72
 
                if (strcmp(node->name, t->name) < 0)
73
 
                        break;
74
 
        if (prev)
75
 
                prev->next = node;
76
 
        else
77
 
                tree_list = node;
78
 
        node->next = t;
79
 
        tree_entries++;
80
 
        return node;
81
 
}
82
 
 
83
 
/*
84
 
 * Set and propagate importance of a node to all depencies of this node
85
 
 */
86
 
static void add_importance(struct makenode *node, int importance)
87
 
{
88
 
        struct makelist *s = node->depend;
89
 
 
90
 
        node->importance += importance;
91
 
        for (s = node->depend; s; s = s->next)
92
 
                add_importance(s->node, importance);
93
 
}
94
 
 
95
 
/*
96
 
 * create a dependecy/selection node
97
 
 */
98
 
static struct makelist *new_list(struct makenode *node, struct makelist *next)
99
 
{
100
 
        struct makelist *x;
101
 
 
102
 
        x = xcalloc(1, sizeof(*x));
103
 
        x->node = node;
104
 
        x->next = next;
105
 
        return x;
106
 
}
107
 
 
108
 
/*
109
 
 * check whether the given target would create an infinte loop
110
 
 */
111
 
static int loop;
112
 
static int check_loop(struct makenode *dep, struct makenode *src)
113
 
{
114
 
        struct makelist *s;
115
 
        for (s = dep->depend; s; s = s->next) {
116
 
                if (s->node == src) {
117
 
                        fprintf(stderr, "loop exists %s in %s!\n", dep->name, src->name);
118
 
                        return 1;
119
 
                }
120
 
                if (loop++ > 99999) {
121
 
                        fprintf(stderr, "too many loops! (loop=%d, dep->name=%s, src->name=%s)\n",
122
 
                                loop, dep->name, src->name);
123
 
                        return 1;
124
 
                }
125
 
                if (check_loop(s->node, src))
126
 
                        return 1;
127
 
        }
128
 
        return 0;
129
 
}
130
 
 
131
 
/*
132
 
 * add to the dependecy and selection lists
133
 
 */
134
 
static void add_depend(struct makenode *node, const char *dst)
135
 
{
136
 
        struct makenode *dep;
137
 
 
138
 
        dep = add_target(dst);
139
 
        loop = 0;
140
 
        if (check_loop(dep, node))
141
 
                return;
142
 
        dep->select = new_list(node, dep->select);
143
 
        dep->num_sels++;
144
 
        node->depend = new_list(dep, node->depend);
145
 
        node->num_deps++;
146
 
}
147
 
 
148
 
/*
149
 
 * mark the selected service as an interactive task
150
 
 * that should run solely
151
 
 */
152
 
static void mark_interactive(const char *name)
153
 
{
154
 
        struct makenode *node = lookup_target(name);
155
 
        if (node)
156
 
                node->interactive = 1;
157
 
}
158
 
 
159
 
 
160
 
#define DELIMITER       " \t\r\n"
161
 
 
162
 
/*
163
 
 * parse (pseudo) makefile
164
 
 *
165
 
 * it may have only the following form:
166
 
 *
167
 
 * TARGETS = xxx ...
168
 
 * INTERACTIVE = yyy ...
169
 
 * aaa:
170
 
 * bbb: xxx ddd ...
171
 
 *
172
 
 * other lines are ignored.
173
 
 */
174
 
void parse_makefile(const char *path)
175
 
{
176
 
        FILE *fp;
177
 
        char buf[LINE_MAX]; /* FIXME: is this enough big? */
178
 
        char *s, *strp, *p;
179
 
        struct makenode *node;
180
 
 
181
 
#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
182
 
        int fd;
183
 
 
184
 
        if (getuid() == (uid_t)0)
185
 
                o_flags |= O_NOATIME;
186
 
        if ((fd = open(path, o_flags)) < 0) {
187
 
                fprintf(stderr, "Can't open %s: %s\n", path, strerror(errno));
188
 
                exit(1);
189
 
        }
190
 
        (void)posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED);
191
 
        (void)posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
192
 
        (void)posix_fadvise(fd, 0, 0, POSIX_FADV_NOREUSE);
193
 
 
194
 
        if ((fp = fdopen(fd, "r")) == NULL)
195
 
#else
196
 
        if ((fp = fopen(path, "r")) == NULL)
197
 
#endif
198
 
        {
199
 
                fprintf(stderr, "Can't open %s: %s\n", path, strerror(errno));
200
 
                exit(1);
201
 
        }
202
 
 
203
 
        while (fgets(buf, sizeof(buf), fp)) {
204
 
                for (s = buf; *s && isspace(*s); s++)
205
 
                        ;
206
 
                if (! *s || *s == '#')
207
 
                        continue;
208
 
                if (! strncmp(s, "TARGETS =", 9)) {
209
 
                        s += 9;
210
 
                        strp = s;
211
 
                        while ((s = strsep(&strp, DELIMITER))) {
212
 
                                if (! *s)
213
 
                                        continue;
214
 
                                add_target(s);
215
 
                        }
216
 
                } else if (! strncmp(s, "INTERACTIVE =", 13)) {
217
 
                        s += 13;
218
 
                        strp = s;
219
 
                        while ((s = strsep(&strp, DELIMITER))) {
220
 
                                if (! *s)
221
 
                                        continue;
222
 
                                mark_interactive(s);
223
 
                        }
224
 
                } else {
225
 
                        p = strchr(s, ':');
226
 
                        if (! p)
227
 
                                continue;
228
 
                        *p = 0;
229
 
                        node = add_target(s);
230
 
                        strp = p + 1;
231
 
                        while ((s = strsep(&strp, DELIMITER))) {
232
 
                                if (! *s)
233
 
                                        continue;
234
 
                                add_depend(node, s);
235
 
                        }
236
 
                }
237
 
        }
238
 
 
239
 
#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
240
 
        (void)posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
241
 
#endif
242
 
 
243
 
        fclose(fp);
244
 
 
245
 
        for (node = tree_list; node; node = node->next) {
246
 
                int importance = 0;
247
 
 
248
 
                if (! strcmp(node->name, "xdm"))
249
 
                        importance = 100;
250
 
 
251
 
                if (! strncmp(node->name, "early", 5))
252
 
                        importance = 8000;
253
 
 
254
 
                if (importance)
255
 
                        add_importance(node, importance);
256
 
        }
257
 
}
258
 
 
259
 
/*
260
 
 * filter out the list targets
261
 
 */
262
 
 
263
 
static int filter_prefix;
264
 
static int dirfilter(const struct dirent *d)
265
 
{
266
 
        return *d->d_name == filter_prefix &&
267
 
                strlen(d->d_name) >= 4; /* to be sure */
268
 
}
269
 
 
270
 
static void filter_files(const char *dir, int prefix, int inverse)
271
 
{
272
 
        char path[64];
273
 
        int i, ndirs;
274
 
        static struct dirent **dirlist;
275
 
        struct makenode *t, *next;
276
 
 
277
 
        filter_prefix = prefix;
278
 
#ifdef SUSE     /* SuSE */
279
 
        snprintf(path, sizeof(path), "/etc/init.d/%s.d", dir);
280
 
#else           /* Debian */
281
 
        snprintf(path, sizeof(path), "/etc/%s.d", dir);
282
 
#endif
283
 
#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
284
 
        if ((i = open(path, o_flags|O_DIRECTORY|O_LARGEFILE)) >= 0) {
285
 
                (void)posix_fadvise(i, 0, 0, POSIX_FADV_SEQUENTIAL);
286
 
                (void)posix_fadvise(i, 0, 0, POSIX_FADV_NOREUSE);
287
 
        }
288
 
#endif
289
 
        ndirs = scandir(path, &dirlist, dirfilter, alphasort);
290
 
#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
291
 
        if (i >= 0) {
292
 
                (void)posix_fadvise(i, 0, 0, POSIX_FADV_DONTNEED);
293
 
                close(i);
294
 
        }
295
 
#endif
296
 
        /* mark all matching nodes */
297
 
        if (ndirs >= 0) {
298
 
                for (i = 0; i < ndirs; i++) {
299
 
                        t = lookup_target(dirlist[i]->d_name + 3);
300
 
                        if (t) {
301
 
                                t->status = 1;
302
 
                                if (asprintf(&t->arg0, "%s/%s", path, dirlist[i]->d_name) < 0)
303
 
                                        t->arg0 = (char*)0;
304
 
                        }
305
 
                        free(dirlist[i]);
306
 
                }
307
 
                free(dirlist);
308
 
        }
309
 
        /* deselect non-matching nodes */
310
 
        for (t = tree_list; t; t = next) {
311
 
                next = t->next;
312
 
                if ((! t->status && ! inverse) || (t->status && inverse)) {
313
 
                        /* remove from the list */
314
 
                        struct makelist *x, *nx;
315
 
                        struct makenode *p;
316
 
                        for (x = t->select; x; x = nx) {
317
 
                                nx = x->next;
318
 
                                x->node->num_deps--;
319
 
                                free(x);
320
 
                        }
321
 
                        for (x = t->depend; x; x = nx) {
322
 
                                nx = x->next;
323
 
                                x->node->num_sels--;
324
 
                                free(x);
325
 
                        }
326
 
                        if (t == tree_list)
327
 
                                tree_list = next;
328
 
                        else {
329
 
                                for (p = tree_list; p->next != t; p = p->next)
330
 
                                        ;
331
 
                                p->next = next;
332
 
                        }
333
 
                        /* don't free the node instance itself - it may be selected
334
 
                         * by others
335
 
                         */
336
 
                        tree_entries--;
337
 
                        continue;
338
 
                }
339
 
                t->status = 0;
340
 
        }
341
 
}
342
 
 
343
 
/*
344
 
 * mark the unnecessary services as finished.
345
 
 *
346
 
 * action is either boot, start or stop.
347
 
 * prev and run are the previous and the next runlevel.
348
 
 */
349
 
void check_run_files(const char *action, const char *prev, const char *run)
350
 
{
351
 
        char buf[4] = "rc0";
352
 
        if (! strcmp(action, "boot")) {
353
 
#ifdef SUSE     /* SuSE */
354
 
                filter_files("boot", 'S', 0);
355
 
        } else if (! strcmp(action, "halt")) {
356
 
                filter_files("boot", 'K', 0);
357
 
        } else if (! strcmp(action, "start")) {
358
 
                buf[2] = *prev;
359
 
                filter_files(buf, 'K', 1);
360
 
                buf[2] = *run;
361
 
                filter_files(buf, 'S', 0);
362
 
        } else {
363
 
                buf[2] = *prev;
364
 
                filter_files(buf, 'K', 0);
365
 
                buf[2] = *run;
366
 
                filter_files(buf, 'S', 1);
367
 
#else           /* Debian */
368
 
                filter_files("rcS", 'S', 0);
369
 
        } else if (! strcmp(action, "start")) {
370
 
                buf[2] = *prev;
371
 
                filter_files(buf, 'S', 1);
372
 
                buf[2] = *run;
373
 
                filter_files(buf, 'S', 0);
374
 
        } else {
375
 
                buf[2] = *prev;
376
 
                filter_files(buf, 'K', 1);
377
 
                buf[2] = *run;
378
 
                filter_files(buf, 'K', 0);
379
 
#endif
380
 
        }
381
 
}
382
 
 
383
 
 
384
 
/*
385
 
 * call blogger
386
 
 */
387
 
#if 0
388
 
static void blogger(char *fmt, ...)
389
 
{
390
 
        va_list ap;
391
 
        char buf[128];
392
 
        int len;
393
 
 
394
 
        strcpy(buf, "blogger \"");
395
 
        len = strlen(buf);
396
 
        va_start(ap, fmt);
397
 
        vsnprintf(buf + len, sizeof(buf) - len - 1, fmt, ap);
398
 
        strcat(buf, "\"");
399
 
        system(buf);
400
 
        va_end(ap);
401
 
}
402
 
#else
403
 
# define blogger(arg...)
404
 
#endif
405
 
 
406
 
 
407
 
/*
408
 
 * pick up the next running task
409
 
 * return NULL if not found.
410
 
 */
411
 
struct makenode *pickup_task(void)
412
 
{
413
 
        struct makenode *node, *best = (struct makenode*)0;
414
 
 
415
 
        for (node = tree_list; node; node = node->next) {
416
 
                if ((! node->status) && (! node->num_deps) &&
417
 
                    ((! best) || (node->importance > best->importance))) {
418
 
                        best = node;
419
 
                }
420
 
        }
421
 
        if (best) {
422
 
#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
423
 
                char path[128];
424
 
                int fd;
425
 
                snprintf(path, sizeof(path), "/etc/init.d/%s", best->name);
426
 
                if ((fd = open(path, o_flags|O_DIRECT)) >= 0) {
427
 
                        (void)posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED);
428
 
                        (void)posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
429
 
                        (void)posix_fadvise(fd, 0, 0, POSIX_FADV_NOREUSE);
430
 
                        close(fd);
431
 
                }
432
 
#endif
433
 
                blogger("service %s", best->name);
434
 
                best->status = T_RUNNING;
435
 
        }
436
 
        return best;
437
 
}
438
 
 
439
 
/*
440
 
 * finish the running task
441
 
 */
442
 
void finish_task(struct makenode *node)
443
 
{
444
 
        struct makelist *n;
445
 
 
446
 
        if (! node)
447
 
                return;
448
 
        for (n = node->select; n; n = n->next)
449
 
                n->node->num_deps--;
450
 
#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
451
 
        {
452
 
                char path[128];
453
 
                int fd;
454
 
                snprintf(path, sizeof(path), "/etc/init.d/%s", node->name);
455
 
                if ((fd = open(path, o_flags|O_DIRECT)) >= 0) {
456
 
                        (void)posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
457
 
                        close(fd);
458
 
                }
459
 
        }
460
 
#endif
461
 
        node->status = T_FINISHED;
462
 
        blogger("service %s done", node->name);
463
 
}
464
 
 
465
 
 
466
 
/*
467
 
 * Print out the status that bash can run eval.
468
 
 * The following things will be printed:
469
 
 * failed services, skipped services and the current progress value.
470
 
 */
471
 
void print_run_result(int *resvec, struct makenode **nodevec, const char *action)
472
 
{
473
 
        int i, r, stop = (! strcmp(action, "stop"));
474
 
 
475
 
        printf("failed_service=\"");
476
 
        i = r = 0;
477
 
        for (i = 0; i < tree_entries; i++) {
478
 
#if DEBUG
479
 
                if (resvec[i] == 255) {
480
 
                        fprintf(stderr, "ERROR: forgotten process??\n");
481
 
                        exit(1);
482
 
                }
483
 
#endif
484
 
                if (resvec[i] >= 1 && resvec[i] <= 4) {
485
 
                        if (r)
486
 
                                printf(" ");
487
 
                        printf("%s", nodevec[i]->name);
488
 
                        r++;
489
 
                } else if (!stop && resvec[i] == 7) {
490
 
                        if (r)
491
 
                                printf(" ");
492
 
                        printf("%s", nodevec[i]->name);
493
 
                        r++;
494
 
                }
495
 
        }
496
 
        printf("\"\n");
497
 
        printf("skipped_service=\"");
498
 
        i = r = 0;
499
 
        for (i = 0; i < tree_entries; i++) {
500
 
                if (resvec[i] == 5 || resvec[i] == 6) {
501
 
                        if (r)
502
 
                                printf(" ");
503
 
                        printf("%s", nodevec[i]->name);
504
 
                        r++;
505
 
                }
506
 
        }
507
 
        printf("\"\n");
508
 
}
509
 
 
510
 
#if DEBUG
511
 
void dump_status(void)
512
 
{
513
 
        struct makenode *node;
514
 
 
515
 
        for (node = tree_list; node; node = node->next)
516
 
                fprintf(stderr, "XXX %s: status = %d, dep = %d, int = %d, imp = %d\n",
517
 
                        node->name, node->status, node->num_deps, node->interactive, node->importance);
518
 
}
519
 
#endif
520
 
 
521
 
#ifdef TEST
522
 
void *xcalloc(size_t nmemb, size_t size)
523
 
{
524
 
        void *r;
525
 
        if ((r = (void *)calloc(nmemb, size)) == 0) {
526
 
                fprintf(stderr, "calloc: out of memory\n");
527
 
                exit(1);
528
 
        }
529
 
        return r;
530
 
}
531
 
 
532
 
int main(int argc, char **argv)
533
 
{
534
 
        struct makenode *nodevec;
535
 
        char makefile[64];
536
 
 
537
 
        if (argc != 4) {
538
 
                fprintf(stderr, "usage: makeboot <action> [<prev> <run>]\n");
539
 
                goto out;
540
 
        }
541
 
 
542
 
        snprintf(makefile, sizeof(makefile), "depend.%s", argv[1]);
543
 
        parse_makefile(makefile);
544
 
 
545
 
        fprintf(stderr, "check_run_files(%s, %s, %s)\n", argv[1], argv[2],
546
 
                argv[3]);
547
 
        check_run_files(argv[1], argv[2], argv[3]);
548
 
out:
549
 
        while ((nodevec = pickup_task())) {
550
 
                fprintf(stdout, "%s (%s)\n", nodevec->name, nodevec->arg0);
551
 
                finish_task(nodevec);
552
 
        }
553
 
 
554
 
        return 0;
555
 
}
556
 
#endif