New alpm_list_join function
[pacman.git] / README
blob9b804f77773817c0728a35ef5909e121f921e61a
1 ALPM library overview & internals
2 =================================
4 Here is a list of the main objects and files from the ALPM (i.e. Arch Linux
5 Package Management) library. This document, whilst not exhaustive, also
6 indicates some limitations (on purpose, or sometimes due to its poor design) of
7 the library at the present time.
9 There is one special file,"alpm.h", which is the public interface that
10 should be distributed and installed on systems with the library. Only
11 structures, data and functions declared within this file are made available to
12 the frontend. Lots of structures are of an opaque type and their fields are
13 only accessible in read-only mode, through some clearly defined functions.
15 In addition to "alpm.h", the interfaces of "alpm_list.h" have also been made
16 available to the frontend. It is not a requirement for the frontend to use
17 these list functions; however, it prevents frontends from having to reimplement
18 a list data structure.
20 Several structures and functions have been renamed compared to pacman 2.9 code.
21 This was done at first for the sake of naming scheme consistency, and then
22 primarily because of potential namespace conflicts between library and frontend
23 spaces. Indeed, it is not possible to have two different functions with the
24 same name declared in both spaces. To avoid such conflicts, internal function
25 names have been prepended with "_alpm_".
27 In a general manner, public library functions are named "alpm_<type>_<action>"
28 (examples: alpm_trans_commit(), alpm_release(), alpm_pkg_getinfo(), ...).
29 Internal (and thus private) functions should be named "_alpm_XXX" for instance
30 (examples: _alpm_needbackup(), _alpm_runscriplet(), ...). Functions defined and
31 used inside a single file should be defined as "static".
34 [Initialization]
36 alpm_init() is used to initialize library internals and to create
37 a transparent handle object. Before its call, the library can't be used.
39 alpm_lib_release() just does the opposite (memory used by the library, and the
40 handle is freed).  After its call, the library is no longer available.
43 [Options]
45 In the future, the library will not use any configuration file.  It will be up
46 to the front end to The handle holds a
47 number of configuration options instead (IGNOREPKG, SYSLOG usage,
48 log file name, registered databases, ...).
50 All of the following options have a alpm_option_get_* and alpm_option_set_*
51 function for getting and setting the value.  The cannot be set before the
52 library is initialized.
54 * logcb: The callback function for "log" operations.
55 * dlcb: The callback function for download progress.
56 * logmask: The logging mask for which level of output is sent to the logcb.
57 * root: The root directory on which pacman operates (Default: /)
58 * dbpath: The base path to pacman's databases (Default: var/lib/pacman)
59 * cachedir: The base path to pacman's download cache (Default: var/cache/pacman)
60 * logfile: The base path to pacman's log file (Default: var/log/pacman.log)
61 * usesyslog: Log to syslog instead of `logfile` for file-base logging.
62 * upgradedelay: The time span to wait before listing a package as an upgrade (Default: 0)
63 * xfercommand: The command to use for downloading instead of pacman's internal
64              downloading functionality.
65 * nopassiveftp: Do not use passive FTP commands for ftp connections.
66 * chomp: No way, easter eggs are secret!
67 * usecolor: Unimplemented, but for the future. You can assume what it means.
69 The following options also have a `alpm_option_add_*` function, as the values
70 are list structures (NOTE: The add functions are NOT plural, as they're in
71 english: alpm_option_get_noupgrades -> alpm_option_add_noupgrade).
73 * noupgrades: Files which will never be touched by pacman (extracted as .pacnew)
74 * noextracts: Files which will never be extracted at all (no .pacnew file)
75 * ignorepkgs: Packages to ignore when upgrading.
76 * holdpkgs: Packages which must be upgraded before continuing.
78 The following options are read-only, having ONLY alpm_option_get_* functions:
80 * localdb: A pmdb_t structure for the local (installed) database
81 * syncdbs: A list of pmdb_t structures to which pacman can sync from.
84 [Transactions]
86 The transaction sturcture permits easy manipulations of several packages
87 at a time (i.e. adding, upgrade and removal operations).
89 A transaction can be initiated with a type (ADD, UPGRADE or REMOVE),
90 and some flags (NODEPS, FORCE, CASCADE, ...).
92 Note: there can only be one type at a time: a transaction is either
93 created to add packages to the system, or either created to remove packages.
94 The frontend can't request for mixed operations: it has to run several
95 transactions, one at a time, in such a case.
97 The flags allow to tweak the library behaviour during its resolution.
98 Note, that some options of the handle can also modify the behavior of a
99 transaction (NOUPGRADE, IGNOREPKG, ...).
101 Note: once a transaction has been initiated, it is not possible anymore
102 to modify its type or its flags.
104 One can also add some targets to a transaction (alpm_trans_addtarget()).
105 These targets represent the list of packages to be handled.
107 Then, a transaction needs to be prepared (alpm_trans_prepare()). It
108 means that the various targets added, will be inspected and challenged
109 against the set of already installed packages (dependency checkings,
111 Last, a callback is associated with each transaction. During the
112 transaction resolution, each time a new step is started or done (i.e
113 dependency or conflict checking, package adding or removal, ...), the
114 callback is called, allowing the frontend to be aware of the progress of
115 the resolution. Can be useful to implement a progress bar.
118 [Package Cache]
120 libalpm maintains two caches for each DB.  One is a general package cache, the
121 other is a group cache (for package groups).  These caches are loaded on demand,
122 and freed when the libary is.
123 It is important to note tha, as a general rule, package structures should NOT be
124 freed manually, as they SHOULD be part of the cache.
125 The cache of a database is always updated by the library after
126 an operation changing the database content (adding and/or removal of
127 packages). Beware frontends ;)
130 [Package]
132 The package structure maintains all information for a package.  In general,
133 packages should never be freed from front-ends, as they should always be part of
134 the package cache.
136 The 'origin' data member indicates whether the package is from a file
137 (i.e. -U operations) or from the package cache.  In the case of a file, all data
138 members available are present in the structure.  Packages indicated as being
139 from the cache have data members filled on demand.  For this reason, the
140 alpm_pkg_get_* functions will load the data from the DB as needed.
143 [Errors]
145 The library provides a global variable pm_errno.
146 It aims at being to the library what errno is for C system calls.
148 Almost all public library functions are returning an integer value: 0
149 indicating success, -1 indicating a failure.
150 If -1 is returned, the variable pm_errno is set to a meaningful value
151 Wise frontends should always care for these returned values.
153 Note: the helper function alpm_strerror() can also be used to translate
154 the error code into a more friendly sentence.
157 [List - alpm_list_t] 
158 The alpm_list_t structure is a doubly-linked list for use with the libalpm
159 routines.  This type is provided publicly so that frontends are free to use it
160 if they have no native list type (C++, glib, python, etc all have list types).
161 See the proper man pages for alpm_list_t references.
165 PACMAN frontend overview & internals
166 ====================================
168 Here are some words about the frontend responsibilities.
169 The library can operate only a small set of well defined operations and
170 dummy operations.
172 High level features are left to the frontend ;)
174 For instance, during a sysupgrade, the library returns the whole list of
175 packages to be upgraded, without any care for its content.
176 The frontend can inspect the list and perhaps notice that "pacman"
177 itself has to be upgraded. In such a case, the frontend can choose to
178 perform a special action.
181 [MAIN] (see pacman.c)
183 Calls for alpm_lib_init(), and alpm_lib_release().
184 Read the configuration file, and parse command line arguments.
185 Based on the action requested, it initiates the appropriate transactions
186 (see pacman_add(), pacman_remove(), pacman_sync() in files add.c,
187 remove.c and sync.c).
190 [CONFIGURATION] (see conf.c)
192 The frontend is using a configuration file, usually "/etc/pacman.conf".
193 Part of these options are only useful for the frontend only (mainly,
194 the download stuffs, and some options like HOLDPKG).
195 The rest is used to configure the library.
198 [ADD/UPGRADE/REMOVE/SYNC]
200 Nothing new here, excepted some reorganization.
202 The file pacman.c has been divided into several smaller files, namely
203 add.c, remove.c, sync.c and query.c, to hold the big parts: pacman_add,
204 pacman_remove, pacman_sync.
206 These 3 functions have been split to ease the code reading.
209 LIMITATIONS/BEHAVIOR CHANGES COMPARED TO PACMAN 2.9
210 ===================================================
212 Excepted missing features still needing to be implemented, one can
213 notice the following limitations:
215 - If pacman is out of date, the frontend displays a warning and recommends
216 to give up the on-going transanction. The frontend does not allow to
217 upgrade pacman itself on-the-fly, and thus it should be restarted with
218 only "pacman" as a target.
220 - ...