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. */
24 #include "package_db.h"
26 #include "category_list.h"
29 #include "filemanip.h"
31 extern "C" int yyerror (char const *s, ...);
32 extern "C" int yylex ();
36 #include "package_meta.h"
37 #include "package_version.h"
38 #include "cygpackage.h"
40 #define YYERROR_VERBOSE 1
43 static packagemeta *cp = 0;
44 extern unsigned int setup_timestamp;
45 extern char *setup_version;
48 char * parse_mirror = 0;
50 static cygpackage *cpv = 0;
53 void add_correct_version();
57 %token SETUP_TIMESTAMP SETUP_VERSION VERSION INSTALL SOURCE SDESC LDESC
58 %token CATEGORY REQUIRES
59 %token APATH PPATH INCLUDE_SETUP EXCLUDE_PACKAGE DOWNLOAD_URL
60 %token T_PREV T_CURR T_TEST T_UNKNOWN
65 : setup_headers packages
69 : setup_header setup_headers
74 : SETUP_TIMESTAMP STRING '\n' { setup_timestamp = strtoul ($2, 0, 0); }
75 | SETUP_VERSION STRING '\n' { setup_version = _strdup ($2); }
77 | error { yyerror ("unrecognized line in setup.ini headers (do you have the latest setup?)"); } '\n'
86 : '@' STRING '\n' { cp = &db.registerpackage($2); cpv = new cygpackage ($2); trust = TRUST_CURR;}
91 : simple_line '\n' lines
96 : VERSION STRING { cpv->set_canonical_version ($2);
97 add_correct_version ();}
98 | SDESC STRING { cpv->set_sdesc ($2); }
99 | LDESC STRING { cpv->set_ldesc ($2); }
100 | CATEGORY categories
102 | INSTALL STRING STRING { if (!cpv->Canonical_version ())
105 if (parse_filename ($2, f))
107 cpv->set_canonical_version (f.ver);
108 add_correct_version ();
114 cpv->bin.size = atoi($3);
115 cpv->bin.set_canonical ($2);
117 cpv->bin.sites.registerbykey (parse_mirror);
119 | SOURCE STRING STRING { if (!cpv->src.size)
121 cpv->src.size = atoi($3);
122 cpv->src.set_canonical ($2);
124 cpv->src.sites.registerbykey (parse_mirror); }
125 | T_PREV { trust = TRUST_PREV; cpv = new cygpackage (cp->name); }
126 | T_CURR { trust = TRUST_CURR; cpv = new cygpackage (cp->name); }
127 | T_TEST { trust = TRUST_TEST; cpv = new cygpackage (cp->name); }
128 | T_UNKNOWN { trust = TRUST_UNKNOWN; }
130 | error '\n' { yylineno --;
131 yyerror ("unrecognized line in package %s (do you have the latest setup?)", cp->name);
137 : STRING { cpv->new_requirement($1); } requires
138 | STRING { cpv->new_requirement($1); }
142 : STRING { cp->add_category (db.categories.register_category ($1));
144 | STRING { cp->add_category (db.categories.register_category ($1)); }
150 add_correct_version()
153 for (size_t n = 1; !merged && n <= cp->versions.number (); n++)
154 if (!strcasecmp(cp->versions.getnth(n)->Canonical_version(), cpv->Canonical_version()))
157 categories and requires are consistent for the same version across
160 /* Copy the binary mirror across if this site claims to have an install */
161 if (cpv->bin.sites.number ())
162 cp->versions.getnth(n)->bin.sites.registerbykey (cpv->bin.sites.getnth(1)->key);
164 if (cpv->src.sites.number ())
165 cp->versions.getnth(n)->src.sites.registerbykey (cpv->src.sites.getnth(1)->key);
166 cpv = (cygpackage *)cp->versions.getnth (n);
170 cp->add_version (*cpv);
175 if (cp->currtimestamp < setup_timestamp)
177 cp->currtimestamp = setup_timestamp;
182 if (cp->prevtimestamp < setup_timestamp)
184 cp->prevtimestamp = setup_timestamp;
189 if (cp->exptimestamp < setup_timestamp)
191 cp->exptimestamp = setup_timestamp;