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