This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpkgparse.h
432 lines (327 loc) · 10.6 KB
/
pkgparse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
/* Copyright (c) 2009 Sebastian Nowicki <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef PKGBUILD_H
#define PKGBUILD_H
/* File: pkgparse.h
A collection functions and data structures relating to the retrieval of
PKGBUILD metadata. The main data structure is <pkgbuild_t>, which
encapsulates all PKGBUILD information. This data structure is populated by
parsing a PKGBUILD using the <pkgbuild_parse()> function.
Example:
(start code)
FILE *fp;
pkgbuild_t *pkgbuild;
// Open the PKGBUILD for reading.
fp = fopen("PKGBUILD", "r");
if(fp == NULL) {
fprintf(stderr, "Unable to open PKGBUILD\n");
exit(1);
}
// Attempt to parse the PKGBUILD.
pkgbuild = pkgbuild_parse(fp);
if(pkgbuild == NULL) {
fprintf(stderr, "Unable to parse PKGBUILD\n");
}
// Print package name, version and release.
printf("Parsed: %s %s-%.1f\n", pkgbuild_names(pkgbuild)[0],
pkgbuild_version(pkgbuild),
pkgbuild_release(pkgbuild));
pkgbuild_release(pkgbuild);
(end)
*/
#include <stdio.h>
/* Type: pkgbuild_t
An opaque data type encapsulating PKGBUILD metadata.
*/
typedef struct _pkgbuild_t pkgbuild_t;
/* Function: pkgbuild_parse
Initialize and return a pkgbuild_t structure by parsing a PKGBUILD file.
Parameters:
fp - A file pointer to the PKGBUILD. The file must be opened in read
mode, and closed, by the caller.
Returns:
An initialized pkgbuild_t structure containing metadata found in the
PKGBUILD. This object must be deallocated using <pkgbuild_release()>.
*/
pkgbuild_t *pkgbuild_parse(FILE *fp);
/* Function: pkgbuild_release
Decrement the pkgbuild's reference count.
The object is deallocated automatically when its reference count reaches 0.
The associated value, if set, will also be deallocated.
Parameters:
pkgbuild - A reference to the symbol to be released.
See Also:
<pkgbuild_retain()>
*/
void pkgbuild_release(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_retain
Increment the pkgbuild's reference count. This should be used whenever you
want to prevent it from being deallocated without your express permission.
The pkgbuild is deallocated automatically when its reference count reaches 0.
Calling <pkgbuild_retain()> increments the reference count, and calling
<pkgbuild_release()> decrements it.
Example:
(start code)
void use_pkgbuild(pkgbuild_t *pkgbuild)
{
pkgbuild_retain(pkgbuild);
// Do something with pkgbuild
pkgbuild_release(pkgbuild);
}
(end)
Parameters:
pkgbuild - A reference to the symbol to be retained.
Returns:
A reference to the pkgbuild.
See Also:
<pkgbuild_release()>
*/
pkgbuild_t *pkgbuild_retain(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_names
Retrieve all names of this package. PKGBUILDs producing split packages will
have multiple elements, while monolithic PKGBUILDs will have a single
element.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of package names, or NULL on error.
*/
char **pkgbuild_names(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_basename
Retrieve the basename of a split package. If not a split package, the
returned value will be NULL.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
A string representing the basename, or NULL if not a split package,
or on error.
*/
char *pkgbuild_basename(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_version
Retrieve the version of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
A string representing the version, or NULL on error.
*/
char *pkgbuild_version(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_release
Retrieve the release of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
A float representing the release, or NULL on error.
*/
float pkgbuild_rel(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_desc
Retrieve the description of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
A string representing the description, or NULL on error.
*/
char *pkgbuild_desc(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_url
Retrieve the url of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
A string representing the url, or NULL on error.
*/
char *pkgbuild_url(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_licenses
Retrieve the licenses of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a license, or NULL on error.
*/
char **pkgbuild_licenses(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_install
Retrieve the relative path of the install scriptlet.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
A string representing the path to the install scriptlet, or NULL on
error.
*/
char *pkgbuild_install(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_sources
Retrieve the sources of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a source, or NULL on error.
*/
char **pkgbuild_sources(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_noextract
Retrieve an array of sources not to be extracted.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a source not to be extracted, or
NULL on error. These values should match those in sources.
See Also:
<pkgbuild_sources()>
*/
char **pkgbuild_noextract(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_md5sums
Retrieve the md5 checksums of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing an md5 checksum, or NULL on error.
*/
char **pkgbuild_md5sums(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_sha1sums
Retrieve the sha1 checksums of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing an sha1 checksum, or NULL on error.
*/
char **pkgbuild_sha1sums(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_sha256sums
Retrieve the sha256 checksums of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing an sha256 checksum, or NULL on error.
*/
char **pkgbuild_sha256sums(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_sha384sums
Retrieve the sha384sums checksums of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing an sha384 checksum, or NULL on error.
*/
char **pkgbuild_sha384sums(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_sha512sums
Retrieve the sha512sums checksums of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing an sha512 checksum, or NULL on error.
*/
char **pkgbuild_sha512sums(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_groups
Retrieve the groups a package belongs to.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a group, or NULL on error.
*/
char **pkgbuild_groups(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_architectures
Retrieve the architectures the package can be built for.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing an architecture, or NULL on error.
*/
char **pkgbuild_architectures(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_backup
Retrieve the paths to be backed up when installing/updating the package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a backup path, or NULL on error.
*/
char **pkgbuild_backup(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_depends
Retrieve the dependencies of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a dependency, or NULL on error. These
dependencies should be other package names, or provisions.
*/
char **pkgbuild_depends(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_makedepends
Retrieve the make-time dependencies of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a dependency, or NULL on error.
See Also:
<pkgbuild_depends()>
*/
char **pkgbuild_makedepends(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_optdepends
Retrieve the optional dependencies of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing an optional dependency, or NULL on
error.
See Also:
PKGBUILD(5) for information about the format of optional dependencies.
*/
char **pkgbuild_optdepends(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_conflicts
Retrieve the packages a package conflicts with.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a conflicting package, or NULL on
error.
*/
char **pkgbuild_conflicts(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_provides
Retrieve the provisions of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a provision, or NULL on error.
See Also:
PKGBUILD(5) for information on what a provision is.
*/
char **pkgbuild_provides(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_replaces
Retrieve the packages a package replaces.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing a replaced package, or NULL on
error.
*/
char **pkgbuild_replaces(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_options
Retrieve the build options of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of strings, each representing an option, or NULL on error.
See Also:
PKGBUILD(5) for possible options.
*/
char **pkgbuild_options(pkgbuild_t *pkgbuild);
/* Function: pkgbuild_splitpkgs
Retrieve the split packages of a package.
Parameters:
pkgbuild - The pkgbuild to query.
Returns:
An array of package objects, each representing a split package, or NULL on
error.
*/
pkgbuild_t **pkgbuild_splitpkgs(pkgbuild_t *pkgbuild);
#endif