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