4 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
6 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
7 * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
8 * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include <sys/types.h> /* for off_t */
31 #include <time.h> /* for time_t */
32 #include <stdarg.h> /* for va_list */
34 #include <alpm_list.h>
36 #define DEPRECATED __attribute__((deprecated))
39 * Arch Linux Package Management library
42 /** @addtogroup alpm_api Public API
43 * The libalpm Public API
49 * These ones are used in multiple contexts, so are forward-declared.
54 * Why the package was installed.
56 typedef enum _alpm_pkgreason_t
{
57 /** Explicitly requested by the user. */
58 ALPM_PKG_REASON_EXPLICIT
= 0,
59 /** Installed as a dependency for another package. */
60 ALPM_PKG_REASON_DEPEND
= 1
63 /** Types of version constraints in dependency specs. */
64 typedef enum _alpm_depmod_t
{
65 /** No version constraint */
67 /** Test version equality (package=x.y.z) */
69 /** Test for at least a version (package>=x.y.z) */
71 /** Test for at most a version (package<=x.y.z) */
73 /** Test for greater than some version (package>x.y.z) */
75 /** Test for less than some version (package<x.y.z) */
81 * Whether the conflict results from a file existing on the filesystem, or with
82 * another target in the transaction.
84 typedef enum _alpm_fileconflicttype_t
{
85 ALPM_FILECONFLICT_TARGET
= 1,
86 ALPM_FILECONFLICT_FILESYSTEM
87 } alpm_fileconflicttype_t
;
90 * GPG signature verification options
92 typedef enum _pgp_verify_t
{
93 PM_PGP_VERIFY_UNKNOWN
,
95 PM_PGP_VERIFY_OPTIONAL
,
103 typedef struct __alpm_handle_t alpm_handle_t
;
104 typedef struct __alpm_db_t alpm_db_t
;
105 typedef struct __alpm_pkg_t alpm_pkg_t
;
106 typedef struct __alpm_trans_t alpm_trans_t
;
109 typedef struct _alpm_depend_t
{
112 unsigned long name_hash
;
116 /** Missing dependency */
117 typedef struct _alpm_depmissing_t
{
119 alpm_depend_t
*depend
;
120 /* this is used in case of remove dependency error only */
125 typedef struct _alpm_conflict_t
{
132 typedef struct _alpm_fileconflict_t
{
134 alpm_fileconflicttype_t type
;
137 } alpm_fileconflict_t
;
140 typedef struct _alpm_group_t
{
143 /** list of alpm_pkg_t packages */
144 alpm_list_t
*packages
;
147 /** Package upgrade delta */
148 typedef struct _alpm_delta_t
{
149 /** filename of the delta patch */
151 /** md5sum of the delta file */
153 /** filename of the 'before' file */
155 /** filename of the 'after' file */
157 /** filesize of the delta file */
159 /** download filesize of the delta file */
163 /** Local package or package file backup entry */
164 typedef struct _alpm_backup_t
{
176 typedef enum _alpm_loglevel_t
{
178 ALPM_LOG_WARNING
= (1 << 1),
179 ALPM_LOG_DEBUG
= (1 << 2),
180 ALPM_LOG_FUNCTION
= (1 << 3)
183 typedef void (*alpm_cb_log
)(alpm_loglevel_t
, const char *, va_list);
184 int alpm_logaction(alpm_handle_t
*handle
, const char *fmt
, ...);
190 /** Type of download progress callbacks.
191 * @param filename the name of the file being downloaded
192 * @param xfered the number of transferred bytes
193 * @param total the total number of bytes to transfer
195 typedef void (*alpm_cb_download
)(const char *filename
,
196 off_t xfered
, off_t total
);
198 typedef void (*alpm_cb_totaldl
)(off_t total
);
200 /** A callback for downloading files
201 * @param url the URL of the file to be downloaded
202 * @param localpath the directory to which the file should be downloaded
203 * @param force whether to force an update, even if the file is the same
204 * @return 0 on success, 1 if the file exists and is identical, -1 on
207 typedef int (*alpm_cb_fetch
)(const char *url
, const char *localpath
,
210 /** Fetch a remote pkg.
211 * @param handle the context handle
212 * @param url URL of the package to download
213 * @return the downloaded filepath on success, NULL on error
215 char *alpm_fetch_pkgurl(alpm_handle_t
*handle
, const char *url
);
217 /** @addtogroup alpm_api_options Options
218 * Libalpm option getters and setters
222 /** Returns the callback used for logging. */
223 alpm_cb_log
alpm_option_get_logcb(alpm_handle_t
*handle
);
224 /** Sets the callback used for logging. */
225 int alpm_option_set_logcb(alpm_handle_t
*handle
, alpm_cb_log cb
);
227 /** Returns the callback used to report download progress. */
228 alpm_cb_download
alpm_option_get_dlcb(alpm_handle_t
*handle
);
229 /** Sets the callback used to report download progress. */
230 int alpm_option_set_dlcb(alpm_handle_t
*handle
, alpm_cb_download cb
);
232 /** Returns the downloading callback. */
233 alpm_cb_fetch
alpm_option_get_fetchcb(alpm_handle_t
*handle
);
234 /** Sets the downloading callback. */
235 int alpm_option_set_fetchcb(alpm_handle_t
*handle
, alpm_cb_fetch cb
);
237 /** Returns the callback used to report total download size. */
238 alpm_cb_totaldl
alpm_option_get_totaldlcb(alpm_handle_t
*handle
);
239 /** Sets the callback used to report total download size. */
240 int alpm_option_set_totaldlcb(alpm_handle_t
*handle
, alpm_cb_totaldl cb
);
242 /** Returns the root of the destination filesystem. Read-only. */
243 const char *alpm_option_get_root(alpm_handle_t
*handle
);
245 /** Returns the path to the database directory. Read-only. */
246 const char *alpm_option_get_dbpath(alpm_handle_t
*handle
);
248 /** Get the name of the database lock file. Read-only. */
249 const char *alpm_option_get_lockfile(alpm_handle_t
*handle
);
251 /** @name Accessors to the list of package cache directories.
254 alpm_list_t
*alpm_option_get_cachedirs(alpm_handle_t
*handle
);
255 int alpm_option_set_cachedirs(alpm_handle_t
*handle
, alpm_list_t
*cachedirs
);
256 int alpm_option_add_cachedir(alpm_handle_t
*handle
, const char *cachedir
);
257 int alpm_option_remove_cachedir(alpm_handle_t
*handle
, const char *cachedir
);
260 /** Returns the logfile name. */
261 const char *alpm_option_get_logfile(alpm_handle_t
*handle
);
262 /** Sets the logfile name. */
263 int alpm_option_set_logfile(alpm_handle_t
*handle
, const char *logfile
);
265 /** Returns the path to libalpm's GnuPG home directory. */
266 const char *alpm_option_get_gpgdir(alpm_handle_t
*handle
);
267 /** Sets the path to libalpm's GnuPG home directory. */
268 int alpm_option_set_gpgdir(alpm_handle_t
*handle
, const char *gpgdir
);
270 /** Returns whether to use syslog (0 is FALSE, TRUE otherwise). */
271 int alpm_option_get_usesyslog(alpm_handle_t
*handle
);
272 /** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */
273 int alpm_option_set_usesyslog(alpm_handle_t
*handle
, int usesyslog
);
275 /** @name Accessors to the list of no-upgrade files.
276 * These functions modify the list of files which should
277 * not be updated by package installation.
280 alpm_list_t
*alpm_option_get_noupgrades(alpm_handle_t
*handle
);
281 int alpm_option_add_noupgrade(alpm_handle_t
*handle
, const char *pkg
);
282 int alpm_option_set_noupgrades(alpm_handle_t
*handle
, alpm_list_t
*noupgrade
);
283 int alpm_option_remove_noupgrade(alpm_handle_t
*handle
, const char *pkg
);
286 /** @name Accessors to the list of no-extract files.
287 * These functions modify the list of filenames which should
288 * be skipped packages which should
289 * not be upgraded by a sysupgrade operation.
292 alpm_list_t
*alpm_option_get_noextracts(alpm_handle_t
*handle
);
293 int alpm_option_add_noextract(alpm_handle_t
*handle
, const char *pkg
);
294 int alpm_option_set_noextracts(alpm_handle_t
*handle
, alpm_list_t
*noextract
);
295 int alpm_option_remove_noextract(alpm_handle_t
*handle
, const char *pkg
);
298 /** @name Accessors to the list of ignored packages.
299 * These functions modify the list of packages that
300 * should be ignored by a sysupgrade.
303 alpm_list_t
*alpm_option_get_ignorepkgs(alpm_handle_t
*handle
);
304 int alpm_option_add_ignorepkg(alpm_handle_t
*handle
, const char *pkg
);
305 int alpm_option_set_ignorepkgs(alpm_handle_t
*handle
, alpm_list_t
*ignorepkgs
);
306 int alpm_option_remove_ignorepkg(alpm_handle_t
*handle
, const char *pkg
);
309 /** @name Accessors to the list of ignored groups.
310 * These functions modify the list of groups whose packages
311 * should be ignored by a sysupgrade.
314 alpm_list_t
*alpm_option_get_ignoregroups(alpm_handle_t
*handle
);
315 int alpm_option_add_ignoregroup(alpm_handle_t
*handle
, const char *grp
);
316 int alpm_option_set_ignoregroups(alpm_handle_t
*handle
, alpm_list_t
*ignoregrps
);
317 int alpm_option_remove_ignoregroup(alpm_handle_t
*handle
, const char *grp
);
320 /** Returns the targeted architecture. */
321 const char *alpm_option_get_arch(alpm_handle_t
*handle
);
322 /** Sets the targeted architecture. */
323 int alpm_option_set_arch(alpm_handle_t
*handle
, const char *arch
);
325 int alpm_option_get_usedelta(alpm_handle_t
*handle
);
326 int alpm_option_set_usedelta(alpm_handle_t
*handle
, int usedelta
);
328 int alpm_option_get_checkspace(alpm_handle_t
*handle
);
329 int alpm_option_set_checkspace(alpm_handle_t
*handle
, int checkspace
);
331 pgp_verify_t
alpm_option_get_default_sigverify(alpm_handle_t
*handle
);
332 int alpm_option_set_default_sigverify(alpm_handle_t
*handle
, pgp_verify_t level
);
336 /** @addtogroup alpm_api_databases Database Functions
337 * Functions to query and manipulate the database of libalpm.
341 /** Get the database of locally installed packages.
342 * The returned pointer points to an internal structure
343 * of libalpm which should only be manipulated through
345 * @return a reference to the local database
347 alpm_db_t
*alpm_option_get_localdb(alpm_handle_t
*handle
);
349 /** Get the list of sync databases.
350 * Returns a list of alpm_db_t structures, one for each registered
352 * @param handle the context handle
353 * @return a reference to an internal list of alpm_db_t structures
355 alpm_list_t
*alpm_option_get_syncdbs(alpm_handle_t
*handle
);
357 /** Register a sync database of packages.
358 * @param handle the context handle
359 * @param treename the name of the sync repository
360 * @param check_sig what level of signature checking to perform on the
361 * database; note that this must be a '.sig' file type verification
362 * @return a alpm_db_t* on success (the value), NULL on error
364 alpm_db_t
*alpm_db_register_sync(alpm_handle_t
*handle
, const char *treename
,
365 pgp_verify_t check_sig
);
367 /** Unregister a package database.
368 * @param db pointer to the package database to unregister
369 * @return 0 on success, -1 on error (pm_errno is set accordingly)
371 int alpm_db_unregister(alpm_db_t
*db
);
373 /** Unregister all package databases.
374 * @param handle the context handle
375 * @return 0 on success, -1 on error (pm_errno is set accordingly)
377 int alpm_db_unregister_all(alpm_handle_t
*handle
);
379 /** Get the name of a package database.
380 * @param db pointer to the package database
381 * @return the name of the package database, NULL on error
383 const char *alpm_db_get_name(const alpm_db_t
*db
);
385 /** Get the signature verification level for a database.
386 * Will return the default verification level if this database is set up
387 * with PM_PGP_VERIFY_UNKNOWN.
388 * @param db pointer to the package database
389 * @return the signature verification level
391 pgp_verify_t
alpm_db_get_sigverify_level(alpm_db_t
*db
);
393 /** Check the validity of a database.
394 * This is most useful for sync databases and verifying signature status.
395 * If invalid, the handle error code will be set accordingly.
396 * @param db pointer to the package database
397 * @return 0 if valid, -1 if invalid (pm_errno is set accordingly)
399 int alpm_db_get_valid(alpm_db_t
*db
);
401 /** @name Accessors to the list of servers for a database.
404 alpm_list_t
*alpm_db_get_servers(const alpm_db_t
*db
);
405 int alpm_db_set_servers(alpm_db_t
*db
, alpm_list_t
*servers
);
406 int alpm_db_add_server(alpm_db_t
*db
, const char *url
);
407 int alpm_db_remove_server(alpm_db_t
*db
, const char *url
);
410 int alpm_db_update(int level
, alpm_db_t
*db
);
412 /** Get a package entry from a package database.
413 * @param db pointer to the package database to get the package from
414 * @param name of the package
415 * @return the package entry on success, NULL on error
417 alpm_pkg_t
*alpm_db_get_pkg(alpm_db_t
*db
, const char *name
);
419 /** Get the package cache of a package database.
420 * @param db pointer to the package database to get the package from
421 * @return the list of packages on success, NULL on error
423 alpm_list_t
*alpm_db_get_pkgcache(alpm_db_t
*db
);
425 /** Get a group entry from a package database.
426 * @param db pointer to the package database to get the group from
427 * @param name of the group
428 * @return the groups entry on success, NULL on error
430 alpm_group_t
*alpm_db_readgroup(alpm_db_t
*db
, const char *name
);
432 /** Get the group cache of a package database.
433 * @param db pointer to the package database to get the group from
434 * @return the list of groups on success, NULL on error
436 alpm_list_t
*alpm_db_get_groupcache(alpm_db_t
*db
);
438 /** Searches a database with regular expressions.
439 * @param db pointer to the package database to search in
440 * @param needles a list of regular expressions to search for
441 * @return the list of packages matching all regular expressions on success, NULL on error
443 alpm_list_t
*alpm_db_search(alpm_db_t
*db
, const alpm_list_t
* needles
);
445 /** Set install reason for a package in db.
446 * @param db pointer to the package database
447 * @param name the name of the package
448 * @param reason the new install reason
449 * @return 0 on success, -1 on error (pm_errno is set accordingly)
451 int alpm_db_set_pkgreason(alpm_db_t
*db
, const char *name
, alpm_pkgreason_t reason
);
455 /** @addtogroup alpm_api_packages Package Functions
456 * Functions to manipulate libalpm packages
460 /** Create a package from a file.
461 * If full is false, the archive is read only until all necessary
462 * metadata is found. If it is true, the entire archive is read, which
463 * serves as a verification of integrity and the filelist can be created.
464 * The allocated structure should be freed using alpm_pkg_free().
465 * @param handle the context handle
466 * @param filename location of the package tarball
467 * @param full whether to stop the load after metadata is read or continue
468 * through the full archive
469 * @param check_sig what level of package signature checking to perform on the
470 * package; note that this must be a '.sig' file type verification
471 * @param pkg address of the package pointer
472 * @return 0 on success, -1 on error (pm_errno is set accordingly)
474 int alpm_pkg_load(alpm_handle_t
*handle
, const char *filename
, int full
,
475 pgp_verify_t check_sig
, alpm_pkg_t
**pkg
);
478 * @param pkg package pointer to free
479 * @return 0 on success, -1 on error (pm_errno is set accordingly)
481 int alpm_pkg_free(alpm_pkg_t
*pkg
);
483 /** Check the integrity (with md5) of a package from the sync cache.
484 * @param pkg package pointer
485 * @return 0 on success, -1 on error (pm_errno is set accordingly)
487 int alpm_pkg_checkmd5sum(alpm_pkg_t
*pkg
);
489 /** Compare two version strings and determine which one is 'newer'. */
490 int alpm_pkg_vercmp(const char *a
, const char *b
);
492 /** Computes the list of packages requiring a given package.
493 * The return value of this function is a newly allocated
494 * list of package names (char*), it should be freed by the caller.
495 * @param pkg a package
496 * @return the list of packages requiring pkg
498 alpm_list_t
*alpm_pkg_compute_requiredby(alpm_pkg_t
*pkg
);
500 /** @name Package Property Accessors
501 * Any pointer returned by these functions points to internal structures
502 * allocated by libalpm. They should not be freed nor modified in any
507 /** Gets the name of the file from which the package was loaded.
508 * @param pkg a pointer to package
509 * @return a reference to an internal string
511 const char *alpm_pkg_get_filename(alpm_pkg_t
*pkg
);
513 /** Returns the package name.
514 * @param pkg a pointer to package
515 * @return a reference to an internal string
517 const char *alpm_pkg_get_name(alpm_pkg_t
*pkg
);
519 /** Returns the package version as a string.
520 * This includes all available epoch, version, and pkgrel components. Use
521 * alpm_pkg_vercmp() to compare version strings if necessary.
522 * @param pkg a pointer to package
523 * @return a reference to an internal string
525 const char *alpm_pkg_get_version(alpm_pkg_t
*pkg
);
527 /** Returns the package description.
528 * @param pkg a pointer to package
529 * @return a reference to an internal string
531 const char *alpm_pkg_get_desc(alpm_pkg_t
*pkg
);
533 /** Returns the package URL.
534 * @param pkg a pointer to package
535 * @return a reference to an internal string
537 const char *alpm_pkg_get_url(alpm_pkg_t
*pkg
);
539 /** Returns the build timestamp of the package.
540 * @param pkg a pointer to package
541 * @return the timestamp of the build time
543 time_t alpm_pkg_get_builddate(alpm_pkg_t
*pkg
);
545 /** Returns the install timestamp of the package.
546 * @param pkg a pointer to package
547 * @return the timestamp of the install time
549 time_t alpm_pkg_get_installdate(alpm_pkg_t
*pkg
);
551 /** Returns the packager's name.
552 * @param pkg a pointer to package
553 * @return a reference to an internal string
555 const char *alpm_pkg_get_packager(alpm_pkg_t
*pkg
);
557 /** Returns the package's MD5 checksum as a string.
558 * The returned string is a sequence of lowercase hexadecimal digits.
559 * @param pkg a pointer to package
560 * @return a reference to an internal string
562 const char *alpm_pkg_get_md5sum(alpm_pkg_t
*pkg
);
564 /** Returns the architecture for which the package was built.
565 * @param pkg a pointer to package
566 * @return a reference to an internal string
568 const char *alpm_pkg_get_arch(alpm_pkg_t
*pkg
);
570 /** Returns the size of the package.
571 * @param pkg a pointer to package
572 * @return the size of the package in bytes.
574 off_t
alpm_pkg_get_size(alpm_pkg_t
*pkg
);
576 /** Returns the installed size of the package.
577 * @param pkg a pointer to package
578 * @return the total size of files installed by the package.
580 off_t
alpm_pkg_get_isize(alpm_pkg_t
*pkg
);
582 /** Returns the package installation reason.
583 * @param pkg a pointer to package
584 * @return an enum member giving the install reason.
586 alpm_pkgreason_t
alpm_pkg_get_reason(alpm_pkg_t
*pkg
);
588 /** Returns the list of package licenses.
589 * @param pkg a pointer to package
590 * @return a pointer to an internal list of strings.
592 alpm_list_t
*alpm_pkg_get_licenses(alpm_pkg_t
*pkg
);
594 /** Returns the list of package groups.
595 * @param pkg a pointer to package
596 * @return a pointer to an internal list of strings.
598 alpm_list_t
*alpm_pkg_get_groups(alpm_pkg_t
*pkg
);
600 /** Returns the list of package dependencies as alpm_depend_t.
601 * @param pkg a pointer to package
602 * @return a reference to an internal list of alpm_depend_t structures.
604 alpm_list_t
*alpm_pkg_get_depends(alpm_pkg_t
*pkg
);
606 /** Returns the list of package optional dependencies.
607 * @param pkg a pointer to package
608 * @return a reference to an internal list of strings.
610 alpm_list_t
*alpm_pkg_get_optdepends(alpm_pkg_t
*pkg
);
612 /** Returns the list of package names conflicting with pkg.
613 * @param pkg a pointer to package
614 * @return a reference to an internal list of strings.
616 alpm_list_t
*alpm_pkg_get_conflicts(alpm_pkg_t
*pkg
);
618 /** Returns the list of package names provided by pkg.
619 * @param pkg a pointer to package
620 * @return a reference to an internal list of strings.
622 alpm_list_t
*alpm_pkg_get_provides(alpm_pkg_t
*pkg
);
624 /** Returns the list of available deltas for pkg.
625 * @param pkg a pointer to package
626 * @return a reference to an internal list of strings.
628 alpm_list_t
*alpm_pkg_get_deltas(alpm_pkg_t
*pkg
);
630 /** Returns the list of packages to be replaced by pkg.
631 * @param pkg a pointer to package
632 * @return a reference to an internal list of strings.
634 alpm_list_t
*alpm_pkg_get_replaces(alpm_pkg_t
*pkg
);
636 /** Returns the list of files installed by pkg.
637 * The filenames are relative to the install root,
638 * and do not include leading slashes.
639 * @param pkg a pointer to package
640 * @return a reference to an internal list of strings.
642 alpm_list_t
*alpm_pkg_get_files(alpm_pkg_t
*pkg
);
644 /** Returns the list of files backed up when installing pkg.
645 * The elements of the returned list have the form
646 * "<filename>\t<md5sum>", where the given md5sum is that of
647 * the file as provided by the package.
648 * @param pkg a pointer to package
649 * @return a reference to an internal list of strings.
651 alpm_list_t
*alpm_pkg_get_backup(alpm_pkg_t
*pkg
);
653 /** Returns the database containing pkg.
654 * Returns a pointer to the alpm_db_t structure the package is
655 * originating from, or NULL if the package was loaded from a file.
656 * @param pkg a pointer to package
657 * @return a pointer to the DB containing pkg, or NULL.
659 alpm_db_t
*alpm_pkg_get_db(alpm_pkg_t
*pkg
);
661 /* End of alpm_pkg_t accessors */
664 /** Open a package changelog for reading.
665 * Similar to fopen in functionality, except that the returned 'file
666 * stream' could really be from an archive as well as from the database.
667 * @param pkg the package to read the changelog of (either file or db)
668 * @return a 'file stream' to the package changelog
670 void *alpm_pkg_changelog_open(alpm_pkg_t
*pkg
);
672 /** Read data from an open changelog 'file stream'.
673 * Similar to fread in functionality, this function takes a buffer and
674 * amount of data to read. If an error occurs pm_errno will be set.
675 * @param ptr a buffer to fill with raw changelog data
676 * @param size the size of the buffer
677 * @param pkg the package that the changelog is being read from
678 * @param fp a 'file stream' to the package changelog
679 * @return the number of characters read, or 0 if there is no more data or an
682 size_t alpm_pkg_changelog_read(void *ptr
, size_t size
,
683 const alpm_pkg_t
*pkg
, const void *fp
);
685 /*int alpm_pkg_changelog_feof(const alpm_pkg_t *pkg, void *fp);*/
687 int alpm_pkg_changelog_close(const alpm_pkg_t
*pkg
, void *fp
);
689 /** Returns whether the package has an install scriptlet.
690 * @return 0 if FALSE, TRUE otherwise
692 int alpm_pkg_has_scriptlet(alpm_pkg_t
*pkg
);
694 /** Returns the size of download.
695 * Returns the size of the files that will be downloaded to install a
697 * @param newpkg the new package to upgrade to
698 * @return the size of the download
700 off_t
alpm_pkg_download_size(alpm_pkg_t
*newpkg
);
702 alpm_list_t
*alpm_pkg_unused_deltas(alpm_pkg_t
*pkg
);
704 /* End of alpm_pkg */
711 int alpm_pkg_check_pgp_signature(alpm_pkg_t
*pkg
);
713 int alpm_db_check_pgp_signature(alpm_db_t
*db
);
719 alpm_list_t
*alpm_find_group_pkgs(alpm_list_t
*dbs
, const char *name
);
725 alpm_pkg_t
*alpm_sync_newversion(alpm_pkg_t
*pkg
, alpm_list_t
*dbs_sync
);
727 /** @addtogroup alpm_api_trans Transaction Functions
728 * Functions to manipulate libalpm transactions
732 /** Transaction flags */
733 typedef enum _alpm_transflag_t
{
734 /** Ignore dependency checks. */
735 ALPM_TRANS_FLAG_NODEPS
= 1,
736 /** Ignore file conflicts and overwrite files. */
737 ALPM_TRANS_FLAG_FORCE
= (1 << 1),
738 /** Delete files even if they are tagged as backup. */
739 ALPM_TRANS_FLAG_NOSAVE
= (1 << 2),
740 /** Ignore version numbers when checking dependencies. */
741 ALPM_TRANS_FLAG_NODEPVERSION
= (1 << 3),
742 /** Remove also any packages depending on a package being removed. */
743 ALPM_TRANS_FLAG_CASCADE
= (1 << 4),
744 /** Remove packages and their unneeded deps (not explicitly installed). */
745 ALPM_TRANS_FLAG_RECURSE
= (1 << 5),
746 /** Modify database but do not commit changes to the filesystem. */
747 ALPM_TRANS_FLAG_DBONLY
= (1 << 6),
748 /* (1 << 7) flag can go here */
749 /** Use ALPM_PKG_REASON_DEPEND when installing packages. */
750 ALPM_TRANS_FLAG_ALLDEPS
= (1 << 8),
751 /** Only download packages and do not actually install. */
752 ALPM_TRANS_FLAG_DOWNLOADONLY
= (1 << 9),
753 /** Do not execute install scriptlets after installing. */
754 ALPM_TRANS_FLAG_NOSCRIPTLET
= (1 << 10),
755 /** Ignore dependency conflicts. */
756 ALPM_TRANS_FLAG_NOCONFLICTS
= (1 << 11),
757 /* (1 << 12) flag can go here */
758 /** Do not install a package if it is already installed and up to date. */
759 ALPM_TRANS_FLAG_NEEDED
= (1 << 13),
760 /** Use ALPM_PKG_REASON_EXPLICIT when installing packages. */
761 ALPM_TRANS_FLAG_ALLEXPLICIT
= (1 << 14),
762 /** Do not remove a package if it is needed by another one. */
763 ALPM_TRANS_FLAG_UNNEEDED
= (1 << 15),
764 /** Remove also explicitly installed unneeded deps (use with ALPM_TRANS_FLAG_RECURSE). */
765 ALPM_TRANS_FLAG_RECURSEALL
= (1 << 16),
766 /** Do not lock the database during the operation. */
767 ALPM_TRANS_FLAG_NOLOCK
= (1 << 17)
770 /** Transaction events.
771 * NULL parameters are passed to in all events unless specified otherwise.
773 typedef enum _alpm_transevt_t
{
774 /** Dependencies will be computed for a package. */
775 ALPM_TRANS_EVT_CHECKDEPS_START
= 1,
776 /** Dependencies were computed for a package. */
777 ALPM_TRANS_EVT_CHECKDEPS_DONE
,
778 /** File conflicts will be computed for a package. */
779 ALPM_TRANS_EVT_FILECONFLICTS_START
,
780 /** File conflicts were computed for a package. */
781 ALPM_TRANS_EVT_FILECONFLICTS_DONE
,
782 /** Dependencies will be resolved for target package. */
783 ALPM_TRANS_EVT_RESOLVEDEPS_START
,
784 /** Dependencies were resolved for target package. */
785 ALPM_TRANS_EVT_RESOLVEDEPS_DONE
,
786 /** Inter-conflicts will be checked for target package. */
787 ALPM_TRANS_EVT_INTERCONFLICTS_START
,
788 /** Inter-conflicts were checked for target package. */
789 ALPM_TRANS_EVT_INTERCONFLICTS_DONE
,
790 /** Package will be installed.
791 * A pointer to the target package is passed to the callback.
793 ALPM_TRANS_EVT_ADD_START
,
794 /** Package was installed.
795 * A pointer to the new package is passed to the callback.
797 ALPM_TRANS_EVT_ADD_DONE
,
798 /** Package will be removed.
799 * A pointer to the target package is passed to the callback.
801 ALPM_TRANS_EVT_REMOVE_START
,
802 /** Package was removed.
803 * A pointer to the removed package is passed to the callback.
805 ALPM_TRANS_EVT_REMOVE_DONE
,
806 /** Package will be upgraded.
807 * A pointer to the upgraded package is passed to the callback.
809 ALPM_TRANS_EVT_UPGRADE_START
,
810 /** Package was upgraded.
811 * A pointer to the new package, and a pointer to the old package is passed
812 * to the callback, respectively.
814 ALPM_TRANS_EVT_UPGRADE_DONE
,
815 /** Target package's integrity will be checked. */
816 ALPM_TRANS_EVT_INTEGRITY_START
,
817 /** Target package's integrity was checked. */
818 ALPM_TRANS_EVT_INTEGRITY_DONE
,
819 /** Target deltas's integrity will be checked. */
820 ALPM_TRANS_EVT_DELTA_INTEGRITY_START
,
821 /** Target delta's integrity was checked. */
822 ALPM_TRANS_EVT_DELTA_INTEGRITY_DONE
,
823 /** Deltas will be applied to packages. */
824 ALPM_TRANS_EVT_DELTA_PATCHES_START
,
825 /** Deltas were applied to packages. */
826 ALPM_TRANS_EVT_DELTA_PATCHES_DONE
,
827 /** Delta patch will be applied to target package.
828 * The filename of the package and the filename of the patch is passed to the
831 ALPM_TRANS_EVT_DELTA_PATCH_START
,
832 /** Delta patch was applied to target package. */
833 ALPM_TRANS_EVT_DELTA_PATCH_DONE
,
834 /** Delta patch failed to apply to target package. */
835 ALPM_TRANS_EVT_DELTA_PATCH_FAILED
,
836 /** Scriptlet has printed information.
837 * A line of text is passed to the callback.
839 ALPM_TRANS_EVT_SCRIPTLET_INFO
,
840 /** Files will be downloaded from a repository.
841 * The repository's tree name is passed to the callback.
843 ALPM_TRANS_EVT_RETRIEVE_START
,
844 /** Disk space usage will be computed for a package */
845 ALPM_TRANS_EVT_DISKSPACE_START
,
846 /** Disk space usage was computed for a package */
847 ALPM_TRANS_EVT_DISKSPACE_DONE
,
850 /** Transaction Conversations (ie, questions) */
851 typedef enum _alpm_transconv_t
{
852 PM_TRANS_CONV_INSTALL_IGNOREPKG
= 1,
853 PM_TRANS_CONV_REPLACE_PKG
= (1 << 1),
854 PM_TRANS_CONV_CONFLICT_PKG
= (1 << 2),
855 PM_TRANS_CONV_CORRUPTED_PKG
= (1 << 3),
856 PM_TRANS_CONV_LOCAL_NEWER
= (1 << 4),
857 PM_TRANS_CONV_REMOVE_PKGS
= (1 << 5),
858 PM_TRANS_CONV_SELECT_PROVIDER
= (1 << 6),
861 /** Transaction Progress */
862 typedef enum _alpm_transprog_t
{
863 PM_TRANS_PROGRESS_ADD_START
,
864 PM_TRANS_PROGRESS_UPGRADE_START
,
865 PM_TRANS_PROGRESS_REMOVE_START
,
866 PM_TRANS_PROGRESS_CONFLICTS_START
,
867 PM_TRANS_PROGRESS_DISKSPACE_START
,
868 PM_TRANS_PROGRESS_INTEGRITY_START
,
871 /** Transaction Event callback */
872 typedef void (*alpm_trans_cb_event
)(alpm_transevt_t
, void *, void *);
874 /** Transaction Conversation callback */
875 typedef void (*alpm_trans_cb_conv
)(alpm_transconv_t
, void *, void *,
878 /** Transaction Progress callback */
879 typedef void (*alpm_trans_cb_progress
)(alpm_transprog_t
, const char *, int, size_t, size_t);
881 /** Returns the bitfield of flags for the current transaction.
882 * @param handle the context handle
883 * @return the bitfield of transaction flags
885 alpm_transflag_t
alpm_trans_get_flags(alpm_handle_t
*handle
);
887 /** Returns a list of packages added by the transaction.
888 * @param handle the context handle
889 * @return a list of alpm_pkg_t structures
891 alpm_list_t
* alpm_trans_get_add(alpm_handle_t
*handle
);
893 /** Returns the list of packages removed by the transaction.
894 * @param handle the context handle
895 * @return a list of alpm_pkg_t structures
897 alpm_list_t
* alpm_trans_get_remove(alpm_handle_t
*handle
);
899 /** Initialize the transaction.
900 * @param handle the context handle
901 * @param flags flags of the transaction (like nodeps, etc)
902 * @param event event callback function pointer
903 * @param conv question callback function pointer
904 * @param progress progress callback function pointer
905 * @return 0 on success, -1 on error (pm_errno is set accordingly)
907 int alpm_trans_init(alpm_handle_t
*handle
, alpm_transflag_t flags
,
908 alpm_trans_cb_event cb_event
, alpm_trans_cb_conv conv
,
909 alpm_trans_cb_progress cb_progress
);
911 /** Prepare a transaction.
912 * @param handle the context handle
913 * @param data the address of an alpm_list where a list
914 * of alpm_depmissing_t objects is dumped (conflicting packages)
915 * @return 0 on success, -1 on error (pm_errno is set accordingly)
917 int alpm_trans_prepare(alpm_handle_t
*handle
, alpm_list_t
**data
);
919 /** Commit a transaction.
920 * @param handle the context handle
921 * @param data the address of an alpm_list where detailed description
922 * of an error can be dumped (ie. list of conflicting files)
923 * @return 0 on success, -1 on error (pm_errno is set accordingly)
925 int alpm_trans_commit(alpm_handle_t
*handle
, alpm_list_t
**data
);
927 /** Interrupt a transaction.
928 * @param handle the context handle
929 * @return 0 on success, -1 on error (pm_errno is set accordingly)
931 int alpm_trans_interrupt(alpm_handle_t
*handle
);
933 /** Release a transaction.
934 * @param handle the context handle
935 * @return 0 on success, -1 on error (pm_errno is set accordingly)
937 int alpm_trans_release(alpm_handle_t
*handle
);
940 /** @name Common Transactions */
943 /** Search for packages to upgrade and add them to the transaction.
944 * @param handle the context handle
945 * @param enable_downgrade allow downgrading of packages if the remote version is lower
946 * @return 0 on success, -1 on error (pm_errno is set accordingly)
948 int alpm_sync_sysupgrade(alpm_handle_t
*handle
, int enable_downgrade
);
950 /** Add a package to the transaction.
951 * If the package was loaded by alpm_pkg_load(), it will be freed upon
952 * alpm_trans_release() invocation.
953 * @param handle the context handle
954 * @param pkg the package to add
955 * @return 0 on success, -1 on error (pm_errno is set accordingly)
957 int alpm_add_pkg(alpm_handle_t
*handle
, alpm_pkg_t
*pkg
);
959 /** Add a package removal action to the transaction.
960 * @param handle the context handle
961 * @param pkg the package to uninstall
962 * @return 0 on success, -1 on error (pm_errno is set accordingly)
964 int alpm_remove_pkg(alpm_handle_t
*handle
, alpm_pkg_t
*pkg
);
968 /** @addtogroup alpm_api_depends Dependency Functions
969 * Functions dealing with libalpm representation of dependency
974 alpm_list_t
*alpm_checkdeps(alpm_handle_t
*handle
, alpm_list_t
*pkglist
,
975 alpm_list_t
*remove
, alpm_list_t
*upgrade
, int reversedeps
);
976 alpm_pkg_t
*alpm_find_satisfier(alpm_list_t
*pkgs
, const char *depstring
);
977 alpm_pkg_t
*alpm_find_dbs_satisfier(alpm_handle_t
*handle
,
978 alpm_list_t
*dbs
, const char *depstring
);
980 alpm_list_t
*alpm_checkconflicts(alpm_handle_t
*handle
, alpm_list_t
*pkglist
);
982 /** Returns a newly allocated string representing the dependency information.
983 * @param dep a dependency info structure
984 * @return a formatted string, e.g. "glibc>=2.12"
986 char *alpm_dep_compute_string(const alpm_depend_t
*dep
);
997 char *alpm_compute_md5sum(const char *name
);
999 /** @addtogroup alpm_api_errors Error Codes
1002 enum _alpm_errno_t
{
1012 PM_ERR_HANDLE_NOT_NULL
,
1019 PM_ERR_DB_NOT_FOUND
,
1025 PM_ERR_SERVER_BAD_URL
,
1028 PM_ERR_TRANS_NOT_NULL
,
1030 PM_ERR_TRANS_DUP_TARGET
,
1031 PM_ERR_TRANS_NOT_INITIALIZED
,
1032 PM_ERR_TRANS_NOT_PREPARED
,
1035 PM_ERR_TRANS_NOT_LOCKED
,
1037 PM_ERR_PKG_NOT_FOUND
,
1041 PM_ERR_PKG_CANT_REMOVE
,
1042 PM_ERR_PKG_INVALID_NAME
,
1043 PM_ERR_PKG_INVALID_ARCH
,
1044 PM_ERR_PKG_REPO_NOT_FOUND
,
1046 PM_ERR_SIG_MISSINGDIR
,
1051 PM_ERR_DLT_PATCHFAILED
,
1053 PM_ERR_UNSATISFIED_DEPS
,
1054 PM_ERR_CONFLICTING_DEPS
,
1055 PM_ERR_FILE_CONFLICTS
,
1058 PM_ERR_INVALID_REGEX
,
1059 /* External library errors */
1062 PM_ERR_EXTERNAL_DOWNLOAD
,
1066 /** Returns the current error code from the handle. */
1067 enum _alpm_errno_t
alpm_errno(alpm_handle_t
*handle
);
1069 /** Returns the string corresponding to an error number. */
1070 const char *alpm_strerror(enum _alpm_errno_t err
);
1072 /* End of alpm_api_errors */
1075 alpm_handle_t
*alpm_initialize(const char *root
, const char *dbpath
,
1076 enum _alpm_errno_t
*err
);
1077 int alpm_release(alpm_handle_t
*handle
);
1078 const char *alpm_version(void);
1080 /* End of alpm_api */
1086 #endif /* _ALPM_H */
1088 /* vim: set ts=2 sw=2 noet: */