summaryrefslogtreecommitdiffstats
path: root/upstream/archlinux/man3/libalpm_databases.3
blob: 0f8343c87d74def4734fb842a399f6c0b6071fdc (plain)
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
.TH "libalpm_databases" 3 "libalpm" \" -*- nroff -*-
.ad l
.nh
.SH NAME
libalpm_databases \- Database
.SH SYNOPSIS
.br
.PP
.SS "Typedefs"

.in +1c
.ti -1c
.RI "typedef struct _alpm_db_t \fBalpm_db_t\fP"
.br
.RI "A database\&. "
.in -1c
.SS "Enumerations"

.in +1c
.ti -1c
.RI "enum \fBalpm_db_usage_t\fP { \fBALPM_DB_USAGE_SYNC\fP = 1, \fBALPM_DB_USAGE_SEARCH\fP = (1 << 1), \fBALPM_DB_USAGE_INSTALL\fP = (1 << 2), \fBALPM_DB_USAGE_UPGRADE\fP = (1 << 3), \fBALPM_DB_USAGE_ALL\fP = (1 << 4) - 1 }"
.br
.RI "The usage level of a database\&. "
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "\fBalpm_db_t\fP * \fBalpm_get_localdb\fP (\fBalpm_handle_t\fP *handle)"
.br
.RI "Get the database of locally installed packages\&. "
.ti -1c
.RI "\fBalpm_list_t\fP * \fBalpm_get_syncdbs\fP (\fBalpm_handle_t\fP *handle)"
.br
.RI "Get the list of sync databases\&. "
.ti -1c
.RI "\fBalpm_db_t\fP * \fBalpm_register_syncdb\fP (\fBalpm_handle_t\fP *handle, const char *treename, int level)"
.br
.RI "Register a sync database of packages\&. "
.ti -1c
.RI "int \fBalpm_unregister_all_syncdbs\fP (\fBalpm_handle_t\fP *handle)"
.br
.RI "Unregister all package databases\&. "
.ti -1c
.RI "int \fBalpm_db_unregister\fP (\fBalpm_db_t\fP *db)"
.br
.RI "Unregister a package database\&. "
.ti -1c
.RI "\fBalpm_handle_t\fP * \fBalpm_db_get_handle\fP (\fBalpm_db_t\fP *db)"
.br
.RI "Get the handle of a package database\&. "
.ti -1c
.RI "const char * \fBalpm_db_get_name\fP (const \fBalpm_db_t\fP *db)"
.br
.RI "Get the name of a package database\&. "
.ti -1c
.RI "int \fBalpm_db_get_siglevel\fP (\fBalpm_db_t\fP *db)"
.br
.RI "Get the signature verification level for a database\&. "
.ti -1c
.RI "int \fBalpm_db_get_valid\fP (\fBalpm_db_t\fP *db)"
.br
.RI "Check the validity of a database\&. "
.ti -1c
.RI "int \fBalpm_db_update\fP (\fBalpm_handle_t\fP *handle, \fBalpm_list_t\fP *dbs, int force)"
.br
.RI "Update package databases\&. "
.ti -1c
.RI "\fBalpm_pkg_t\fP * \fBalpm_db_get_pkg\fP (\fBalpm_db_t\fP *db, const char *name)"
.br
.RI "Get a package entry from a package database\&. "
.ti -1c
.RI "\fBalpm_list_t\fP * \fBalpm_db_get_pkgcache\fP (\fBalpm_db_t\fP *db)"
.br
.RI "Get the package cache of a package database\&. "
.ti -1c
.RI "\fBalpm_group_t\fP * \fBalpm_db_get_group\fP (\fBalpm_db_t\fP *db, const char *name)"
.br
.RI "Get a group entry from a package database\&. "
.ti -1c
.RI "\fBalpm_list_t\fP * \fBalpm_db_get_groupcache\fP (\fBalpm_db_t\fP *db)"
.br
.RI "Get the group cache of a package database\&. "
.ti -1c
.RI "int \fBalpm_db_search\fP (\fBalpm_db_t\fP *db, const \fBalpm_list_t\fP *needles, \fBalpm_list_t\fP **ret)"
.br
.RI "Searches a database with regular expressions\&. "
.in -1c
.SS "Server accessors"

