-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathxbps.h.in
More file actions
2444 lines (2238 loc) · 73.5 KB
/
xbps.h.in
File metadata and controls
2444 lines (2238 loc) · 73.5 KB
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
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*-
* Copyright (c) 2008-2020 Juan Romero Pardines <xtraeme@gmail.com>
* Copyright (c) 2014-2019 Enno Boland <gottox@voidlinux.org>
* Copyright (c) 2016-2019 Duncan Overbruck <mail@duncano.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*-
*/
#ifndef _XBPS_H_
#define _XBPS_H_
#include <stdio.h>
#include <stdbool.h>
#include <inttypes.h>
#include <errno.h>
#include <xbps/xbps_array.h>
#include <xbps/xbps_bool.h>
#include <xbps/xbps_data.h>
#include <xbps/xbps_dictionary.h>
#include <xbps/xbps_number.h>
#include <xbps/xbps_string.h>
#define XBPS_MAXPATH 512
#define XBPS_NAME_SIZE 64
/**
* @file include/xbps.h
* @brief XBPS Library API header
*
* This header documents the full API for the XBPS Library.
*/
#define XBPS_API_VERSION "20250629"
#ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET"
#endif
#ifndef XBPS_GIT
#define XBPS_GIT "UNSET"
#endif
/**
* @def XBPS_RELVER
* Current library release date.
*/
#define XBPS_RELVER "XBPS: " XBPS_VERSION \
" API: " XBPS_API_VERSION \
" GIT: " XBPS_GIT
/**
* @def XBPS_SYSCONF_PATH
* Default configuration PATH to find XBPS_CONF_PLIST.
*/
#define XBPS_SYSDIR "/xbps.d"
#ifndef XBPS_SYSCONF_PATH
# define XBPS_SYSCONF_PATH "/etc" XBPS_SYSDIR
#endif
#ifndef XBPS_SYSDEFCONF_PATH
# define XBPS_SYSDEFCONF_PATH "/usr/share" XBPS_SYSDIR
#endif
/**
* @def XBPS_META_PATH
* Default root PATH to store metadata info.
*/
#ifndef XBPS_META_PATH
#define XBPS_META_PATH "var/db/xbps"
#endif
/**
* @def XBPS_CACHE_PATH
* Default cache PATH to store downloaded binpkgs.
*/
#define XBPS_CACHE_PATH "var/cache/xbps"
/**
* @def XBPS_PKGDB
* Filename for the package database.
*/
#define XBPS_PKGDB "pkgdb-0.38.plist"
/**
* @def XBPS_PKGPROPS
* Filename for package metadata property list.
*/
#define XBPS_PKGPROPS "props.plist"
/**
* @def XBPS_PKGFILES
* Filename for package metadata files property list.
*/
#define XBPS_PKGFILES "files.plist"
/**
* @def XBPS_REPODATA_INDEX
* Filename for the repository index property list.
*/
#define XBPS_REPODATA_INDEX "index.plist"
/**
* @def XBPS_REPODATA_STAGE
* Filename for the repository stage property list.
*/
#define XBPS_REPODATA_STAGE "stage.plist"
/**
* @def XBPS_REPODATA_META
* Filename for the repository index metadata property list.
*/
#define XBPS_REPODATA_META "index-meta.plist"
/**
* @def XBPS_FLAG_VERBOSE
* Verbose flag that can be used in the function callbacks to alter
* its behaviour. Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_VERBOSE 0x00000001
/**
* @def XBPS_FLAG_FORCE_CONFIGURE
* Force flag used in xbps_configure_pkg(), if set the package(s)
* will be reconfigured even if its state is XBPS_PKG_STATE_INSTALLED.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_FORCE_CONFIGURE 0x00000002
/**
* @def XBPS_FLAG_FORCE_REMOVE_FILES
* Force flag used in xbps_remove_pkg_files(), if set the package
* files will be removed even if its SHA256 hash don't match.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_FORCE_REMOVE_FILES 0x00000004
/**
* @def XBPS_FLAG_INSTALL_AUTO
* Enabled automatic install mode for a package and all dependencies
* installed direct and indirectly.
*/
#define XBPS_FLAG_INSTALL_AUTO 0x00000010
/**
* @def XBPS_FLAG_DEBUG
* Enable debug mode to output debugging printfs to stdout/stderr.
*/
#define XBPS_FLAG_DEBUG 0x00000020
/**
* @def XBPS_FLAG_FORCE_UNPACK
* Force flag used in xbps_unpack_binary_pkg(). If set its package
* files will be unpacked overwritting the current ones.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_FORCE_UNPACK 0x00000040
/**
* @def XBPS_FLAG_DISABLE_SYSLOG
* Disable syslog logging, enabled by default.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_DISABLE_SYSLOG 0x00000080
/**
* @def XBPS_FLAG_BESTMATCH
* Enable pkg best matching when resolving packages.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_BESTMATCH 0x00000100
/**
* @def XBPS_FLAG_IGNORE_CONF_REPOS
* Ignore repos defined in configuration files.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_IGNORE_CONF_REPOS 0x00000200
/**
* @def XBPS_FLAG_REPOS_MEMSYNC
* Fetch and store repodata in memory, ignoring on-disk metadata.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_REPOS_MEMSYNC 0x00000400
/**
* @def XBPS_FLAG_FORCE_REMOVE_REVDEPS
* Continue with transaction even if there are broken reverse
* dependencies, due to unresolved shared libraries or dependencies.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_FORCE_REMOVE_REVDEPS 0x00000800
/**
* @def XBPS_FLAG_UNPACK_ONLY
* Do not configure packages in the transaction, just unpack them.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_UNPACK_ONLY 0x00001000
/**
* @def XBPS_FLAG_DOWNLOAD_ONLY
* Only download packages to the cache, do not do any installation steps.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_DOWNLOAD_ONLY 0x00002000
/*
* @def XBPS_FLAG_IGNORE_FILE_CONFLICTS
* Continue with transaction even if there are file conflicts.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_IGNORE_FILE_CONFLICTS 0x00004000
/**
* @def XBPS_FLAG_INSTALL_REPRO
* Enabled reproducible mode; skips adding the "install-date"
* and "repository" objs into pkgdb.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_INSTALL_REPRO 0x00008000
/**
* @def XBPS_FLAG_KEEP_CONFIG
* Don't overwrite configuration files that have not changed since
* installation.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_KEEP_CONFIG 0x00010000
/**
* @def XBPS_FLAG_USE_STAGE
* Use the staging repository if available.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_USE_STAGE 0x00020000
/**
* @def XBPS_FETCH_CACHECONN
* Default (global) limit of cached connections used in libfetch.
*/
#define XBPS_FETCH_CACHECONN 32
/**
* @def XBPS_FETCH_CACHECONN_HOST
* Default (per host) limit of cached connections used in libfetch.
*/
#define XBPS_FETCH_CACHECONN_HOST 16
/**
* @def XBPS_FETCH_TIMEOUT
* Default timeout limit (in seconds) to wait for stalled connections.
*/
#define XBPS_FETCH_TIMEOUT 30
/**
* @def XBPS_SHA256_DIGEST_SIZE
* The size for a binary SHA256 digests.
*/
#define XBPS_SHA256_DIGEST_SIZE 32
/**
* @def XBPS_SHA256_SIZE
* The size for a hex string SHA256 hash.
*/
#define XBPS_SHA256_SIZE (XBPS_SHA256_DIGEST_SIZE*2)+1
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup initend */
/**@{*/
/**
* @enum xbps_state_t
*
* Integer representing the xbps callback returned state. Possible values:
*
* - XBPS_STATE_UKKNOWN: state hasn't been prepared or unknown error.
* - XBPS_STATE_TRANS_DOWNLOAD: transaction is downloading binary packages.
* - XBPS_STATE_TRANS_VERIFY: transaction is verifying binary package integrity.
* - XBPS_STATE_TRANS_RUN: transaction is performing operations: install, update, remove, replace.
* - XBPS_STATE_TRANS_CONFIGURE: transaction is configuring all unpacked packages.
* - XBPS_STATE_TRANS_FAIL: transaction has failed.
* - XBPS_STATE_DOWNLOAD: a binary package is being downloaded.
* - XBPS_STATE_VERIFY: a binary package is being verified.
* - XBPS_STATE_REMOVE: a package is being removed.
* - XBPS_STATE_REMOVE_DONE: a package has been removed successfully.
* - XBPS_STATE_REMOVE_FILE: a package file is being removed.
* - XBPS_STATE_REMOVE_OBSOLETE: an obsolete package file is being removed.
* - XBPS_STATE_REPLACE: a package is being replaced.
* - XBPS_STATE_INSTALL: a package is being installed.
* - XBPS_STATE_INSTALL_DONE: a package has been installed successfully.
* - XBPS_STATE_UPDATE: a package is being updated.
* - XBPS_STATE_UPDATE_DONE: a package has been updated successfully.
* - XBPS_STATE_UNPACK: a package is being unpacked.
* - XBPS_STATE_CONFIGURE: a package is being configured.
* - XBPS_STATE_CONFIGURE_DONE: a package has been configured successfully.
* - XBPS_STATE_CONFIG_FILE: a package configuration file is being processed.
* - XBPS_STATE_REPOSYNC: a remote repository's package index is being synchronized.
* - XBPS_STATE_VERIFY_FAIL: binary package integrity has failed.
* - XBPS_STATE_DOWNLOAD_FAIL: binary package download has failed.
* - XBPS_STATE_REMOVE_FAIL: a package removal has failed.
* - XBPS_STATE_REMOVE_FILE_FAIL: a package file removal has failed.
* - XBPS_STATE_REMOVE_FILE_HASH_FAIL: a package file removal has failed due to hash.
* - XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL: an obsolete package file removal has failed.
* - XBPS_STATE_CONFIGURE_FAIL: package configure has failed.
* - XBPS_STATE_CONFIG_FILE_FAIL: package configuration file operation has failed.
* - XBPS_STATE_UPDATE_FAIL: package update has failed.
* - XBPS_STATE_UNPACK_FAIL: package unpack has failed.
* - XBPS_STATE_REPOSYNC_FAIL: syncing remote repositories has failed.
* - XBPS_STATE_REPO_KEY_IMPORT: repository is signed and needs to import pubkey.
* - XBPS_STATE_INVALID_DEP: package has an invalid dependency.
* - XBPS_STATE_ALTGROUP_ADDED: package has registered an alternative group.
* - XBPS_STATE_ALTGROUP_REMOVED: package has unregistered an alternative group.
* - XBPS_STATE_ALTGROUP_SWITCHED: alternative group has been switched.
* - XBPS_STATE_ALTGROUP_LINK_ADDED: link added by an alternative group.
* - XBPS_STATE_ALTGROUP_LINK_REMOVED: link removed by an alternative group.
* - XBPS_STATE_UNPACK_FILE_PRESERVED: package unpack preserved a file.
* - XBPS_STATE_PKGDB: pkgdb upgrade in progress.
* - XBPS_STATE_PKGDB_DONE: pkgdb has been upgraded successfully.
*/
typedef enum xbps_state {
XBPS_STATE_UNKNOWN = 0,
XBPS_STATE_TRANS_DOWNLOAD,
XBPS_STATE_TRANS_VERIFY,
XBPS_STATE_TRANS_FILES,
XBPS_STATE_TRANS_RUN,
XBPS_STATE_TRANS_CONFIGURE,
XBPS_STATE_TRANS_FAIL,
XBPS_STATE_DOWNLOAD,
XBPS_STATE_VERIFY,
XBPS_STATE_FILES,
XBPS_STATE_REMOVE,
XBPS_STATE_REMOVE_DONE,
XBPS_STATE_REMOVE_FILE,
XBPS_STATE_REMOVE_FILE_OBSOLETE,
XBPS_STATE_PURGE,
XBPS_STATE_PURGE_DONE,
XBPS_STATE_REPLACE,
XBPS_STATE_INSTALL,
XBPS_STATE_INSTALL_DONE,
XBPS_STATE_UPDATE,
XBPS_STATE_UPDATE_DONE,
XBPS_STATE_UNPACK,
XBPS_STATE_CONFIGURE,
XBPS_STATE_CONFIG_FILE,
XBPS_STATE_REPOSYNC,
XBPS_STATE_VERIFY_FAIL,
XBPS_STATE_FILES_FAIL,
XBPS_STATE_DOWNLOAD_FAIL,
XBPS_STATE_REMOVE_FAIL,
XBPS_STATE_REMOVE_FILE_FAIL,
XBPS_STATE_REMOVE_FILE_HASH_FAIL,
XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
XBPS_STATE_PURGE_FAIL,
XBPS_STATE_CONFIGURE_FAIL,
XBPS_STATE_CONFIG_FILE_FAIL,
XBPS_STATE_UPDATE_FAIL,
XBPS_STATE_UNPACK_FAIL,
XBPS_STATE_REPOSYNC_FAIL,
XBPS_STATE_CONFIGURE_DONE,
XBPS_STATE_REPO_KEY_IMPORT,
XBPS_STATE_INVALID_DEP,
XBPS_STATE_UNPACK_FILE_PRESERVED,
XBPS_STATE_PKGDB,
XBPS_STATE_PKGDB_DONE,
XBPS_STATE_TRANS_ADDPKG,
XBPS_STATE_ALTGROUP_ADDED,
XBPS_STATE_ALTGROUP_REMOVED,
XBPS_STATE_ALTGROUP_SWITCHED,
XBPS_STATE_ALTGROUP_LINK_ADDED,
XBPS_STATE_ALTGROUP_LINK_REMOVED
} xbps_state_t;
/**
* @struct xbps_state_cb_data xbps.h "xbps.h"
* @brief Structure to be passed as argument to the state function callback.
* All members are read-only and set internally by libxbps.
*/
struct xbps_state_cb_data {
/**
* @var xhp
*
* Pointer to our struct xbps_handle passed to xbps_init().
*/
struct xbps_handle *xhp;
/**
* @var desc
*
* Current state string description.
*/
const char *desc;
/**
* @var arg
*
* State string argument. String set on this
* variable may change depending on \a state.
*/
const char *arg;
/**
* @var err
*
* Current state error value (set internally, read-only).
*/
int err;
/**
* @var state
*
* Current state.
*/
xbps_state_t state;
};
/**
* @struct xbps_fetch_cb_data xbps.h "xbps.h"
* @brief Structure to be passed to the fetch function callback.
*
* This structure is passed as argument to the fetch progress function
* callback and its members will be updated when there's any progress.
* All members marked as read-only in this struct are set internally by
* xbps_unpack_binary_pkg() and shouldn't be modified in the passed
* function callback.
*/
struct xbps_fetch_cb_data {
/**
* @var xhp
*
* Pointer to our struct xbps_handle passed to xbps_init().
*/
struct xbps_handle *xhp;
/**
* @var file_size
*
* Filename size for the file to be fetched.
*/
off_t file_size;
/**
* @var file_offset
*
* Current offset for the filename being fetched.
*/
off_t file_offset;
/**
* @var file_dloaded
*
* Bytes downloaded for the file being fetched.
*/
off_t file_dloaded;
/**
* @var file_name
*
* File name being fetched.
*/
const char *file_name;
/**
* @var cb_start
*
* If true the function callback should be prepared to start
* the transfer progress.
*/
bool cb_start;
/**
* @var cb_update
*
* If true the function callback should be prepared to
* update the transfer progress.
*/
bool cb_update;
/**
* @var cb_end
*
* If true the function callback should be prepated to
* end the transfer progress.
*/
bool cb_end;
};
/**
* @struct xbps_unpack_cb_data xbps.h "xbps.h"
* @brief Structure to be passed to the unpack function callback.
*
* This structure is passed as argument to the unpack progress function
* callback and its members will be updated when there's any progress.
* All members in this struct are set internally by libxbps
* and should be used in read-only mode in the supplied function
* callback.
*/
struct xbps_unpack_cb_data {
/**
* @var xhp
*
* Pointer to our struct xbps_handle passed to xbps_init().
*/
struct xbps_handle *xhp;
/**
* @var pkgver
*
* Package name/version string of package being unpacked.
*/
const char *pkgver;
/**
* @var entry
*
* Entry pathname string.
*/
const char *entry;
/**
* @var entry_size
*
* Entry file size.
*/
int64_t entry_size;
/**
* @var entry_extract_count
*
* Total number of extracted entries.
*/
ssize_t entry_extract_count;
/**
* @var entry_total_count
*
* Total number of entries in package.
*/
ssize_t entry_total_count;
/**
* @var entry_is_conf
*
* If true "entry" is a configuration file.
*/
bool entry_is_conf;
};
/**
* @struct xbps_handle xbps.h "xbps.h"
* @brief Generic XBPS structure handler for initialization.
*
* This structure sets some global properties for libxbps, to set some
* function callbacks and data to the fetch, transaction and unpack functions,
* the root and cache directory, flags, etc.
*/
struct xbps_handle {
/**
* @private
*/
xbps_array_t preserved_files;
xbps_array_t ignored_pkgs;
xbps_array_t noextract;
/**
* @var repositories
*
* Proplib array of strings with repositories, overriding the list
* in the configuration file.
*/
xbps_array_t repositories;
/**
* @private
*/
int lock_fd;
/**
* @private
*/
xbps_dictionary_t pkgdb_revdeps;
xbps_dictionary_t vpkgd;
xbps_dictionary_t vpkgd_conf;
/**
* @var pkgdb
*
* Proplib dictionary with the master package database
* stored in XBPS_META_PATH/XBPS_PKGDB.
*/
xbps_dictionary_t pkgdb;
/**
* @var transd
*
* Proplib dictionary with transaction objects, required by
* xbps_transaction_commit().
*/
xbps_dictionary_t transd;
/**
* Pointer to the supplifed function callback to be used
* in the XBPS possible states.
*/
int (*state_cb)(const struct xbps_state_cb_data *, void *);
/**
* @var state_cb_data
*
* Pointer to user supplied data to be passed as argument to
* the \a xbps_state_cb function callback.
*/
void *state_cb_data;
/**
* Pointer to the supplied function callback to be used in
* xbps_unpack_binary_pkg().
*/
void (*unpack_cb)(const struct xbps_unpack_cb_data *, void *);
/**
* @var unpack_cb_data
*
* Pointer to user supplied data to be passed as argument to
* the \a xbps_unpack_cb function callback.
*/
void *unpack_cb_data;
/**
* Pointer to the supplied function callback to be used in
* xbps_fetch_file().
*/
void (*fetch_cb)(const struct xbps_fetch_cb_data *, void *);
/**
* @var fetch_cb_data
*
* Pointer to user supplied data to be passed as argument to
* the \a xbps_fetch_cb function callback.
*/
void *fetch_cb_data;
/**
* @var pkgdb_plist;
*
* Absolute pathname to the pkgdb plist file.
*/
char *pkgdb_plist;
/**
* @var target_arch
*
* Target architecture, as set by XBPS_TARGET_ARCH from environment.
*/
const char *target_arch;
/**
* @var confdir
*
* Full path to the xbps configuration directory.
*/
char confdir[XBPS_MAXPATH];
/**
* @var confdir
*
* Full path to the xbps configuration directory.
*/
char sysconfdir[XBPS_MAXPATH];
/**
* @var rootdir
*
* Root directory for all operations in XBPS.
* If unset, defaults to '/'.
*/
char rootdir[XBPS_MAXPATH];
/**
* @var cachedir
*
* Cache directory to store downloaded binary packages.
* If unset, defaults to \a XBPS_CACHE_PATH (relative to rootdir).
*/
char cachedir[XBPS_MAXPATH];
/**
* @var metadir
*
* Metadata directory for all operations in XBPS.
* If unset, defaults to \a XBPS_CACHE_PATH (relative to rootdir).
*/
char metadir[XBPS_MAXPATH];
/**
* @var native_arch
*
* Machine architecture, defaults to uname(2) machine
* if XBPS_ARCH is not set from environment.
*/
char native_arch[64];
/**
* @var flags
*
* Flags to be set globally by ORing them, possible value:
*
* - XBPS_FLAG_* (see above)
*/
int flags;
/**
* Number of parallel fetch jobs.
*/
unsigned int fetch_jobs;
};
/**
* Initialize the XBPS library with the following steps:
*
* - Set function callbacks for fetching and unpacking.
* - Set default cache connections for libfetch.
* - Parse configuration file.
*
* @param[in] xhp Pointer to an xbps_handle struct.
* @note It's assumed that \a xhp is a valid pointer.
*
* @return 0 on success, an errno value otherwise.
*/
int xbps_init(struct xbps_handle *xhp);
/**
* Releases all resources used by libxbps.
*
* @param[in] xhp Pointer to an xbps_handle struct.
*/
void xbps_end(struct xbps_handle *xhp);
/**@}*/
/** @addtogroup log */
/**@{*/
/**
* @brief The Debug level.
*/
extern int xbps_debug_level;
extern int xbps_verbose_level;
#if __has_attribute(format)
# define PRINTF_LIKE(a, b) __attribute__ ((format (printf, a, b)))
#else
# define PRINTF_LIKE(a, b) /* printflike */
#endif
/**
* @brief Prints debug messages to stderr.
* @param[in] fmt format specifier for the message.
*/
void xbps_dbg_printf(const char *fmt, ...) PRINTF_LIKE(1, 2);
/**
* @brief Prints debug messages to stderr.
* @param[in] fmt format specifier for the message.
*/
void xbps_dbg_printf_append(const char *fmt, ...) PRINTF_LIKE(1, 2);
/**
* @brief Prints messages to stderr if verbosity is enabled.
* @param[in] fmt format specifier for the message.
*/
void xbps_verbose_printf(const char *, ...) PRINTF_LIKE(1, 2);
/**
* @brief Prints error messages to stderr.
* @param[in] fmt format specifier for the message.
*/
void xbps_error_printf(const char *fmt, ...) PRINTF_LIKE(1, 2);
/**
* @brief Prints warning messages to stderr.
* @param[in] fmt format specifier for the message.
*/
void xbps_warn_printf(const char *fmt, ...) PRINTF_LIKE(1, 2);
/**
* @brief Prints formatted log message to stderr and returns error.
* @param[in] r errno to be returned.
* @param[in] fmt format specifier for the error message.
* @returns returns the specified error value \a r.
*/
int xbps_error_errno(int r, const char *fmt, ...) PRINTF_LIKE(2, 3);
/**
* @brief Log out of memory condition.
* @returns Returns `-ENOMEM`.
*/
#define xbps_error_oom() \
xbps_error_errno(ENOMEM, "%s:%d %s: out of memory\n", __FILE__, \
__LINE__, __func__)
/**
* @brief Log and abort for code that should be unreachable.
*/
#define xbps_unreachable() \
do { \
xbps_error_printf("%s:%d %s: code should not be reached\n", \
__FILE__, __LINE__, __func__); \
abort(); \
} while (0)
/**@}*/
/** @addtogroup configure */
/**@{*/
/**
* Configure (or force reconfiguration of) a package.
*
* @param[in] xhp Pointer to an xbps_handle struct.
* @param[in] pkgname Package name to configure.
* @param[in] check_state Set it to true to check that package is
* in unpacked state.
* @param[in] update Set it to true if this package is being updated.
*
* @return 0 on success, otherwise an errno value.
*/
int xbps_configure_pkg(struct xbps_handle *xhp, const char *pkgname,
bool check_state, bool update);
/**
* Configure (or force reconfiguration of) all packages.
*
* @param[in] xhp Pointer to an xbps_handle struct.
* @param[in] ignpkgs Proplib array of strings with pkgname or pkgvers to ignore.
*
* @return 0 on success, otherwise an errno value.
*/
int xbps_configure_packages(struct xbps_handle *xhp, xbps_array_t ignpkgs);
/**@}*/
/** @addtogroup download */
/**@{*/
/**
* Download a file from a remote URL to current working directory.
*
* @param[in] xhp Pointer to an xbps_handle struct.
* @param[in] uri Remote URI string.
* @param[in] flags Flags passed to libfetch's fetchXget().
*
* @return -1 on error, 0 if not downloaded (because local/remote size/mtime
* do not match) and 1 if downloaded successfully.
**/
int xbps_fetch_file(struct xbps_handle *xhp, const char *uri,
const char *flags);
/**
* Download and digest a file from a remote URL to current working directory.
*
* @param[in] xhp Pointer to an xbps_handle struct.
* @param[in] uri Remote URI string.
* @param[in] flags Flags passed to libfetch's fetchXget().
* @param[out] digest SHA256 digest buffer for the downloaded file or NULL.
* @param[in] digestlen Size of \a digest if specified; must be at least
* XBPS_SHA256_DIGEST_SIZE.
*
* @return -1 on error, 0 if not downloaded (because local/remote size/mtime
* do not match) and 1 if downloaded successfully.
**/
int xbps_fetch_file_sha256(struct xbps_handle *xhp, const char *uri,
const char *flags, unsigned char *digest,
size_t digestlen);
/**
* Download a file from a remote URL to current working directory,
* and writing file to \a filename.
*
* @param[in] xhp Pointer to an xbps_handle struct.
* @param[in] uri Remote URI string.
* @param[in] filename Local filename to safe the file
* @param[in] flags Flags passed to libfetch's fetchXget().
*
* @return -1 on error, 0 if not downloaded (because local/remote size/mtime
* do not match) and 1 if downloaded successfully.
**/
int xbps_fetch_file_dest(struct xbps_handle *xhp, const char *uri,
const char *filename, const char *flags);
/**
* Download and digest a file from a remote URL to current working directory,
* and writing file to \a filename.
*
* @param[in] xhp Pointer to an xbps_handle struct.
* @param[in] uri Remote URI string.
* @param[in] filename Local filename to safe the file
* @param[in] flags Flags passed to libfetch's fetchXget().
* @param[out] digest SHA256 digest buffer of the downloaded file or NULL.
* @param[in] digestlen Size of \a digest if specified; must be at least
* XBPS_SHA256_DIGEST_SIZE.
*
* @return -1 on error, 0 if not downloaded (because local/remote size/mtime
* do not match) and 1 if downloaded successfully.
**/
int xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri,
const char *filename, const char *flags,
unsigned char *digest, size_t digestlen);
/**
* Returns last error string reported by xbps_fetch_file().
*
* @return A string with the appropiate error message.
*/
const char *xbps_fetch_error_string(void);
/**@}*/
/**
* @ingroup pkg_orphans
*
* Finds all package orphans currently installed.
*
* @param[in] xhp Pointer to an xbps_handle struct.
* @param[in] orphans Proplib array of strings with package names of
* packages that should be treated as they were already removed (optional).
*
* @return A proplib array of dictionaries with all orphans found,
* on error NULL is returned and errno is set appropiately.
*/
xbps_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans);
/** @addtogroup pkgdb */
/**@{*/
/**
* Locks the pkgdb to allow a write transaction.
*
* This routine should be called before a write transaction is the target:
* install, remove or update.
*
* @param[in] xhp The pointer to the xbps_handle struct.
* @return 0 on success, otherwise an errno value.
*/
int xbps_pkgdb_lock(struct xbps_handle *xhp);
/**
* Unlocks the pkgdb after a write transaction.
*
* @param[in] xhp The pointer to the xbps_handle struct.
*/
void xbps_pkgdb_unlock(struct xbps_handle *xhp);
/**
* Executes a function callback per a package dictionary registered
* in the package database (pkgdb) plist.
*
* @param[in] xhp The pointer to the xbps_handle struct.
* @param[in] fn Function callback to run for any pkg dictionary.
* @param[in] arg Argument to be passed to the function callback.
*
* @return 0 on success (all objects were processed), otherwise
* the value returned by the function callback.
*/
int xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
int (*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *),
void *arg);
/**
* Executes a function callback per a package dictionary registered
* in the package database (pkgdb) plist.
*
* This is a multithreaded implementation spawning a thread per core. Each
* thread processes a fraction of total objects in the pkgdb dictionary.
*
* @param[in] xhp The pointer to the xbps_handle struct.
* @param[in] fn Function callback to run for any pkg dictionary.
* @param[in] arg Argument to be passed to the function callback.
*
* @return 0 on success (all objects were processed), otherwise
* the value returned by the function callback.
*/
int xbps_pkgdb_foreach_cb_multi(struct xbps_handle *xhp,
int (*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *),
void *arg);
/**
* Returns a package dictionary from the package database (pkgdb),
* matching pkgname or pkgver object in \a pkg.
*
* @param[in] xhp The pointer to the xbps_handle struct.
* @param[in] pkg Package name or name-version to match.
*
* @return The matching proplib package dictionary, NULL otherwise.
*/
xbps_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp,
const char *pkg);
/**
* Returns a package dictionary from the package database (pkgdb),
* matching virtual pkgname or pkgver object in \a pkg.
*
* @param[in] xhp The pointer to the xbps_handle struct.
* @param[in] pkg Package name or name-version to match.
*
* @return The matching proplib package dictionary, NULL otherwise.
*/
xbps_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp,
const char *pkg);
/**
* Returns the package dictionary with all files for \a pkg.
*
* @param[in] xhp The pointer to the xbps_handle struct.
* @param[in] pkg Package expression to match.
*
* @return The matching package dictionary, NULL otherwise.
*/