New fileconflict004.py pactest
[pacman-ng.git] / README
blob46b5bb2bc79e03b3807054cbc5277c48322fedf1
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 * xfercommand: The command to use for downloading instead of pacman's internal
63              downloading functionality.
64 * nopassiveftp: Do not use passive FTP commands for ftp connections.
65 * chomp: No way, easter eggs are secret!
66 * usecolor: Unimplemented, but for the future. You can assume what it means.
68 The following options also have a `alpm_option_add_*` function, as the values
69 are list structures (NOTE: The add functions are NOT plural, as they're in
70 english: alpm_option_get_noupgrades -> alpm_option_add_noupgrade).
72 * noupgrades: Files which will never be touched by pacman (extracted as .pacnew)
73 * noextracts: Files which will never be extracted at all (no .pacnew file)
74 * ignorepkgs: Packages to ignore when upgrading.
75 * holdpkgs: Packages which must be upgraded before continuing.
77 The following options are read-only, having ONLY alpm_option_get_* functions:
79 * localdb: A pmdb_t structure for the local (installed) database
80 * syncdbs: A list of pmdb_t structures to which pacman can sync from.
83 [Transactions]
85 The transaction sturcture permits easy manipulations of several packages
86 at a time (i.e. adding, upgrade and removal operations).
88 A transaction can be initiated with a type (ADD, UPGRADE or REMOVE),
89 and some flags (NODEPS, FORCE, CASCADE, ...).
91 Note: there can only be one type at a time: a transaction is either
92 created to add packages to the system, or either created to remove packages.
93 The frontend can't request for mixed operations: it has to run several
94 transactions, one at a time, in such a case.
96 The flags allow to tweak the library behaviour during its resolution.
97 Note, that some options of the handle can also modify the behavior of a
98 transaction (NOUPGRADE, IGNOREPKG, ...).
100 Note: once a transaction has been initiated, it is not possible anymore
101 to modify its type or its flags.
103 One can also add some targets to a transaction (alpm_trans_addtarget()).
104 These targets represent the list of packages to be handled.
106 Then, a transaction needs to be prepared (alpm_trans_prepare()). It
107 means that the various targets added, will be inspected and challenged
108 against the set of already installed packages (dependency checkings,
110 Last, a callback is associated with each transaction. During the
111 transaction resolution, each time a new step is started or done (i.e
112 dependency or conflict checking, package adding or removal, ...), the
113 callback is called, allowing the frontend to be aware of the progress of
114 the resolution. Can be useful to implement a progress bar.
117 [Package Cache]
119 libalpm maintains two caches for each DB.  One is a general package cache, the
120 other is a group cache (for package groups).  These caches are loaded on demand,
121 and freed when the libary is.
122 It is important to note tha, as a general rule, package structures should NOT be
123 freed manually, as they SHOULD be part of the cache.
124 The cache of a database is always updated by the library after
125 an operation changing the database content (adding and/or removal of
126 packages). Beware frontends ;)
129 [Package]
131 The package structure maintains all information for a package.  In general,
132 packages should never be freed from front-ends, as they should always be part of
133 the package cache.
135 The 'origin' data member indicates whether the package is from a file
136 (i.e. -U operations) or from the package cache.  In the case of a file, all data
137 members available are present in the structure.  Packages indicated as being
138 from the cache have data members filled on demand.  For this reason, the
139 alpm_pkg_get_* functions will load the data from the DB as needed.
142 [Errors]
144 The library provides a global variable pm_errno.
145 It aims at being to the library what errno is for C system calls.
147 Almost all public library functions are returning an integer value: 0
148 indicating success, -1 indicating a failure.
149 If -1 is returned, the variable pm_errno is set to a meaningful value
150 Wise frontends should always care for these returned values.
152 Note: the helper function alpm_strerror() can also be used to translate
153 the error code into a more friendly sentence.
156 [List - alpm_list_t] 
157 The alpm_list_t structure is a doubly-linked list for use with the libalpm
158 routines.  This type is provided publicly so that frontends are free to use it
159 if they have no native list type (C++, glib, python, etc all have list types).
160 See the proper man pages for alpm_list_t references.
164 PACMAN frontend overview & internals
165 ====================================
167 Here are some words about the frontend responsibilities.
168 The library can operate only a small set of well defined operations and
169 dummy operations.
171 High level features are left to the frontend ;)
173 For instance, during a sysupgrade, the library returns the whole list of
174 packages to be upgraded, without any care for its content.
175 The frontend can inspect the list and perhaps notice that "pacman"
176 itself has to be upgraded. In such a case, the frontend can choose to
177 perform a special action.
180 [MAIN] (see pacman.c)
182 Calls for alpm_lib_init(), and alpm_lib_release().
183 Read the configuration file, and parse command line arguments.
184 Based on the action requested, it initiates the appropriate transactions
185 (see pacman_add(), pacman_remove(), pacman_sync() in files add.c,
186 remove.c and sync.c).
189 [CONFIGURATION] (see conf.c)
191 The frontend is using a configuration file, usually "/etc/pacman.conf".
192 Part of these options are only useful for the frontend only (mainly,
193 the download stuffs, and some options like HOLDPKG).
194 The rest is used to configure the library.
197 [ADD/UPGRADE/REMOVE/SYNC]
199 Nothing new here, excepted some reorganization.
201 The file pacman.c has been divided into several smaller files, namely
202 add.c, remove.c, sync.c and query.c, to hold the big parts: pacman_add,
203 pacman_remove, pacman_sync.
205 These 3 functions have been split to ease the code reading.
208 LIMITATIONS/BEHAVIOR CHANGES COMPARED TO PACMAN 2.9
209 ===================================================
211 Excepted missing features still needing to be implemented, one can
212 notice the following limitations:
214 - If pacman is out of date, the frontend displays a warning and recommends
215 to give up the on-going transanction. The frontend does not allow to
216 upgrade pacman itself on-the-fly, and thus it should be restarted with
217 only "pacman" as a target.
219 - ...