makepkg: check pkgver validity after updating
[pacman-ng.git] / README
blobc4199ddbcfdc0e42ffdd118bdb8a3a40df5459b5
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, while 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, for allowing it to manipulate the lists returned by
17 the backend.
19 Several structures and functions have been renamed compared to pacman 2.9 code.
20 This was done at first for the sake of naming scheme consistency, and then
21 primarily because of potential namespace conflicts between library and frontend
22 spaces. Indeed, it is not possible to have two different functions with the
23 same name declared in both spaces. To avoid such conflicts, internal function
24 names have been prepended with "_alpm_".
26 In a general manner, public library functions are named "alpm_<type>_<action>"
27 (examples: alpm_trans_commit(), alpm_release(), alpm_pkg_get_name(), ...).
28 Internal (and thus private) functions should be named "_alpm_XXX" for instance
29 (examples: _alpm_needbackup(), _alpm_runscriplet(), ...). Functions defined and
30 used inside a single file should be defined as "static".
33 [Initialization]
35 alpm_initialize() is used to initialize library internals and to create
36 a transparent handle object. Before its call, the library can't be used.
38 alpm_release() just does the opposite (memory used by the library, and the
39 handle is freed). After its call, the library is no longer available.
42 [Options]
44 The library does not use any configuration file. It is up to the front end to
45 configure the library as needed; the handle holds a number of configuration
46 options instead.
48 All of the following options have a alpm_option_get_* and alpm_option_set_*
49 function for getting and setting the value. They cannot be set before the
50 library is initialized.
52 * logcb: The callback function for "log" operations.
53 * dlcb: The callback function for download progress of each package.
54 * fetchcb: Callback for custom download function.
55 * totaldlcb: The callback function for overall download progress.
56 * root: The root directory for pacman to install to (Default: /)
57 * dbpath: The toplevel database directory (Default: /var/lib/pacman)
58 * logfile: The base path to pacman's log file (Default: /var/log/pacman.log)
59 * usesyslog: Log to syslog instead of `logfile` for file-base logging.
61 The following options also have `alpm_option_{add,remove}_*` functions, as the
62 values are list structures.
63 NOTE: The add and remove functions are NOT plural, as they are in English:
64 alpm_option_{get,set}_noupgrades -> alpm_option_{add,remove}_noupgrade.
66 * cachedirs: Paths to pacman's download caches (Default: /var/cache/pacman/pkg)
67 * noupgrades: Files which will never be touched by pacman (extracted as .pacnew)
68 * noextracts: Files which will never be extracted at all (no .pacnew file)
69 * ignorepkgs: Packages to ignore when upgrading.
70 * ignoregrps: Groups to ignore when upgrading.
72 The following options are read-only, having ONLY alpm_option_get_* functions:
74 * lockfile: The file used for locking the database
75   (Default: <dbpath>/db.lck)
76 * localdb: A alpm_db_t structure for the local (installed) database
77 * syncdbs: A list of alpm_db_t structures to which pacman can sync from.
79 The following options are write-only, having ONLY alpm_option_set_* functions:
81 * usedelta: Download delta files instead of complete packages if possible.
83 [Transactions]
85 The transaction structure 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 (SYNC, 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 checking, etc...)
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 library is.
123 It is important to note that, as a general rule, package structures should NOT
124 be freed manually, as they SHOULD be part of the cache.  The cache of a
125 database is always updated by the library after an operation changing the
126 database content (adding and/or removal of 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
133 of the package cache.
135 The 'origin' data member indicates whether the package is from a file (i.e. -U
136 operations) or from the package cache. In the case of a file, all data members
137 available are present in the structure. Packages indicated as being from the
138 cache have data members filled on demand. For this reason, the alpm_pkg_get_*
139 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 one
153 specified error code into a more friendly sentence, and alpm_strerrorlast()
154 does the same for the last error encountered (represented by pm_errno).
157 [List - alpm_list_t]
159 The alpm_list_t structure is a doubly-linked list for use with the libalpm
160 routines. This type is provided publicly so that frontends are free to use it
161 if they have no native list type (C++, glib, python, etc all have list types).
162 See the proper man pages for alpm_list_t references.
166 PACMAN frontend overview & internals
167 ====================================
169 Here are some words about the frontend responsibilities.
170 The library can operate only a small set of well defined operations and
171 dummy operations.
173 High level features are left to the frontend ;)
175 For instance, during a sysupgrade, the library returns the whole list of
176 packages to be upgraded, without any care for its content.
177 The frontend can inspect the list and perhaps notice that "pacman"
178 itself has to be upgraded. In such a case, the frontend can choose to
179 perform a special action.
182 [MAIN] (see pacman.c)
184 Calls for alpm_initialize(), and alpm_release().
185 Read the configuration file, and parse command line arguments.
186 Based on the action requested, it initiates the appropriate transactions
187 (see pacman_upgrade(), pacman_remove(), pacman_sync() in files upgrade.c,
188 remove.c and sync.c).
191 [CONFIGURATION] (see conf.h)
193 The frontend is using a configuration file, usually "/etc/pacman.conf".  Some
194 of these options are only useful for the frontend only (mainly the ones used to
195 control the output like totaldownload, or the behavior with cleanmethod and
196 syncfirst).  The rest is used to configure the library.
199 [UPGRADE/REMOVE/SYNC]
201 The file pacman.c has been divided into several smaller files, namely
202 upgrade.c, remove.c, sync.c and query.c, to hold the big parts: pacman_upgrade,
203 pacman_remove, pacman_sync.
205 These 3 functions have been split to ease the code reading.
209 API CHANGES BETWEEN 3.1 AND 3.2
210 ===============================
212 [REMOVED]
213 - alpm_db_whatprovides()
214 - alpm_splitdep (no longer public)
215 - trans->targets was removed, so alpm_trans_get_targets() as well
216 - error codes:
217     PM_ERR_OPT_*, PM_ERR_PKG_INSTALLED, PM_ERR_DLT_CORRUPTED,
218     PM_ERR_LIBARCHIVE_ERROR
219 - event: PM_TRANS_EVT_EXTRACT_DONE
220 - PM_TRANS_TYPE_ADD pmtranstype_t (add transaction)
221 - PM_TRANS_FLAG_DEPENDSONLY pmtransflag_t
223 [CHANGED]
224 - alpm_grp_get_pkgs returns with pmpkg_t list, not package-name list
225 - Swap parameters on PM_TRANS_CONV_INSTALL_IGNOREPKG callback function
226 - download callback API changed: alpm_cb_download, alpm_cb_totaldl split
227   (+ new alpm_option_get_totaldlcb(), alpm_option_set_totaldlcb() functions)
228 - unsigned long->off_t changes where size is used
229 - pmsyncpkg_t struct changes:
230   - pmsynctype_t and alpm_sync_get_type() were removed
231   - alpm_sync_get_data() was removed
232   - alpm_sync_get_removes() was added
234 [ADDED]
235 - alpm_delta_get_from_md5sum(), alpm_delta_get_to_md5sum()
236 - alpm_miss_get_causingpkg() (new causingpkg field in pmdepmissing_t)
237 - alpm_checkdbconflicts()
238 - alpm_sync_newversion()
239 - alpm_deptest()
240 - error codes :
241     PM_ERR_DLT_INVALID, PM_ERR_LIBARCHIVE, PM_ERR_LIBDOWNLOAD and
242     PM_ERR_EXTERNAL_DOWNLOAD
243 - flags:
244     PM_TRANS_FLAG_ALLEXPLICIT, PM_TRANS_FLAG_UNNEEDED and
245     PM_TRANS_FLAG_RECURSEALL
248 API CHANGES BETWEEN 3.2 AND 3.3
249 ===============================
251 [REMOVED]
252 - pmsyncpkg_t struct (pmpkg_t is used for all types of transaction targets):
253   - alpm_sync_get_pkg()
254   - alpm_sync_get_removes() (use alpm_pkg_get_removes() instead)
255 - HoldPkg handling (it is the front-end's task):
256   - alpm_option_get_holdpkgs()
257   - alpm_option_add_holdpkg()
258   - alpm_option_set_holdpkgs()
259   - alpm_option_remove_holdpkg()
260   - PM_TRANS_CONV_REMOVE_HOLDPKG conversation
261 - Print URIs feature (it is the front-end's task):
262   - flag: PM_TRANS_FLAG_PRINTURIS
263   - event: PM_TRANS_EVT_PRINTURI
264 - alpm_delta_get_from_md5sum() and alpm_delta_get_to_md5sum()
265 - alpm_sync_sysupgrade()
266 - error codes:
267     PM_ERR_TRANS_COMMITING, PM_ERR_TRANS_DOWNLOADING, PM_ERR_PKG_LOAD,
268     PM_ERR_PKG_CANT_FRESH, PM_ERR_GRP_NOT_FOUND, PM_ERR_USER_ABORT,
269     PM_ERR_INTERNAL_ERROR, PM_ERR_DB_SYNC, PM_ERR_PKG_HOLD and
270     PM_ERR_LIBDOWNLOAD
272 [CHANGED]
273 - XferCommand support was removed, any fetch callback function can be defined:
274   - alpm_option_get_xfercommand() and alpm_option_set_xfercommand() were removed
275   - alpm_option_get_fetchcb() and alpm_option_set_fetchcb() were added
276 - function renames:
277   - alpm_db_getpkgcache() -> alpm_db_get_pkgcache()
278   - alpm_db_getgrpcache() -> alpm_db_get_grpcache()
279   - alpm_dep_get_string() -> alpm_dep_compute_string()
280   - alpm_get_md5sum() -> alpm_compute_md5sum()
281   - alpm_checkdbconflicts() -> alpm_checkconflicts()
282 - alpm_trans_sysupgrade() has a new enable_downgrade parameter
283 - alpm_checkdeps() and alpm_checkconflicts() require local package list instead
284   of local database
285 - the to-be-upgraded package is passed to the callback function with
286   PM_TRANS_EVT_UPGRADE_START (as the second parameter)
287 - the "requiredby" package is never passed to the callback function with
288   PM_TRANS_CONV_INSTALL_IGNOREPKG (the second parameter is always NULL)
290 [ADDED]
291 - alpm_pkg_get_db()
292 - alpm_pkg_get_removes()
293 - conversation: PM_TRANS_CONV_REMOVE_PKGS (remove unresolvable targets)
294 - flag: PM_TRANS_FLAG_NOLOCK (do not lock database)
295 - error codes:
296     PM_ERR_SERVER_NONE, PM_ERR_TRANS_NOT_LOCKED, PM_ERR_PKG_IGNORED and
297     PM_ERR_LIBFETCH
300 API CHANGES BETWEEN 3.3 AND 3.4
301 ===============================
303 [REMOVED]
304 - pmtranstype_t struct (transaction type), alpm_trans_get_type()
305 - alpm_option_get_nopassiveftp(), alpm_option_set_nopassiveftp()
307 [CHANGED]
308 - interface for target loading:
309   - alpm_trans_addtarget() and alpm_trans_sysupgrade() were removed
310   - alpm_sync_target() and alpm_sync_dbtarget() can be used to add a sync target
311   - alpm_sync_sysupgrade() can be used to add outdated packages (for sysupgrade)
312   - alpm_add_target() can be used to add an add/upgrade target
313   - alpm_remove_target() can be used to add a remove target
314 - interface for target listing:
315   - alpm_trans_get_pkgs() was removed
316   - alpm_pkg_get_removes() was removed
317   - alpm_trans_get_add() can be used to list add/upgrade/sync targets
318   - alpm_trans_get_remove() can be used to list to-be-removed packages
319 - the type parameter of alpm_trans_init() was removed
320 - the type of alpm_db_fetch callback function: mtimeold and mtimenew parameters
321   were replaced by force parameter
322 - unsigned short -> int changes for Boolean variables
324 [ADDED]
325 - alpm_db_set_pkgreason()
326 - alpm_option_get_arch(), alpm_option_set_arch()
327 - alpm_option_get_usedelta()
328 - alpm_pkg_unused_deltas()
329 - alpm_conflict_get_reason()
330 - error code: PM_ERR_PKG_INVALID_ARCH
333 API CHANGES BETWEEN 3.4 AND 3.5
334 ===============================
336 [REMOVED]
337 - alpm_db_register_local()
338 - alpm_pkg_has_force()
339 - alpm_depcmp()
341 [CHANGED]
342 - alpm_trans_cb_progress type had some types changed from int to size_t
343 - alpm_cb_log format string is now const char *
344 - the interface to add/remove targets:
345   - functions take pmpkg_t * rather than char *.
346   - alpm_sync_target() and alpm_sync_dbtarget() are replaced by alpm_add_pkg()
347   - alpm_add_target() is replaced by alpm_add_pkg()
348   - alpm_remove_target() is replaced by alpm_remove_pkg()
349   - packages can come from:
350      - alpm_db_get_pkg() for normal targets
351      - alpm_find_dbs_satisfier() for versioned provisions
352      - alpm_find_grp_pkgs() for groups
353 - alpm_deptest() is replaced by the more flexibile alpm_find_satisfier()
354 - size_t used for alpm_list_t sizes
355   - return type for alpm_list_count()
356   - parameter type in alpm_list_msort() and alpm_list_nth()
358 [ADDED]
359 - alpm_option_get_checkspace(), alpm_option_set_checkspace()
360 - alpm_find_grp_pkgs()
361 - alpm_trans_get_flags()
362 - error codes:
363    PM_ERR_DISK_SPACE, PM_ERR_WRITE
364 - flags
365    PM_TRANS_FLAG_NODEPVERSION, PM_TRANS_EVT_DISKSPACE_START,
366    PM_TRANS_EVT_DISKSPACE_DONE, PM_TRANS_CONV_SELECT_PROVIDER,
367    PM_TRANS_PROGRESS_DISKSPACE_START, PM_TRANS_PROGRESS_INTEGRITY_START
369 API CHANGES BETWEEN 3.5 AND 4.0
370 ===============================
372 [REMOVED]
373 - error codes:
374     PM_ERR_LIBFETCH, PM_ERR_WRITE
375 - alpm_option_set_root(), alpm_option_set_dbpath()
376 - alpm_list_first()
377 - alpm_grp_get_name(), alpm_grp_get_pkgs()
378 - alpm_delta_get_from(), alpm_delta_get_to(), alpm_delta_get_filename(),
379     alpm_delta_get_md5sum(), alpm_delta_get_size()
380 - alpm_miss_get_target(), alpm_miss_get_dep(), alpm_miss_get_causingpkg()
381 - alpm_dep_get_mod(), alpm_dep_get_name(), alpm_dep_get_version()
382 - alpm_conflict_get_package1(), alpm_conflict_get_package2(),
383     alpm_conflict_get_reason()
384 - alpm_fileconflict_get_target(), alpm_fileconflict_get_type(),
385     alpm_fileconflict_get_file(), alpm_fileconflict_get_ctarget()
386 - alpm_db_get_url()
388 [CHANGED]
389 - PM_ prefixes for enum values are now ALPM_
390 - pm prefixes for structs and enums are now alpm_
391 - alpm_initialize now has parameters: char *root, char *dbpath,
392     alpm_errno_t *err and returns an alpm_handle_t struct.
393 - alpm_release now takes an alpm_handle_t *.
394 - alpm_db_register_sync() now requires a extra parameter of a alpm_siglevel_t.
395 - alpm_pkg_load() now requires an extra parameter of an alpm_siglevel_t
396 - alpm_db_setserver() replaced by alpm_db_set_servers(), alpm_db_add_server(),
397     alpm_db_remove_server()
398 - alpm_trans_init() no longer takes callbacks, set those using
399     alpm_option_set_*cb() functions
400 - many functions now require a first parameter of an alpm_handle_t *:
401   - alpm_option_get_*
402   - alpm_option_set_*
403   - alpm_option_add_*
404   - alpm_option_remove_*
405   - alpm_trans_*
406   - alpm_add_pkg
407   - alpm_checkconflicts
408   - alpm_checkdeps
409   - alpm_db_register_sync
410   - alpm_db_set_pkgreason
411   - alpm_db_unregister_all
412   - alpm_fetch_pkgurl
413   - alpm_find_dbs_satisfier
414   - alpm_logaction
415   - alpm_pkg_load
416   - alpm_release
417   - alpm_remove_pkg
418   - alpm_sync_sysupgrade
419 - several structs are no longer opaque
420   - alpm_conflict_t
421   - alpm_delta_t
422   - alpm_depend_t
423   - alpm_depmissing_t
424   - alpm_depmod_t
425   - alpm_fileconflict_t
426   - alpm_group_t
427   - alpm_pkg_reason_t
429 [ADDED]
430 - option functions:
431     alpm_{get,set}_eventcb(), alpm_option_{get,set}_convcb(),
432         alpm_option_{get,set}_progresscb()
433 - package signing functions:
434     alpm_option_get_default_siglevel(), alpm_option_set_default_siglevel(),
435     alpm_option_get_gpgdir(), alpm_option_set_gpgdir(), alpm_db_get_siglevel(),
436     alpm_siglist_cleanup(), alpm_db_check_pgp_signature(), alpm_pkg_check_pgp_signature(),
437     alpm_pkg_get_origin(), alpm_pkg_get_sha256sum(), alpm_pkg_get_base64_sig()
438 - list functions:
439     alpm_list_to_array(), alpm_list_previous()
440 - structs:
441     alpm_backup_t, alpm_file_t, alpm_filelist_t
442 - enums:
443     alpm_siglevel_t, alpm_sigstatus_t, alpm_sigvalidity_t, alpm_pkgfrom_t
444 - error codes:
445     ALPM_ERR_DB_INVALID, ALPM_ERR_DB_INVALID_SIG, ALPM_ERR_GPGME,
446     ALPM_ERR_PKG_INVALID_CHECKSUM, ALPM_ERR_PKG_INVALID_SIG, ALPM_ERR_SIG_INVALID,
447     ALPM_ERR_SIG_MISSING