Yet more url ripping - buildroot is never an url
[platform/upstream/rpm.git] / build / rpmspec.h
1 #ifndef _H_SPEC_
2 #define _H_SPEC_
3
4 /** \ingroup rpmbuild
5  * \file build/rpmspec.h
6  *  The rpmSpec and Package data structures used during build.
7  */
8
9 #include <rpm/rpmstring.h>      /* StringBuf */
10 #include <rpm/rpmcli.h> /* for QVA_t */
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /** \ingroup rpmbuild
17  */
18 typedef struct Package_s * Package;
19
20 /** \ingroup rpmbuild
21  */
22 struct TriggerFileEntry {
23     int index;
24 char * fileName;
25 char * script;
26 char * prog;
27 struct TriggerFileEntry * next;
28 };
29
30 #define RPMBUILD_ISSOURCE       (1 << 0)
31 #define RPMBUILD_ISPATCH        (1 << 1)
32 #define RPMBUILD_ISICON         (1 << 2)
33 #define RPMBUILD_ISNO           (1 << 3)
34
35 #define RPMBUILD_DEFAULT_LANG "C"
36
37 /** \ingroup rpmbuild
38  */
39 struct Source {
40 char * fullSource;
41 char * source;     /* Pointer into fullSource */
42     int flags;
43     int num;
44 struct Source * next;
45 };
46
47 /** \ingroup rpmbuild
48  */
49 typedef struct ReadLevelEntry {
50     int reading;
51     struct ReadLevelEntry * next;
52 } RLE_t;
53
54 /** \ingroup rpmbuild
55  */
56 typedef struct OpenFileInfo {
57     char * fileName;
58     FD_t fd;
59     int lineNum;
60     char readBuf[BUFSIZ];
61     char * readPtr;
62     struct OpenFileInfo * next;
63 } OFI_t;
64
65 /** \ingroup rpmbuild
66  */
67 typedef struct spectag_s {
68     int t_tag;
69     int t_startx;
70     int t_nlines;
71     char * t_lang;
72     char * t_msgid;
73 } * spectag;
74
75 /** \ingroup rpmbuild
76  */
77 typedef struct spectags_s {
78 spectag st_t;
79     int st_nalloc;
80     int st_ntags;
81 } * spectags;
82
83 /** \ingroup rpmbuild
84  */
85 typedef struct speclines_s {
86 char **sl_lines;
87     int sl_nalloc;
88     int sl_nlines;
89 } * speclines;
90
91 /** \ingroup rpmbuild
92  * The structure used to store values parsed from a spec file.
93  */
94 struct rpmSpec_s {
95     char * specFile;    /*!< Name of the spec file. */
96     char * buildRoot;
97     char * buildSubdir;
98     char * rootDir;
99
100     speclines sl;
101     spectags st;
102
103     struct OpenFileInfo * fileStack;
104     char lbuf[10*BUFSIZ];
105     char *lbufPtr;
106     char nextpeekc;
107     char * nextline;
108     char * line;
109     int lineNum;
110
111     struct ReadLevelEntry * readStack;
112
113     Header buildRestrictions;
114     rpmSpec * BASpecs;
115     const char ** BANames;
116     int BACount;
117     int recursing;              /*!< parse is recursive? */
118
119     int force;
120     int anyarch;
121
122     int gotBuildRoot;
123
124     char * passPhrase;
125     int timeCheck;
126     char * cookie;
127
128     struct Source * sources;
129     int numSources;
130     int noSource;
131
132     char * sourceRpmName;
133     unsigned char * sourcePkgId;
134     Header sourceHeader;
135     rpmfi sourceCpioList;
136
137     rpmMacroContext macros;
138
139     StringBuf prep;             /*!< %prep scriptlet. */
140     StringBuf build;            /*!< %build scriptlet. */
141     StringBuf install;          /*!< %install scriptlet. */
142     StringBuf check;            /*!< %check scriptlet. */
143     StringBuf clean;            /*!< %clean scriptlet. */
144
145     Package packages;           /*!< Package list. */
146 };
147
148 /** \ingroup rpmbuild
149  * The structure used to store values for a package.
150  */
151 struct Package_s {
152     Header header;
153     rpmds ds;                   /*!< Requires: N = EVR */
154     rpmfi cpioList;
155
156     struct Source * icon;
157
158     int autoReq;
159     int autoProv;
160
161     char * preInFile;   /*!< %pre scriptlet. */
162     char * postInFile;  /*!< %post scriptlet. */
163     char * preUnFile;   /*!< %preun scriptlet. */
164     char * postUnFile;  /*!< %postun scriptlet. */
165     char * preTransFile;        /*!< %pretrans scriptlet. */
166     char * postTransFile;       /*!< %posttrans scriptlet. */
167     char * verifyFile;  /*!< %verifyscript scriptlet. */
168
169     StringBuf specialDoc;
170
171     struct TriggerFileEntry * triggerFiles;
172
173     char * fileFile;
174     StringBuf fileList;         /* If NULL, package will not be written */
175
176     Package next;
177 };
178
179 /** \ingroup rpmbuild
180  * Create and initialize rpmSpec structure.
181  * @return spec         spec file control structure
182  */
183 rpmSpec newSpec(void);
184
185 /** \ingroup rpmbuild
186  * Destroy Spec structure.
187  * @param spec          spec file control structure
188  * @return              NULL always
189  */
190 rpmSpec freeSpec(rpmSpec spec);
191
192 /** \ingroup rpmbuild
193  * Function to query spec file(s).
194  * @param ts            transaction set
195  * @param qva           parsed query/verify options
196  * @param arg           query argument
197  * @return              0 on success, else no. of failures
198  */
199 int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg);
200
201 /** \ingroup rpmbuild
202  */
203 struct OpenFileInfo * newOpenFileInfo(void);
204
205 /** \ingroup rpmbuild
206  * stashSt.
207  * @param spec          spec file control structure
208  * @param h             header
209  * @param tag           tag
210  * @param lang          locale
211  */
212 spectag stashSt(rpmSpec spec, Header h, rpmTag tag, const char * lang);
213
214 /** \ingroup rpmbuild
215  * addSource.
216  * @param spec          spec file control structure
217  * @param pkg           package control
218  * @param field         field to parse
219  * @param tag           tag
220  */
221 int addSource(rpmSpec spec, Package pkg, const char * field, rpmTag tag);
222
223 /** \ingroup rpmbuild
224  * parseNoSource.
225  * @param spec          spec file control structure
226  * @param field         field to parse
227  * @param tag           tag
228  */
229 int parseNoSource(rpmSpec spec, const char * field, rpmTag tag);
230
231 #ifdef __cplusplus
232 }
233 #endif
234
235 #endif /* _H_SPEC_ */