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. */
22 #include "iniparse.hh"
23 #include "PackageTrust.h"
25 extern int yyerror (const std::string& s);
28 #include "IniDBBuilder.h"
30 #define YYERROR_VERBOSE 1
31 #define YYINITDEPTH 1000
34 IniDBBuilder *iniBuilder;
37 void add_correct_version();
41 %token SETUP_TIMESTAMP SETUP_VERSION PACKAGEVERSION INSTALL SOURCE SDESC LDESC
42 %token CATEGORY DEPENDS REQUIRES
43 %token APATH PPATH INCLUDE_SETUP EXCLUDE_PACKAGE DOWNLOAD_URL
44 %token T_PREV T_CURR T_TEST
45 %token SHA512 MD5 INSTALLEDSIZE MAINTAINER PRIORITY
46 %token DESCTAG DESCRIPTION FILESIZE ARCHITECTURE SOURCEPACKAGE MD5LINE
47 %token RECOMMENDS PREDEPENDS
48 %token SUGGESTS CONFLICTS REPLACES PROVIDES PACKAGENAME STRTOEOL PARAGRAPH
49 %token EMAIL COMMA OR NL AT
50 %token OPENBRACE CLOSEBRACE EQUAL GT LT GTEQUAL LTEQUAL
51 %token OPENSQUARE CLOSESQUARE
52 %token BINARYPACKAGE BUILDDEPENDS STANDARDSVERSION FORMAT DIRECTORY FILES
53 %token MESSAGE AUTODEP
59 : setup_headers packageseparator packages
62 setup_headers: /* empty */
63 | setup_headers header
66 header /* non-empty */
67 : SETUP_TIMESTAMP STRING { iniBuilder->buildTimestamp ($2); } NL
68 | SETUP_VERSION STRING { iniBuilder->buildVersion ($2); } NL
69 | RELEASE STRING { iniBuilder->set_release ($2); } NL
70 | ARCH STRING { iniBuilder->set_arch ($2); } NL
74 | packages package packageseparator
77 packageseparator: /* empty */
81 package /* non-empty */
82 : packagename NL packagedata
85 packagename /* non-empty */
86 : AT STRING { iniBuilder->buildPackage ($2); }
87 | PACKAGENAME STRING { iniBuilder->buildPackage ($2); }
90 packagedata: /* empty */
91 | packagedata singleitem
94 singleitem /* non-empty */
95 : PACKAGEVERSION STRING NL { iniBuilder->buildPackageVersion ($2); }
96 | SDESC STRING NL { iniBuilder->buildPackageSDesc($2); }
97 | LDESC STRING NL { iniBuilder->buildPackageLDesc($2); }
98 | T_PREV NL { iniBuilder->buildPackageTrust (TRUST_PREV); }
99 | T_CURR NL { iniBuilder->buildPackageTrust (TRUST_CURR); }
100 | T_TEST NL { iniBuilder->buildPackageTrust (TRUST_TEST); }
101 | PRIORITY STRING NL { iniBuilder->buildPriority ($2); }
102 | INSTALLEDSIZE STRING NL { iniBuilder->buildInstalledSize ($2); }
103 | MAINTAINER STRING NL { iniBuilder->buildMaintainer ($2); }
104 | ARCHITECTURE packagearchspec NL { iniBuilder->buildArchitecture ($2); }
105 | FILESIZE STRING NL { iniBuilder->buildInstallSize($2); }
106 | FORMAT STRING NL { /* TODO */ }
107 | DIRECTORY STRING NL { /* TODO */ }
108 | STANDARDSVERSION STRING NL { /* TODO */ }
109 | MD5LINE MD5 NL { iniBuilder->buildInstallMD5 ((unsigned char *)$2); }
110 | SOURCEPACKAGE source NL
111 | CATEGORY categories NL
112 | INSTALL STRING { iniBuilder->buildPackageInstall ($2); } installmeta NL
113 | SOURCE STRING STRING sourcechksum NL {iniBuilder->buildPackageSource ($2, $3);}
114 | PROVIDES { iniBuilder->buildBeginProvides(); } packagelist NL
115 | BINARYPACKAGE { iniBuilder->buildBeginBinary (); } packagelist NL
116 | CONFLICTS { iniBuilder->buildBeginConflicts(); } versionedpackagelist NL
117 | DEPENDS { iniBuilder->buildBeginDepends(); } versionedpackagelist NL
118 | REQUIRES { iniBuilder->buildBeginDepends(); } versionedpackagelistsp NL
119 | PREDEPENDS { iniBuilder->buildBeginPreDepends(); } versionedpackagelist NL
120 | RECOMMENDS { iniBuilder->buildBeginRecommends(); } versionedpackagelist NL
121 | SUGGESTS { iniBuilder->buildBeginSuggests(); } versionedpackagelist NL
122 | REPLACES { iniBuilder->buildBeginReplaces(); } versionedpackagelist NL
123 | BUILDDEPENDS { iniBuilder->buildBeginBuildDepends(); } versionedpackagelist NL
124 | FILES NL SourceFilesList
125 | MESSAGE STRING STRING NL { iniBuilder->buildMessage ($2, $3); }
126 | AUTODEP STRING STRING NL { iniBuilder->autodep ($2, $3); }
128 | error { yyerror (std::string("unrecognized line ")
129 + stringify(yylineno)
130 + " (do you have the latest setup?)");
134 packagearchspec: /* empty */
135 | packagearchspec STRING { iniBuilder->buildArchitecture ($2); }
138 categories: /* empty */
139 | categories STRING { iniBuilder->buildPackageCategory ($2); }
142 installmeta: /* empty */
143 | STRING installchksum { iniBuilder->buildInstallSize($1); }
146 installchksum: /* empty */
147 | MD5 { iniBuilder->buildInstallMD5 ((unsigned char *)$1);}
148 | SHA512 { iniBuilder->buildInstallSHA512 ((unsigned char *)$1);}
151 sourcechksum: /* empty */
152 | MD5 { iniBuilder->buildSourceMD5 ((unsigned char *)$1); }
153 | SHA512 { iniBuilder->buildSourceSHA512 ((unsigned char *)$1); }
156 source /* non-empty */
157 : STRING { iniBuilder->buildSourceName ($1); } versioninfo
160 versioninfo: /* empty */
161 | OPENBRACE STRING CLOSEBRACE { iniBuilder->buildSourceNameVersion ($2); }
164 mlinedesc: /* empty */
165 | mlinedesc STRTOEOL NL { iniBuilder->buildDescription ($2); }
166 | mlinedesc STRTOEOL PARAGRAPH { iniBuilder->buildDescription ($2); }
169 packagelist /* non-empty */
170 : packagelist COMMA { iniBuilder->buildPackageListAndNode(); } packageentry
171 | { iniBuilder->buildPackageListAndNode(); } packageentry
174 packageentry /* empty not allowed */
175 : STRING { iniBuilder->buildPackageListOrNode($1); }
176 | packageentry OR STRING { iniBuilder->buildPackageListOrNode($3); }
179 versionedpackagelist /* non-empty */
180 : { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
181 | versionedpackagelist listseparator { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
184 versionedpackagelistsp /* non-empty */
185 : { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
186 | versionedpackagelistsp { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
190 listseparator: /* empty */
195 versionedpackageentry /* empty not allowed */
196 : STRING { iniBuilder->buildPackageListOrNode($1); } versioncriteria architecture
197 | versionedpackageentry OR STRING { iniBuilder->buildPackageListOrNode($3); } versioncriteria architecture
200 versioncriteria: /* empty */
201 | OPENBRACE operator STRING CLOSEBRACE { iniBuilder->buildPackageListOperatorVersion ($3); }
204 operator /* non-empty */
205 : EQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::Equals); }
206 | LT { iniBuilder->buildPackageListOperator (PackageSpecification::LessThan); }
207 | GT { iniBuilder->buildPackageListOperator (PackageSpecification::MoreThan); }
208 | LTEQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::LessThanEquals); }
209 | GTEQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::MoreThanEquals); }
212 architecture: /* empty */
213 | OPENSQUARE architecturelist CLOSESQUARE
216 architecturelist: /* empty */
217 | architecturelist STRING
221 SourceFilesList: /* empty */
222 | SourceFilesList MD5 STRING STRING { iniBuilder->buildSourceFile ((unsigned char *)$2, $3, $4); } NL