extract.c revision 328
1#ifndef lint
2static const char *rcsid = "$Id: extract.c,v 1.4 1993/08/24 09:23:14 jkh Exp $";
3#endif
4
5/*
6 * FreeBSD install - a package for the installation and maintainance
7 * of non-core utilities.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * Jordan K. Hubbard
19 * 18 July 1993
20 *
21 * This is the package extraction code for the add module.
22 *
23 */
24
25#include "lib.h"
26#include "add.h"
27
28void
29extract_plist(char *home, Package *pkg)
30{
31    PackingList p = pkg->head;
32    char *last_file;
33
34    /* Reset the world */
35    Owner = NULL;
36    Group = NULL;
37    Mode = NULL;
38    last_file = NULL;
39    Directory = home;
40
41    /* Do it */
42    while (p) {
43	switch(p->type) {
44	case PLIST_NAME:
45	    PkgName = p->name;
46	    if (Verbose)
47		printf("extract: Package name is %s\n", p->name);
48	    break;
49
50	case PLIST_FILE:
51	    last_file = p->name;
52	    if (Verbose)
53		printf("extract: %s/%s\n", Directory, p->name);
54	    if (!Fake) {
55		copy_hierarchy(Directory, p->name, TRUE);
56		apply_perms(Directory, p->name);
57	    }
58	    break;
59
60	case PLIST_CWD:
61	    if (Verbose)
62		printf("extract: CWD to %s\n", p->name);
63	    if (strcmp(p->name, ".")) {
64		if (!Fake && make_hierarchy(p->name) == FAIL)
65		    barf("Unable make directory '%s'.", p->name);
66		Directory = p->name;
67	    }
68	    else
69		Directory = home;
70	    break;
71
72	case PLIST_CMD:
73	    if (Verbose)
74		printf("extract: exec cmd '%s' (lastfile = %s)\n", p->name,
75		       last_file);
76	    if (!Fake && vsystem(p->name, last_file))
77		whinge("Command '%s' failed.", p->name);
78	    break;
79
80	case PLIST_CHMOD:
81	    Mode = p->name;
82	    break;
83
84	case PLIST_CHOWN:
85	    Owner = p->name;
86	    break;
87
88	case PLIST_CHGRP:
89	    Group = p->name;
90	    break;
91
92	case PLIST_COMMENT:
93	    break;
94
95	case PLIST_IGNORE:
96	    p = p->next;
97	    break;
98	}
99	p = p->next;
100    }
101}
102