.in +1c
.ti -1c
.RI "\fBalpm_list_t\fP * \fBalpm_db_get_servers\fP (const \fBalpm_db_t\fP *db)"
.br
.RI "Get the list of servers assigned to this db\&. "
.ti -1c
.RI "int \fBalpm_db_set_servers\fP (\fBalpm_db_t\fP *db, \fBalpm_list_t\fP *servers)"
.br
.RI "Sets the list of servers for the database to use\&. "
.ti -1c
.RI "int \fBalpm_db_add_server\fP (\fBalpm_db_t\fP *db, const char *url)"
.br
.RI "Add a download server to a database\&. "
.ti -1c
.RI "int \fBalpm_db_remove_server\fP (\fBalpm_db_t\fP *db, const char *url)"
.br
.RI "Remove a download server from a database\&. "
.ti -1c
.RI "\fBalpm_list_t\fP * \fBalpm_db_get_cache_servers\fP (const \fBalpm_db_t\fP *db)"
.br
.RI "Get the list of cache servers assigned to this db\&. "
.ti -1c
.RI "int \fBalpm_db_set_cache_servers\fP (\fBalpm_db_t\fP *db, \fBalpm_list_t\fP *servers)"
.br
.RI "Sets the list of cache servers for the database to use\&. "
.ti -1c
.RI "int \fBalpm_db_add_cache_server\fP (\fBalpm_db_t\fP *db, const char *url)"
.br
.RI "Add a download cache server to a database\&. "
.ti -1c
.RI "int \fBalpm_db_remove_cache_server\fP (\fBalpm_db_t\fP *db, const char *url)"
.br
.RI "Remove a download cache server from a database\&. "
.in -1c
.SS "Usage accessors"

.in +1c
.ti -1c
.RI "int \fBalpm_db_set_usage\fP (\fBalpm_db_t\fP *db, int usage)"
.br
.RI "Sets the usage of a database\&. "
.ti -1c
.RI "int \fBalpm_db_get_usage\fP (\fBalpm_db_t\fP *db, int *usage)"
.br
.RI "Gets the usage of a database\&. "
.in -1c
.SH "Detailed Description"
.PP 


Functions to query and manipulate the database of libalpm\&. 
.SH "Typedef Documentation"
.PP 
.SS "typedef struct _alpm_db_t \fBalpm_db_t\fP"

.PP
A database\&. A database is a container that stores metadata about packages\&.
.PP
A database can be located on the local filesystem or on a remote server\&.
.PP
To use a database, it must first be registered via \fBalpm_register_syncdb\fP\&. If the database is already present in dbpath then it will be usable\&. Otherwise, the database needs to be downloaded using \fBalpm_db_update\fP\&. Even if the source of the database is the local filesystem\&.
.PP
After this, the database can be used to query packages and groups\&. Any packages or groups from the database will continue to be owned by the database and do not need to be freed by the user\&. They will be freed when the database is unregistered\&.
.PP
Databases are automatically unregistered when the \fBalpm_handle_t\fP is released\&. 
.SH "Enumeration Type Documentation"
.PP 
.SS "enum \fBalpm_db_usage_t\fP"

.PP
The usage level of a database\&. 
.PP
\fBEnumerator\fP
.in +1c
.TP
\fB\fIALPM_DB_USAGE_SYNC \fP\fP
Enable refreshes for this database\&. 
.TP
\fB\fIALPM_DB_USAGE_SEARCH \fP\fP
Enable search for this database\&. 
.TP
\fB\fIALPM_DB_USAGE_INSTALL \fP\fP
Enable installing packages from this database\&. 
.TP
\fB\fIALPM_DB_USAGE_UPGRADE \fP\fP
Enable sysupgrades with this database\&. 
.TP
\fB\fIALPM_DB_USAGE_ALL \fP\fP
Enable all usage levels\&. 
.SH "Function Documentation"
.PP 
.SS "int alpm_db_add_cache_server (\fBalpm_db_t\fP * db, const char * url)"

.PP
Add a download cache server to a database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP database pointer 
.br
\fIurl\fP url of the server 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -1 on error (pm_errno is set accordingly) 
.RE
.PP

.SS "int alpm_db_add_server (\fBalpm_db_t\fP * db, const char * url)"

.PP
Add a download server to a database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP database pointer 
.br
\fIurl\fP url of the server 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -1 on error (pm_errno is set accordingly) 
.RE
.PP

.SS "\fBalpm_list_t\fP * alpm_db_get_cache_servers (const \fBalpm_db_t\fP * db)"

.PP
Get the list of cache servers assigned to this db\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the database to get the servers from 
.RE
.PP
\fBReturns\fP
.RS 4
a char* list of servers 
.RE
.PP

