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