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();
52 void process_src (cygpackage *, packagesource &src, char *, char*, char* = 0);
56 %token SETUP_TIMESTAMP SETUP_VERSION PACKAGEVERSION 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
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 = new char [strlen($2) + 1];strcpy (setup_version, $2); }
77 | error { yyerror ("unrecognized line in setup.ini headers (do you have the latest setup?)"); } '\n'
86 : '@' STRING '\n' {packagedb db; cp = &db.packages.registerbykey($2); cpv = new cygpackage ($2); trust = TRUST_CURR;}
91 : simple_line '\n' lines
96 : PACKAGEVERSION 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 MD5 { process_src (cpv, cpv->bin, $2, $3, $4); }
103 | INSTALL STRING STRING { process_src (cpv, cpv->bin, $2, $3); }
104 | SOURCE STRING STRING MD5 { process_src (cpv, cpv->src, $2, $3, $4); }
105 | SOURCE STRING STRING { process_src (cpv, cpv->src, $2, $3); }
106 | T_PREV { trust = TRUST_PREV; cpv = new cygpackage (cp->name); }
107 | T_CURR { trust = TRUST_CURR; cpv = new cygpackage (cp->name); }
108 | T_TEST { trust = TRUST_TEST; cpv = new cygpackage (cp->name); }
109 | T_UNKNOWN { trust = TRUST_UNKNOWN; }
111 | error '\n' { yylineno --;
112 yyerror ("unrecognized line in package %s (do you have the latest setup?)", cp->name.cstr_oneuse());
118 : STRING { cpv->new_requirement($1); } requires
119 | STRING { cpv->new_requirement($1); }
123 : STRING { packagedb db; cp->add_category (db.categories.registerbykey ($1));
125 | STRING { packagedb db; cp->add_category (db.categories.registerbykey ($1)); }
131 add_correct_version()
134 for (size_t n = 1; !merged && n <= cp->versions.number (); n++)
135 if (!cp->versions[n]->Canonical_version().casecompare(cpv->Canonical_version()))
138 categories and requires are consistent for the same version across
141 /* Copy the binary mirror across if this site claims to have an install */
142 if (cpv->bin.sites.number ())
143 cp->versions[n]->bin.sites.registerbykey (cpv->bin.sites[1]->key);
145 if (cpv->src.sites.number ())
146 cp->versions[n]->src.sites.registerbykey (cpv->src.sites[1]->key);
147 /* Copy the descriptions across */
148 if (cpv->SDesc ().size() && !cp->versions[n]->SDesc ().size())
149 cp->versions[n]->set_sdesc (cpv->SDesc ());
150 if (cpv->LDesc ().size() && !cp->versions[n]->LDesc ().size())
151 cp->versions[n]->set_ldesc (cpv->LDesc ());
152 cpv = (cygpackage *)cp->versions[n];
156 cp->add_version (*cpv);
161 if (cp->currtimestamp < setup_timestamp)
163 cp->currtimestamp = setup_timestamp;
168 if (cp->prevtimestamp < setup_timestamp)
170 cp->prevtimestamp = setup_timestamp;
175 if (cp->exptimestamp < setup_timestamp)
177 cp->exptimestamp = setup_timestamp;
185 process_src (cygpackage *cpv, packagesource &src, char *path, char*size, char*md5 )
187 if (!cpv->Canonical_version ().size())
190 if (parse_filename (path, f))
192 cpv->set_canonical_version (f.ver);
193 add_correct_version ();
199 src.size = atoi(size);
200 src.set_canonical (path);
202 if (md5 && !src.md5.isSet())
203 src.md5.set((unsigned char *)md5);
204 src.sites.registerbykey (parse_mirror);