.SS "\fBalpm_group_t\fP * alpm_db_get_group (\fBalpm_db_t\fP * db, const char * name)"

.PP
Get a group entry from a package database\&. Looking up a group is O(1) and will be significantly faster than iterating over the groupcahe\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database to get the group from 
.br
\fIname\fP of the group 
.RE
.PP
\fBReturns\fP
.RS 4
the groups entry on success, NULL on error 
.RE
.PP

.SS "\fBalpm_list_t\fP * alpm_db_get_groupcache (\fBalpm_db_t\fP * db)"

.PP
Get the group cache of a package database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database to get the group from 
.RE
.PP
\fBReturns\fP
.RS 4
the list of groups on success, NULL on error 
.RE
.PP

.SS "\fBalpm_handle_t\fP * alpm_db_get_handle (\fBalpm_db_t\fP * db)"

.PP
Get the handle of a package database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database 
.RE
.PP
\fBReturns\fP
.RS 4
the alpm handle that the package database belongs to 
.RE
.PP

.SS "const char * alpm_db_get_name (const \fBalpm_db_t\fP * db)"

.PP
Get the name of a package database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database 
.RE
.PP
\fBReturns\fP
.RS 4
the name of the package database, NULL on error 
.RE
.PP

.SS "\fBalpm_pkg_t\fP * alpm_db_get_pkg (\fBalpm_db_t\fP * db, const char * name)"

.PP
Get a package entry from a package database\&. Looking up a package is O(1) and will be significantly faster than iterating over the pkgcahe\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database to get the package from 
.br
\fIname\fP of the package 
.RE
.PP
\fBReturns\fP
.RS 4
the package entry on success, NULL on error 
.RE
.PP

.SS "\fBalpm_list_t\fP * alpm_db_get_pkgcache (\fBalpm_db_t\fP * db)"

.PP
Get the package cache of a package database\&. This is a list of all packages the db contains\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database to get the package from 
.RE
.PP
\fBReturns\fP
.RS 4
the list of packages on success, NULL on error 
.RE
.PP

.SS "\fBalpm_list_t\fP * alpm_db_get_servers (const \fBalpm_db_t\fP * db)"

.PP
Get the list of servers assigned to this db\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the database to get the servers from 
.RE
.PP
\fBReturns\fP
.RS 4
a char* list of servers 
.RE
.PP

.SS "int alpm_db_get_siglevel (\fBalpm_db_t\fP * db)"

.PP
Get the signature verification level for a database\&. Will return the default verification level if this database is set up with ALPM_SIG_USE_DEFAULT\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database 
.RE
.PP
\fBReturns\fP
.RS 4
the signature verification level 
.RE
.PP

.SS "int alpm_db_get_usage (\fBalpm_db_t\fP * db, int * usage)"

.PP
Gets the usage of a database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database to get the status of 
.br
\fIusage\fP pointer to an alpm_db_usage_t to store db's status 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, or -1 on error 
.RE
.PP

.SS "int alpm_db_get_valid (\fBalpm_db_t\fP * db)"

.PP
Check the validity of a database\&. This is most useful for sync databases and verifying signature status\&. If invalid, the handle error code will be set accordingly\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database 
.RE
.PP
\fBReturns\fP
.RS 4
0 if valid, -1 if invalid (pm_errno is set accordingly) 
.RE
.PP

.SS "int alpm_db_remove_cache_server (\fBalpm_db_t\fP * db, const char * url)"

.PP
Remove a download cache server from a database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP database pointer 
.br
\fIurl\fP url of the server 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, 1 on server not present, -1 on error (pm_errno is set accordingly) 
.RE
.PP

.SS "int alpm_db_remove_server (\fBalpm_db_t\fP * db, const char * url)"

.PP
Remove a download server from a database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP database pointer 
.br
\fIurl\fP url of the server 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, 1 on server not present, -1 on error (pm_errno is set accordingly) 
.RE
.PP

.SS "int alpm_db_search (\fBalpm_db_t\fP * db, const \fBalpm_list_t\fP * needles, \fBalpm_list_t\fP ** ret)"

.PP
Searches a database with regular expressions\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database to search in 
.br
\fIneedles\fP a list of regular expressions to search for 
.br
\fIret\fP pointer to list for storing packages matching all regular expressions - must point to an empty (NULL) \fBalpm_list_t\fP *\&. 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -1 on error (pm_errno is set accordingly) 
.RE
.PP

