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