4 * Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org>
5 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
6 * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
7 * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 #include <time.h> /* for time_t */
30 #include <stdarg.h> /* for va_list */
32 #include <alpm_list.h>
34 #define DEPRECATED __attribute__((deprecated))
37 * Arch Linux Package Management library
44 typedef struct __pmdb_t pmdb_t
;
45 typedef struct __pmpkg_t pmpkg_t
;
46 typedef struct __pmdelta_t pmdelta_t
;
47 typedef struct __pmgrp_t pmgrp_t
;
48 typedef struct __pmserver_t pmserver_t
;
49 typedef struct __pmtrans_t pmtrans_t
;
50 typedef struct __pmsyncpkg_t pmsyncpkg_t
;
51 typedef struct __pmdepend_t pmdepend_t
;
52 typedef struct __pmdepmissing_t pmdepmissing_t
;
53 typedef struct __pmconflict_t pmconflict_t
;
54 typedef struct __pmfileconflict_t pmfileconflict_t
;
55 typedef struct __pmgraph_t pmgraph_t
;
61 int alpm_initialize(void);
62 int alpm_release(void);
69 typedef enum _pmloglevel_t
{
71 PM_LOG_WARNING
= 0x02,
73 PM_LOG_FUNCTION
= 0x08
76 typedef void (*alpm_cb_log
)(pmloglevel_t
, char *, va_list);
77 int alpm_logaction(char *fmt
, ...);
83 typedef void (*alpm_cb_download
)(const char *filename
, int file_xfered
,
84 int file_total
, int list_xfered
, int list_total
);
90 #define PM_DLFNM_LEN 22
92 alpm_cb_log
alpm_option_get_logcb();
93 void alpm_option_set_logcb(alpm_cb_log cb
);
95 alpm_cb_download
alpm_option_get_dlcb();
96 void alpm_option_set_dlcb(alpm_cb_download cb
);
98 const char *alpm_option_get_root();
99 int alpm_option_set_root(const char *root
);
101 const char *alpm_option_get_dbpath();
102 int alpm_option_set_dbpath(const char *dbpath
);
104 alpm_list_t
*alpm_option_get_cachedirs();
105 int alpm_option_add_cachedir(const char *cachedir
);
106 void alpm_option_set_cachedirs(alpm_list_t
*cachedirs
);
107 int alpm_option_remove_cachedir(const char *cachedir
);
109 const char *alpm_option_get_logfile();
110 int alpm_option_set_logfile(const char *logfile
);
112 const char *alpm_option_get_lockfile();
113 /* no set_lockfile, path is determined from dbpath */
115 unsigned short alpm_option_get_usesyslog();
116 void alpm_option_set_usesyslog(unsigned short usesyslog
);
118 alpm_list_t
*alpm_option_get_noupgrades();
119 void alpm_option_add_noupgrade(const char *pkg
);
120 void alpm_option_set_noupgrades(alpm_list_t
*noupgrade
);
121 int alpm_option_remove_noupgrade(const char *pkg
);
123 alpm_list_t
*alpm_option_get_noextracts();
124 void alpm_option_add_noextract(const char *pkg
);
125 void alpm_option_set_noextracts(alpm_list_t
*noextract
);
126 int alpm_option_remove_noextract(const char *pkg
);
128 alpm_list_t
*alpm_option_get_ignorepkgs();
129 void alpm_option_add_ignorepkg(const char *pkg
);
130 void alpm_option_set_ignorepkgs(alpm_list_t
*ignorepkgs
);
131 int alpm_option_remove_ignorepkg(const char *pkg
);
133 alpm_list_t
*alpm_option_get_holdpkgs();
134 void alpm_option_add_holdpkg(const char *pkg
);
135 void alpm_option_set_holdpkgs(alpm_list_t
*holdpkgs
);
136 int alpm_option_remove_holdpkg(const char *pkg
);
138 alpm_list_t
*alpm_option_get_ignoregrps();
139 void alpm_option_add_ignoregrp(const char *grp
);
140 void alpm_option_set_ignoregrps(alpm_list_t
*ignoregrps
);
141 int alpm_option_remove_ignoregrp(const char *grp
);
143 const char *alpm_option_get_xfercommand();
144 void alpm_option_set_xfercommand(const char *cmd
);
146 unsigned short alpm_option_get_nopassiveftp();
147 void alpm_option_set_nopassiveftp(unsigned short nopasv
);
148 void alpm_option_set_usedelta(unsigned short usedelta
);
150 pmdb_t
*alpm_option_get_localdb();
151 alpm_list_t
*alpm_option_get_syncdbs();
157 /* Preferred interfaces db_register_local and db_register_sync */
158 pmdb_t
*alpm_db_register_local(void);
159 pmdb_t
*alpm_db_register_sync(const char *treename
);
160 int alpm_db_unregister(pmdb_t
*db
);
161 int alpm_db_unregister_all(void);
163 const char *alpm_db_get_name(const pmdb_t
*db
);
164 const char *alpm_db_get_url(const pmdb_t
*db
);
166 int alpm_db_setserver(pmdb_t
*db
, const char *url
);
168 int alpm_db_update(int level
, pmdb_t
*db
);
170 pmpkg_t
*alpm_db_get_pkg(pmdb_t
*db
, const char *name
);
171 alpm_list_t
*alpm_db_getpkgcache(pmdb_t
*db
);
172 alpm_list_t
*alpm_db_whatprovides(pmdb_t
*db
, const char *name
);
174 pmgrp_t
*alpm_db_readgrp(pmdb_t
*db
, const char *name
);
175 alpm_list_t
*alpm_db_getgrpcache(pmdb_t
*db
);
176 alpm_list_t
*alpm_db_search(pmdb_t
*db
, const alpm_list_t
* needles
);
182 /* Info parameters */
184 /* reasons -- ie, why the package was installed */
185 typedef enum _pmpkgreason_t
{
186 PM_PKG_REASON_EXPLICIT
= 0, /* explicitly requested by the user */
187 PM_PKG_REASON_DEPEND
= 1 /* installed as a dependency for another package */
190 int alpm_pkg_load(const char *filename
, unsigned short full
, pmpkg_t
**pkg
);
191 int alpm_pkg_free(pmpkg_t
*pkg
);
192 int alpm_pkg_checkmd5sum(pmpkg_t
*pkg
);
193 char *alpm_fetch_pkgurl(const char *url
);
194 int alpm_pkg_vercmp(const char *ver1
, const char *ver2
);
195 alpm_list_t
*alpm_pkg_compute_requiredby(pmpkg_t
*pkg
);
197 const char *alpm_pkg_get_filename(pmpkg_t
*pkg
);
198 const char *alpm_pkg_get_name(pmpkg_t
*pkg
);
199 const char *alpm_pkg_get_version(pmpkg_t
*pkg
);
200 const char *alpm_pkg_get_desc(pmpkg_t
*pkg
);
201 const char *alpm_pkg_get_url(pmpkg_t
*pkg
);
202 time_t alpm_pkg_get_builddate(pmpkg_t
*pkg
);
203 time_t alpm_pkg_get_installdate(pmpkg_t
*pkg
);
204 const char *alpm_pkg_get_packager(pmpkg_t
*pkg
);
205 const char *alpm_pkg_get_md5sum(pmpkg_t
*pkg
);
206 const char *alpm_pkg_get_arch(pmpkg_t
*pkg
);
207 unsigned long alpm_pkg_get_size(pmpkg_t
*pkg
);
208 unsigned long alpm_pkg_get_isize(pmpkg_t
*pkg
);
209 pmpkgreason_t
alpm_pkg_get_reason(pmpkg_t
*pkg
);
210 alpm_list_t
*alpm_pkg_get_licenses(pmpkg_t
*pkg
);
211 alpm_list_t
*alpm_pkg_get_groups(pmpkg_t
*pkg
);
212 alpm_list_t
*alpm_pkg_get_depends(pmpkg_t
*pkg
);
213 alpm_list_t
*alpm_pkg_get_optdepends(pmpkg_t
*pkg
);
214 alpm_list_t
*alpm_pkg_get_conflicts(pmpkg_t
*pkg
);
215 alpm_list_t
*alpm_pkg_get_provides(pmpkg_t
*pkg
);
216 alpm_list_t
*alpm_pkg_get_deltas(pmpkg_t
*pkg
);
217 alpm_list_t
*alpm_pkg_get_replaces(pmpkg_t
*pkg
);
218 alpm_list_t
*alpm_pkg_get_files(pmpkg_t
*pkg
);
219 alpm_list_t
*alpm_pkg_get_backup(pmpkg_t
*pkg
);
220 void *alpm_pkg_changelog_open(pmpkg_t
*pkg
);
221 size_t alpm_pkg_changelog_read(void *ptr
, size_t size
,
222 const pmpkg_t
*pkg
, const void *fp
);
223 /*int alpm_pkg_changelog_feof(const pmpkg_t *pkg, void *fp);*/
224 int alpm_pkg_changelog_close(const pmpkg_t
*pkg
, void *fp
);
225 unsigned short alpm_pkg_has_scriptlet(pmpkg_t
*pkg
);
227 unsigned long alpm_pkg_download_size(pmpkg_t
*newpkg
, pmdb_t
*db_local
);
233 const char *alpm_delta_get_from(pmdelta_t
*delta
);
234 const char *alpm_delta_get_to(pmdelta_t
*delta
);
235 unsigned long alpm_delta_get_size(pmdelta_t
*delta
);
236 const char *alpm_delta_get_filename(pmdelta_t
*delta
);
237 const char *alpm_delta_get_md5sum(pmdelta_t
*delta
);
242 const char *alpm_grp_get_name(const pmgrp_t
*grp
);
243 const alpm_list_t
*alpm_grp_get_pkgs(const pmgrp_t
*grp
);
249 pmpkgreason_t
alpm_sync_get_newreason(const pmsyncpkg_t
*sync
);
250 pmpkg_t
*alpm_sync_get_pkg(const pmsyncpkg_t
*sync
);
251 alpm_list_t
*alpm_sync_get_removes(const pmsyncpkg_t
*sync
);
252 int alpm_sync_sysupgrade(pmdb_t
*db_local
,
253 alpm_list_t
*dbs_sync
, alpm_list_t
**syncpkgs
);
260 typedef enum _pmtranstype_t
{
261 PM_TRANS_TYPE_ADD
= 1,
262 PM_TRANS_TYPE_REMOVE
,
263 PM_TRANS_TYPE_REMOVEUPGRADE
,
264 PM_TRANS_TYPE_UPGRADE
,
269 typedef enum _pmtransflag_t
{
270 PM_TRANS_FLAG_NODEPS
= 0x01,
271 PM_TRANS_FLAG_FORCE
= 0x02,
272 PM_TRANS_FLAG_NOSAVE
= 0x04,
273 /* 0x08 flag can go here */
274 PM_TRANS_FLAG_CASCADE
= 0x10,
275 PM_TRANS_FLAG_RECURSE
= 0x20,
276 PM_TRANS_FLAG_DBONLY
= 0x40,
277 PM_TRANS_FLAG_DEPENDSONLY
= 0x80,
278 PM_TRANS_FLAG_ALLDEPS
= 0x100,
279 PM_TRANS_FLAG_DOWNLOADONLY
= 0x200,
280 PM_TRANS_FLAG_NOSCRIPTLET
= 0x400,
281 PM_TRANS_FLAG_NOCONFLICTS
= 0x800,
282 PM_TRANS_FLAG_PRINTURIS
= 0x1000,
283 PM_TRANS_FLAG_NEEDED
= 0x2000,
284 PM_TRANS_FLAG_ALLEXPLICIT
= 0x4000
287 /* Transaction Events */
288 typedef enum _pmtransevt_t
{
289 PM_TRANS_EVT_CHECKDEPS_START
= 1,
290 PM_TRANS_EVT_CHECKDEPS_DONE
,
291 PM_TRANS_EVT_FILECONFLICTS_START
,
292 PM_TRANS_EVT_FILECONFLICTS_DONE
,
293 PM_TRANS_EVT_RESOLVEDEPS_START
,
294 PM_TRANS_EVT_RESOLVEDEPS_DONE
,
295 PM_TRANS_EVT_INTERCONFLICTS_START
,
296 PM_TRANS_EVT_INTERCONFLICTS_DONE
,
297 PM_TRANS_EVT_ADD_START
,
298 PM_TRANS_EVT_ADD_DONE
,
299 PM_TRANS_EVT_REMOVE_START
,
300 PM_TRANS_EVT_REMOVE_DONE
,
301 PM_TRANS_EVT_UPGRADE_START
,
302 PM_TRANS_EVT_UPGRADE_DONE
,
303 PM_TRANS_EVT_EXTRACT_DONE
,
304 PM_TRANS_EVT_INTEGRITY_START
,
305 PM_TRANS_EVT_INTEGRITY_DONE
,
306 PM_TRANS_EVT_DELTA_INTEGRITY_START
,
307 PM_TRANS_EVT_DELTA_INTEGRITY_DONE
,
308 PM_TRANS_EVT_DELTA_PATCHES_START
,
309 PM_TRANS_EVT_DELTA_PATCHES_DONE
,
310 PM_TRANS_EVT_DELTA_PATCH_START
,
311 PM_TRANS_EVT_DELTA_PATCH_DONE
,
312 PM_TRANS_EVT_DELTA_PATCH_FAILED
,
313 PM_TRANS_EVT_SCRIPTLET_INFO
,
314 PM_TRANS_EVT_PRINTURI
,
315 PM_TRANS_EVT_RETRIEVE_START
,
318 /* Transaction Conversations (ie, questions) */
319 typedef enum _pmtransconv_t
{
320 PM_TRANS_CONV_INSTALL_IGNOREPKG
= 0x01,
321 PM_TRANS_CONV_REPLACE_PKG
= 0x02,
322 PM_TRANS_CONV_CONFLICT_PKG
= 0x04,
323 PM_TRANS_CONV_CORRUPTED_PKG
= 0x08,
324 PM_TRANS_CONV_LOCAL_NEWER
= 0x10,
325 /* 0x20 flag can go here */
326 PM_TRANS_CONV_REMOVE_HOLDPKG
= 0x40
329 /* Transaction Progress */
330 typedef enum _pmtransprog_t
{
331 PM_TRANS_PROGRESS_ADD_START
,
332 PM_TRANS_PROGRESS_UPGRADE_START
,
333 PM_TRANS_PROGRESS_REMOVE_START
,
334 PM_TRANS_PROGRESS_CONFLICTS_START
337 /* Transaction Event callback */
338 typedef void (*alpm_trans_cb_event
)(pmtransevt_t
, void *, void *);
340 /* Transaction Conversation callback */
341 typedef void (*alpm_trans_cb_conv
)(pmtransconv_t
, void *, void *,
344 /* Transaction Progress callback */
345 typedef void (*alpm_trans_cb_progress
)(pmtransprog_t
, const char *, int, int, int);
347 pmtranstype_t
alpm_trans_get_type();
348 unsigned int alpm_trans_get_flags();
349 alpm_list_t
* alpm_trans_get_targets();
350 alpm_list_t
* alpm_trans_get_pkgs();
351 int alpm_trans_init(pmtranstype_t type
, pmtransflag_t flags
,
352 alpm_trans_cb_event cb_event
, alpm_trans_cb_conv conv
,
353 alpm_trans_cb_progress cb_progress
);
354 int alpm_trans_sysupgrade(void);
355 int alpm_trans_addtarget(char *target
);
356 int alpm_trans_prepare(alpm_list_t
**data
);
357 int alpm_trans_commit(alpm_list_t
**data
);
358 int alpm_trans_interrupt(void);
359 int alpm_trans_release(void);
362 * Dependencies and conflicts
365 typedef enum _pmdepmod_t
{
374 int alpm_depcmp(pmpkg_t
*pkg
, pmdepend_t
*dep
);
375 alpm_list_t
*alpm_checkdeps(pmdb_t
*db
, int reversedeps
,
376 alpm_list_t
*remove
, alpm_list_t
*upgrade
);
377 alpm_list_t
*alpm_deptest(pmdb_t
*db
, alpm_list_t
*targets
);
379 const char *alpm_miss_get_target(const pmdepmissing_t
*miss
);
380 pmdepend_t
*alpm_miss_get_dep(pmdepmissing_t
*miss
);
382 alpm_list_t
*alpm_checkdbconflicts(pmdb_t
*db_local
);
384 const char *alpm_conflict_get_package1(pmconflict_t
*conflict
);
385 const char *alpm_conflict_get_package2(pmconflict_t
*conflict
);
387 pmdepmod_t
alpm_dep_get_mod(const pmdepend_t
*dep
);
388 const char *alpm_dep_get_name(const pmdepend_t
*dep
);
389 const char *alpm_dep_get_version(const pmdepend_t
*dep
);
390 char *alpm_dep_get_string(const pmdepend_t
*dep
);
396 typedef enum _pmfileconflicttype_t
{
397 PM_FILECONFLICT_TARGET
= 1,
398 PM_FILECONFLICT_FILESYSTEM
399 } pmfileconflicttype_t
;
401 const char *alpm_fileconflict_get_target(pmfileconflict_t
*conflict
);
402 pmfileconflicttype_t
alpm_fileconflict_get_type(pmfileconflict_t
*conflict
);
403 const char *alpm_fileconflict_get_file(pmfileconflict_t
*conflict
);
404 const char *alpm_fileconflict_get_ctarget(pmfileconflict_t
*conflict
);
411 char *alpm_get_md5sum(const char *name
);
425 PM_ERR_HANDLE_NOT_NULL
,
436 PM_ERR_SERVER_BAD_URL
,
442 PM_ERR_OPT_USESYSLOG
,
444 PM_ERR_TRANS_NOT_NULL
,
446 PM_ERR_TRANS_DUP_TARGET
,
447 PM_ERR_TRANS_NOT_INITIALIZED
,
448 PM_ERR_TRANS_NOT_PREPARED
,
451 PM_ERR_TRANS_COMMITING
,
452 PM_ERR_TRANS_DOWNLOADING
,
454 PM_ERR_PKG_NOT_FOUND
,
458 PM_ERR_PKG_INSTALLED
,
459 PM_ERR_PKG_CANT_FRESH
,
460 PM_ERR_PKG_CANT_REMOVE
,
461 PM_ERR_PKG_INVALID_NAME
,
462 PM_ERR_PKG_CORRUPTED
,
463 PM_ERR_PKG_REPO_NOT_FOUND
,
465 PM_ERR_DLT_CORRUPTED
,
466 PM_ERR_DLT_PATCHFAILED
,
468 PM_ERR_GRP_NOT_FOUND
,
470 PM_ERR_UNSATISFIED_DEPS
,
471 PM_ERR_CONFLICTING_DEPS
,
472 PM_ERR_FILE_CONFLICTS
,
475 PM_ERR_INTERNAL_ERROR
,
476 PM_ERR_LIBARCHIVE_ERROR
,
480 PM_ERR_INVALID_REGEX
,
482 PM_ERR_CONNECT_FAILED
,
486 extern enum _pmerrno_t pm_errno
;
488 const char *alpm_strerror(int err
);
489 const char *alpm_strerrorlast(void);
496 /* vim: set ts=2 sw=2 noet: */