.SS "int alpm_db_set_cache_servers (\fBalpm_db_t\fP * db, \fBalpm_list_t\fP * servers)"

.PP
Sets the list of cache servers for the database to use\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP the database to set the servers\&. The list will be duped and the original will still need to be freed by the caller\&. 
.br
\fIservers\fP a char* list of servers\&. 
.RE
.PP

.SS "int alpm_db_set_servers (\fBalpm_db_t\fP * db, \fBalpm_list_t\fP * servers)"

.PP
Sets the list of servers for the database to use\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP the database to set the servers\&. The list will be duped and the original will still need to be freed by the caller\&. 
.br
\fIservers\fP a char* list of servers\&. 
.RE
.PP

.SS "int alpm_db_set_usage (\fBalpm_db_t\fP * db, int usage)"

.PP
Sets the usage of a database\&. 
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database to set the status for 
.br
\fIusage\fP a bitmask of alpm_db_usage_t values 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, or -1 on error 
.RE
.PP

.SS "int alpm_db_unregister (\fBalpm_db_t\fP * db)"

.PP
Unregister a package database\&. Databases can not be unregistered when there is an active transaction\&.
.PP
\fBParameters\fP
.RS 4
\fIdb\fP pointer to the package database to unregister 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -1 on error (pm_errno is set accordingly) 
.RE
.PP

.SS "int alpm_db_update (\fBalpm_handle_t\fP * handle, \fBalpm_list_t\fP * dbs, int force)"

.PP
Update package databases\&. An update of the package databases in the list \fIdbs\fP will be attempted\&. Unless \fIforce\fP is true, the update will only be performed if the remote databases were modified since the last update\&.
.PP
This operation requires a database lock, and will return an applicable error if the lock could not be obtained\&.
.PP
Example: 
.PP
.nf
alpm_list_t *dbs = alpm_get_syncdbs(config\->handle);
ret = alpm_db_update(config\->handle, dbs, force);
if(ret < 0) {
    pm_printf(ALPM_LOG_ERROR, _("failed to synchronize all databases (%s)\\n"),
        alpm_strerror(alpm_errno(config\->handle)));
}

.fi
.PP
.PP
\fBNote\fP
.RS 4
After a successful update, the \fBpackage cache \fP will be invalidated 
.RE
.PP
\fBParameters\fP
.RS 4
\fIhandle\fP the context handle 
.br
\fIdbs\fP list of package databases to update 
.br
\fIforce\fP if true, then forces the update, otherwise update only in case the databases aren't up to date 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -1 on error (pm_errno is set accordingly), 1 if all databases are up to to date 
.RE
.PP

.SS "\fBalpm_db_t\fP * alpm_get_localdb (\fBalpm_handle_t\fP * handle)"

.PP
Get the database of locally installed packages\&. The returned pointer points to an internal structure of libalpm which should only be manipulated through libalpm functions\&. 
.PP
\fBReturns\fP
.RS 4
a reference to the local database 
.RE
.PP

.SS "\fBalpm_list_t\fP * alpm_get_syncdbs (\fBalpm_handle_t\fP * handle)"

.PP
Get the list of sync databases\&. Returns a list of alpm_db_t structures, one for each registered sync database\&.
.PP
\fBParameters\fP
.RS 4
\fIhandle\fP the context handle 
.RE
.PP
\fBReturns\fP
.RS 4
a reference to an internal list of alpm_db_t structures 
.RE
.PP

.SS "\fBalpm_db_t\fP * alpm_register_syncdb (\fBalpm_handle_t\fP * handle, const char * treename, int level)"

.PP
Register a sync database of packages\&. Databases can not be registered when there is an active transaction\&.
.PP
\fBParameters\fP
.RS 4
\fIhandle\fP the context handle 
.br
\fItreename\fP the name of the sync repository 
.br
\fIlevel\fP what level of signature checking to perform on the database; note that this must be a '\&.sig' file type verification 
.RE
.PP
\fBReturns\fP
.RS 4
an alpm_db_t* on success (the value), NULL on error 
.RE
.PP

.SS "int alpm_unregister_all_syncdbs (\fBalpm_handle_t\fP * handle)"

.PP
Unregister all package databases\&. Databases can not be unregistered while there is an active transaction\&.
.PP
\fBParameters\fP
.RS 4
\fIhandle\fP the context handle 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -1 on error (pm_errno is set accordingly) 
.RE
.PP

.SH "Author"
.PP 
Generated automatically by Doxygen for libalpm from the source code\&.