]>
Commit | Line | Data |
---|---|---|
23c9e63c DD |
1 | %{ |
2 | /* | |
3 | * Copyright (c) 2000, Red Hat, Inc. | |
4 | * | |
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. | |
9 | * | |
10 | * A copy of the GNU General Public License can be found at | |
11 | * http://www.gnu.org/ | |
12 | * | |
13 | * Written by DJ Delorie <dj@cygnus.com> | |
14 | * | |
15 | */ | |
16 | ||
17 | /* Parse the setup.ini files. inilex.l provides the tokens for this. */ | |
18 | ||
b11b49f3 | 19 | #include <stdio.h> |
23c9e63c | 20 | #include <stdlib.h> |
cb2a4b55 | 21 | #include <string.h> |
23c9e63c | 22 | |
55e204f6 | 23 | #include "win32.h" |
7b606ae5 RC |
24 | #include "package_db.h" |
25 | #include "category.h" | |
23c9e63c DD |
26 | #include "ini.h" |
27 | #include "iniparse.h" | |
0af2d779 CF |
28 | #include "filemanip.h" |
29 | ||
6391823e | 30 | extern int yyerror (String const &s); |
341988b9 | 31 | int yylex (); |
23c9e63c | 32 | |
13d27274 DD |
33 | #include "port.h" |
34 | ||
bb849dbd RC |
35 | #include "package_meta.h" |
36 | #include "package_version.h" | |
37 | #include "cygpackage.h" | |
b92028a4 | 38 | #include "IniState.h" |
bb849dbd | 39 | |
b11b49f3 DD |
40 | #define YYERROR_VERBOSE 1 |
41 | /*#define YYDEBUG 1*/ | |
42 | ||
bb849dbd | 43 | static packagemeta *cp = 0; |
b92028a4 | 44 | extern IniState *parseState; |
b11b49f3 | 45 | extern int yylineno; |
23c9e63c | 46 | |
bb849dbd | 47 | char * parse_mirror = 0; |
bb849dbd RC |
48 | static cygpackage *cpv = 0; |
49 | static int trust; | |
23c9e63c | 50 | |
bb849dbd | 51 | void add_correct_version(); |
58ee6135 | 52 | void process_src (cygpackage *, packagesource &src, char *, char*, char* = 0); |
23c9e63c DD |
53 | %} |
54 | ||
55 | %token STRING | |
f6100b6f | 56 | %token SETUP_TIMESTAMP SETUP_VERSION PACKAGEVERSION INSTALL SOURCE SDESC LDESC |
38c97581 | 57 | %token CATEGORY REQUIRES |
c46a33a9 | 58 | %token APATH PPATH INCLUDE_SETUP EXCLUDE_PACKAGE DOWNLOAD_URL |
b11b49f3 | 59 | %token T_PREV T_CURR T_TEST T_UNKNOWN |
58ee6135 | 60 | %token MD5 |
23c9e63c DD |
61 | |
62 | %% | |
63 | ||
64 | whole_file | |
65 | : setup_headers packages | |
66 | ; | |
67 | ||
68 | setup_headers | |
69 | : setup_header setup_headers | |
70 | | /* empty */ | |
71 | ; | |
72 | ||
73 | setup_header | |
b92028a4 RC |
74 | : SETUP_TIMESTAMP STRING '\n' { parseState->timestamp = strtoul ($2, 0, 0); } |
75 | | SETUP_VERSION STRING '\n' { parseState->version = $2; } | |
89725f30 | 76 | | '\n' |
13d27274 | 77 | | error { yyerror ("unrecognized line in setup.ini headers (do you have the latest setup?)"); } '\n' |
23c9e63c DD |
78 | ; |
79 | ||
80 | packages | |
81 | : package packages | |
82 | | /* empty */ | |
83 | ; | |
84 | ||
85 | package | |
5e0464a1 | 86 | : '@' STRING '\n' {packagedb db; cp = &db.packages.registerbykey($2); cpv = new cygpackage ($2); trust = TRUST_CURR;} |
23c9e63c | 87 | lines |
23c9e63c DD |
88 | ; |
89 | ||
90 | lines | |
91 | : simple_line '\n' lines | |
92 | | simple_line | |
93 | ; | |
94 | ||
95 | simple_line | |
f6100b6f | 96 | : PACKAGEVERSION STRING { cpv->set_canonical_version ($2); |
bb849dbd RC |
97 | add_correct_version ();} |
98 | | SDESC STRING { cpv->set_sdesc ($2); } | |
99 | | LDESC STRING { cpv->set_ldesc ($2); } | |
8f53e82a | 100 | | CATEGORY categories |
38c97581 | 101 | | REQUIRES requires |
58ee6135 RC |
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); } | |
bb849dbd RC |
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); } | |
b11b49f3 | 109 | | T_UNKNOWN { trust = TRUST_UNKNOWN; } |
23c9e63c | 110 | | /* empty */ |
b11b49f3 | 111 | | error '\n' { yylineno --; |
6391823e | 112 | yyerror (String("unrecognized line in package ") + cp->name + " (do you have the latest setup?)"); |
b11b49f3 DD |
113 | yylineno ++; |
114 | } | |
23c9e63c DD |
115 | ; |
116 | ||
38c97581 | 117 | requires |
bb849dbd RC |
118 | : STRING { cpv->new_requirement($1); } requires |
119 | | STRING { cpv->new_requirement($1); } | |
38c97581 CF |
120 | ; |
121 | ||
8f53e82a | 122 | categories |
5e0464a1 | 123 | : STRING { packagedb db; cp->add_category (db.categories.registerbykey ($1)); |
8f53e82a | 124 | } categories |
5e0464a1 | 125 | | STRING { packagedb db; cp->add_category (db.categories.registerbykey ($1)); } |
8f53e82a RC |
126 | ; |
127 | ||
23c9e63c DD |
128 | %% |
129 | ||
bb849dbd RC |
130 | void |
131 | add_correct_version() | |
23c9e63c | 132 | { |
bcf20115 RC |
133 | int merged = 0; |
134 | for (size_t n = 1; !merged && n <= cp->versions.number (); n++) | |
3c054baf | 135 | if (!cp->versions[n]->Canonical_version().casecompare(cpv->Canonical_version())) |
bb849dbd RC |
136 | { |
137 | /* ASSUMPTIONS: | |
138 | categories and requires are consistent for the same version across | |
139 | all mirrors | |
140 | */ | |
141 | /* Copy the binary mirror across if this site claims to have an install */ | |
142 | if (cpv->bin.sites.number ()) | |
341988b9 | 143 | cp->versions[n]->bin.sites.registerbykey (cpv->bin.sites[1]->key); |
bb849dbd RC |
144 | /* Ditto for src */ |
145 | if (cpv->src.sites.number ()) | |
341988b9 | 146 | cp->versions[n]->src.sites.registerbykey (cpv->src.sites[1]->key); |
bcf20115 | 147 | /* Copy the descriptions across */ |
3c054baf | 148 | if (cpv->SDesc ().size() && !cp->versions[n]->SDesc ().size()) |
bcf20115 | 149 | cp->versions[n]->set_sdesc (cpv->SDesc ()); |
3c054baf | 150 | if (cpv->LDesc ().size() && !cp->versions[n]->LDesc ().size()) |
bcf20115 | 151 | cp->versions[n]->set_ldesc (cpv->LDesc ()); |
341988b9 | 152 | cpv = (cygpackage *)cp->versions[n]; |
bb849dbd RC |
153 | merged = 1; |
154 | } | |
155 | if (!merged) | |
156 | cp->add_version (*cpv); | |
157 | /* trust setting */ | |
158 | switch (trust) | |
159 | { | |
160 | case TRUST_CURR: | |
b92028a4 | 161 | if (cp->currtimestamp < parseState->timestamp) |
bb849dbd | 162 | { |
b92028a4 | 163 | cp->currtimestamp = parseState->timestamp; |
bb849dbd RC |
164 | cp->curr = cpv; |
165 | } | |
166 | break; | |
167 | case TRUST_PREV: | |
b92028a4 | 168 | if (cp->prevtimestamp < parseState->timestamp) |
23c9e63c | 169 | { |
b92028a4 | 170 | cp->prevtimestamp = parseState->timestamp; |
bb849dbd | 171 | cp->prev = cpv; |
c46a33a9 | 172 | } |
bb849dbd RC |
173 | break; |
174 | case TRUST_TEST: | |
b92028a4 | 175 | if (cp->exptimestamp < parseState->timestamp) |
c46a33a9 | 176 | { |
b92028a4 | 177 | cp->exptimestamp = parseState->timestamp; |
bb849dbd | 178 | cp->exp = cpv; |
23c9e63c | 179 | } |
bb849dbd RC |
180 | break; |
181 | } | |
8f53e82a | 182 | } |
58ee6135 RC |
183 | |
184 | void | |
185 | process_src (cygpackage *cpv, packagesource &src, char *path, char*size, char*md5 ) | |
186 | { | |
187 | if (!cpv->Canonical_version ().size()) | |
188 | { | |
189 | fileparse f; | |
190 | if (parse_filename (path, f)) | |
191 | { | |
192 | cpv->set_canonical_version (f.ver); | |
193 | add_correct_version (); | |
194 | } | |
195 | } | |
196 | ||
197 | if (!src.size) | |
198 | { | |
199 | src.size = atoi(size); | |
200 | src.set_canonical (path); | |
201 | } | |
202 | if (md5 && !src.md5.isSet()) | |
203 | src.md5.set((unsigned char *)md5); | |
204 | src.sites.registerbykey (parse_mirror); | |
205 | } |