3 * Copyright (c) 2000, Red Hat, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * A copy of the GNU General Public License can be found at
13 * Written by DJ Delorie <dj@cygnus.com>
17 /* Parse the setup.ini files. inilex.l provides the tokens for this. */
26 #include "filemanip.h"
28 extern "C" int yyerror (char *s, ...);
29 extern "C" int yylex ();
33 #define YYERROR_VERBOSE 1
38 extern unsigned int setup_timestamp;
39 extern char *setup_version;
42 #define cpt (cp->info+trust)
47 %token SETUP_TIMESTAMP SETUP_VERSION VERSION INSTALL SOURCE SDESC LDESC
48 %token CATEGORY REQUIRES
49 %token APATH PPATH INCLUDE_SETUP EXCLUDE_PACKAGE DOWNLOAD_URL
50 %token T_PREV T_CURR T_TEST T_UNKNOWN
55 : setup_headers packages
59 : setup_header setup_headers
64 : SETUP_TIMESTAMP STRING '\n' { setup_timestamp = strtoul ($2, 0, 0); }
65 | SETUP_VERSION STRING '\n' { setup_version = _strdup ($2); }
67 | error { yyerror ("unrecognized line in setup.ini headers (do you have the latest setup?)"); } '\n'
76 : '@' STRING '\n' { new_package($2); }
81 : simple_line '\n' lines
86 : VERSION STRING { cpt->version = $2; }
87 | SDESC STRING { cp->sdesc = $2; }
88 | LDESC STRING { cp->ldesc = $2; }
89 | CATEGORY STRING { cp->category = $2; }
91 | INSTALL STRING STRING { cpt->install = $2;
92 cpt->install_size = atoi($3);
96 if (parse_filename ($2, f))
97 cpt->version = strdup (f.ver);
100 | SOURCE STRING STRING { cpt->source = $2;
101 cpt->source_size = atoi($3); }
102 | T_PREV { trust = TRUST_PREV; }
103 | T_CURR { trust = TRUST_CURR; }
104 | T_TEST { trust = TRUST_TEST; }
105 | EXCLUDE_PACKAGE { cp->exclude = EXCLUDE_BY_SETUP; }
106 | T_UNKNOWN { trust = TRUST_UNKNOWN; }
108 | error '\n' { yylineno --;
109 yyerror ("unrecognized line in package %s (do you have the latest setup?)", cp->name);
115 : STRING { new_requirement(cp, $1); } requires
116 | STRING { new_requirement(cp, $1); }
121 Package *package = NULL;
123 static int maxpackages = 0;
126 new_package (char *name)
129 maxpackages = npackages = 0;
130 if (npackages >= maxpackages)
134 package = (Package *) realloc (package, (1 + maxpackages) * sizeof (Package));
136 package = (Package *) malloc ((1 + maxpackages) * sizeof (Package));
137 memset (package + npackages, 0, (1 + maxpackages - npackages) * sizeof (Package));
139 cp = getpkgbyname (name);
142 cp = package + npackages;
144 cp->name = strdup (name);
152 new_requirement(Package *package, char *dependson)
157 dp = (Dependency *) malloc (sizeof (Dependency));
158 dp->next = cp->required;
159 dp->package = dependson;