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"
28 #include "filemanip.h"
30 extern "C" int yyerror (char const *s, ...);
31 extern "C" int yylex ();
35 #include "package_meta.h"
36 #include "package_version.h"
37 #include "cygpackage.h"
39 #define YYERROR_VERBOSE 1
42 static packagemeta *cp = 0;
43 extern unsigned int setup_timestamp;
44 extern char *setup_version;
47 char * parse_mirror = 0;
49 static cygpackage *cpv = 0;
52 void add_correct_version();
56 %token SETUP_TIMESTAMP SETUP_VERSION VERSION INSTALL SOURCE SDESC LDESC
57 %token CATEGORY REQUIRES
58 %token APATH PPATH INCLUDE_SETUP EXCLUDE_PACKAGE DOWNLOAD_URL
59 %token T_PREV T_CURR T_TEST T_UNKNOWN
64 : setup_headers packages
68 : setup_header setup_headers
73 : SETUP_TIMESTAMP STRING '\n' { setup_timestamp = strtoul ($2, 0, 0); }
74 | SETUP_VERSION STRING '\n' { setup_version = _strdup ($2); }
76 | error { yyerror ("unrecognized line in setup.ini headers (do you have the latest setup?)"); } '\n'
85 : '@' STRING '\n' { cp = &db.registerpackage($2); cpv = new cygpackage ($2); trust = TRUST_CURR;}
90 : simple_line '\n' lines
95 : VERSION STRING { cpv->set_canonical_version ($2);
96 add_correct_version ();}
97 | SDESC STRING { cpv->set_sdesc ($2); }
98 | LDESC STRING { cpv->set_ldesc ($2); }
101 | INSTALL STRING STRING { if (!cpv->Canonical_version ())
104 if (parse_filename ($2, f))
106 cpv->set_canonical_version (f.ver);
107 add_correct_version ();
113 cpv->bin.size = atoi($3);
114 cpv->bin.set_canonical ($2);
116 cpv->bin.sites.registerbykey (parse_mirror);
118 | SOURCE STRING STRING { if (!cpv->src.size)
120 cpv->src.size = atoi($3);
121 cpv->src.set_canonical ($2);
123 cpv->src.sites.registerbykey (parse_mirror); }
124 | T_PREV { trust = TRUST_PREV; cpv = new cygpackage (cp->name); }
125 | T_CURR { trust = TRUST_CURR; cpv = new cygpackage (cp->name); }
126 | T_TEST { trust = TRUST_TEST; cpv = new cygpackage (cp->name); }
127 | T_UNKNOWN { trust = TRUST_UNKNOWN; }
129 | error '\n' { yylineno --;
130 yyerror ("unrecognized line in package %s (do you have the latest setup?)", cp->name);
136 : STRING { cpv->new_requirement($1); } requires
137 | STRING { cpv->new_requirement($1); }
141 : STRING { cp->add_category (db.categories.registerbykey ($1));
143 | STRING { cp->add_category (db.categories.registerbykey ($1)); }
149 add_correct_version()
152 for (size_t n = 1; !merged && n <= cp->versions.number (); n++)
153 if (!strcasecmp(cp->versions.getnth(n)->Canonical_version(), cpv->Canonical_version()))
156 categories and requires are consistent for the same version across
159 /* Copy the binary mirror across if this site claims to have an install */
160 if (cpv->bin.sites.number ())
161 cp->versions.getnth(n)->bin.sites.registerbykey (cpv->bin.sites.getnth(1)->key);
163 if (cpv->src.sites.number ())
164 cp->versions.getnth(n)->src.sites.registerbykey (cpv->src.sites.getnth(1)->key);
165 cpv = (cygpackage *)cp->versions.getnth (n);
169 cp->add_version (*cpv);
174 if (cp->currtimestamp < setup_timestamp)
176 cp->currtimestamp = setup_timestamp;
181 if (cp->prevtimestamp < setup_timestamp)
183 cp->prevtimestamp = setup_timestamp;
188 if (cp->exptimestamp < setup_timestamp)
190 cp->exptimestamp = setup_timestamp;