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, ...);
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;
48 static cygpackage *cpv = 0;
51 void add_correct_version();
55 %token SETUP_TIMESTAMP SETUP_VERSION VERSION INSTALL SOURCE SDESC LDESC
56 %token CATEGORY REQUIRES
57 %token APATH PPATH INCLUDE_SETUP EXCLUDE_PACKAGE DOWNLOAD_URL
58 %token T_PREV T_CURR T_TEST T_UNKNOWN
63 : setup_headers packages
67 : setup_header setup_headers
72 : SETUP_TIMESTAMP STRING '\n' { setup_timestamp = strtoul ($2, 0, 0); }
73 | SETUP_VERSION STRING '\n' { setup_version = new char [strlen($2) + 1];strcpy (setup_version, $2); }
75 | error { yyerror ("unrecognized line in setup.ini headers (do you have the latest setup?)"); } '\n'
84 : '@' STRING '\n' {packagedb db; cp = &db.packages.registerbykey($2); cpv = new cygpackage ($2); trust = TRUST_CURR;}
89 : simple_line '\n' lines
94 : VERSION STRING { cpv->set_canonical_version ($2);
95 add_correct_version ();}
96 | SDESC STRING { cpv->set_sdesc ($2); }
97 | LDESC STRING { cpv->set_ldesc ($2); }
100 | INSTALL STRING STRING { if (!cpv->Canonical_version ())
103 if (parse_filename ($2, f))
105 cpv->set_canonical_version (f.ver);
106 add_correct_version ();
112 cpv->bin.size = atoi($3);
113 cpv->bin.set_canonical ($2);
115 cpv->bin.sites.registerbykey (parse_mirror);
117 | SOURCE STRING STRING { if (!cpv->src.size)
119 cpv->src.size = atoi($3);
120 cpv->src.set_canonical ($2);
122 cpv->src.sites.registerbykey (parse_mirror); }
123 | T_PREV { trust = TRUST_PREV; cpv = new cygpackage (cp->name); }
124 | T_CURR { trust = TRUST_CURR; cpv = new cygpackage (cp->name); }
125 | T_TEST { trust = TRUST_TEST; cpv = new cygpackage (cp->name); }
126 | T_UNKNOWN { trust = TRUST_UNKNOWN; }
128 | error '\n' { yylineno --;
129 yyerror ("unrecognized line in package %s (do you have the latest setup?)", cp->name);
135 : STRING { cpv->new_requirement($1); } requires
136 | STRING { cpv->new_requirement($1); }
140 : STRING { packagedb db; cp->add_category (db.categories.registerbykey ($1));
142 | STRING { packagedb db; cp->add_category (db.categories.registerbykey ($1)); }
148 add_correct_version()
151 for (size_t n = 1; !merged && n <= cp->versions.number (); n++)
152 if (!strcasecmp(cp->versions[n]->Canonical_version(), cpv->Canonical_version()))
155 categories and requires are consistent for the same version across
158 /* Copy the binary mirror across if this site claims to have an install */
159 if (cpv->bin.sites.number ())
160 cp->versions[n]->bin.sites.registerbykey (cpv->bin.sites[1]->key);
162 if (cpv->src.sites.number ())
163 cp->versions[n]->src.sites.registerbykey (cpv->src.sites[1]->key);
164 /* Copy the descriptions across */
165 if (cpv->SDesc () && !cp->versions[n]->SDesc ())
166 cp->versions[n]->set_sdesc (cpv->SDesc ());
167 if (cpv->LDesc () && !cp->versions[n]->LDesc ())
168 cp->versions[n]->set_ldesc (cpv->LDesc ());
169 cpv = (cygpackage *)cp->versions[n];
173 cp->add_version (*cpv);
178 if (cp->currtimestamp < setup_timestamp)
180 cp->currtimestamp = setup_timestamp;
185 if (cp->prevtimestamp < setup_timestamp)
187 cp->prevtimestamp = setup_timestamp;
192 if (cp->exptimestamp < setup_timestamp)
194 cp->exptimestamp = setup_timestamp;