mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 17:31:52 -05:00
This mainly deals with code clarity- removing currently unneeded
optimizations in order to make the code much more readable and type-checkable. Every enum in the library now has it's own type that should be used instead of the generic 'unsigned char'. In addition, several #define statements dealing with constants were converted to enums. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
This commit is contained in:
parent
8387672053
commit
1b61cc8c69
@ -332,7 +332,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
||||
register struct archive *archive;
|
||||
struct archive_entry *entry;
|
||||
char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
|
||||
unsigned char cb_state;
|
||||
pmtransprog_t cb_state;
|
||||
time_t t;
|
||||
alpm_list_t *targ, *lp;
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
/* Globals */
|
||||
pmhandle_t *handle = NULL;
|
||||
enum __pmerrno_t pm_errno;
|
||||
enum _pmerrno_t pm_errno;
|
||||
|
||||
/** \addtogroup alpm_interface Interface Functions
|
||||
* @brief Functions to initialize and release libalpm
|
||||
@ -622,7 +622,9 @@ alpm_list_t *alpm_db_search(pmdb_t *db)
|
||||
* @param progress progress callback function pointer
|
||||
* @return 0 on success, -1 on error (pm_errno is set accordingly)
|
||||
*/
|
||||
int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress)
|
||||
int alpm_trans_init(pmtranstype_t type, unsigned int flags,
|
||||
alpm_trans_cb_event event, alpm_trans_cb_conv conv,
|
||||
alpm_trans_cb_progress progress)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
|
||||
|
@ -71,13 +71,15 @@ int alpm_release(void);
|
||||
*/
|
||||
|
||||
/* Levels */
|
||||
#define PM_LOG_DEBUG 0x01
|
||||
#define PM_LOG_ERROR 0x02
|
||||
#define PM_LOG_WARNING 0x04
|
||||
#define PM_LOG_FLOW1 0x08
|
||||
#define PM_LOG_FLOW2 0x10
|
||||
#define PM_LOG_FUNCTION 0x20
|
||||
#define PM_LOG_DOWNLOAD 0x40
|
||||
typedef enum _pmloglevel_t {
|
||||
PM_LOG_DEBUG = 0x01,
|
||||
PM_LOG_ERROR = 0x02,
|
||||
PM_LOG_WARNING = 0x04,
|
||||
PM_LOG_FLOW1 = 0x08,
|
||||
PM_LOG_FLOW2 = 0x10,
|
||||
PM_LOG_FUNCTION = 0x20,
|
||||
PM_LOG_DOWNLOAD = 0x40
|
||||
} pmloglevel_t;
|
||||
|
||||
typedef void (*alpm_cb_log)(unsigned short, char *);
|
||||
int alpm_logaction(char *fmt, ...);
|
||||
@ -100,8 +102,8 @@ void alpm_option_set_logcb(alpm_cb_log cb);
|
||||
alpm_cb_download alpm_option_get_dlcb();
|
||||
void alpm_option_set_dlcb(alpm_cb_download cb);
|
||||
|
||||
unsigned char alpm_option_get_logmask();
|
||||
void alpm_option_set_logmask(unsigned char mask);
|
||||
unsigned short alpm_option_get_logmask();
|
||||
void alpm_option_set_logmask(unsigned short mask);
|
||||
|
||||
const char *alpm_option_get_root();
|
||||
void alpm_option_set_root(const char *root);
|
||||
@ -115,8 +117,8 @@ void alpm_option_set_cachedir(const char *cachedir);
|
||||
const char *alpm_option_get_logfile();
|
||||
void alpm_option_set_logfile(const char *logfile);
|
||||
|
||||
unsigned char alpm_option_get_usesyslog();
|
||||
void alpm_option_set_usesyslog(unsigned char usesyslog);
|
||||
unsigned short alpm_option_get_usesyslog();
|
||||
void alpm_option_set_usesyslog(unsigned short usesyslog);
|
||||
|
||||
alpm_list_t *alpm_option_get_noupgrades();
|
||||
void alpm_option_add_noupgrade(char *pkg);
|
||||
@ -188,19 +190,26 @@ alpm_list_t *alpm_db_search(pmdb_t *db);
|
||||
/* Info parameters */
|
||||
|
||||
/* reasons -- ie, why the package was installed */
|
||||
#define PM_PKG_REASON_EXPLICIT 0 /* explicitly requested by the user */
|
||||
#define PM_PKG_REASON_DEPEND 1 /* installed as a dependency for another package */
|
||||
typedef enum _pmpkgreason_t {
|
||||
PM_PKG_REASON_EXPLICIT = 0, /* explicitly requested by the user */
|
||||
PM_PKG_REASON_DEPEND = 1 /* installed as a dependency for another package */
|
||||
} pmpkgreason_t;
|
||||
|
||||
/* package name formats */
|
||||
#define PM_PKG_WITHOUT_ARCH 0 /* pkgname-pkgver-pkgrel, used under PM_DBPATH */
|
||||
#define PM_PKG_WITH_ARCH 1 /* ie, pkgname-pkgver-pkgrel-arch, used under PM_CACHEDIR */
|
||||
/*
|
||||
typedef enum _pmpkghasarch_t {
|
||||
PM_PKG_WITHOUT_ARCH = 0, / pkgname-pkgver-pkgrel, used under PM_DBPATH /
|
||||
PM_PKG_WITH_ARCH = 1 / pkgname-pkgver-pkgrel-arch, used under PM_CACHEDIR /
|
||||
} pmpkghasarch_t;
|
||||
*/
|
||||
|
||||
int alpm_pkg_load(char *filename, pmpkg_t **pkg);
|
||||
int alpm_pkg_free(pmpkg_t *pkg);
|
||||
int alpm_pkg_checkmd5sum(pmpkg_t *pkg);
|
||||
int alpm_pkg_checksha1sum(pmpkg_t *pkg);
|
||||
char *alpm_fetch_pkgurl(char *url);
|
||||
int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this_section);
|
||||
int alpm_parse_config(char *file, alpm_cb_db_register callback,
|
||||
const char *this_section);
|
||||
int alpm_pkg_vercmp(const char *ver1, const char *ver2);
|
||||
char *alpm_pkg_name_hasarch(char *pkgname);
|
||||
|
||||
@ -218,7 +227,7 @@ const char *alpm_pkg_get_sha1sum(pmpkg_t *pkg);
|
||||
const char *alpm_pkg_get_arch(pmpkg_t *pkg);
|
||||
unsigned long alpm_pkg_get_size(pmpkg_t *pkg);
|
||||
unsigned long alpm_pkg_get_isize(pmpkg_t *pkg);
|
||||
unsigned char alpm_pkg_get_reason(pmpkg_t *pkg);
|
||||
pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg);
|
||||
alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg);
|
||||
alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg);
|
||||
alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg);
|
||||
@ -229,7 +238,7 @@ alpm_list_t *alpm_pkg_get_provides(pmpkg_t *pkg);
|
||||
alpm_list_t *alpm_pkg_get_replaces(pmpkg_t *pkg);
|
||||
alpm_list_t *alpm_pkg_get_files(pmpkg_t *pkg);
|
||||
alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg);
|
||||
unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg);
|
||||
unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg);
|
||||
|
||||
/*
|
||||
* Groups
|
||||
@ -242,13 +251,13 @@ alpm_list_t *alpm_grp_get_packages(pmgrp_t *grp);
|
||||
*/
|
||||
|
||||
/* Types */
|
||||
enum {
|
||||
typedef enum _pmsynctype_t {
|
||||
PM_SYNC_TYPE_REPLACE = 1,
|
||||
PM_SYNC_TYPE_UPGRADE,
|
||||
PM_SYNC_TYPE_DEPEND
|
||||
};
|
||||
} pmsynctype_t;
|
||||
|
||||
unsigned char alpm_sync_get_type(pmsyncpkg_t *sync);
|
||||
pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync);
|
||||
pmpkg_t *alpm_sync_get_package(pmsyncpkg_t *sync);
|
||||
void *alpm_sync_get_data(pmsyncpkg_t *sync);
|
||||
|
||||
@ -257,30 +266,32 @@ void *alpm_sync_get_data(pmsyncpkg_t *sync);
|
||||
*/
|
||||
|
||||
/* Types */
|
||||
enum {
|
||||
typedef enum _pmtranstype_t {
|
||||
PM_TRANS_TYPE_ADD = 1,
|
||||
PM_TRANS_TYPE_REMOVE,
|
||||
PM_TRANS_TYPE_UPGRADE,
|
||||
PM_TRANS_TYPE_SYNC
|
||||
};
|
||||
} pmtranstype_t;
|
||||
|
||||
/* Flags */
|
||||
#define PM_TRANS_FLAG_NODEPS 0x01
|
||||
#define PM_TRANS_FLAG_FORCE 0x02
|
||||
#define PM_TRANS_FLAG_NOSAVE 0x04
|
||||
#define PM_TRANS_FLAG_FRESHEN 0x08
|
||||
#define PM_TRANS_FLAG_CASCADE 0x10
|
||||
#define PM_TRANS_FLAG_RECURSE 0x20
|
||||
#define PM_TRANS_FLAG_DBONLY 0x40
|
||||
#define PM_TRANS_FLAG_DEPENDSONLY 0x80
|
||||
#define PM_TRANS_FLAG_ALLDEPS 0x100
|
||||
#define PM_TRANS_FLAG_DOWNLOADONLY 0x200
|
||||
#define PM_TRANS_FLAG_NOSCRIPTLET 0x400
|
||||
#define PM_TRANS_FLAG_NOCONFLICTS 0x800
|
||||
#define PM_TRANS_FLAG_PRINTURIS 0x1000
|
||||
typedef enum _pmtransflag_t {
|
||||
PM_TRANS_FLAG_NODEPS = 0x01,
|
||||
PM_TRANS_FLAG_FORCE = 0x02,
|
||||
PM_TRANS_FLAG_NOSAVE = 0x04,
|
||||
PM_TRANS_FLAG_FRESHEN = 0x08,
|
||||
PM_TRANS_FLAG_CASCADE = 0x10,
|
||||
PM_TRANS_FLAG_RECURSE = 0x20,
|
||||
PM_TRANS_FLAG_DBONLY = 0x40,
|
||||
PM_TRANS_FLAG_DEPENDSONLY = 0x80,
|
||||
PM_TRANS_FLAG_ALLDEPS = 0x100,
|
||||
PM_TRANS_FLAG_DOWNLOADONLY = 0x200,
|
||||
PM_TRANS_FLAG_NOSCRIPTLET = 0x400,
|
||||
PM_TRANS_FLAG_NOCONFLICTS = 0x800,
|
||||
PM_TRANS_FLAG_PRINTURIS = 0x1000
|
||||
} pmtransflag_t;
|
||||
|
||||
/* Transaction Events */
|
||||
enum {
|
||||
typedef enum _pmtransevt_t {
|
||||
PM_TRANS_EVT_CHECKDEPS_START = 1,
|
||||
PM_TRANS_EVT_CHECKDEPS_DONE,
|
||||
PM_TRANS_EVT_FILECONFLICTS_START,
|
||||
@ -306,10 +317,10 @@ enum {
|
||||
PM_TRANS_EVT_PRINTURI,
|
||||
PM_TRANS_EVT_RETRIEVE_START,
|
||||
PM_TRANS_EVT_RETRIEVE_LOCAL
|
||||
};
|
||||
} pmtransevt_t;
|
||||
|
||||
/* Transaction Conversations (ie, questions) */
|
||||
enum {
|
||||
typedef enum _pmtransconv_t {
|
||||
PM_TRANS_CONV_INSTALL_IGNOREPKG = 0x01,
|
||||
PM_TRANS_CONV_REPLACE_PKG = 0x02,
|
||||
PM_TRANS_CONV_CONFLICT_PKG = 0x04,
|
||||
@ -317,30 +328,33 @@ enum {
|
||||
PM_TRANS_CONV_LOCAL_NEWER = 0x10,
|
||||
PM_TRANS_CONV_LOCAL_UPTODATE = 0x20,
|
||||
PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
|
||||
};
|
||||
} pmtransconv_t;
|
||||
|
||||
/* Transaction Progress */
|
||||
enum {
|
||||
typedef enum _pmtransprog_t {
|
||||
PM_TRANS_PROGRESS_ADD_START,
|
||||
PM_TRANS_PROGRESS_UPGRADE_START,
|
||||
PM_TRANS_PROGRESS_REMOVE_START,
|
||||
PM_TRANS_PROGRESS_CONFLICTS_START
|
||||
};
|
||||
} pmtransprog_t;
|
||||
|
||||
/* Transaction Event callback */
|
||||
typedef void (*alpm_trans_cb_event)(unsigned char, void *, void *);
|
||||
typedef void (*alpm_trans_cb_event)(pmtransevt_t, void *, void *);
|
||||
|
||||
/* Transaction Conversation callback */
|
||||
typedef void (*alpm_trans_cb_conv)(unsigned char, void *, void *, void *, int *);
|
||||
typedef void (*alpm_trans_cb_conv)(pmtransconv_t, void *, void *,
|
||||
void *, int *);
|
||||
|
||||
/* Transaction Progress callback */
|
||||
typedef void (*alpm_trans_cb_progress)(unsigned char, char *, int, int, int);
|
||||
typedef void (*alpm_trans_cb_progress)(pmtransprog_t, char *, int, int, int);
|
||||
|
||||
unsigned char alpm_trans_get_type();
|
||||
pmtranstype_t alpm_trans_get_type();
|
||||
unsigned int alpm_trans_get_flags();
|
||||
alpm_list_t * alpm_trans_get_targets();
|
||||
alpm_list_t * alpm_trans_get_packages();
|
||||
int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv, alpm_trans_cb_progress cb_progress);
|
||||
int alpm_trans_init(pmtranstype_t type, unsigned int flags,
|
||||
alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv,
|
||||
alpm_trans_cb_progress cb_progress);
|
||||
int alpm_trans_sysupgrade(void);
|
||||
int alpm_trans_addtarget(char *target);
|
||||
int alpm_trans_prepare(alpm_list_t **data);
|
||||
@ -351,21 +365,22 @@ int alpm_trans_release(void);
|
||||
* Dependencies and conflicts
|
||||
*/
|
||||
|
||||
enum {
|
||||
typedef enum _pmdepmod_t {
|
||||
PM_DEP_MOD_ANY = 1,
|
||||
PM_DEP_MOD_EQ,
|
||||
PM_DEP_MOD_GE,
|
||||
PM_DEP_MOD_LE
|
||||
};
|
||||
enum {
|
||||
} pmdepmod_t;
|
||||
|
||||
typedef enum _pmdeptype_t {
|
||||
PM_DEP_TYPE_DEPEND = 1,
|
||||
PM_DEP_TYPE_REQUIRED,
|
||||
PM_DEP_TYPE_CONFLICT
|
||||
};
|
||||
} pmdeptype_t;
|
||||
|
||||
const char *alpm_dep_get_target(pmdepmissing_t *miss);
|
||||
unsigned char alpm_dep_get_type(pmdepmissing_t *miss);
|
||||
unsigned char alpm_dep_get_mod(pmdepmissing_t *miss);
|
||||
pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss);
|
||||
pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss);
|
||||
const char *alpm_dep_get_name(pmdepmissing_t *miss);
|
||||
const char *alpm_dep_get_version(pmdepmissing_t *miss);
|
||||
|
||||
@ -373,19 +388,20 @@ const char *alpm_dep_get_version(pmdepmissing_t *miss);
|
||||
* File conflicts
|
||||
*/
|
||||
|
||||
enum {
|
||||
typedef enum _pmconflicttype_t {
|
||||
PM_CONFLICT_TYPE_TARGET = 1,
|
||||
PM_CONFLICT_TYPE_FILE
|
||||
};
|
||||
} pmconflicttype_t;
|
||||
|
||||
const char *alpm_conflict_get_target(pmconflict_t *conflict);
|
||||
unsigned char alpm_conflict_get_type(pmconflict_t *conflict);
|
||||
pmconflicttype_t alpm_conflict_get_type(pmconflict_t *conflict);
|
||||
const char *alpm_conflict_get_file(pmconflict_t *conflict);
|
||||
const char *alpm_conflict_get_ctarget(pmconflict_t *conflict);
|
||||
|
||||
/*
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
|
||||
/* md5sums */
|
||||
char *alpm_get_md5sum(char *name);
|
||||
@ -394,7 +410,7 @@ char *alpm_get_sha1sum(char *name);
|
||||
/*
|
||||
* Errors
|
||||
*/
|
||||
enum __pmerrno_t {
|
||||
enum _pmerrno_t {
|
||||
PM_ERR_MEMORY = 1,
|
||||
PM_ERR_SYSTEM,
|
||||
PM_ERR_BADPERMS,
|
||||
@ -466,7 +482,7 @@ enum __pmerrno_t {
|
||||
PM_ERR_FORK_FAILED
|
||||
};
|
||||
|
||||
extern enum __pmerrno_t pm_errno;
|
||||
extern enum _pmerrno_t pm_errno;
|
||||
|
||||
char *alpm_strerror(int err);
|
||||
|
||||
|
@ -98,7 +98,7 @@ void _alpm_db_rewind(pmdb_t *db)
|
||||
rewinddir(db->handle);
|
||||
}
|
||||
|
||||
pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq)
|
||||
pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq)
|
||||
{
|
||||
struct dirent *ent = NULL;
|
||||
struct stat sbuf;
|
||||
|
@ -41,12 +41,12 @@
|
||||
/* Returns a new package cache from db.
|
||||
* It frees the cache if it already exists.
|
||||
*/
|
||||
int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel)
|
||||
int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
|
||||
{
|
||||
pmpkg_t *info;
|
||||
int count = 0;
|
||||
/* The group cache needs INFRQ_DESC as well */
|
||||
/*unsigned char infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
|
||||
/* pmdbinfrq_t infolevel = INFRQ_DEPENDS | INFRQ_DESC;*/
|
||||
|
||||
if(db == NULL) {
|
||||
return(-1);
|
||||
@ -86,7 +86,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
|
||||
}
|
||||
}
|
||||
|
||||
alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
|
||||
alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
|
||||
{
|
||||
if(db == NULL) {
|
||||
return(NULL);
|
||||
@ -101,7 +101,7 @@ alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
|
||||
return(db->pkgcache);
|
||||
}
|
||||
|
||||
int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel)
|
||||
int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
|
||||
{
|
||||
int reloaded = 0;
|
||||
/* for each pkg, check and reload if the requested
|
||||
|
@ -27,12 +27,12 @@
|
||||
#include "package.h"
|
||||
|
||||
/* packages */
|
||||
int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel);
|
||||
int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
|
||||
void _alpm_db_free_pkgcache(pmdb_t *db);
|
||||
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
|
||||
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
|
||||
alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
|
||||
int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel);
|
||||
alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
|
||||
int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
|
||||
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target);
|
||||
/* groups */
|
||||
int _alpm_db_load_grpcache(pmdb_t *db);
|
||||
|
@ -368,7 +368,7 @@ const char *alpm_conflict_get_target(pmconflict_t *conflict)
|
||||
return conflict->target;
|
||||
}
|
||||
|
||||
unsigned char alpm_conflict_get_type(pmconflict_t *conflict)
|
||||
pmconflicttype_t alpm_conflict_get_type(pmconflict_t *conflict)
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, return(-1));
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
struct __pmconflict_t {
|
||||
char target[PKG_NAME_LEN];
|
||||
unsigned char type;
|
||||
pmconflicttype_t type;
|
||||
char file[CONFLICT_FILE_LEN];
|
||||
char ctarget[PKG_NAME_LEN];
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles)
|
||||
char *matched = NULL;
|
||||
regex_t reg;
|
||||
|
||||
if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0) {
|
||||
if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) {
|
||||
RET_ERR(PM_ERR_INVALID_REGEX, NULL);
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,14 @@
|
||||
#include <limits.h>
|
||||
|
||||
/* Database entries */
|
||||
#define INFRQ_NONE 0x00
|
||||
#define INFRQ_DESC 0x01
|
||||
#define INFRQ_DEPENDS 0x02
|
||||
#define INFRQ_FILES 0x04
|
||||
#define INFRQ_SCRIPTLET 0x08
|
||||
#define INFRQ_ALL 0xFF
|
||||
typedef enum _pmdbinfrq_t {
|
||||
INFRQ_NONE = 0x00,
|
||||
INFRQ_DESC = 0x01,
|
||||
INFRQ_DEPENDS = 0x02,
|
||||
INFRQ_FILES = 0x04,
|
||||
INFRQ_SCRIPTLET = 0x08,
|
||||
INFRQ_ALL = 0xFF
|
||||
} pmdbinfrq_t;
|
||||
|
||||
/* Database */
|
||||
struct __pmdb_t {
|
||||
@ -55,9 +57,9 @@ int _alpm_db_install(pmdb_t *db, const char *dbfile);
|
||||
int _alpm_db_open(pmdb_t *db);
|
||||
void _alpm_db_close(pmdb_t *db);
|
||||
void _alpm_db_rewind(pmdb_t *db);
|
||||
pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq);
|
||||
int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info);
|
||||
int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq);
|
||||
pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq);
|
||||
int _alpm_db_read(pmdb_t *db, pmdbinfrq_t inforeq, pmpkg_t *info);
|
||||
int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
|
||||
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info);
|
||||
int _alpm_db_getlastupdate(pmdb_t *db, char *ts);
|
||||
int _alpm_db_setlastupdate(pmdb_t *db, char *ts);
|
||||
|
@ -44,8 +44,9 @@
|
||||
|
||||
extern pmhandle_t *handle;
|
||||
|
||||
pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod,
|
||||
const char *depname, const char *depversion)
|
||||
pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
|
||||
pmdepmod_t depmod, const char *depname,
|
||||
const char *depversion)
|
||||
{
|
||||
pmdepmissing_t *miss;
|
||||
|
||||
@ -187,7 +188,8 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode)
|
||||
* dependencies can include versions with depmod operators.
|
||||
*
|
||||
*/
|
||||
alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages)
|
||||
alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
||||
alpm_list_t *packages)
|
||||
{
|
||||
pmdepend_t depend;
|
||||
alpm_list_t *i, *j, *k;
|
||||
@ -224,7 +226,7 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
|
||||
continue;
|
||||
}
|
||||
if(_alpm_pkg_isin(p->name, packages)) {
|
||||
/* this package is also in the upgrade list, so don't worry about it */
|
||||
/* this package also in the upgrade list, so don't worry about it */
|
||||
continue;
|
||||
}
|
||||
_alpm_db_read(db, INFRQ_DEPENDS, p);
|
||||
@ -246,8 +248,10 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
|
||||
FREELISTPTR(provides);
|
||||
}
|
||||
if(!_alpm_depcmp(tp, &depend)) {
|
||||
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), depend.name, p->name);
|
||||
miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod, depend.name, depend.version);
|
||||
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
|
||||
depend.name, p->name);
|
||||
miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod,
|
||||
depend.name, depend.version);
|
||||
if(!_alpm_depmiss_isin(miss, baddeps)) {
|
||||
baddeps = alpm_list_add(baddeps, miss);
|
||||
} else {
|
||||
@ -278,7 +282,8 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
|
||||
_alpm_splitdep((char *)j->data, &depend);
|
||||
found = 0;
|
||||
/* check database for literal packages */
|
||||
for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS); k && !found; k = k->next) {
|
||||
for(k = _alpm_db_get_pkgcache(db, INFRQ_DESC|INFRQ_DEPENDS);
|
||||
k && !found; k = k->next) {
|
||||
pmpkg_t *p = (pmpkg_t *)k->data;
|
||||
found = _alpm_depcmp(p, &depend);
|
||||
}
|
||||
@ -316,8 +321,9 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
|
||||
/* else if still not found... */
|
||||
if(!found) {
|
||||
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as a dependency for %s"),
|
||||
depend.name, tp->name);
|
||||
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod, depend.name, depend.version);
|
||||
depend.name, tp->name);
|
||||
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod,
|
||||
depend.name, depend.version);
|
||||
if(!_alpm_depmiss_isin(miss, baddeps)) {
|
||||
baddeps = alpm_list_add(baddeps, miss);
|
||||
} else {
|
||||
@ -363,8 +369,10 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alp
|
||||
}
|
||||
}
|
||||
if(!found) {
|
||||
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), reqname, tp->name);
|
||||
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED, PM_DEP_MOD_ANY, j->data, NULL);
|
||||
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
|
||||
reqname, tp->name);
|
||||
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED,
|
||||
PM_DEP_MOD_ANY, j->data, NULL);
|
||||
if(!_alpm_depmiss_isin(miss, baddeps)) {
|
||||
baddeps = alpm_list_add(baddeps, miss);
|
||||
} else {
|
||||
@ -512,8 +520,9 @@ alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
|
||||
*
|
||||
* make sure *list and *trail are already initialized
|
||||
*/
|
||||
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
|
||||
alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data)
|
||||
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
|
||||
alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
|
||||
alpm_list_t **data)
|
||||
{
|
||||
alpm_list_t *i, *j;
|
||||
alpm_list_t *targ;
|
||||
@ -647,7 +656,7 @@ const char *alpm_dep_get_target(pmdepmissing_t *miss)
|
||||
return miss->target;
|
||||
}
|
||||
|
||||
unsigned char alpm_dep_get_type(pmdepmissing_t *miss)
|
||||
pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss)
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, return(-1));
|
||||
@ -656,7 +665,7 @@ unsigned char alpm_dep_get_type(pmdepmissing_t *miss)
|
||||
return miss->type;
|
||||
}
|
||||
|
||||
unsigned char alpm_dep_get_mod(pmdepmissing_t *miss)
|
||||
pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss)
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, return(-1));
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
/* Dependency */
|
||||
struct __pmdepend_t {
|
||||
unsigned char mod;
|
||||
pmdepmod_t mod;
|
||||
char name[PKG_NAME_LEN];
|
||||
char version[PKG_VERSION_LEN];
|
||||
};
|
||||
@ -38,19 +38,22 @@ struct __pmdepend_t {
|
||||
/* Missing dependency */
|
||||
struct __pmdepmissing_t {
|
||||
char target[PKG_NAME_LEN];
|
||||
unsigned char type;
|
||||
pmdeptype_t type;
|
||||
pmdepend_t depend;
|
||||
};
|
||||
|
||||
pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod,
|
||||
const char *depname, const char *depversion);
|
||||
pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
|
||||
pmdepmod_t depmod, const char *depname,
|
||||
const char *depversion);
|
||||
int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack);
|
||||
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode);
|
||||
alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages);
|
||||
alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
||||
alpm_list_t *packages);
|
||||
int _alpm_splitdep(char *depstr, pmdepend_t *depend);
|
||||
alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs);
|
||||
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
|
||||
alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data);
|
||||
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
|
||||
alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
|
||||
alpm_list_t **data);
|
||||
|
||||
#endif /* _ALPM_DEPS_H */
|
||||
|
||||
|
@ -117,12 +117,12 @@ int _alpm_handle_free(pmhandle_t *handle)
|
||||
|
||||
alpm_cb_log alpm_option_get_logcb() { return handle->logcb; }
|
||||
alpm_cb_download alpm_option_get_dlcb() { return handle->dlcb; }
|
||||
unsigned char alpm_option_get_logmask() { return handle->logmask; }
|
||||
unsigned short alpm_option_get_logmask() { return handle->logmask; }
|
||||
const char *alpm_option_get_root() { return handle->root; }
|
||||
const char *alpm_option_get_dbpath() { return handle->dbpath; }
|
||||
const char *alpm_option_get_cachedir() { return handle->cachedir; }
|
||||
const char *alpm_option_get_logfile() { return handle->logfile; }
|
||||
unsigned char alpm_option_get_usesyslog() { return handle->usesyslog; }
|
||||
unsigned short alpm_option_get_usesyslog() { return handle->usesyslog; }
|
||||
alpm_list_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
|
||||
alpm_list_t *alpm_option_get_noextracts() { return handle->noextract; }
|
||||
alpm_list_t *alpm_option_get_ignorepkgs() { return handle->ignorepkg; }
|
||||
@ -135,13 +135,16 @@ alpm_list_t *alpm_option_get_needles() { return handle->needles; }
|
||||
unsigned short alpm_option_get_usecolor() { return handle->use_color; }
|
||||
|
||||
pmdb_t *alpm_option_get_localdb() { return handle->db_local; }
|
||||
alpm_list_t *alpm_option_get_syncdbs() { return handle->dbs_sync; }
|
||||
alpm_list_t *alpm_option_get_syncdbs()
|
||||
{
|
||||
return handle->dbs_sync;
|
||||
}
|
||||
|
||||
void alpm_option_set_logcb(alpm_cb_log cb) { handle->logcb = cb; }
|
||||
|
||||
void alpm_option_set_dlcb(alpm_cb_download cb) { handle->dlcb = cb; }
|
||||
|
||||
void alpm_option_set_logmask(unsigned char mask) { handle->logmask = mask; }
|
||||
void alpm_option_set_logmask(unsigned short mask) { handle->logmask = mask; }
|
||||
|
||||
void alpm_option_set_root(const char *root)
|
||||
{
|
||||
@ -176,12 +179,16 @@ void alpm_option_set_logfile(const char *logfile)
|
||||
}
|
||||
}
|
||||
|
||||
void alpm_option_set_usesyslog(unsigned char usesyslog) { handle->usesyslog = usesyslog; }
|
||||
void alpm_option_set_usesyslog(unsigned short usesyslog)
|
||||
{
|
||||
handle->usesyslog = usesyslog;
|
||||
}
|
||||
|
||||
void alpm_option_add_noupgrade(char *pkg)
|
||||
{
|
||||
handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
|
||||
}
|
||||
|
||||
void alpm_option_set_noupgrades(alpm_list_t *noupgrade)
|
||||
{
|
||||
if(handle->noupgrade) FREELIST(handle->noupgrade);
|
||||
@ -218,7 +225,10 @@ void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs)
|
||||
if(holdpkgs) handle->holdpkg = holdpkgs;
|
||||
}
|
||||
|
||||
void alpm_option_set_upgradedelay(time_t delay) { handle->upgradedelay = delay; }
|
||||
void alpm_option_set_upgradedelay(time_t delay)
|
||||
{
|
||||
handle->upgradedelay = delay;
|
||||
}
|
||||
|
||||
void alpm_option_set_xfercommand(const char *cmd)
|
||||
{
|
||||
@ -226,7 +236,10 @@ void alpm_option_set_xfercommand(const char *cmd)
|
||||
if(cmd) handle->xfercommand = strdup(cmd);
|
||||
}
|
||||
|
||||
void alpm_option_set_nopassiveftp(unsigned short nopasv) { handle->nopassiveftp = nopasv; }
|
||||
void alpm_option_set_nopassiveftp(unsigned short nopasv)
|
||||
{
|
||||
handle->nopassiveftp = nopasv;
|
||||
}
|
||||
|
||||
void alpm_option_set_chomp(unsigned short chomp) { handle->chomp = chomp; }
|
||||
|
||||
@ -239,6 +252,9 @@ void alpm_option_set_needles(alpm_list_t *needles)
|
||||
if(handle->needles) FREELIST(handle->needles);
|
||||
if(needles) handle->needles = needles;
|
||||
}
|
||||
void alpm_option_set_usecolor(unsigned short usecolor) { handle->use_color = usecolor; }
|
||||
void alpm_option_set_usecolor(unsigned short usecolor)
|
||||
{
|
||||
handle->use_color = usecolor;
|
||||
}
|
||||
|
||||
/* vim: set ts=2 sw=2 et: */
|
||||
|
@ -45,12 +45,12 @@ typedef struct _pmhandle_t {
|
||||
/* options */
|
||||
alpm_cb_log logcb; /* Log callback function */
|
||||
alpm_cb_download dlcb; /* Download callback function */
|
||||
unsigned char logmask; /* Output mask for logging functions */
|
||||
unsigned short logmask; /* Output mask for logging functions */
|
||||
char *root; /* Root path, default '/' */
|
||||
char *dbpath; /* Base path to pacman's DBs */
|
||||
char *cachedir; /* Base path to pacman's cache */
|
||||
char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
|
||||
unsigned char usesyslog; /* Use syslog instead of logfile? */
|
||||
unsigned short usesyslog; /* Use syslog instead of logfile? */
|
||||
|
||||
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
|
||||
alpm_list_t *noextract; /* List of packages NOT to extrace */ /*TODO is this used?*/
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "alpm.h"
|
||||
#include "log.h"
|
||||
|
||||
void _alpm_log(unsigned char flag, char *fmt, ...)
|
||||
void _alpm_log(pmloglevel_t flag, char *fmt, ...)
|
||||
{
|
||||
alpm_cb_log logcb = alpm_option_get_logcb();
|
||||
if(logcb == NULL) {
|
||||
|
@ -21,9 +21,11 @@
|
||||
#ifndef _ALPM_LOG_H
|
||||
#define _ALPM_LOG_H
|
||||
|
||||
#include "alpm.h"
|
||||
|
||||
#define LOG_STR_LEN 1024
|
||||
|
||||
void _alpm_log(unsigned char flag, char *fmt, ...);
|
||||
void _alpm_log(pmloglevel_t flag, char *fmt, ...);
|
||||
|
||||
#endif /* _ALPM_LOG_H */
|
||||
|
||||
|
@ -606,7 +606,7 @@ unsigned long alpm_pkg_get_isize(pmpkg_t *pkg)
|
||||
return pkg->isize;
|
||||
}
|
||||
|
||||
unsigned char alpm_pkg_get_reason(pmpkg_t *pkg)
|
||||
pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg)
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, return(-1));
|
||||
@ -741,7 +741,7 @@ alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg)
|
||||
return pkg->backup;
|
||||
}
|
||||
|
||||
unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg)
|
||||
unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg)
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, return(-1));
|
||||
|
@ -30,11 +30,12 @@
|
||||
#endif
|
||||
|
||||
#include "alpm.h"
|
||||
#include "db.h"
|
||||
|
||||
enum {
|
||||
typedef enum _pmpkgfrom_t {
|
||||
PKG_FROM_CACHE = 1,
|
||||
PKG_FROM_FILE
|
||||
};
|
||||
} pmpkgfrom_t;
|
||||
|
||||
/* Packages */
|
||||
#define PKG_FILENAME_LEN 512
|
||||
@ -65,10 +66,10 @@ struct __pmpkg_t {
|
||||
char arch[PKG_ARCH_LEN];
|
||||
unsigned long size;
|
||||
unsigned long isize;
|
||||
unsigned char scriptlet;
|
||||
unsigned char force;
|
||||
unsigned short scriptlet;
|
||||
unsigned short force;
|
||||
time_t date;
|
||||
unsigned char reason;
|
||||
pmpkgreason_t reason;
|
||||
alpm_list_t *desc_localized;
|
||||
alpm_list_t *license;
|
||||
alpm_list_t *replaces;
|
||||
@ -81,9 +82,9 @@ struct __pmpkg_t {
|
||||
alpm_list_t *conflicts;
|
||||
alpm_list_t *provides;
|
||||
/* internal */
|
||||
unsigned char origin;
|
||||
unsigned short origin;
|
||||
void *data;
|
||||
unsigned char infolevel;
|
||||
pmdbinfrq_t infolevel;
|
||||
};
|
||||
|
||||
#define FREEPKG(p) do { if(p){_alpm_pkg_free(p); p = NULL;}} while(0)
|
||||
|
@ -1069,7 +1069,7 @@ error:
|
||||
return(-1);
|
||||
}
|
||||
|
||||
unsigned char alpm_sync_get_type(pmsyncpkg_t *sync)
|
||||
pmsynctype_t alpm_sync_get_type(pmsyncpkg_t *sync)
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(sync != NULL, return(-1));
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
/* Sync package */
|
||||
struct __pmsyncpkg_t {
|
||||
unsigned char type;
|
||||
pmsynctype_t type;
|
||||
pmpkg_t *pkg;
|
||||
void *data;
|
||||
};
|
||||
|
@ -85,7 +85,9 @@ void _alpm_trans_free(void *data)
|
||||
FREE(trans);
|
||||
}
|
||||
|
||||
int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress)
|
||||
int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, unsigned int flags,
|
||||
alpm_trans_cb_event event, alpm_trans_cb_conv conv,
|
||||
alpm_trans_cb_progress progress)
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||
@ -226,7 +228,7 @@ int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data)
|
||||
return(0);
|
||||
}
|
||||
|
||||
unsigned char alpm_trans_get_type()
|
||||
pmtranstype_t alpm_trans_get_type()
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, return(-1));
|
||||
|
@ -26,20 +26,7 @@
|
||||
|
||||
#include "alpm.h"
|
||||
|
||||
/* Transaction */
|
||||
struct __pmtrans_t {
|
||||
unsigned char type;
|
||||
unsigned int flags;
|
||||
unsigned char state;
|
||||
alpm_list_t *targets; /* alpm_list_t of (char *) */
|
||||
alpm_list_t *packages; /* alpm_list_t of (pmpkg_t *) or (pmsyncpkg_t *) */
|
||||
alpm_list_t *skiplist; /* alpm_list_t of (char *) */
|
||||
alpm_trans_cb_event cb_event;
|
||||
alpm_trans_cb_conv cb_conv;
|
||||
alpm_trans_cb_progress cb_progress;
|
||||
};
|
||||
|
||||
enum {
|
||||
typedef enum _pmtransstate_t {
|
||||
STATE_IDLE = 0,
|
||||
STATE_INITIALIZED,
|
||||
STATE_PREPARED,
|
||||
@ -47,6 +34,19 @@ enum {
|
||||
STATE_COMMITING,
|
||||
STATE_COMMITED,
|
||||
STATE_INTERRUPTED
|
||||
} pmtransstate_t;
|
||||
|
||||
/* Transaction */
|
||||
struct __pmtrans_t {
|
||||
pmtranstype_t type;
|
||||
unsigned int flags;
|
||||
pmtransstate_t state;
|
||||
alpm_list_t *targets; /* alpm_list_t of (char *) */
|
||||
alpm_list_t *packages; /* alpm_list_t of (pmpkg_t *) or (pmsyncpkg_t *) */
|
||||
alpm_list_t *skiplist; /* alpm_list_t of (char *) */
|
||||
alpm_trans_cb_event cb_event;
|
||||
alpm_trans_cb_conv cb_conv;
|
||||
alpm_trans_cb_progress cb_progress;
|
||||
};
|
||||
|
||||
#define FREETRANS(p) \
|
||||
@ -77,7 +77,9 @@ do { \
|
||||
|
||||
pmtrans_t *_alpm_trans_new(void);
|
||||
void _alpm_trans_free(void *data);
|
||||
int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress);
|
||||
int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, unsigned int flags,
|
||||
alpm_trans_cb_event event, alpm_trans_cb_conv conv,
|
||||
alpm_trans_cb_progress progress);
|
||||
int _alpm_trans_sysupgrade(pmtrans_t *trans);
|
||||
int _alpm_trans_addtarget(pmtrans_t *trans, char *target);
|
||||
int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data);
|
||||
|
@ -66,7 +66,7 @@
|
||||
|
||||
#ifdef __sun__
|
||||
/* This is a replacement for strsep which is not portable (missing on Solaris).
|
||||
* Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
|
||||
* Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */
|
||||
char* strsep(char** str, const char* delims)
|
||||
{
|
||||
char* token;
|
||||
@ -342,7 +342,7 @@ int _alpm_rmrf(char *path)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str)
|
||||
int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str)
|
||||
{
|
||||
_alpm_log(PM_LOG_DEBUG, _("logaction called: %s"), str);
|
||||
|
||||
|
@ -62,7 +62,7 @@ int _alpm_lckmk(char *file);
|
||||
int _alpm_lckrm(char *file);
|
||||
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
|
||||
int _alpm_rmrf(char *path);
|
||||
int _alpm_logaction(unsigned char usesyslog, FILE *f, const char *str);
|
||||
int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
|
||||
int _alpm_ldconfig(char *root);
|
||||
#ifdef _ALPM_TRANS_H
|
||||
int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans);
|
||||
|
@ -253,17 +253,19 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
|
||||
} else {
|
||||
int cmp = _alpm_versioncmp(pkg->version, dep->version);
|
||||
switch(dep->mod) {
|
||||
case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
|
||||
case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
|
||||
case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
|
||||
case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
|
||||
case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
|
||||
case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
|
||||
default: equal = 1; break;
|
||||
}
|
||||
}
|
||||
|
||||
char *mod = "~=";
|
||||
switch(dep->mod) {
|
||||
case PM_DEP_MOD_EQ: mod = "=="; break;
|
||||
case PM_DEP_MOD_GE: mod = ">="; break;
|
||||
case PM_DEP_MOD_LE: mod = "<="; break;
|
||||
case PM_DEP_MOD_EQ: mod = "=="; break;
|
||||
case PM_DEP_MOD_GE: mod = ">="; break;
|
||||
case PM_DEP_MOD_LE: mod = "<="; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if(strlen(dep->version) > 0) {
|
||||
|
@ -96,9 +96,17 @@ int pacman_add(alpm_list_t *targets)
|
||||
MSG(NL, _(":: %s: requires %s"), alpm_dep_get_target(miss),
|
||||
alpm_dep_get_name(miss));
|
||||
switch(alpm_dep_get_mod(miss)) {
|
||||
case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_ANY:
|
||||
break;
|
||||
case PM_DEP_MOD_EQ:
|
||||
MSG(CL, "=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
case PM_DEP_MOD_GE:
|
||||
MSG(CL, ">=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
case PM_DEP_MOD_LE:
|
||||
MSG(CL, "<=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
}
|
||||
MSG(CL, "\n");
|
||||
}
|
||||
|
@ -114,9 +114,17 @@ int pacman_deptest(alpm_list_t *targets)
|
||||
if(!config->op_d_resolve) {
|
||||
MSG(NL, _("requires: %s"), alpm_dep_get_name(miss));
|
||||
switch(alpm_dep_get_mod(miss)) {
|
||||
case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_ANY:
|
||||
break;
|
||||
case PM_DEP_MOD_EQ:
|
||||
MSG(CL, "=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
case PM_DEP_MOD_GE:
|
||||
MSG(CL, ">=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
case PM_DEP_MOD_LE:
|
||||
MSG(CL, "<=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
}
|
||||
MSG(CL, "\n");
|
||||
}
|
||||
|
@ -579,12 +579,21 @@ int pacman_sync(alpm_list_t *targets)
|
||||
for(i = data; i; i = alpm_list_next(i)) {
|
||||
pmdepmissing_t *miss = alpm_list_getdata(i);
|
||||
MSG(NL, ":: %s %s %s", alpm_dep_get_target(miss),
|
||||
alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ? _("requires") : _("is required by"),
|
||||
alpm_dep_get_name(miss));
|
||||
alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ?
|
||||
_("requires") : _("is required by"),
|
||||
alpm_dep_get_name(miss));
|
||||
switch(alpm_dep_get_mod(miss)) {
|
||||
case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
|
||||
case PM_DEP_MOD_ANY:
|
||||
break;
|
||||
case PM_DEP_MOD_EQ:
|
||||
MSG(CL, "=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
case PM_DEP_MOD_GE:
|
||||
MSG(CL, ">=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
case PM_DEP_MOD_LE:
|
||||
MSG(CL, "<=%s", alpm_dep_get_version(miss));
|
||||
break;
|
||||
}
|
||||
MSG(CL, "\n");
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ static int prevpercent=0; /* for less progressbar output */
|
||||
|
||||
/* Callback to handle transaction events
|
||||
*/
|
||||
void cb_trans_evt(unsigned char event, void *data1, void *data2)
|
||||
void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
|
||||
{
|
||||
char str[LOG_STR_LEN] = "";
|
||||
char out[PATH_MAX];
|
||||
@ -53,38 +53,42 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
|
||||
switch(event) {
|
||||
case PM_TRANS_EVT_CHECKDEPS_START:
|
||||
pm_fprintf(stderr, NL, _("checking dependencies... "));
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_FILECONFLICTS_START:
|
||||
if(config->noprogressbar) {
|
||||
MSG(NL, _("checking for file conflicts... "));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_CLEANUP_START:
|
||||
pm_fprintf(stderr, NL, _("resolving dependencies... "));
|
||||
break;
|
||||
case PM_TRANS_EVT_RESOLVEDEPS_START:
|
||||
pm_fprintf(stderr, NL, _("resolving dependencies... "));
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_INTERCONFLICTS_START:
|
||||
pm_fprintf(stderr, NL, _("looking for inter-conflicts... "));
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_FILECONFLICTS_DONE:
|
||||
if(config->noprogressbar) {
|
||||
MSG(CL, _("done.\n"));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_CHECKDEPS_DONE:
|
||||
case PM_TRANS_EVT_CLEANUP_DONE:
|
||||
case PM_TRANS_EVT_RESOLVEDEPS_DONE:
|
||||
case PM_TRANS_EVT_INTERCONFLICTS_DONE:
|
||||
pm_fprintf(stderr, CL, _("done.\n"));
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_EXTRACT_DONE:
|
||||
if(config->noprogressbar) {
|
||||
MSG(CL, _("done.\n"));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_ADD_START:
|
||||
if(config->noprogressbar) {
|
||||
MSG(NL, _("installing %s... "), alpm_pkg_get_name(data1));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_ADD_DONE:
|
||||
if(config->noprogressbar) {
|
||||
MSG(CL, _("done.\n"));
|
||||
@ -93,12 +97,12 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
|
||||
alpm_pkg_get_name(data1),
|
||||
alpm_pkg_get_version(data1));
|
||||
alpm_logaction(str);
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_REMOVE_START:
|
||||
if(config->noprogressbar) {
|
||||
MSG(NL, _("removing %s... "), alpm_pkg_get_name(data1));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_REMOVE_DONE:
|
||||
if(config->noprogressbar) {
|
||||
MSG(CL, _("done.\n"));
|
||||
@ -107,12 +111,12 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
|
||||
alpm_pkg_get_name(data1),
|
||||
alpm_pkg_get_version(data1));
|
||||
alpm_logaction(str);
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_UPGRADE_START:
|
||||
if(config->noprogressbar) {
|
||||
MSG(NL, _("upgrading %s... "), alpm_pkg_get_name(data1));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_UPGRADE_DONE:
|
||||
if(config->noprogressbar) {
|
||||
MSG(CL, _("done.\n"));
|
||||
@ -122,34 +126,34 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
|
||||
(char *)alpm_pkg_get_version(data2),
|
||||
(char *)alpm_pkg_get_version(data1));
|
||||
alpm_logaction(str);
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_INTEGRITY_START:
|
||||
MSG(NL, _("checking package integrity... "));
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_INTEGRITY_DONE:
|
||||
MSG(CL, _("done.\n"));
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_SCRIPTLET_INFO:
|
||||
MSG(NL, "%s\n", (char*)data1);
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_SCRIPTLET_START:
|
||||
MSG(NL, (char*)data1);
|
||||
MSG(CL, "...");
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_SCRIPTLET_DONE:
|
||||
if(!(long)data1) {
|
||||
MSG(CL, _(" done.\n"));
|
||||
} else {
|
||||
MSG(CL, _(" failed.\n"));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_PRINTURI:
|
||||
MSG(NL, "%s/%s\n", (char*)data1, (char*)data2);
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_RETRIEVE_START:
|
||||
MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1);
|
||||
fflush(stdout);
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_EVT_RETRIEVE_LOCAL:
|
||||
MSG(NL, " %s [", (char*)data1);
|
||||
unsigned int maxcols = getcols();
|
||||
@ -159,11 +163,12 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
|
||||
MSG(CL, " ");
|
||||
}
|
||||
fputs(_("] 100% LOCAL "), stdout);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, int *response)
|
||||
void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
|
||||
void *data3, int *response)
|
||||
{
|
||||
char str[LOG_STR_LEN] = "";
|
||||
|
||||
@ -181,7 +186,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
|
||||
alpm_pkg_get_name(data2));
|
||||
*response = yesno(str);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_CONV_REMOVE_HOLDPKG:
|
||||
if(config->noask) {
|
||||
if(config->ask & PM_TRANS_CONV_REMOVE_HOLDPKG) {
|
||||
@ -190,11 +195,11 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
|
||||
*response = 0;
|
||||
}
|
||||
} else {
|
||||
snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "),
|
||||
snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "),
|
||||
alpm_pkg_get_name(data1));
|
||||
*response = yesno(str);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_CONV_REPLACE_PKG:
|
||||
if(config->noask) {
|
||||
if(config->ask & PM_TRANS_CONV_REPLACE_PKG) {
|
||||
@ -209,7 +214,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
|
||||
alpm_pkg_get_name(data2));
|
||||
*response = yesno(str);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_CONV_CONFLICT_PKG:
|
||||
if(config->noask) {
|
||||
if(config->ask & PM_TRANS_CONV_CONFLICT_PKG) {
|
||||
@ -224,7 +229,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
|
||||
(char *)data2);
|
||||
*response = yesno(str);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_CONV_LOCAL_NEWER:
|
||||
if(config->noask) {
|
||||
if(config->ask & PM_TRANS_CONV_LOCAL_NEWER) {
|
||||
@ -242,7 +247,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
|
||||
*response = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_CONV_LOCAL_UPTODATE:
|
||||
if(config->noask) {
|
||||
if(config->ask & PM_TRANS_CONV_LOCAL_UPTODATE) {
|
||||
@ -260,7 +265,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
|
||||
*response = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PM_TRANS_CONV_CORRUPTED_PKG:
|
||||
if(config->noask) {
|
||||
if(config->ask & PM_TRANS_CONV_CORRUPTED_PKG) {
|
||||
@ -277,11 +282,12 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
|
||||
*response = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howmany, int remain)
|
||||
void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
|
||||
int howmany, int remain)
|
||||
{
|
||||
static int lasthash = 0, mouth = 0;
|
||||
int i, hash;
|
||||
@ -311,19 +317,19 @@ void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howm
|
||||
switch (event) {
|
||||
case PM_TRANS_PROGRESS_ADD_START:
|
||||
ptr = _("installing");
|
||||
break;
|
||||
break;
|
||||
|
||||
case PM_TRANS_PROGRESS_UPGRADE_START:
|
||||
ptr = _("upgrading");
|
||||
break;
|
||||
break;
|
||||
|
||||
case PM_TRANS_PROGRESS_REMOVE_START:
|
||||
ptr = _("removing");
|
||||
break;
|
||||
break;
|
||||
|
||||
case PM_TRANS_PROGRESS_CONFLICTS_START:
|
||||
ptr = _("checking for file conflicts");
|
||||
break;
|
||||
break;
|
||||
}
|
||||
hash=percent*progresslen/100;
|
||||
|
||||
|
@ -22,12 +22,14 @@
|
||||
#define _PM_TRANS_H
|
||||
|
||||
/* callback to handle messages/notifications from pacman transactions */
|
||||
void cb_trans_evt(unsigned char event, void *data1, void *data2);
|
||||
void cb_trans_evt(pmtransevt_t event, void *data1, void *data2);
|
||||
|
||||
/* callback to handle questions from pacman transactions (yes/no) */
|
||||
void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, int *response);
|
||||
void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
|
||||
void *data3, int *response);
|
||||
|
||||
void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howmany, int remain);
|
||||
void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
|
||||
int howmany, int remain);
|
||||
|
||||
#endif /* _PM_TRANS_H */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user