XBPS Library API 20260225
The X Binary Package System
xbps.h
1/*-
2 * Copyright (c) 2008-2020 Juan Romero Pardines <xtraeme@gmail.com>
3 * Copyright (c) 2014-2019 Enno Boland <gottox@voidlinux.org>
4 * Copyright (c) 2016-2019 Duncan Overbruck <mail@duncano.de>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *-
27 */
28
29#ifndef _XBPS_H_
30#define _XBPS_H_
31
32#include <stdio.h>
33#include <stdbool.h>
34#include <inttypes.h>
35#include <errno.h>
36
37#include <xbps/xbps_array.h>
38#include <xbps/xbps_bool.h>
39#include <xbps/xbps_data.h>
40#include <xbps/xbps_dictionary.h>
41#include <xbps/xbps_number.h>
42#include <xbps/xbps_string.h>
43
44#define XBPS_MAXPATH 512
45#define XBPS_NAME_SIZE 64
46
47/**
48 * @file include/xbps.h
49 * @brief XBPS Library API header
50 *
51 * This header documents the full API for the XBPS Library.
52 */
53#define XBPS_API_VERSION "20250629"
54
55#ifndef XBPS_VERSION
56 #define XBPS_VERSION "UNSET"
57#endif
58#ifndef XBPS_GIT
59 #define XBPS_GIT "UNSET"
60#endif
61/**
62 * @def XBPS_RELVER
63 * Current library release date.
64 */
65#define XBPS_RELVER "XBPS: " XBPS_VERSION \
66 " API: " XBPS_API_VERSION \
67 " GIT: " XBPS_GIT
68
69/**
70 * @def XBPS_SYSCONF_PATH
71 * Default configuration PATH to find XBPS_CONF_PLIST.
72 */
73#define XBPS_SYSDIR "/xbps.d"
74#ifndef XBPS_SYSCONF_PATH
75# define XBPS_SYSCONF_PATH "/etc" XBPS_SYSDIR
76#endif
77#ifndef XBPS_SYSDEFCONF_PATH
78# define XBPS_SYSDEFCONF_PATH "/usr/share" XBPS_SYSDIR
79#endif
80
81/**
82 * @def XBPS_META_PATH
83 * Default root PATH to store metadata info.
84 */
85#ifndef XBPS_META_PATH
86#define XBPS_META_PATH "var/db/xbps"
87#endif
88
89/**
90 * @def XBPS_CACHE_PATH
91 * Default cache PATH to store downloaded binpkgs.
92 */
93#define XBPS_CACHE_PATH "var/cache/xbps"
94
95/**
96 * @def XBPS_PKGDB
97 * Filename for the package database.
98 */
99#define XBPS_PKGDB "pkgdb-0.38.plist"
100
101/**
102 * @def XBPS_PKGPROPS
103 * Filename for package metadata property list.
104 */
105#define XBPS_PKGPROPS "props.plist"
106
107/**
108 * @def XBPS_PKGFILES
109 * Filename for package metadata files property list.
110 */
111#define XBPS_PKGFILES "files.plist"
112
113/**
114 * @def XBPS_REPODATA_INDEX
115 * Filename for the repository index property list.
116 */
117#define XBPS_REPODATA_INDEX "index.plist"
118
119/**
120 * @def XBPS_REPODATA_STAGE
121 * Filename for the repository stage property list.
122 */
123#define XBPS_REPODATA_STAGE "stage.plist"
124
125/**
126 * @def XBPS_REPODATA_META
127 * Filename for the repository index metadata property list.
128 */
129#define XBPS_REPODATA_META "index-meta.plist"
130
131/**
132 * @def XBPS_FLAG_VERBOSE
133 * Verbose flag that can be used in the function callbacks to alter
134 * its behaviour. Must be set through the xbps_handle::flags member.
135 */
136#define XBPS_FLAG_VERBOSE 0x00000001
137
138/**
139 * @def XBPS_FLAG_FORCE_CONFIGURE
140 * Force flag used in xbps_configure_pkg(), if set the package(s)
141 * will be reconfigured even if its state is XBPS_PKG_STATE_INSTALLED.
142 * Must be set through the xbps_handle::flags member.
143 */
144#define XBPS_FLAG_FORCE_CONFIGURE 0x00000002
145
146/**
147 * @def XBPS_FLAG_FORCE_REMOVE_FILES
148 * Force flag used in xbps_remove_pkg_files(), if set the package
149 * files will be removed even if its SHA256 hash don't match.
150 * Must be set through the xbps_handle::flags member.
151 */
152#define XBPS_FLAG_FORCE_REMOVE_FILES 0x00000004
153
154/**
155 * @def XBPS_FLAG_INSTALL_AUTO
156 * Enabled automatic install mode for a package and all dependencies
157 * installed direct and indirectly.
158 */
159#define XBPS_FLAG_INSTALL_AUTO 0x00000010
160
161/**
162 * @def XBPS_FLAG_DEBUG
163 * Enable debug mode to output debugging printfs to stdout/stderr.
164 */
165#define XBPS_FLAG_DEBUG 0x00000020
166
167/**
168 * @def XBPS_FLAG_FORCE_UNPACK
169 * Force flag used in xbps_unpack_binary_pkg(). If set its package
170 * files will be unpacked overwritting the current ones.
171 * Must be set through the xbps_handle::flags member.
172 */
173#define XBPS_FLAG_FORCE_UNPACK 0x00000040
174
175/**
176 * @def XBPS_FLAG_DISABLE_SYSLOG
177 * Disable syslog logging, enabled by default.
178 * Must be set through the xbps_handle::flags member.
179 */
180#define XBPS_FLAG_DISABLE_SYSLOG 0x00000080
181
182/**
183 * @def XBPS_FLAG_BESTMATCH
184 * Enable pkg best matching when resolving packages.
185 * Must be set through the xbps_handle::flags member.
186 */
187#define XBPS_FLAG_BESTMATCH 0x00000100
188
189/**
190 * @def XBPS_FLAG_IGNORE_CONF_REPOS
191 * Ignore repos defined in configuration files.
192 * Must be set through the xbps_handle::flags member.
193 */
194#define XBPS_FLAG_IGNORE_CONF_REPOS 0x00000200
195
196/**
197 * @def XBPS_FLAG_REPOS_MEMSYNC
198 * Fetch and store repodata in memory, ignoring on-disk metadata.
199 * Must be set through the xbps_handle::flags member.
200 */
201#define XBPS_FLAG_REPOS_MEMSYNC 0x00000400
202
203/**
204 * @def XBPS_FLAG_FORCE_REMOVE_REVDEPS
205 * Continue with transaction even if there are broken reverse
206 * dependencies, due to unresolved shared libraries or dependencies.
207 * Must be set through the xbps_handle::flags member.
208 */
209#define XBPS_FLAG_FORCE_REMOVE_REVDEPS 0x00000800
210
211/**
212 * @def XBPS_FLAG_UNPACK_ONLY
213 * Do not configure packages in the transaction, just unpack them.
214 * Must be set through the xbps_handle::flags member.
215 */
216#define XBPS_FLAG_UNPACK_ONLY 0x00001000
217
218/**
219 * @def XBPS_FLAG_DOWNLOAD_ONLY
220 * Only download packages to the cache, do not do any installation steps.
221 * Must be set through the xbps_handle::flags member.
222 */
223#define XBPS_FLAG_DOWNLOAD_ONLY 0x00002000
224
225/*
226 * @def XBPS_FLAG_IGNORE_FILE_CONFLICTS
227 * Continue with transaction even if there are file conflicts.
228 * Must be set through the xbps_handle::flags member.
229 */
230#define XBPS_FLAG_IGNORE_FILE_CONFLICTS 0x00004000
231
232/**
233 * @def XBPS_FLAG_INSTALL_REPRO
234 * Enabled reproducible mode; skips adding the "install-date"
235 * and "repository" objs into pkgdb.
236 * Must be set through the xbps_handle::flags member.
237 */
238#define XBPS_FLAG_INSTALL_REPRO 0x00008000
239
240/**
241 * @def XBPS_FLAG_KEEP_CONFIG
242 * Don't overwrite configuration files that have not changed since
243 * installation.
244 * Must be set through the xbps_handle::flags member.
245 */
246#define XBPS_FLAG_KEEP_CONFIG 0x00010000
247
248/**
249 * @def XBPS_FLAG_USE_STAGE
250 * Use the staging repository if available.
251 * Must be set through the xbps_handle::flags member.
252 */
253#define XBPS_FLAG_USE_STAGE 0x00020000
254
255/**
256 * @def XBPS_FETCH_CACHECONN
257 * Default (global) limit of cached connections used in libfetch.
258 */
259#define XBPS_FETCH_CACHECONN 32
260
261/**
262 * @def XBPS_FETCH_CACHECONN_HOST
263 * Default (per host) limit of cached connections used in libfetch.
264 */
265#define XBPS_FETCH_CACHECONN_HOST 16
266
267/**
268 * @def XBPS_FETCH_TIMEOUT
269 * Default timeout limit (in seconds) to wait for stalled connections.
270 */
271#define XBPS_FETCH_TIMEOUT 30
272
273/**
274 * @def XBPS_SHA256_DIGEST_SIZE
275 * The size for a binary SHA256 digests.
276 */
277#define XBPS_SHA256_DIGEST_SIZE 32
278
279/**
280 * @def XBPS_SHA256_SIZE
281 * The size for a hex string SHA256 hash.
282 */
283#define XBPS_SHA256_SIZE (XBPS_SHA256_DIGEST_SIZE*2)+1
284
285#ifdef __cplusplus
286extern "C" {
287#endif
288
289/** @addtogroup initend */
290/**@{*/
291
292/**
293 * @enum xbps_state_t
294 *
295 * Integer representing the xbps callback returned state. Possible values:
296 *
297 * - XBPS_STATE_UKKNOWN: state hasn't been prepared or unknown error.
298 * - XBPS_STATE_TRANS_DOWNLOAD: transaction is downloading binary packages.
299 * - XBPS_STATE_TRANS_VERIFY: transaction is verifying binary package integrity.
300 * - XBPS_STATE_TRANS_RUN: transaction is performing operations: install, update, remove, replace.
301 * - XBPS_STATE_TRANS_CONFIGURE: transaction is configuring all unpacked packages.
302 * - XBPS_STATE_TRANS_FAIL: transaction has failed.
303 * - XBPS_STATE_DOWNLOAD: a binary package is being downloaded.
304 * - XBPS_STATE_VERIFY: a binary package is being verified.
305 * - XBPS_STATE_REMOVE: a package is being removed.
306 * - XBPS_STATE_REMOVE_DONE: a package has been removed successfully.
307 * - XBPS_STATE_REMOVE_FILE: a package file is being removed.
308 * - XBPS_STATE_REMOVE_OBSOLETE: an obsolete package file is being removed.
309 * - XBPS_STATE_REPLACE: a package is being replaced.
310 * - XBPS_STATE_INSTALL: a package is being installed.
311 * - XBPS_STATE_INSTALL_DONE: a package has been installed successfully.
312 * - XBPS_STATE_UPDATE: a package is being updated.
313 * - XBPS_STATE_UPDATE_DONE: a package has been updated successfully.
314 * - XBPS_STATE_UNPACK: a package is being unpacked.
315 * - XBPS_STATE_CONFIGURE: a package is being configured.
316 * - XBPS_STATE_CONFIGURE_DONE: a package has been configured successfully.
317 * - XBPS_STATE_CONFIG_FILE: a package configuration file is being processed.
318 * - XBPS_STATE_REPOSYNC: a remote repository's package index is being synchronized.
319 * - XBPS_STATE_VERIFY_FAIL: binary package integrity has failed.
320 * - XBPS_STATE_DOWNLOAD_FAIL: binary package download has failed.
321 * - XBPS_STATE_REMOVE_FAIL: a package removal has failed.
322 * - XBPS_STATE_REMOVE_FILE_FAIL: a package file removal has failed.
323 * - XBPS_STATE_REMOVE_FILE_HASH_FAIL: a package file removal has failed due to hash.
324 * - XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL: an obsolete package file removal has failed.
325 * - XBPS_STATE_CONFIGURE_FAIL: package configure has failed.
326 * - XBPS_STATE_CONFIG_FILE_FAIL: package configuration file operation has failed.
327 * - XBPS_STATE_UPDATE_FAIL: package update has failed.
328 * - XBPS_STATE_UNPACK_FAIL: package unpack has failed.
329 * - XBPS_STATE_REPOSYNC_FAIL: syncing remote repositories has failed.
330 * - XBPS_STATE_REPO_KEY_IMPORT: repository is signed and needs to import pubkey.
331 * - XBPS_STATE_INVALID_DEP: package has an invalid dependency.
332 * - XBPS_STATE_ALTGROUP_ADDED: package has registered an alternative group.
333 * - XBPS_STATE_ALTGROUP_REMOVED: package has unregistered an alternative group.
334 * - XBPS_STATE_ALTGROUP_SWITCHED: alternative group has been switched.
335 * - XBPS_STATE_ALTGROUP_LINK_ADDED: link added by an alternative group.
336 * - XBPS_STATE_ALTGROUP_LINK_REMOVED: link removed by an alternative group.
337 * - XBPS_STATE_UNPACK_FILE_PRESERVED: package unpack preserved a file.
338 * - XBPS_STATE_PKGDB: pkgdb upgrade in progress.
339 * - XBPS_STATE_PKGDB_DONE: pkgdb has been upgraded successfully.
340 */
341typedef enum xbps_state {
342 XBPS_STATE_UNKNOWN = 0,
343 XBPS_STATE_TRANS_DOWNLOAD,
344 XBPS_STATE_TRANS_VERIFY,
345 XBPS_STATE_TRANS_FILES,
346 XBPS_STATE_TRANS_RUN,
347 XBPS_STATE_TRANS_CONFIGURE,
348 XBPS_STATE_TRANS_FAIL,
349 XBPS_STATE_DOWNLOAD,
350 XBPS_STATE_VERIFY,
351 XBPS_STATE_FILES,
352 XBPS_STATE_REMOVE,
353 XBPS_STATE_REMOVE_DONE,
354 XBPS_STATE_REMOVE_FILE,
355 XBPS_STATE_REMOVE_FILE_OBSOLETE,
356 XBPS_STATE_PURGE,
357 XBPS_STATE_PURGE_DONE,
358 XBPS_STATE_REPLACE,
359 XBPS_STATE_INSTALL,
360 XBPS_STATE_INSTALL_DONE,
361 XBPS_STATE_UPDATE,
362 XBPS_STATE_UPDATE_DONE,
363 XBPS_STATE_UNPACK,
364 XBPS_STATE_CONFIGURE,
365 XBPS_STATE_CONFIG_FILE,
366 XBPS_STATE_REPOSYNC,
367 XBPS_STATE_VERIFY_FAIL,
368 XBPS_STATE_FILES_FAIL,
369 XBPS_STATE_DOWNLOAD_FAIL,
370 XBPS_STATE_REMOVE_FAIL,
371 XBPS_STATE_REMOVE_FILE_FAIL,
372 XBPS_STATE_REMOVE_FILE_HASH_FAIL,
373 XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
374 XBPS_STATE_PURGE_FAIL,
375 XBPS_STATE_CONFIGURE_FAIL,
376 XBPS_STATE_CONFIG_FILE_FAIL,
377 XBPS_STATE_UPDATE_FAIL,
378 XBPS_STATE_UNPACK_FAIL,
379 XBPS_STATE_REPOSYNC_FAIL,
380 XBPS_STATE_CONFIGURE_DONE,
381 XBPS_STATE_REPO_KEY_IMPORT,
382 XBPS_STATE_INVALID_DEP,
383 XBPS_STATE_UNPACK_FILE_PRESERVED,
384 XBPS_STATE_PKGDB,
385 XBPS_STATE_PKGDB_DONE,
386 XBPS_STATE_TRANS_ADDPKG,
387 XBPS_STATE_ALTGROUP_ADDED,
388 XBPS_STATE_ALTGROUP_REMOVED,
389 XBPS_STATE_ALTGROUP_SWITCHED,
390 XBPS_STATE_ALTGROUP_LINK_ADDED,
391 XBPS_STATE_ALTGROUP_LINK_REMOVED
393
394/**
395 * @struct xbps_state_cb_data xbps.h "xbps.h"
396 * @brief Structure to be passed as argument to the state function callback.
397 * All members are read-only and set internally by libxbps.
398 */
400 /**
401 * @var xhp
402 *
403 * Pointer to our struct xbps_handle passed to xbps_init().
404 */
406 /**
407 * @var desc
408 *
409 * Current state string description.
410 */
411 const char *desc;
412 /**
413 * @var arg
414 *
415 * State string argument. String set on this
416 * variable may change depending on \a state.
417 */
418 const char *arg;
419 /**
420 * @var err
421 *
422 * Current state error value (set internally, read-only).
423 */
424 int err;
425 /**
426 * @var state
427 *
428 * Current state.
429 */
431};
432
433/**
434 * @struct xbps_fetch_cb_data xbps.h "xbps.h"
435 * @brief Structure to be passed to the fetch function callback.
436 *
437 * This structure is passed as argument to the fetch progress function
438 * callback and its members will be updated when there's any progress.
439 * All members marked as read-only in this struct are set internally by
440 * xbps_unpack_binary_pkg() and shouldn't be modified in the passed
441 * function callback.
442 */
444 /**
445 * @var xhp
446 *
447 * Pointer to our struct xbps_handle passed to xbps_init().
448 */
450 /**
451 * @var file_size
452 *
453 * Filename size for the file to be fetched.
454 */
456 /**
457 * @var file_offset
458 *
459 * Current offset for the filename being fetched.
460 */
462 /**
463 * @var file_dloaded
464 *
465 * Bytes downloaded for the file being fetched.
466 */
468 /**
469 * @var file_name
470 *
471 * File name being fetched.
472 */
473 const char *file_name;
474 /**
475 * @var cb_start
476 *
477 * If true the function callback should be prepared to start
478 * the transfer progress.
479 */
481 /**
482 * @var cb_update
483 *
484 * If true the function callback should be prepared to
485 * update the transfer progress.
486 */
488 /**
489 * @var cb_end
490 *
491 * If true the function callback should be prepated to
492 * end the transfer progress.
493 */
494 bool cb_end;
495};
496
497/**
498 * @struct xbps_unpack_cb_data xbps.h "xbps.h"
499 * @brief Structure to be passed to the unpack function callback.
500 *
501 * This structure is passed as argument to the unpack progress function
502 * callback and its members will be updated when there's any progress.
503 * All members in this struct are set internally by libxbps
504 * and should be used in read-only mode in the supplied function
505 * callback.
506 */
508 /**
509 * @var xhp
510 *
511 * Pointer to our struct xbps_handle passed to xbps_init().
512 */
514 /**
515 * @var pkgver
516 *
517 * Package name/version string of package being unpacked.
518 */
519 const char *pkgver;
520 /**
521 * @var entry
522 *
523 * Entry pathname string.
524 */
525 const char *entry;
526 /**
527 * @var entry_size
528 *
529 * Entry file size.
530 */
531 int64_t entry_size;
532 /**
533 * @var entry_extract_count
534 *
535 * Total number of extracted entries.
536 */
538 /**
539 * @var entry_total_count
540 *
541 * Total number of entries in package.
542 */
544 /**
545 * @var entry_is_conf
546 *
547 * If true "entry" is a configuration file.
548 */
550};
551
552/**
553 * @struct xbps_handle xbps.h "xbps.h"
554 * @brief Generic XBPS structure handler for initialization.
555 *
556 * This structure sets some global properties for libxbps, to set some
557 * function callbacks and data to the fetch, transaction and unpack functions,
558 * the root and cache directory, flags, etc.
559 */
561 /**
562 * @private
563 */
564 xbps_array_t preserved_files;
565 xbps_array_t ignored_pkgs;
566 xbps_array_t noextract;
567 /**
568 * @var repositories
569 *
570 * Proplib array of strings with repositories, overriding the list
571 * in the configuration file.
572 */
573 xbps_array_t repositories;
574 /**
575 * @private
576 */
577 int lock_fd;
578 /**
579 * @private
580 */
581 xbps_dictionary_t pkgdb_revdeps;
582 xbps_dictionary_t vpkgd;
583 xbps_dictionary_t vpkgd_conf;
584 /**
585 * @var pkgdb
586 *
587 * Proplib dictionary with the master package database
588 * stored in XBPS_META_PATH/XBPS_PKGDB.
589 */
590 xbps_dictionary_t pkgdb;
591 /**
592 * @var transd
593 *
594 * Proplib dictionary with transaction objects, required by
595 * xbps_transaction_commit().
596 */
597 xbps_dictionary_t transd;
598 /**
599 * Pointer to the supplifed function callback to be used
600 * in the XBPS possible states.
601 */
602 int (*state_cb)(const struct xbps_state_cb_data *, void *);
603 /**
604 * @var state_cb_data
605 *
606 * Pointer to user supplied data to be passed as argument to
607 * the \a xbps_state_cb function callback.
608 */
610 /**
611 * Pointer to the supplied function callback to be used in
612 * xbps_unpack_binary_pkg().
613 */
614 void (*unpack_cb)(const struct xbps_unpack_cb_data *, void *);
615 /**
616 * @var unpack_cb_data
617 *
618 * Pointer to user supplied data to be passed as argument to
619 * the \a xbps_unpack_cb function callback.
620 */
622 /**
623 * Pointer to the supplied function callback to be used in
624 * xbps_fetch_file().
625 */
626 void (*fetch_cb)(const struct xbps_fetch_cb_data *, void *);
627 /**
628 * @var fetch_cb_data
629 *
630 * Pointer to user supplied data to be passed as argument to
631 * the \a xbps_fetch_cb function callback.
632 */
634 /**
635 * @var pkgdb_plist;
636 *
637 * Absolute pathname to the pkgdb plist file.
638 */
640 /**
641 * @var target_arch
642 *
643 * Target architecture, as set by XBPS_TARGET_ARCH from environment.
644 */
645 const char *target_arch;
646 /**
647 * @var confdir
648 *
649 * Full path to the xbps configuration directory.
650 */
651 char confdir[XBPS_MAXPATH];
652 /**
653 * @var confdir
654 *
655 * Full path to the xbps configuration directory.
656 */
657 char sysconfdir[XBPS_MAXPATH];
658 /**
659 * @var rootdir
660 *
661 * Root directory for all operations in XBPS.
662 * If unset, defaults to '/'.
663 */
664 char rootdir[XBPS_MAXPATH];
665 /**
666 * @var cachedir
667 *
668 * Cache directory to store downloaded binary packages.
669 * If unset, defaults to \a XBPS_CACHE_PATH (relative to rootdir).
670 */
671 char cachedir[XBPS_MAXPATH];
672 /**
673 * @var metadir
674 *
675 * Metadata directory for all operations in XBPS.
676 * If unset, defaults to \a XBPS_CACHE_PATH (relative to rootdir).
677 */
678 char metadir[XBPS_MAXPATH];
679 /**
680 * @var native_arch
681 *
682 * Machine architecture, defaults to uname(2) machine
683 * if XBPS_ARCH is not set from environment.
684 */
685 char native_arch[64];
686 /**
687 * @var flags
688 *
689 * Flags to be set globally by ORing them, possible value:
690 *
691 * - XBPS_FLAG_* (see above)
692 */
693 int flags;
694};
695
696/**
697 * Initialize the XBPS library with the following steps:
698 *
699 * - Set function callbacks for fetching and unpacking.
700 * - Set default cache connections for libfetch.
701 * - Parse configuration file.
702 *
703 * @param[in] xhp Pointer to an xbps_handle struct.
704 * @note It's assumed that \a xhp is a valid pointer.
705 *
706 * @return 0 on success, an errno value otherwise.
707 */
708int xbps_init(struct xbps_handle *xhp);
709
710/**
711 * Releases all resources used by libxbps.
712 *
713 * @param[in] xhp Pointer to an xbps_handle struct.
714 */
715void xbps_end(struct xbps_handle *xhp);
716
717/**@}*/
718
719/** @addtogroup log */
720/**@{*/
721
722/**
723 * @brief The Debug level.
724 */
725extern int xbps_debug_level;
726extern int xbps_verbose_level;
727
728#if __has_attribute(format)
729# define PRINTF_LIKE(a, b) __attribute__ ((format (printf, a, b)))
730#else
731# define PRINTF_LIKE(a, b) /* printflike */
732#endif
733
734/**
735 * @brief Prints debug messages to stderr.
736 * @param[in] fmt format specifier for the message.
737 */
738void xbps_dbg_printf(const char *fmt, ...) PRINTF_LIKE(1, 2);
739
740/**
741 * @brief Prints debug messages to stderr.
742 * @param[in] fmt format specifier for the message.
743 */
744void xbps_dbg_printf_append(const char *fmt, ...) PRINTF_LIKE(1, 2);
745
746/**
747 * @brief Prints messages to stderr if verbosity is enabled.
748 * @param[in] fmt format specifier for the message.
749 */
750void xbps_verbose_printf(const char *, ...) PRINTF_LIKE(1, 2);
751
752/**
753 * @brief Prints error messages to stderr.
754 * @param[in] fmt format specifier for the message.
755 */
756void xbps_error_printf(const char *fmt, ...) PRINTF_LIKE(1, 2);
757
758/**
759 * @brief Prints warning messages to stderr.
760 * @param[in] fmt format specifier for the message.
761 */
762void xbps_warn_printf(const char *fmt, ...) PRINTF_LIKE(1, 2);
763
764/**
765 * @brief Prints formatted log message to stderr and returns error.
766 * @param[in] r errno to be returned.
767 * @param[in] fmt format specifier for the error message.
768 * @returns returns the specified error value \a r.
769 */
770int xbps_error_errno(int r, const char *fmt, ...) PRINTF_LIKE(2, 3);
771
772/**
773 * @brief Log out of memory condition.
774 * @returns Returns `-ENOMEM`.
775 */
776#define xbps_error_oom() \
777 xbps_error_errno(ENOMEM, "%s:%d %s: out of memory\n", __FILE__, \
778 __LINE__, __func__)
779
780/**
781 * @brief Log and abort for code that should be unreachable.
782 */
783#define xbps_unreachable() \
784 do { \
785 xbps_error_printf("%s:%d %s: code should not be reached\n", \
786 __FILE__, __LINE__, __func__); \
787 abort(); \
788 } while (0)
789
790/**@}*/
791
792/** @addtogroup configure */
793/**@{*/
794
795/**
796 * Configure (or force reconfiguration of) a package.
797 *
798 * @param[in] xhp Pointer to an xbps_handle struct.
799 * @param[in] pkgname Package name to configure.
800 * @param[in] check_state Set it to true to check that package is
801 * in unpacked state.
802 * @param[in] update Set it to true if this package is being updated.
803 *
804 * @return 0 on success, otherwise an errno value.
805 */
806int xbps_configure_pkg(struct xbps_handle *xhp, const char *pkgname,
807 bool check_state, bool update);
808
809/**
810 * Configure (or force reconfiguration of) all packages.
811 *
812 * @param[in] xhp Pointer to an xbps_handle struct.
813 * @param[in] ignpkgs Proplib array of strings with pkgname or pkgvers to ignore.
814 *
815 * @return 0 on success, otherwise an errno value.
816 */
817int xbps_configure_packages(struct xbps_handle *xhp, xbps_array_t ignpkgs);
818
819/**@}*/
820
821/** @addtogroup download */
822/**@{*/
823
824/**
825 * Download a file from a remote URL to current working directory.
826 *
827 * @param[in] xhp Pointer to an xbps_handle struct.
828 * @param[in] uri Remote URI string.
829 * @param[in] flags Flags passed to libfetch's fetchXget().
830 *
831 * @return -1 on error, 0 if not downloaded (because local/remote size/mtime
832 * do not match) and 1 if downloaded successfully.
833 **/
834int xbps_fetch_file(struct xbps_handle *xhp, const char *uri,
835 const char *flags);
836
837/**
838 * Download and digest a file from a remote URL to current working directory.
839 *
840 * @param[in] xhp Pointer to an xbps_handle struct.
841 * @param[in] uri Remote URI string.
842 * @param[in] flags Flags passed to libfetch's fetchXget().
843 * @param[out] digest SHA256 digest buffer for the downloaded file or NULL.
844 * @param[in] digestlen Size of \a digest if specified; must be at least
845 * XBPS_SHA256_DIGEST_SIZE.
846 *
847 * @return -1 on error, 0 if not downloaded (because local/remote size/mtime
848 * do not match) and 1 if downloaded successfully.
849 **/
850int xbps_fetch_file_sha256(struct xbps_handle *xhp, const char *uri,
851 const char *flags, unsigned char *digest,
852 size_t digestlen);
853
854/**
855 * Download a file from a remote URL to current working directory,
856 * and writing file to \a filename.
857 *
858 * @param[in] xhp Pointer to an xbps_handle struct.
859 * @param[in] uri Remote URI string.
860 * @param[in] filename Local filename to safe the file
861 * @param[in] flags Flags passed to libfetch's fetchXget().
862 *
863 * @return -1 on error, 0 if not downloaded (because local/remote size/mtime
864 * do not match) and 1 if downloaded successfully.
865 **/
866int xbps_fetch_file_dest(struct xbps_handle *xhp, const char *uri,
867 const char *filename, const char *flags);
868
869/**
870 * Download and digest a file from a remote URL to current working directory,
871 * and writing file to \a filename.
872 *
873 * @param[in] xhp Pointer to an xbps_handle struct.
874 * @param[in] uri Remote URI string.
875 * @param[in] filename Local filename to safe the file
876 * @param[in] flags Flags passed to libfetch's fetchXget().
877 * @param[out] digest SHA256 digest buffer of the downloaded file or NULL.
878 * @param[in] digestlen Size of \a digest if specified; must be at least
879 * XBPS_SHA256_DIGEST_SIZE.
880 *
881 * @return -1 on error, 0 if not downloaded (because local/remote size/mtime
882 * do not match) and 1 if downloaded successfully.
883 **/
884int xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri,
885 const char *filename, const char *flags,
886 unsigned char *digest, size_t digestlen);
887
888/**
889 * Returns last error string reported by xbps_fetch_file().
890 *
891 * @return A string with the appropiate error message.
892 */
893const char *xbps_fetch_error_string(void);
894
895/**@}*/
896
897/**
898 * @ingroup pkg_orphans
899 *
900 * Finds all package orphans currently installed.
901 *
902 * @param[in] xhp Pointer to an xbps_handle struct.
903 * @param[in] orphans Proplib array of strings with package names of
904 * packages that should be treated as they were already removed (optional).
905 *
906 * @return A proplib array of dictionaries with all orphans found,
907 * on error NULL is returned and errno is set appropiately.
908 */
909xbps_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans);
910
911/** @addtogroup pkgdb */
912/**@{*/
913
914/**
915 * Locks the pkgdb to allow a write transaction.
916 *
917 * This routine should be called before a write transaction is the target:
918 * install, remove or update.
919 *
920 * @param[in] xhp The pointer to the xbps_handle struct.
921 * @return 0 on success, otherwise an errno value.
922 */
923int xbps_pkgdb_lock(struct xbps_handle *xhp);
924
925/**
926 * Unlocks the pkgdb after a write transaction.
927 *
928 * @param[in] xhp The pointer to the xbps_handle struct.
929 */
930void xbps_pkgdb_unlock(struct xbps_handle *xhp);
931
932/**
933 * Executes a function callback per a package dictionary registered
934 * in the package database (pkgdb) plist.
935 *
936 * @param[in] xhp The pointer to the xbps_handle struct.
937 * @param[in] fn Function callback to run for any pkg dictionary.
938 * @param[in] arg Argument to be passed to the function callback.
939 *
940 * @return 0 on success (all objects were processed), otherwise
941 * the value returned by the function callback.
942 */
944 int (*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *),
945 void *arg);
946
947/**
948 * Executes a function callback per a package dictionary registered
949 * in the package database (pkgdb) plist.
950 *
951 * This is a multithreaded implementation spawning a thread per core. Each
952 * thread processes a fraction of total objects in the pkgdb dictionary.
953 *
954 * @param[in] xhp The pointer to the xbps_handle struct.
955 * @param[in] fn Function callback to run for any pkg dictionary.
956 * @param[in] arg Argument to be passed to the function callback.
957 *
958 * @return 0 on success (all objects were processed), otherwise
959 * the value returned by the function callback.
960 */
962 int (*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *),
963 void *arg);
964
965/**
966 * Returns a package dictionary from the package database (pkgdb),
967 * matching pkgname or pkgver object in \a pkg.
968 *
969 * @param[in] xhp The pointer to the xbps_handle struct.
970 * @param[in] pkg Package name or name-version to match.
971 *
972 * @return The matching proplib package dictionary, NULL otherwise.
973 */
974xbps_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp,
975 const char *pkg);
976
977/**
978 * Returns a package dictionary from the package database (pkgdb),
979 * matching virtual pkgname or pkgver object in \a pkg.
980 *
981 * @param[in] xhp The pointer to the xbps_handle struct.
982 * @param[in] pkg Package name or name-version to match.
983 *
984 * @return The matching proplib package dictionary, NULL otherwise.
985 */
986xbps_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp,
987 const char *pkg);
988
989/**
990 * Returns the package dictionary with all files for \a pkg.
991 *
992 * @param[in] xhp The pointer to the xbps_handle struct.
993 * @param[in] pkg Package expression to match.
994 *
995 * @return The matching package dictionary, NULL otherwise.
996 */
997xbps_dictionary_t xbps_pkgdb_get_pkg_files(struct xbps_handle *xhp,
998 const char *pkg);
999
1000/**
1001 * Returns a proplib array of strings with reverse dependencies
1002 * for \a pkg. The array is generated dynamically based on the list
1003 * of packages currently installed.
1004 *
1005 * @param[in] xhp The pointer to the xbps_handle struct.
1006 * @param[in] pkg Package expression to match.
1007 *
1008 * @return A proplib array of strings with reverse dependencies for \a pkg,
1009 * NULL otherwise.
1010 */
1011xbps_array_t xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp,
1012 const char *pkg);
1013
1014/**
1015 * Returns a proplib array of strings with a proper sorted list
1016 * of packages of a full dependency graph for \a pkg.
1017 *
1018 * @param[in] xhp The pointer to the xbps_handle struct.
1019 * @param[in] pkg Package expression to match.
1020 *
1021 * @return A proplib array of strings with the full dependency graph for \a pkg,
1022 * NULL otherwise.
1023 */
1025 const char *pkg);
1026
1027/**
1028 * Updates the package database (pkgdb) with new contents from the
1029 * cached memory copy to disk.
1030 *
1031 * @param[in] xhp The pointer to the xbps_handle struct.
1032 * @param[in] flush If true the pkgdb plist contents in memory will
1033 * be flushed atomically to storage.
1034 * @param[in] update If true, the pkgdb plist stored on disk will be re-read
1035 * and the in memory copy will be refreshed.
1036 *
1037 * @return 0 on success, otherwise an errno value.
1038 */
1039int xbps_pkgdb_update(struct xbps_handle *xhp, bool flush, bool update);
1040
1041/**
1042 * Creates a temporary file and executes it in rootdir.
1043 *
1044 * @param[in] xhp The pointer to the xbps_handle struct.
1045 * @param[in] blob The buffer pointer where the data is stored.
1046 * @param[in] blobsiz The size of the buffer data.
1047 * @param[in] pkgver The package name/version associated.
1048 * @param[in] action The action to execute on the temporary file.
1049 * @param[in] update Set to true if package is being updated.
1050 *
1051 * @return 0 on success, or an errno value otherwise.
1052 */
1054 const void *blob,
1055 const size_t blobsiz,
1056 const char *pkgver,
1057 const char *action,
1058 bool update);
1059
1060/**
1061 * Creates a temporary file and executes it in rootdir.
1062 *
1063 * @param[in] xhp The pointer to the xbps_handle struct.
1064 * @param[in] d Package dictionary where the script data is stored.
1065 * @param[in] script Key associated with the script in dictionary.
1066 * @param[in] action The action to execute on the temporary file.
1067 * @param[in] update Set to true if package is being updated.
1068 *
1069 * @return 0 on success, or an errno value otherwise.
1070 */
1072 xbps_dictionary_t d,
1073 const char *script,
1074 const char *action,
1075 bool update);
1076
1077/**@}*/
1078
1079/** @addtogroup alternatives */
1080/**@{*/
1081
1082/**
1083 * Sets all alternatives provided by this \a pkg, or only those
1084 * set by a \a group.
1085 *
1086 * @param[in] xhp The pointer to the xbps_handle struct.
1087 * @param[in] pkg Package name to match.
1088 * @param[in] group Alternatives group to match.
1089 *
1090 * @return 0 on success, or an errno value otherwise.
1091 */
1092int xbps_alternatives_set(struct xbps_handle *xhp, const char *pkg, const char *group);
1093
1094/**
1095 * Registers all alternative groups provided by a package.
1096 *
1097 * @param[in] xhp The pointer to the xbps_handle struct.
1098 * @param[in] pkgd Package dictionary as stored in the transaction dictionary.
1099 *
1100 * @return 0 on success, or an errno value otherwise.
1101 */
1102int xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkgd);
1103
1104/**
1105 * Unregisters all alternative groups provided by a package.
1106 *
1107 * @param[in] xhp The pointer to the xbps_handle struct.
1108 * @param[in] pkgd Package dictionary as stored in the transaction dictionary.
1109 *
1110 * @return 0 on success, or an errno value otherwise.
1111 */
1112int xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd);
1113
1114/**@}*/
1115
1116/** @addtogroup plist */
1117/**@{*/
1118
1119/**
1120 * Executes a function callback (\a fn) per object in the proplib array \a array.
1121 *
1122 * @param[in] xhp The pointer to the xbps_handle struct.
1123 * @param[in] array The proplib array to traverse.
1124 * @param[in] dict The dictionary associated with the array.
1125 * @param[in] fn Function callback to run for any pkg dictionary.
1126 * @param[in] arg Argument to be passed to the function callback.
1127 *
1128 * @return 0 on success (all objects were processed), otherwise
1129 * the value returned by the function callback.
1130 */
1132 xbps_array_t array,
1133 xbps_dictionary_t dict,
1134 int (*fn)(struct xbps_handle *, xbps_object_t obj, const char *, void *arg, bool *done),
1135 void *arg);
1136
1137/**
1138 * Executes a function callback (\a fn) per object in the proplib array \a array.
1139 * This is a multithreaded implementation spawning a thread per core. Each
1140 * thread processes a fraction of total objects in the array.
1141 *
1142 * @param[in] xhp The pointer to the xbps_handle struct.
1143 * @param[in] array The proplib array to traverse.
1144 * @param[in] dict The dictionary associated with the array.
1145 * @param[in] fn Function callback to run for any pkg dictionary.
1146 * @param[in] arg Argument to be passed to the function callback.
1147 *
1148 * @return 0 on success (all objects were processed), otherwise
1149 * the value returned by the function callback.
1150 */
1152 xbps_array_t array,
1153 xbps_dictionary_t dict,
1154 int (*fn)(struct xbps_handle *, xbps_object_t obj, const char *, void *arg, bool *done),
1155 void *arg);
1156
1157/**
1158 * Match a virtual package name or pattern by looking at proplib array
1159 * of strings.
1160 *
1161 * @param[in] array Proplib array of strings.
1162 * @param[in] str Virtual package name or package pattern to match.
1163 *
1164 * @return True if \a str matches a virtual package in \a array, false
1165 * otherwise.
1166 */
1167bool xbps_match_virtual_pkg_in_array(xbps_array_t array, const char *str);
1168
1169/**
1170 * Match a virtual package name or pattern by looking at package's
1171 * dictionary "provides" array object.
1172 *
1173 * @param[in] pkgd Package dictionary.
1174 * @param[in] str Virtual package name or package pattern to match.
1175 *
1176 * @return True if \a str matches a virtual package in \a pkgd, false
1177 * otherwise.
1178 */
1179bool xbps_match_virtual_pkg_in_dict(xbps_dictionary_t pkgd, const char *str);
1180
1181/**
1182 * Match any virtual package from array \a provides in they array \a rundeps
1183 * with dependencies.
1184 *
1185 * @param[in] rundeps Proplib array with dependencies as strings, i.e foo>=2.0.
1186 * @param[in] provides Proplib array of strings with virtual pkgdeps, i.e
1187 * foo-1.0 blah-2.0.
1188 *
1189 * @return True if \a any virtualpkg has been matched, false otherwise.
1190 */
1191bool xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps, xbps_array_t provides);
1192
1193/**
1194 * Match a package name in the specified array of strings.
1195 *
1196 * @param[in] array The proplib array to search on.
1197 * @param[in] pkgname The package name to match.
1198 *
1199 * @return true on success, false otherwise and errno is set appropiately.
1200 */
1201bool xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname);
1202
1203/**
1204 * Match a package name/version in the specified array of strings with pkgnames.
1205 *
1206 * @param[in] array The proplib array to search on.
1207 * @param[in] pkgver The package name/version to match.
1208 *
1209 * @return true on success, false otherwise and errno is set appropiately.
1210 */
1211bool xbps_match_pkgver_in_array(xbps_array_t array, const char *pkgver);
1212
1213/**
1214 * Match a package pattern in the specified array of strings.
1215 *
1216 * @param[in] array The proplib array to search on.
1217 * @param[in] pattern The package pattern to match, i.e `foo>=0' or `foo<1'.
1218 *
1219 * @return true on success, false otherwise and errno is set appropiately.
1220 */
1221bool xbps_match_pkgpattern_in_array(xbps_array_t array, const char *pattern);
1222
1223/**
1224 * Match a package dependency against any package pattern in the specified
1225 * array of strings.
1226 *
1227 * @param[in] array The proplib array to search on.
1228 * @param[in] pkgver The package name-version to match, i.e `foo-1.0_1'.
1229 *
1230 * @return true on success, false otherwise and errno is set appropiately.
1231 */
1232bool xbps_match_pkgdep_in_array(xbps_array_t array, const char *pkgver);
1233
1234/**
1235 * Match a string (exact match) in the specified array of strings.
1236 *
1237 * @param[in] array The proplib array to search on.
1238 * @param[in] val The string to be matched.
1239 *
1240 * @return true on success, false otherwise and errno is set appropiately.
1241 */
1242bool xbps_match_string_in_array(xbps_array_t array, const char *val);
1243
1244/**
1245 * Returns a proplib object iterator associated with an array, contained
1246 * in a proplib dictionary matching the specified key.
1247 *
1248 * @param[in] dict Proplib dictionary where to look for the array.
1249 * @param[in] key Key associated with the array.
1250 *
1251 * @return A proplib object iterator on success, NULL otherwise and
1252 * errno is set appropiately.
1253 */
1254xbps_object_iterator_t xbps_array_iter_from_dict(xbps_dictionary_t dict, const char *key);
1255
1256/**@}*/
1257
1258/** @addtogroup transaction */
1259/**@{*/
1260
1261/**
1262 * Finds a package by name or by pattern and enqueues it into
1263 * the transaction dictionary for future use. The first repository
1264 * matching \a pkg wins.
1265 *
1266 * @param[in] xhp Pointer to the xbps_handle struct.
1267 * @param[in] pkg Package name, package/version or package pattern to match, i.e
1268 * `foo', `foo-1.0_1' or `foo>=1.2'.
1269 * @param[in] force If true, package will be queued (if \a str matches)
1270 * even if package is already installed or in hold mode.
1271 *
1272 * @return 0 on success, otherwise an errno value.
1273 * @retval EEXIST Package is already installed (reinstall wasn't enabled).
1274 * @retval ENOENT Package not matched in repository pool.
1275 * @retval ENOTSUP No repositories are available.
1276 * @retval ENXIO Package depends on invalid dependencies.
1277 * @retval EINVAL Any other error ocurred in the process.
1278 * @retval EBUSY The xbps package must be updated.
1279 */
1280int xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, bool force);
1281
1282/**
1283 * Marks a package as "going to be updated" in the transaction dictionary.
1284 * The first repository that contains an updated version wins.
1285 *
1286 * If bestmaching is enabled (see \a XBPS_FLAG_BESTMATCH),
1287 * all repositories in the pool will be used, and newest version
1288 * available will be enqueued if it's greater than current installed
1289 * version.
1290 *
1291 * @param[in] xhp Pointer to the xbps_handle struct.
1292 * @param[in] pkgname The package name to update.
1293 * @param[in] force If true, package will be queued (if \a str matches)
1294 * even if package is already installed or in hold mode.
1295 *
1296 * @return 0 on success, otherwise an errno value.
1297 * @retval EEXIST Package is already up-to-date.
1298 * @retval ENOENT Package not matched in repository pool.
1299 * @retval ENOTSUP No repositories are available.
1300 * @retval ENXIO Package depends on invalid dependencies.
1301 * @retval EINVAL Any other error ocurred in the process.
1302 * @retval EBUSY The xbps package must be updated.
1303 */
1304int xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkgname, bool force);
1305
1306/**
1307 * Finds newer versions for all installed packages by looking at the
1308 * repository pool. If a newer version exists, package will be enqueued
1309 * into the transaction dictionary.
1310 *
1311 * @param[in] xhp Pointer to the xbps_handle struct.
1312 *
1313 * @return 0 on success, otherwise an errno value.
1314 * @retval EBUSY The xbps package must be updated.
1315 * @retval EEXIST All installed packages are already up-to-date.
1316 * @retval ENOENT No packages currently register.
1317 * @retval ENOTSUP No repositories currently installed.
1318 * @retval EINVAL Any other error ocurred in the process.
1319 */
1321
1322/**
1323 * Removes a package currently installed. The package dictionary will
1324 * be added into the transaction dictionary.
1325 *
1326 * @param[in] xhp Pointer to the xbps_handle struct.
1327 * @param[in] pkgname Package name to be removed.
1328 * @param[in] recursive If true, all packages that are currently depending
1329 * on the package to be removed, and if they are orphans, will be added.
1330 *
1331 * @retval 0 success.
1332 * @retval ENOENT Package is not installed.
1333 * @retval EEXIST Package has reverse dependencies.
1334 * @retval EINVAL
1335 * @retval ENXIO A problem ocurred in the process.
1336 */
1337int xbps_transaction_remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive);
1338
1339/**
1340 * Finds all package orphans currently installed and adds them into
1341 * the transaction dictionary.
1342 *
1343 * @param[in] xhp Pointer to the xbps_handle struct.
1344 *
1345 * @retval 0 success.
1346 * @retval ENOENT No package orphans were found.
1347 * @retval ENXIO
1348 * @retval EINVAL A problem ocurred in the process.
1349 */
1351
1352/**
1353 * Returns the transaction dictionary, as shown above in the image.
1354 * Before returning the package list is sorted in the correct order
1355 * and total installed/download size for the transaction is computed.
1356 *
1357 * @param[in] xhp Pointer to the xbps_handle struct.
1358 *
1359 * @retval 0 success.
1360 * @retval ENXIO if transaction dictionary and missing deps array were not created,
1361 * due to xbps_transaction_install_pkg() or xbps_transaction_update_pkg() not
1362 * previously called.
1363 * @retval ENODEV if there are missing dependencies in transaction ("missing_deps"
1364 * array of strings object in xhp->transd dictionary).
1365 * @retval ENOEXEC if there are unresolved shared libraries in transaction ("missing_shlibs"
1366 * array of strings object in xhp->transd dictionary).
1367 * @retval EAGAIN if there are package conflicts in transaction ("conflicts"
1368 * array of strings object in xhp->transd dictionary).
1369 * @retval ENOSPC Not enough free space on target rootdir to continue with the
1370 * transaction.
1371 * @retval EINVAL There was an error sorting packages or computing the transaction
1372 * sizes.
1373 */
1375
1376/**
1377 * Commit a transaction. The transaction dictionary in xhp->transd contains all
1378 * steps to be executed in the transaction, as prepared by
1379 * xbps_transaction_prepare().
1380 *
1381 * @param[in] xhp Pointer to the xbps_handle struct.
1382 * @return 0 on success, otherwise an errno value.
1383 */
1385
1386/**
1387 * @enum xbps_trans_type_t
1388 *
1389 * uint8_t representing the pkg transaction type in transaction dictionary.
1390 *
1391 * - XBPS_TRANS_UNKNOWN: Unknown type
1392 * - XBPS_TRANS_INSTALL: pkg will be installed
1393 * - XBPS_TRANS_REINSTALL: pkg will be reinstalled
1394 * - XBPS_TRANS_UPDATE: pkg will be updated
1395 * - XBPS_TRANS_CONFIGURE: pkg will be configured
1396 * - XBPS_TRANS_REMOVE: pkg will be removed
1397 * - XBPS_TRANS_HOLD: pkg won't be updated (on hold mode)
1398 * - XBPS_TRANS_DOWNLOAD: pkg will be downloaded
1399 */
1400typedef enum xbps_trans_type {
1401 XBPS_TRANS_UNKNOWN = 0,
1402 XBPS_TRANS_INSTALL,
1403 XBPS_TRANS_REINSTALL,
1404 XBPS_TRANS_UPDATE,
1405 XBPS_TRANS_CONFIGURE,
1406 XBPS_TRANS_REMOVE,
1407 XBPS_TRANS_HOLD,
1408 XBPS_TRANS_DOWNLOAD
1410
1411/**
1412 * Returns the transaction type associated with \a pkg_repod.
1413 *
1414 * See \a xbps_trans_type_t for possible values.
1415 *
1416 * @param[in] pkg_repod Package dictionary stored in a repository.
1417 *
1418 * @return The transaction type associated.
1419 */
1420xbps_trans_type_t xbps_transaction_pkg_type(xbps_dictionary_t pkg_repod);
1421
1422/**
1423 * Sets the transaction type associated with \a pkg_repod.
1424 *
1425 * See \a xbps_trans_type_t for possible values.
1426 *
1427 * @param[in] pkg_repod Package dictionary stored in a repository.
1428 * @param[in] type The transaction type to set.
1429 *
1430 * @return Returns true on success, false otherwise.
1431 */
1432
1433bool xbps_transaction_pkg_type_set(xbps_dictionary_t pkg_repod, xbps_trans_type_t type);
1434
1435/**@}*/
1436
1437/** @addtogroup plist_fetch */
1438/**@{*/
1439
1440/**
1441 * Returns a buffer of a file stored in an archive locally or
1442 * remotely as specified in the url \a url.
1443 *
1444 * @param[in] url Full URL to binary package file (local or remote path).
1445 * @param[in] fname File name to match.
1446 *
1447 * @return A malloc(3)ed buffer with the contents of \a fname, NULL otherwise
1448 * and errno is set appropiately.
1449 */
1450char *xbps_archive_fetch_file(const char *url, const char *fname);
1451
1452/**
1453 * Returns a file stored in an archive locally or
1454 * remotely as specified in the url \a url and stores it into the
1455 * file descriptor \a fd.
1456 *
1457 * @param[in] url Full URL to binary package file (local or remote path).
1458 * @param[in] fname File name to match.
1459 * @param[in] fd An open file descriptor to put the file into.
1460 *
1461 * @return 0 on success, an errno value otherwise.
1462 */
1463int xbps_archive_fetch_file_into_fd(const char *url, const char *fname, int fd);
1464
1465/**
1466 * Internalizes a plist file in an archive stored locally or
1467 * remotely as specified in the url \a url.
1468 *
1469 * @param[in] url Full URL to binary package file (local or remote path).
1470 * @param[in] p Proplist file name to internalize as a dictionary.
1471 *
1472 * @return An internalized proplib dictionary, otherwise NULL and
1473 * errno is set appropiately.
1474 */
1475xbps_dictionary_t xbps_archive_fetch_plist(const char *url, const char *p);
1476
1477/**@}*/
1478
1479/** @addtogroup repopool */
1480/**@{*/
1481
1482/**
1483 * @struct xbps_repo xbps.h "xbps.h"
1484 * @brief Repository structure
1485 *
1486 * Repository object structure registered in a private simple queue.
1487 * The structure contains repository data: uri and dictionaries associated.
1488 */
1490 /**
1491 * @private
1492 */
1493 struct {
1494 struct xbps_repo *sqe_next; /* next element */
1495 } entries;
1496 /**
1497 * @var xhp
1498 *
1499 * Pointer to our xbps_handle struct passed to xbps_rpool_foreach.
1500 */
1502 /**
1503 * @var arch
1504 *
1505 * The architecture of the repository.
1506 */
1507 const char *arch;
1508 /**
1509 * @var idx
1510 *
1511 * Proplib dictionary associated with the repository index.
1512 */
1513 xbps_dictionary_t idx;
1514 /**
1515 * @var index
1516 *
1517 * Proplib dictionary associated with the repository index.
1518 */
1519 xbps_dictionary_t index;
1520 /**
1521 * @var idx
1522 *
1523 * Proplib dictionary associated with the repository index.
1524 */
1525 xbps_dictionary_t stage;
1526 /**
1527 * @var idxmeta
1528 *
1529 * Proplib dictionary associated with the repository index-meta.
1530 */
1531 xbps_dictionary_t idxmeta;
1532 /**
1533 * @var uri
1534 *
1535 * URI string associated with repository.
1536 */
1537 const char *uri;
1538 /**
1539 * var is_remote
1540 *
1541 * True if repository is remote, false if it's a local repository.
1542 */
1544 /**
1545 * var is_signed
1546 *
1547 * True if this repository has been signed, false otherwise.
1548 */
1550};
1551
1552void xbps_rpool_release(struct xbps_handle *xhp);
1553
1554/**
1555 * Synchronizes repository data for all remote repositories
1556 * as specified in the configuration file or if \a uri argument is
1557 * set, just sync for that repository.
1558 *
1559 * @param[in] xhp Pointer to the xbps_handle struct.
1560 * @param[in] uri Repository URI to match for sync (optional).
1561 *
1562 * @return 0 on success, ENOTSUP if no repositories were found in
1563 * the configuration file.
1564 */
1565int xbps_rpool_sync(struct xbps_handle *xhp, const char *uri);
1566
1567/**
1568 * Iterates over the repository pool and executes the \a fn function
1569 * callback passing in the void * \a arg argument to it. The bool pointer
1570 * argument can be used in the callbacks to stop immediately the loop if
1571 * set to true, otherwise it will only be stopped if it returns a
1572 * non-zero value.
1573 * Removes repos failed to open from pool. This condition causes function
1574 * to return error, but don't break the loop.
1575 *
1576 * @param[in] xhp Pointer to the xbps_handle struct.
1577 * @param[in] fn Function callback to execute for every repository registered in
1578 * the pool.
1579 * @param[in] arg Opaque data passed in to the \a fn function callback for
1580 * client data.
1581 *
1582 * @return 0 on success, otherwise an errno value.
1583 */
1584int xbps_rpool_foreach(struct xbps_handle *xhp,
1585 int (*fn)(struct xbps_repo *, void *, bool *),
1586 void *arg);
1587
1588/**
1589 * Returns a pointer to a struct xbps_repo matching \a url.
1590 *
1591 * @param[in] url Repository url to match.
1592 * @return The matched xbps_repo pointer, NULL otherwise.
1593 */
1594struct xbps_repo *xbps_rpool_get_repo(const char *url);
1595
1596/**
1597 * Finds a package dictionary in the repository pool by specifying a
1598 * package pattern or a package name. This function does not take into
1599 * account virtual packages, just matches real packages.
1600 *
1601 * @param[in] xhp Pointer to the xbps_handle struct.
1602 * @param[in] pkg Package pattern, exact pkg or pkg name.
1603 *
1604 * @return The package dictionary if found, NULL otherwise.
1605 * @note When returned dictionary is no longer needed, you must release it
1606 * with xbps_object_release(3).
1607 */
1608xbps_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg);
1609
1610/**
1611 * Finds a package dictionary in repository pool by specifying a
1612 * virtual package pattern or a package name.
1613 *
1614 * @param[in] xhp Pointer to the xbps_handle struct.
1615 * @param[in] pkg Virtual package pattern or name to match.
1616 *
1617 * @return The package dictionary if found, NULL otherwise.
1618 * @note When returned dictionary is no longer needed, you must release it
1619 * with xbps_object_release(3).
1620 */
1621xbps_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg);
1622
1623/**
1624 * Returns a proplib array of strings with reverse dependencies of all
1625 * registered repositories matching the expression \a pkg.
1626 *
1627 * @param[in] xhp Pointer to the xbps_handle structure.
1628 * @param[in] pkg Package expression to match in this repository index.
1629 *
1630 * @return The array of strings on success, NULL otherwise and errno is
1631 * set appropiately.
1632 */
1633xbps_array_t xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg);
1634
1635/**
1636 * Returns a proplib array of strings with a proper sorted list
1637 * of packages of a full dependency graph for \a pkg.
1638 *
1639 * @param[in] xhp The pointer to the xbps_handle struct.
1640 * @param[in] pkg Package expression to match.
1641 *
1642 * @return A proplib array of strings with the full dependency graph for \a pkg,
1643 * NULL otherwise.
1644 */
1645xbps_array_t xbps_rpool_get_pkg_fulldeptree(struct xbps_handle *xhp, const char *pkg);
1646
1647/**@}*/
1648
1649/** @addtogroup repo */
1650/**@{*/
1651
1652/**
1653 * Stores repository \a url into the repository pool.
1654 *
1655 * @param[in] xhp Pointer to the xbps_handle struct.
1656 * @param[in] url Repository URI to store.
1657 *
1658 * @return True on success, false otherwise.
1659 */
1660bool xbps_repo_store(struct xbps_handle *xhp, const char *url);
1661
1662/**
1663 * Removes repository \a url from the repository pool.
1664 *
1665 * @param[in] xhp Pointer to the xbps_handle struct.
1666 * @param[in] url Repository URI to remove.
1667 *
1668 * @return True on success, false otherwise.
1669 */
1670bool xbps_repo_remove(struct xbps_handle *xhp, const char *url);
1671
1672/**
1673 * Creates a lock for a local repository to obtain exclusive access (write).
1674 *
1675 * @param[in] xhp Pointer to the xbps_handle struct.
1676 * @param[in] uri Repository URI to match.
1677 * @param[out] lockfd Lock file descriptor assigned.
1678 * @param[out] lockfname Lock filename assigned.
1679 *
1680 * @return True on success and lockfd/lockfname are assigned appropiately.
1681 * otherwise false and lockfd/lockfname aren't set.
1682 */
1683int xbps_repo_lock(const char *repodir, const char *arch);
1684
1685/**
1686 * Unlocks a local repository and removes its lock file.
1687 *
1688 * @param[in] lockfd Lock file descriptor.
1689 * @param[in] lockfname Lock filename.
1690 */
1691void xbps_repo_unlock(const char *repodir, const char *arch, int fd);
1692
1693/**
1694 * Opens a repository and returns a xbps_repo object.
1695 *
1696 * @param[in] xhp Pointer to the xbps_handle struct.
1697 * @param[in] uri Repository URI to match.
1698 *
1699 * @return The matching repository object, NULL otherwise.
1700 */
1701struct xbps_repo *xbps_repo_open(struct xbps_handle *xhp, const char *uri);
1702
1703/**
1704 * Opens a repository and returns a xbps_repo object.
1705 *
1706 * @param[in] xhp Pointer to the xbps_handle struct.
1707 * @param[in] uri Repository URI to match.
1708 *
1709 * @return The matching repository object, NULL otherwise.
1710 */
1711struct xbps_repo *xbps_repo_public_open(struct xbps_handle *xhp, const char *uri);
1712
1713/**
1714 * Closes a repository object, its archive associated is
1715 * closed and those resources released.
1716 *
1717 * @param[in] repo The repository object to close.
1718 */
1719void xbps_repo_close(struct xbps_repo *repo);
1720
1721/**
1722 * This calls xbps_repo_close() and releases all resources
1723 * associated with this repository object.
1724 *
1725 * @param[in] repo The repository object to release.
1726 */
1727void xbps_repo_release(struct xbps_repo *repo);
1728
1729/**
1730 *
1731 * Returns a heap-allocated string with the repository local path.
1732 *
1733 * @param[in] xhp The xbps_handle object.
1734 * @param[in] url The repository URL to match.
1735 *
1736 * @return A heap allocated string that must be free(3)d when it's unneeded.
1737 */
1738char *xbps_repo_path(struct xbps_handle *xhp, const char *url);
1739
1740/**
1741 * Returns a pkg dictionary from a repository \a repo matching
1742 * the expression \a pkg.
1743 *
1744 * @param[in] repo Pointer to an xbps_repo structure.
1745 * @param[in] pkg Package expression to match in this repository index.
1746 *
1747 * @return The pkg dictionary on success, NULL otherwise.
1748 */
1749xbps_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg);
1750
1751/**
1752 * Returns a pkg dictionary from a repository \a repo matching
1753 * the expression \a pkg. On match the first package matching the virtual
1754 * package expression will be returned.
1755 *
1756 * @param[in] repo Pointer to an xbps_repo structure.
1757 * @param[in] pkg Package expression to match in this repository index.
1758 *
1759 * @return The pkg dictionary on success, NULL otherwise.
1760 */
1761xbps_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg);
1762
1763/**
1764 * Returns a proplib array of strings with reverse dependencies from
1765 * repository \a repo matching the expression \a pkg.
1766 *
1767 * @param[in] repo Pointer to an xbps_repo structure.
1768 * @param[in] pkg Package expression to match in this repository index.
1769 *
1770 * @return The array of strings on success, NULL otherwise and errno is
1771 * set appropiately.
1772 */
1773xbps_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg);
1774
1775/**
1776 * Imports the RSA public key of target repository. The repository must be
1777 * signed properly for this to work.
1778 *
1779 * @param[in] repo Pointer to the target xbps_repo structure.
1780 *
1781 * @return 0 on success, an errno value otherwise.
1782 */
1783int xbps_repo_key_import(struct xbps_repo *repo);
1784
1785/**@}*/
1786
1787/** @addtogroup archive_util */
1788/**@{*/
1789
1790struct archive;
1791
1792/**
1793 * Appends a file to the \a ar archive by using a memory buffer \a buf of
1794 * size \a sizelen.
1795 *
1796 * @param[in] ar The archive object.
1797 * @param[in] buf The memory buffer to be used as file data.
1798 * @param[in] buflen The size of the memory buffer.
1799 * @param[in] fname The filename to be used for the entry.
1800 * @param[in] mode The mode to be used in the entry.
1801 * @param[in] uname The user name to be used in the entry.
1802 * @param[in] gname The group name to be used in the entry.
1803 *
1804 * @return 0 on success, or any negative or errno value otherwise.
1805 */
1806int xbps_archive_append_buf(struct archive *ar, const void *buf,
1807 const size_t buflen, const char *fname, const mode_t mode,
1808 const char *uname, const char *gname);
1809
1810/**@}*/
1811
1812/** @addtogroup pkgstates */
1813/**@{*/
1814
1815/**
1816 * @enum pkg_state_t
1817 *
1818 * Integer representing a state on which a package may be. Possible
1819 * values for this are:
1820 *
1821 * - XBPS_PKG_STATE_UNPACKED: Package has been unpacked correctly
1822 * but has not been configured due to unknown reasons.
1823 * - XBPS_PKG_STATE_INSTALLED: Package has been installed successfully.
1824 * - XBPS_PKG_STATE_BROKEN: not yet used.
1825 * - XBPS_PKG_STATE_HALF_REMOVED: Package has been removed but not
1826 * completely: the purge action in REMOVE script wasn't executed, pkg
1827 * metadata directory still exists and is registered in package database.
1828 * - XBPS_PKG_STATE_NOT_INSTALLED: Package going to be installed in
1829 * a transaction dictionary but that has not been yet unpacked.
1830 */
1831typedef enum pkg_state {
1832 XBPS_PKG_STATE_UNPACKED = 1,
1833 XBPS_PKG_STATE_INSTALLED,
1834 XBPS_PKG_STATE_BROKEN,
1835 XBPS_PKG_STATE_HALF_REMOVED,
1836 XBPS_PKG_STATE_NOT_INSTALLED,
1837} pkg_state_t;
1838
1839/**
1840 * Gets package state from package \a pkgname, and sets its state
1841 * into \a state.
1842 *
1843 * @param[in] xhp The pointer to an xbps_handle struct.
1844 * @param[in] pkgname Package name.
1845 * @param[out] state Package state returned.
1846 *
1847 * @return 0 on success, otherwise an errno value.
1848 */
1849int xbps_pkg_state_installed(struct xbps_handle *xhp, const char *pkgname, pkg_state_t *state);
1850
1851/**
1852 * Gets package state from a package dictionary \a dict, and sets its
1853 * state into \a state.
1854 *
1855 * @param[in] dict Package dictionary.
1856 * @param[out] state Package state returned.
1857 *
1858 * @return 0 on success, otherwise an errno value.
1859 */
1860int xbps_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t *state);
1861
1862/**
1863 * Sets package state \a state in package \a pkgname.
1864 *
1865 * @param[in] xhp The pointer to an xbps_handle struct.
1866 * @param[in] pkgver Package name/version to match.
1867 * @param[in] state Package state to be set.
1868 *
1869 * @return 0 on success, otherwise an errno value.
1870 */
1872 const char *pkgver,
1873 pkg_state_t state);
1874
1875/**
1876 * Sets package state \a state in package dictionary \a dict.
1877 *
1878 * @param[in] dict Package dictionary.
1879 * @param[in] state Package state to be set.
1880 *
1881 * @return 0 on success, otherwise an errno value.
1882 */
1883int xbps_set_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t state);
1884
1885/**@}*/
1886
1887/** @addtogroup util */
1888/**@{*/
1889
1890/**
1891 * Removes a string object matching \a pkgname in
1892 * the \a array array of strings.
1893 *
1894 * @param[in] array Proplib array of strings.
1895 * @param[in] pkgname pkgname string object to remove.
1896 *
1897 * @return true on success, false otherwise.
1898 */
1899bool xbps_remove_pkgname_from_array(xbps_array_t array, const char *pkgname);
1900
1901/**
1902 * Removes a string object matching \a str in the
1903 * \a array array of strings.
1904 *
1905 * @param[in] array Proplib array of strings.
1906 * @param[in] str string object to remove.
1907 *
1908 * @return true on success, false otherwise.
1909 */
1910bool xbps_remove_string_from_array(xbps_array_t array, const char *str);
1911
1912/**
1913 * Creates a directory (and required components if necessary).
1914 *
1915 * @param[in] path Path for final directory.
1916 * @param[in] mode Mode for final directory (0755 if not specified).
1917 *
1918 * @return 0 on success, -1 on error and errno set appropiately.
1919 */
1920int xbps_mkpath(const char *path, mode_t mode);
1921
1922/**
1923 * Returns a string by concatenating its variable argument list
1924 * as specified by the format string \a fmt.
1925 *
1926 * @param[in] fmt Format string, see printf(3).
1927 * @return A pointer to a malloc(3)ed string, NULL otherwise and errno
1928 * is set appropiately. The pointer should be free(3)d when it's
1929 * no longer needed.
1930 */
1931char *xbps_xasprintf(const char *fmt, ...)__attribute__ ((format (printf, 1, 2)));
1932
1933/**
1934 * Creates a memory mapped object from file \a file into \a mmf
1935 * with size \a mmflen, and file size to \a filelen;
1936 *
1937 * @param[in] file Path to a file.
1938 * @param[out] mmf Memory mapped object.
1939 * @param[out] mmflen Length of memory mapped object.
1940 * @param[out] filelen File size length.
1941 *
1942 * @return True on success, false otherwise and errno
1943 * is set appropiately. The mmaped object should be munmap()ed when it's
1944 * not longer needed.
1945 */
1946bool xbps_mmap_file(const char *file, void **mmf, size_t *mmflen, size_t *filelen);
1947
1948/**
1949 * Computes a sha256 hex digest into \a dst of size \a len
1950 * from file \a file.
1951 *
1952 * @param[out] dst Destination buffer.
1953 * @param[in] len Size of \a dst must be at least XBPS_SHA256_LENGTH.
1954 * @param[in] file The file to read.
1955 *
1956 * @return true on success, false otherwise.
1957 */
1958bool xbps_file_sha256(char *dst, size_t len, const char *file);
1959
1960/**
1961 * Computes a sha256 binary digest into \a dst of size \a len
1962 * from file \a file.
1963 *
1964 * @param[out] dst Destination buffer.
1965 * @param[in] len Size of \a dst must be at least XBPS_SHA256_DIGEST_SIZE_LENGTH.
1966 * @param[in] file The file to read.
1967 *
1968 * @return true on success, false otherwise.
1969 */
1970bool xbps_file_sha256_raw(unsigned char *dst, size_t len, const char *file);
1971
1972/**
1973 * Compares the sha256 hash of the file \a file with the sha256
1974 * string specified by \a sha256.
1975 *
1976 * @param[in] file Path to a file.
1977 * @param[in] sha256 SHA256 hash to compare.
1978 *
1979 * @return 0 if \a file and \a sha256 have the same hash, ERANGE
1980 * if it differs, or any other errno value on error.
1981 */
1982int xbps_file_sha256_check(const char *file, const char *sha256);
1983
1984/**
1985 * Verifies the RSA signature \a sigfile against \a digest with the
1986 * RSA public-key associated in \a repo.
1987 *
1988 * @param[in] repo Repository to use with the RSA public key associated.
1989 * @param[in] sigfile The signature file name used to verify \a digest.
1990 * @param[in] digest The digest to verify.
1991 *
1992 * @return True if the signature is valid, false otherwise.
1993 */
1994bool xbps_verify_signature(struct xbps_repo *repo, const char *sigfile,
1995 unsigned char *digest);
1996
1997/**
1998 * Verifies the RSA signature of \a fname with the RSA public-key associated
1999 * in \a repo.
2000 *
2001 * @param[in] repo Repository to use with the RSA public key associated.
2002 * @param[in] fname The filename to verify, the signature file must have a .sig2
2003 * extension, i.e `<fname>.sig2`.
2004 *
2005 * @return True if the signature is valid, false otherwise.
2006 */
2007bool xbps_verify_file_signature(struct xbps_repo *repo, const char *fname);
2008
2009/**
2010 * Checks if a package is currently installed in pkgdb by matching \a pkg.
2011 * To be installed, the pkg must be in "installed" or "unpacked" state.
2012 *
2013 * @param[in] xhp The pointer to an xbps_handle struct.
2014 * @param[in] pkg Package name, version pattern or exact pkg to match.
2015 *
2016 * @return -1 on error (errno set appropiately), 0 if \a pkg
2017 * didn't match installed package, 1 if \a pkg pattern fully
2018 * matched installed package.
2019 */
2020int xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg);
2021
2022/**
2023 * Checks if a package is currently ignored by matching \a pkg.
2024 * To be ignored, the pkg must be ignored by the users configuration.
2025 *
2026 * @param[in] xhp The pointer to an xbps_handle struct.
2027 * @param[in] pkg Package name, version pattern or exact pkg to match.
2028 *
2029 * @return True if the package is ignored, false otherwise.
2030 */
2031bool xbps_pkg_is_ignored(struct xbps_handle *xhp, const char *pkg);
2032
2033/**
2034 * Returns true if binary package exists in cachedir or in a local repository,
2035 * false otherwise.
2036 *
2037 * @param[in] xhp The pointer to an xbps_handle struct.
2038 * @param[in] pkgd Package dictionary returned by rpool.
2039 *
2040 * @return true if exists, false otherwise.
2041 */
2042bool xbps_binpkg_exists(struct xbps_handle *xhp, xbps_dictionary_t pkgd);
2043
2044/**
2045 * Returns true if binary package and signature exists in cachedir,
2046 * false otherwise.
2047 *
2048 * @param[in] xhp The pointer to an xbps_handle struct.
2049 * @param[in] pkgd Package dictionary returned by rpool.
2050 *
2051 * @return true if exists, false otherwise.
2052 */
2053bool xbps_remote_binpkg_exists(struct xbps_handle *xhp, xbps_dictionary_t pkgd);
2054
2055/**
2056 * Checks if the URI specified by \a uri is remote or local.
2057 *
2058 * @param[in] uri URI string.
2059 *
2060 * @return true if URI is remote, false if local.
2061 */
2062bool xbps_repository_is_remote(const char *uri);
2063
2064/**
2065 * Returns an allocated string with the full path to the binary package
2066 * matching \a pkgd.
2067 *
2068 * The \a pkgd dictionary must contain the following objects:
2069 * - architecture (string)
2070 * - pkgver (string)
2071 * - repository (string)
2072 *
2073 * @param[in] xhp The pointer to an xbps_handle struct.
2074 * @param[in] pkgd The package dictionary to match.
2075 *
2076 * @return A malloc(3)ed buffer with the full path, NULL otherwise.
2077 * The buffer should be free(3)d when it's no longer needed.
2078 */
2079char *xbps_repository_pkg_path(struct xbps_handle *xhp, xbps_dictionary_t pkgd);
2080
2081/**
2082 * Put the path to the binary package \a pkgd into \a dst.
2083 *
2084 * The \a pkgd dictionary must contain the following objects:
2085 * - architecture (string)
2086 * - pkgver (string)
2087 * - repository (string)
2088 *
2089 * @param[in] xhp Pointer to an xbps_handle struct.
2090 * @param[in] dst Destination buffer.
2091 * @param[in] dstsz Destination buffer size.
2092 * @param[in] pkgd Package dictionary.
2093 *
2094 * @return The length of the path or a negative errno on error.
2095 * @retval -EINVAL Missing required dictionary entry.
2096 * @retval -ENOBUFS The path would exceed the supplied \a dst buffer.
2097 */
2098ssize_t xbps_pkg_path(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd);
2099
2100/**
2101 * Put the url to the binary package \a pkgd into \a dst.
2102 *
2103 * The \a pkgd dictionary must contain the following objects:
2104 * - architecture (string)
2105 * - pkgver (string)
2106 * - repository (string)
2107 *
2108 * @param[in] xhp The pointer to an xbps_handle struct.
2109 * @param[in] pkgd The package dictionary to match.
2110 *
2111 * @return The length of the path or a negative errno on error.
2112 * @retval -EINVAL Missing required dictionary entry.
2113 * @retval -ENOBUFS The path would exceed the supplied \a dst buffer.
2114 */
2115ssize_t xbps_pkg_url(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd);
2116
2117/**
2118 * Put the url or path (if cached) to the binary package \a pkgd into \a dst.
2119 *
2120 * The \a pkgd dictionary must contain the following objects:
2121 * - architecture (string)
2122 * - pkgver (string)
2123 * - repository (string)
2124 *
2125 * @param[in] xhp The pointer to an xbps_handle struct.
2126 * @param[in] pkgd The package dictionary to match.
2127 *
2128 * @return The length of the path or a negative errno on error.
2129 * @retval -EINVAL Missing required dictionary entry.
2130 * @retval -ENOBUFS The path would exceed the supplied \a dst buffer.
2131 */
2132ssize_t xbps_pkg_path_or_url(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd);
2133
2134/**
2135 * Gets the name of a package string. Package strings are composed
2136 * by a @<pkgname@>/@<version@> pair and separated by the *minus*
2137 * sign, i.e `foo-2.0`.
2138 *
2139 * @param[out] dst Destination buffer to store result.
2140 * @param[in] len Length of \a dst.
2141 * @param[in] pkg Package version string.
2142 *
2143 * @return true on success, false otherwise.
2144 */
2145bool xbps_pkg_name(char *dst, size_t len, const char *pkg);
2146
2147/**
2148 * Gets a the package name of a package pattern string specified by
2149 * the \a pattern argument.
2150 *
2151 * Package patterns are composed of the package name and
2152 * either a *equals* (`foo=2.0`) constraint or a *greater than* (`foo>2.0`) or
2153 * *greater equals* (`foo>=2.0`) or *lower than* (`foo<2.0`) or *lower equals*
2154 * (`foo<=2.0`) or a combination of both (`foo>=1.0<2.0`).
2155 *
2156 * @param[out] dst Destination buffer to store result.
2157 * @param[in] len Length of \a dst.
2158 * @param[in] pattern A package pattern.
2159 *
2160 * @return true on success, false otherwise.
2161 */
2162bool xbps_pkgpattern_name(char *dst, size_t len, const char *pattern);
2163
2164/**
2165 * Gets the package version in a package string, i.e `foo-2.0`.
2166 *
2167 * @param[in] pkg Package string.
2168 *
2169 * @return A string with the version string, NULL if it couldn't
2170 * find the version component.
2171 */
2172const char *xbps_pkg_version(const char *pkg);
2173
2174/**
2175 * Gets the pkgname/version componentn of a binary package string,
2176 * i.e `foo-2.0_1.<arch>.xbps`.
2177 *
2178 * @param[in] pkg Package string.
2179 *
2180 * @return A pointer to a malloc(ed) string with the pkgver component,
2181 * NULL if it couldn't find the version component. The pointer should
2182 * be free(3)d when it's no longer needed.
2183 */
2184char *xbps_binpkg_pkgver(const char *pkg);
2185
2186/**
2187 * Gets the architecture component of a binary package string,
2188 * i.e `<pkgver>.<arch>.xbps`.
2189 *
2190 * @param[in] pkg Package string.
2191 *
2192 * @return A pointer to a malloc(ed) string with the architecture component,
2193 * NULL if it couldn't find the version component. The pointer should
2194 * be free(3)d when it's no longer needed.
2195 */
2196char *xbps_binpkg_arch(const char *pkg);
2197
2198/**
2199 * Gets the package version of a package pattern string specified by
2200 * the \a pattern argument.
2201 *
2202 * @param[in] pattern A package pattern. The same rules in
2203 * xbps_get_pkgpattern_name() apply here.
2204 *
2205 * @return A string with the pattern version, NULL otherwise and
2206 * errno is set appropiately.
2207 */
2208const char *xbps_pkgpattern_version(const char *pattern);
2209
2210/**
2211 * Package pattern matching.
2212 *
2213 * There are 3 strategies for version matching:
2214 * - simple compare: pattern equals to pkgver.
2215 * - shell wildcards: see fnmatch(3).
2216 * - relational dewey matching: '>' '<' '>=' '<='.
2217 *
2218 * @param[in] pkgver Package name/version, i.e `foo-1.0'.
2219 * @param[in] pattern Package pattern to match against \a pkgver.
2220 *
2221 * @return 1 if \a pkgver is matched against \a pattern, 0 if no match.
2222 */
2223int xbps_pkgpattern_match(const char *pkgver, const char *pattern);
2224
2225/**
2226 * Gets the package version revision in a package string.
2227 *
2228 * @param[in] pkg Package string, i.e `foo-2.0_1`.
2229 *
2230 * @return A string with the revision number, NULL if it couldn't
2231 * find the revision component.
2232 */
2233const char *xbps_pkg_revision(const char *pkg);
2234
2235/**
2236 * Returns true if provided string is valid for target architecture.
2237 *
2238 * @param[in] xhp The pointer to an xbps_handle struct.
2239 * @param[in] orig Architecture to match.
2240 * @param[in] target If not NULL, \a orig will be matched against it
2241 * rather than returned value of uname(2).
2242 *
2243 * @return True on match, false otherwise.
2244 */
2245bool xbps_pkg_arch_match(struct xbps_handle *xhp, const char *orig, const char *target);
2246
2247/**
2248 * Converts the 64 bits signed number specified in \a bytes to
2249 * a human parsable string buffer pointed to \a buf.
2250 *
2251 * @param[out] buf Buffer to store the resulting string. At least
2252 * it should have space for 6 chars.
2253 * @param[in] bytes 64 bits signed number to convert.
2254 *
2255 * @return A negative number is returned on error, 0 otherwise.
2256 */
2257int xbps_humanize_number(char *buf, int64_t bytes);
2258
2259/**
2260 * Append the string \a src to the end of \a dst.
2261 *
2262 * @param[out] dst Buffer to store the resulting string.
2263 * @param[in] src Source string.
2264 * @param[in] dstsize Size of the \a dst buffer.
2265 *
2266 * @return The total length of the created string, if the return
2267 * value is >= \a dstsize, the output string has been truncated.
2268 */
2269size_t xbps_strlcat(char *dst, const char *src, size_t dstsize);
2270
2271/**
2272 * Copy up to \a dstsize - 1 from the string \a src to \a dest,
2273 * NUL-terminating the result if \a dstsize is not 0.
2274 *
2275 * @param[out] dst Buffer to store the resulting string.
2276 * @param[in] src Source string.
2277 * @param[in] dstsize Size of the \a dst buffer.
2278 *
2279 * @return The total length of the created string, if the return
2280 * value is >= \a dstsize, the output string has been truncated.
2281 */
2282size_t xbps_strlcpy(char *dst, const char *src, size_t dstsize);
2283
2284/**
2285 * Tests if pkgver is reverted by pkg
2286 *
2287 * The package version is defined by:
2288 * ${NAME}-{${VERSION}_${REVISION}.
2289 *
2290 * the name part is ignored.
2291 *
2292 * @param[in] pkg a package which is a candidate to revert pkgver.
2293 * @param[in] pkgver a package version string
2294 *
2295 * @return true if pkg reverts pkgver, false otherwise.
2296 */
2297bool xbps_pkg_reverts(xbps_dictionary_t pkg, const char *pkgver);
2298
2299/**
2300 * Compares package version strings.
2301 *
2302 * The package version is defined by:
2303 * ${VERSION}[_${REVISION}].
2304 *
2305 * @param[in] pkg1 a package version string.
2306 * @param[in] pkg2 a package version string.
2307 *
2308 * @return -1, 0 or 1 depending if pkg1 is less than, equal to or
2309 * greater than pkg2.
2310 */
2311int xbps_cmpver(const char *pkg1, const char *pkg2);
2312
2313/**
2314 * Converts a RSA public key in PEM format to a hex fingerprint.
2315 *
2316 * @param[in] pubkey The public-key in PEM format as xbps_data_t.
2317 *
2318 * @return The OpenSSH fingerprint in hexadecimal.
2319 * The returned buffer must be free(3)d when necessary.
2320 */
2321char *xbps_pubkey2fp(xbps_data_t pubkey);
2322
2323/**
2324 * Returns a buffer with a sanitized path from \a src.
2325 * This removes multiple slashes.
2326 *
2327 * @param[in] src path component.
2328 *
2329 * @return The sanitized path in a buffer.
2330 * The returned buffer must be free(3)d when it's no longer necessary.
2331 */
2332char *xbps_sanitize_path(const char *src);
2333
2334/**
2335 * Turns the path in \a path into the shortest path equivalent to \a path
2336 * by purely lexical processing.
2337 *
2338 * @param[in,out] path The path to clean.
2339 *
2340 * @return The length of the path or -1 on error.
2341 */
2342ssize_t xbps_path_clean(char *path);
2343
2344/**
2345 * Returns the relative path from \a from to \a to.
2346 *
2347 * @param[out] dst Destination buffer to store result.
2348 * @param[in] len Length of \a dst.
2349 * @param[in] from The base path.
2350 * @param[in] to The path that becomes relative to \a from.
2351 *
2352 * @return The length of the path or -1 on error.
2353 */
2354ssize_t xbps_path_rel(char *dst, size_t len, const char *from, const char *to);
2355
2356/**
2357 * Joins multiple path components into the \a dst buffer.
2358 *
2359 * The last argument has to be (char *)NULL.
2360 *
2361 * @param[out] dst Destination buffer to store result.
2362 * @param[in] len Length of \a dst.
2363 *
2364 * @return The length of the path or -1 on error.
2365 */
2366ssize_t xbps_path_join(char *dst, size_t len, ...);
2367
2368/**
2369 * Adds \a rootdir and \a path to the \a dst buffer.
2370 *
2371 * @param[out] dst Destination buffer to store result.
2372 * @param[in] len Length of \a dst.
2373 * @param[in] suffix Suffix to append.
2374 *
2375 * @return The length of the path or -1 on error.
2376 */
2377ssize_t xbps_path_append(char *dst, size_t len, const char *suffix);
2378
2379/**
2380 * Adds \a rootdir and \a path to the \a dst buffer.
2381 *
2382 * @param[out] dst Destination buffer to store result.
2383 * @param[in] len Length of \a dst.
2384 * @param[in] prefix Prefix to prepend.
2385 *
2386 * @return The length of the path or -1 on error.
2387 */
2388ssize_t xbps_path_prepend(char *dst, size_t len, const char *prefix);
2389
2390/**
2391 * Returns a sanitized target file of \a path without the rootdir component.
2392 *
2393 * @param[in] xhp The pointer to an xbps_handle struct.
2394 * @param[in] path path component.
2395 * @param[in] target The stored target file of a symlink.
2396 *
2397 * @return The sanitized path in a buffer.
2398 * The returned buffer must be free(3)d when it's no longer necessary.
2399 */
2400char *xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *target);
2401
2402/**
2403 * Returns true if any of the fnmatch patterns in \a patterns matches
2404 * and is not negated by a later match.
2405 *
2406 * @param[in] patterns The patterns to match against.
2407 * @param[in] path The path that is matched against the patterns.
2408 *
2409 * @return true if any pattern matches, false otherwise.
2410 * The returned buffer must be free(3)d when it's no longer necessary.
2411 */
2412bool xbps_patterns_match(xbps_array_t patterns, const char *path);
2413
2414/**
2415 * Internalizes a plist file declared in \a path and returns a proplib array.
2416 *
2417 * @param[in] path The file path.
2418 *
2419 * @return The internalized proplib array, NULL otherwise.
2420 */
2421xbps_array_t
2422xbps_plist_array_from_file(const char *path);
2423
2424/**
2425 * Internalizes a plist file declared in \a path and returns a proplib dictionary.
2426 *
2427 * @param[in] path The file path.
2428 *
2429 * @return The internalized proplib array, NULL otherwise.
2430 */
2431xbps_dictionary_t
2432xbps_plist_dictionary_from_file(const char *path);
2433
2434/**@}*/
2435
2436#ifdef __cplusplus
2437}
2438#endif
2439
2440#endif /* !_XBPS_H_ */
int xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
int xbps_alternatives_set(struct xbps_handle *xhp, const char *pkg, const char *group)
int xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
int xbps_archive_append_buf(struct archive *ar, const void *buf, const size_t buflen, const char *fname, const mode_t mode, const char *uname, const char *gname)
Definition archive.c:114
int xbps_configure_pkg(struct xbps_handle *xhp, const char *pkgname, bool check_state, bool update)
int xbps_configure_packages(struct xbps_handle *xhp, xbps_array_t ignpkgs)
int xbps_fetch_file_sha256(struct xbps_handle *xhp, const char *uri, const char *flags, unsigned char *digest, size_t digestlen)
Definition download.c:346
const char * xbps_fetch_error_string(void)
Definition download.c:89
int xbps_fetch_file_dest(struct xbps_handle *xhp, const char *uri, const char *filename, const char *flags)
Definition download.c:339
int xbps_fetch_file(struct xbps_handle *xhp, const char *uri, const char *flags)
Definition download.c:362
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)
Definition download.c:98
xbps_dictionary_t pkgdb
Definition xbps.h:590
void * fetch_cb_data
Definition xbps.h:633
char rootdir[XBPS_MAXPATH]
Definition xbps.h:664
off_t file_size
Definition xbps.h:455
xbps_dictionary_t transd
Definition xbps.h:597
struct xbps_handle * xhp
Definition xbps.h:405
xbps_array_t repositories
Definition xbps.h:573
const char * desc
Definition xbps.h:411
const char * pkgver
Definition xbps.h:519
const char * target_arch
Definition xbps.h:645
ssize_t entry_extract_count
Definition xbps.h:537
void * unpack_cb_data
Definition xbps.h:621
const char * file_name
Definition xbps.h:473
off_t file_offset
Definition xbps.h:461
char confdir[XBPS_MAXPATH]
Definition xbps.h:651
int64_t entry_size
Definition xbps.h:531
xbps_state_t state
Definition xbps.h:430
int(* state_cb)(const struct xbps_state_cb_data *, void *)
Definition xbps.h:602
void(* unpack_cb)(const struct xbps_unpack_cb_data *, void *)
Definition xbps.h:614
const char * arg
Definition xbps.h:418
int flags
Definition xbps.h:693
void * state_cb_data
Definition xbps.h:609
void(* fetch_cb)(const struct xbps_fetch_cb_data *, void *)
Definition xbps.h:626
off_t file_dloaded
Definition xbps.h:467
char metadir[XBPS_MAXPATH]
Definition xbps.h:678
char native_arch[64]
Definition xbps.h:685
ssize_t entry_total_count
Definition xbps.h:543
char * pkgdb_plist
Definition xbps.h:639
const char * entry
Definition xbps.h:525
char cachedir[XBPS_MAXPATH]
Definition xbps.h:671
Structure to be passed as argument to the state function callback. All members are read-only and set ...
Definition xbps.h:399
Structure to be passed to the unpack function callback.
Definition xbps.h:507
Generic XBPS structure handler for initialization.
Definition xbps.h:560
Structure to be passed to the fetch function callback.
Definition xbps.h:443
xbps_state_t
Definition xbps.h:341
int xbps_init(struct xbps_handle *xhp)
Definition initend.c:45
void xbps_end(struct xbps_handle *xhp)
Definition initend.c:190
void xbps_verbose_printf(const char *,...)
Prints messages to stderr if verbosity is enabled.
Definition log.c:80
int xbps_debug_level
The Debug level.
Definition log.c:33
int xbps_error_errno(int r, const char *fmt,...)
Prints formatted log message to stderr and returns error.
Definition log.c:113
void xbps_error_printf(const char *fmt,...)
Prints error messages to stderr.
Definition log.c:93
void xbps_dbg_printf(const char *fmt,...)
Prints debug messages to stderr.
Definition log.c:67
void xbps_dbg_printf_append(const char *fmt,...)
Prints debug messages to stderr.
Definition log.c:54
void xbps_warn_printf(const char *fmt,...)
Prints warning messages to stderr.
Definition log.c:103
xbps_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans)
xbps_array_t xbps_pkgdb_get_pkg_fulldeptree(struct xbps_handle *xhp, const char *pkg)
Definition pkgdb.c:508
int xbps_pkgdb_foreach_cb_multi(struct xbps_handle *xhp, int(*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *), void *arg)
Definition pkgdb.c:368
int xbps_pkg_exec_buffer(struct xbps_handle *xhp, const void *blob, const size_t blobsiz, const char *pkgver, const char *action, bool update)
xbps_dictionary_t xbps_pkgdb_get_pkg_files(struct xbps_handle *xhp, const char *pkg)
Definition pkgdb.c:514
void xbps_pkgdb_unlock(struct xbps_handle *xhp)
Definition pkgdb.c:110
xbps_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
Definition pkgdb.c:403
int xbps_pkgdb_foreach_cb(struct xbps_handle *xhp, int(*fn)(struct xbps_handle *, xbps_object_t, const char *, void *, bool *), void *arg)
Definition pkgdb.c:349
xbps_array_t xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
Definition pkgdb.c:490
int xbps_pkgdb_update(struct xbps_handle *xhp, bool flush, bool update)
Definition pkgdb.c:288
int xbps_pkgdb_lock(struct xbps_handle *xhp)
Definition pkgdb.c:67
xbps_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
Definition pkgdb.c:389
int xbps_pkg_exec_script(struct xbps_handle *xhp, xbps_dictionary_t d, const char *script, const char *action, bool update)
int xbps_pkg_state_installed(struct xbps_handle *xhp, const char *pkgname, pkg_state_t *state)
int xbps_set_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t state)
pkg_state_t
Definition xbps.h:1831
int xbps_set_pkg_state_installed(struct xbps_handle *xhp, const char *pkgver, pkg_state_t state)
int xbps_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t *state)
char * xbps_archive_fetch_file(const char *url, const char *fname)
Definition plist_fetch.c:76
xbps_dictionary_t xbps_archive_fetch_plist(const char *url, const char *p)
int xbps_archive_fetch_file_into_fd(const char *url, const char *fname, int fd)
xbps_object_iterator_t xbps_array_iter_from_dict(xbps_dictionary_t dict, const char *key)
Definition plist.c:232
bool xbps_match_pkgver_in_array(xbps_array_t array, const char *pkgver)
bool xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname)
bool xbps_match_pkgdep_in_array(xbps_array_t array, const char *pkgver)
bool xbps_match_string_in_array(xbps_array_t array, const char *val)
bool xbps_match_virtual_pkg_in_dict(xbps_dictionary_t pkgd, const char *str)
Definition plist_match.c:58
int xbps_array_foreach_cb_multi(struct xbps_handle *xhp, xbps_array_t array, xbps_dictionary_t dict, int(*fn)(struct xbps_handle *, xbps_object_t obj, const char *, void *arg, bool *done), void *arg)
Definition plist.c:101
bool xbps_match_virtual_pkg_in_array(xbps_array_t array, const char *str)
Definition plist_match.c:43
bool xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps, xbps_array_t provides)
Definition plist_match.c:71
bool xbps_match_pkgpattern_in_array(xbps_array_t array, const char *pattern)
int xbps_array_foreach_cb(struct xbps_handle *xhp, xbps_array_t array, xbps_dictionary_t dict, int(*fn)(struct xbps_handle *, xbps_object_t obj, const char *, void *arg, bool *done), void *arg)
Definition plist.c:200
xbps_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg)
Definition repo.c:598
struct xbps_repo * xbps_repo_open(struct xbps_handle *xhp, const char *uri)
Definition repo.c:493
void xbps_repo_release(struct xbps_repo *repo)
Definition repo.c:539
int xbps_repo_lock(const char *repodir, const char *arch)
Definition repo.c:49
bool xbps_repo_remove(struct xbps_handle *xhp, const char *url)
Definition repo.c:433
int xbps_repo_key_import(struct xbps_repo *repo)
Definition repo.c:768
struct xbps_repo * xbps_repo_public_open(struct xbps_handle *xhp, const char *uri)
void xbps_repo_close(struct xbps_repo *repo)
char * xbps_repo_path(struct xbps_handle *xhp, const char *url)
xbps_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg)
Definition repo.c:564
xbps_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
Definition repo.c:726
void xbps_repo_unlock(const char *repodir, const char *arch, int fd)
Definition repo.c:86
bool xbps_repo_store(struct xbps_handle *xhp, const char *url)
Definition repo.c:394
bool is_signed
Definition xbps.h:1549
xbps_dictionary_t idxmeta
Definition xbps.h:1531
bool is_remote
Definition xbps.h:1543
struct xbps_handle * xhp
Definition xbps.h:1501
xbps_dictionary_t index
Definition xbps.h:1519
const char * uri
Definition xbps.h:1537
xbps_dictionary_t idx
Definition xbps.h:1513
const char * arch
Definition xbps.h:1507
Repository structure.
Definition xbps.h:1489
int xbps_rpool_foreach(struct xbps_handle *xhp, int(*fn)(struct xbps_repo *, void *, bool *), void *arg)
Definition rpool.c:139
struct xbps_repo * xbps_rpool_get_repo(const char *url)
Definition rpool.c:112
xbps_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
Definition rpool.c:323
xbps_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg)
Definition rpool.c:329
xbps_array_t xbps_rpool_get_pkg_fulldeptree(struct xbps_handle *xhp, const char *pkg)
Definition rpool.c:344
xbps_array_t xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
Definition rpool.c:338
int xbps_rpool_sync(struct xbps_handle *xhp, const char *uri)
int xbps_transaction_commit(struct xbps_handle *xhp)
xbps_trans_type_t xbps_transaction_pkg_type(xbps_dictionary_t pkg_repod)
int xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
int xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
xbps_trans_type_t
Definition xbps.h:1400
int xbps_transaction_remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive)
bool xbps_transaction_pkg_type_set(xbps_dictionary_t pkg_repod, xbps_trans_type_t type)
int xbps_transaction_prepare(struct xbps_handle *xhp)
int xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkgname, bool force)
int xbps_transaction_update_packages(struct xbps_handle *xhp)
xbps_dictionary_t xbps_plist_dictionary_from_file(const char *path)
bool xbps_remove_pkgname_from_array(xbps_array_t array, const char *pkgname)
char * xbps_pubkey2fp(xbps_data_t pubkey)
Definition pubkey2fp.c:66
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf
ssize_t xbps_path_append(char *dst, size_t len, const char *suffix)
Definition util_path.c:219
int xbps_humanize_number(char *buf, int64_t bytes)
Definition util.c:553
const char * xbps_pkgpattern_version(const char *pattern)
Definition util.c:313
bool xbps_verify_file_signature(struct xbps_repo *repo, const char *fname)
Definition verifysig.c:137
xbps_array_t xbps_plist_array_from_file(const char *path)
int xbps_file_sha256_check(const char *file, const char *sha256)
Definition util_hash.c:201
char bool xbps_mmap_file(const char *file, void **mmf, size_t *mmflen, size_t *filelen)
Definition util_hash.c:65
bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
Definition util.c:249
char * xbps_sanitize_path(const char *src)
Definition util.c:607
bool xbps_patterns_match(xbps_array_t patterns, const char *path)
Definition util.c:724
int xbps_mkpath(const char *path, mode_t mode)
Definition mkpath.c:42
bool xbps_pkg_is_ignored(struct xbps_handle *xhp, const char *pkg)
Definition util.c:99
bool xbps_verify_signature(struct xbps_repo *repo, const char *sigfile, unsigned char *digest)
Definition verifysig.c:76
bool xbps_file_sha256(char *dst, size_t len, const char *file)
Definition util_hash.c:148
ssize_t xbps_pkg_url(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
char * xbps_binpkg_pkgver(const char *pkg)
Definition util.c:146
size_t xbps_strlcpy(char *dst, const char *src, size_t dstsize)
Definition util.c:571
ssize_t xbps_path_clean(char *path)
Definition util_path.c:67
bool xbps_pkg_reverts(xbps_dictionary_t pkg, const char *pkgver)
Definition util.c:583
bool xbps_remote_binpkg_exists(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
Definition util.c:451
ssize_t xbps_path_prepend(char *dst, size_t len, const char *prefix)
Definition util_path.c:249
bool xbps_remove_string_from_array(xbps_array_t array, const char *str)
ssize_t xbps_pkg_path(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
Definition util.c:321
int xbps_cmpver(const char *pkg1, const char *pkg2)
Definition dewey.c:273
ssize_t xbps_pkg_path_or_url(struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
int xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg)
Definition util.c:75
char * xbps_binpkg_arch(const char *pkg)
Definition util.c:188
int xbps_pkgpattern_match(const char *pkgver, const char *pattern)
Definition util.c:526
const char * xbps_pkg_revision(const char *pkg)
Definition util.c:223
const char * xbps_pkg_version(const char *pkg)
Definition util.c:120
bool xbps_repository_is_remote(const char *uri)
Definition util.c:62
bool xbps_pkgpattern_name(char *dst, size_t len, const char *pattern)
Definition util.c:285
bool xbps_binpkg_exists(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
Definition util.c:425
ssize_t xbps_path_join(char *dst, size_t len,...)
Definition util_path.c:208
bool xbps_pkg_arch_match(struct xbps_handle *xhp, const char *orig, const char *target)
Definition util.c:480
char * xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *target)
Definition util.c:634
bool xbps_file_sha256_raw(unsigned char *dst, size_t len, const char *file)
Definition util_hash.c:116
size_t xbps_strlcat(char *dst, const char *src, size_t dstsize)
Definition util.c:562
char * xbps_repository_pkg_path(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
Definition util.c:389
ssize_t xbps_path_rel(char *dst, size_t len, const char *from, const char *to)
Definition util_path.c:131