[pacman-dev] [PATCH 01/10] Remove ALPM_LOG_FUNC macro
The usefulness of this is rather limited due to it not being compiled into production builds. When you do choose to see the output, it is often overwhelming and not helpful. The best bet is to use a debugger and/or well-placed fprintf() statements. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/add.c | 6 ---- lib/libalpm/alpm.c | 2 - lib/libalpm/backup.c | 2 - lib/libalpm/be_local.c | 19 -------------- lib/libalpm/be_package.c | 8 ------ lib/libalpm/be_sync.c | 7 ----- lib/libalpm/conflict.c | 24 ------------------ lib/libalpm/db.c | 60 ---------------------------------------------- lib/libalpm/delta.c | 2 - lib/libalpm/deps.c | 24 ------------------ lib/libalpm/dload.c | 2 - lib/libalpm/group.c | 8 ------ lib/libalpm/handle.c | 12 --------- lib/libalpm/log.c | 2 - lib/libalpm/log.h | 7 ----- lib/libalpm/package.c | 16 ------------ lib/libalpm/pkghash.c | 2 - lib/libalpm/remove.c | 14 ---------- lib/libalpm/signing.c | 7 ----- lib/libalpm/sync.c | 6 ---- lib/libalpm/trans.c | 16 ------------ lib/libalpm/util.c | 6 ---- 22 files changed, 0 insertions(+), 252 deletions(-) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index ee56e87..e9dc7dc 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -55,8 +55,6 @@ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg) pmdb_t *db_local; pmpkg_t *local; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); @@ -474,8 +472,6 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, int is_upgrade = 0; pmpkg_t *oldpkg = NULL; - ALPM_LOG_FUNC; - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); snprintf(scriptlet, PATH_MAX, "%s%s-%s/install", @@ -708,8 +704,6 @@ int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db) int skip_ldconfig = 0, ret = 0; alpm_list_t *targ; - ALPM_LOG_FUNC; - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index bafd922..a13d653 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -79,8 +79,6 @@ int SYMEXPORT alpm_release(void) { pmdb_t *db; - ALPM_LOG_FUNC; - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); /* close local database */ diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c index 7df9747..6431b28 100644 --- a/lib/libalpm/backup.c +++ b/lib/libalpm/backup.c @@ -83,8 +83,6 @@ char *_alpm_needbackup(const char *file, const alpm_list_t *backup) { const alpm_list_t *lp; - ALPM_LOG_FUNC; - if(file == NULL || backup == NULL) { return NULL; } diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 3610545..fc138e3 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -44,7 +44,6 @@ #define LAZY_LOAD(info, errret) \ do { \ - ALPM_LOG_FUNC; \ ASSERT(handle != NULL, return (errret)); \ if(pkg->origin != PKG_FROM_FILE && !(pkg->infolevel & info)) { \ _alpm_local_db_read(pkg->origin_data.db, pkg, info); \ @@ -138,8 +137,6 @@ static alpm_list_t *_cache_get_groups(pmpkg_t *pkg) static int _cache_has_scriptlet(pmpkg_t *pkg) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return -1); @@ -187,8 +184,6 @@ static alpm_list_t *_cache_get_deltas(pmpkg_t UNUSED *pkg) static alpm_list_t *_cache_get_files(pmpkg_t *pkg) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); @@ -201,8 +196,6 @@ static alpm_list_t *_cache_get_files(pmpkg_t *pkg) static alpm_list_t *_cache_get_backup(pmpkg_t *pkg) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); @@ -221,8 +214,6 @@ static alpm_list_t *_cache_get_backup(pmpkg_t *pkg) */ static void *_cache_changelog_open(pmpkg_t *pkg) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); @@ -346,8 +337,6 @@ static int local_db_populate(pmdb_t *db) const char *dbpath; DIR *dbdir; - ALPM_LOG_FUNC; - ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); dbpath = _alpm_db_path(db); @@ -473,8 +462,6 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) char line[1024]; char *pkgpath = NULL; - ALPM_LOG_FUNC; - if(db == NULL) { RET_ERR(PM_ERR_DB_NULL, -1); } @@ -721,8 +708,6 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) int retval = 0; char *pkgpath = NULL; - ALPM_LOG_FUNC; - if(db == NULL || info == NULL) { return -1; } @@ -884,8 +869,6 @@ int _alpm_local_db_remove(pmdb_t *db, pmpkg_t *info) int ret = 0; char *pkgpath = NULL; - ALPM_LOG_FUNC; - if(db == NULL || info == NULL) { RET_ERR(PM_ERR_DB_NULL, -1); } @@ -962,8 +945,6 @@ pmdb_t *_alpm_db_register_local(void) { pmdb_t *db; - ALPM_LOG_FUNC; - _alpm_log(PM_LOG_DEBUG, "registering local database\n"); db = _alpm_db_new("local", 1); diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 9e59d69..8da317f 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -43,8 +43,6 @@ */ static void *_package_changelog_open(pmpkg_t *pkg) { - ALPM_LOG_FUNC; - ASSERT(pkg != NULL, return NULL); struct archive *archive = NULL; @@ -144,8 +142,6 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg) int linenum = 0; struct archive_read_buffer buf; - ALPM_LOG_FUNC; - memset(&buf, 0, sizeof(buf)); /* 512K for a line length seems reasonable */ buf.max_line_size = 512 * 1024; @@ -236,8 +232,6 @@ pmpkg_t *_alpm_pkg_load_internal(const char *pkgfile, int full, pmpkg_t *newpkg = NULL; struct stat st; - ALPM_LOG_FUNC; - if(pkgfile == NULL || strlen(pkgfile) == 0) { RET_ERR(PM_ERR_WRONG_ARGS, NULL); } @@ -383,8 +377,6 @@ error: int SYMEXPORT alpm_pkg_load(const char *filename, int full, pgp_verify_t check_sig, pmpkg_t **pkg) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 9d85a45..77c9207 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -87,8 +87,6 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) mode_t oldmask; pgp_verify_t check_sig; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(db != NULL && db != handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1)); @@ -242,8 +240,6 @@ static int sync_db_populate(pmdb_t *db) struct archive_entry *entry; pmpkg_t *pkg = NULL; - ALPM_LOG_FUNC; - ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); if((archive = archive_read_new()) == NULL) { @@ -360,8 +356,6 @@ static int sync_db_read(pmdb_t *db, struct archive *archive, pmpkg_t *pkg; struct archive_read_buffer buf; - ALPM_LOG_FUNC; - if(db == NULL) { RET_ERR(PM_ERR_DB_NULL, -1); } @@ -512,7 +506,6 @@ pmdb_t *_alpm_db_register_sync(const char *treename) { pmdb_t *db; - ALPM_LOG_FUNC; _alpm_log(PM_LOG_DEBUG, "registering sync database '%s'\n", treename); db = _alpm_db_new(treename, 0); diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index fbc988b..995c6cb 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -45,8 +45,6 @@ pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2, { pmconflict_t *conflict; - ALPM_LOG_FUNC; - MALLOC(conflict, sizeof(pmconflict_t), RET_ERR(PM_ERR_MEMORY, NULL)); STRDUP(conflict->package1, package1, RET_ERR(PM_ERR_MEMORY, NULL)); @@ -82,8 +80,6 @@ static int conflict_isin(pmconflict_t *needle, alpm_list_t *haystack) const char *npkg1 = needle->package1; const char *npkg2 = needle->package2; - ALPM_LOG_FUNC; - for(i = haystack; i; i = i->next) { pmconflict_t *conflict = i->data; const char *cpkg1 = conflict->package1; @@ -168,8 +164,6 @@ alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages) { alpm_list_t *baddeps = NULL; - ALPM_LOG_FUNC; - _alpm_log(PM_LOG_DEBUG, "check targets vs targets\n"); check_conflict(packages, packages, &baddeps, 0); @@ -184,8 +178,6 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages) { alpm_list_t *baddeps = NULL; - ALPM_LOG_FUNC; - if(db == NULL) { return NULL; } @@ -359,8 +351,6 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, size_t numtargs = alpm_list_count(upgrade); size_t current; - ALPM_LOG_FUNC; - if(db == NULL || upgrade == NULL || trans == NULL) { return NULL; } @@ -517,8 +507,6 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, const char SYMEXPORT *alpm_conflict_get_package1(pmconflict_t *conflict) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); @@ -528,8 +516,6 @@ const char SYMEXPORT *alpm_conflict_get_package1(pmconflict_t *conflict) const char SYMEXPORT *alpm_conflict_get_package2(pmconflict_t *conflict) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); @@ -539,8 +525,6 @@ const char SYMEXPORT *alpm_conflict_get_package2(pmconflict_t *conflict) const char SYMEXPORT *alpm_conflict_get_reason(pmconflict_t *conflict) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); @@ -550,8 +534,6 @@ const char SYMEXPORT *alpm_conflict_get_reason(pmconflict_t *conflict) const char SYMEXPORT *alpm_fileconflict_get_target(pmfileconflict_t *conflict) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); @@ -561,8 +543,6 @@ const char SYMEXPORT *alpm_fileconflict_get_target(pmfileconflict_t *conflict) pmfileconflicttype_t SYMEXPORT alpm_fileconflict_get_type(pmfileconflict_t *conflict) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return -1); ASSERT(conflict != NULL, return -1); @@ -572,8 +552,6 @@ pmfileconflicttype_t SYMEXPORT alpm_fileconflict_get_type(pmfileconflict_t *conf const char SYMEXPORT *alpm_fileconflict_get_file(pmfileconflict_t *conflict) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); @@ -583,8 +561,6 @@ const char SYMEXPORT *alpm_fileconflict_get_file(pmfileconflict_t *conflict) const char SYMEXPORT *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 3133614..94173a2 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -47,8 +47,6 @@ /** Register a sync database of packages. */ pmdb_t SYMEXPORT *alpm_db_register_sync(const char *treename) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, NULL)); ASSERT(treename != NULL && strlen(treename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); @@ -75,8 +73,6 @@ int SYMEXPORT alpm_db_unregister_all(void) alpm_list_t *i; pmdb_t *db; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); /* Do not unregister a database if a transaction is on-going */ @@ -97,8 +93,6 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db) { int found = 0; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); @@ -132,8 +126,6 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db) /** Get the serverlist of a database. */ alpm_list_t SYMEXPORT *alpm_db_get_servers(const pmdb_t *db) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, NULL)); @@ -143,8 +135,6 @@ alpm_list_t SYMEXPORT *alpm_db_get_servers(const pmdb_t *db) /** Set the serverlist of a database. */ int SYMEXPORT alpm_db_set_servers(pmdb_t *db, alpm_list_t *servers) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); @@ -175,8 +165,6 @@ int SYMEXPORT alpm_db_add_server(pmdb_t *db, const char *url) { char *newurl; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(url != NULL && strlen(url) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1)); @@ -202,8 +190,6 @@ int SYMEXPORT alpm_db_remove_server(pmdb_t *db, const char *url) { char *newurl, *vdata = NULL; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(url != NULL && strlen(url) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1)); @@ -230,8 +216,6 @@ int SYMEXPORT alpm_db_remove_server(pmdb_t *db, const char *url) */ int SYMEXPORT alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); @@ -245,8 +229,6 @@ int SYMEXPORT alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify) /** Get the name of a package database. */ const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); @@ -259,8 +241,6 @@ const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db) { char *url; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); @@ -275,8 +255,6 @@ const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db) /** Get a package entry from a package database. */ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); @@ -288,8 +266,6 @@ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name) /** Get the package cache of a package database. */ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); @@ -300,8 +276,6 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db) /** Get a group entry from a package database. */ pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); @@ -313,8 +287,6 @@ pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name) /** Get the group cache of a package database. */ alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); @@ -325,8 +297,6 @@ alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db) /** Searches a database. */ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); @@ -337,8 +307,6 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles) /** Set install reason for a package in db. */ int SYMEXPORT alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(db != NULL && name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); @@ -369,8 +337,6 @@ pmdb_t *_alpm_db_new(const char *treename, int is_local) { pmdb_t *db; - ALPM_LOG_FUNC; - CALLOC(db, 1, sizeof(pmdb_t), RET_ERR(PM_ERR_MEMORY, NULL)); STRDUP(db->treename, treename, RET_ERR(PM_ERR_MEMORY, NULL)); db->is_local = is_local; @@ -380,8 +346,6 @@ pmdb_t *_alpm_db_new(const char *treename, int is_local) void _alpm_db_free(pmdb_t *db) { - ALPM_LOG_FUNC; - /* cleanup pkgcache */ _alpm_db_free_pkgcache(db); /* cleanup server list */ @@ -446,8 +410,6 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles) /* copy the pkgcache- we will free the list var after each needle */ alpm_list_t *list = alpm_list_copy(_alpm_db_get_pkgcache(db)); - ALPM_LOG_FUNC; - for(i = needles; i; i = i->next) { char *targ; regex_t reg; @@ -520,8 +482,6 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles) */ int _alpm_db_load_pkgcache(pmdb_t *db) { - ALPM_LOG_FUNC; - if(db == NULL) { return -1; } @@ -541,8 +501,6 @@ int _alpm_db_load_pkgcache(pmdb_t *db) void _alpm_db_free_pkgcache(pmdb_t *db) { - ALPM_LOG_FUNC; - if(db == NULL || !db->pkgcache_loaded) { return; } @@ -560,8 +518,6 @@ void _alpm_db_free_pkgcache(pmdb_t *db) pmpkghash_t *_alpm_db_get_pkgcache_hash(pmdb_t *db) { - ALPM_LOG_FUNC; - if(db == NULL) { return NULL; } @@ -580,8 +536,6 @@ pmpkghash_t *_alpm_db_get_pkgcache_hash(pmdb_t *db) alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db) { - ALPM_LOG_FUNC; - pmpkghash_t *hash = _alpm_db_get_pkgcache_hash(db); if(hash == NULL) { @@ -596,8 +550,6 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg) { pmpkg_t *newpkg; - ALPM_LOG_FUNC; - if(db == NULL || !db->pkgcache_loaded || pkg == NULL) { return -1; } @@ -620,8 +572,6 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg) { pmpkg_t *data = NULL; - ALPM_LOG_FUNC; - if(db == NULL || !db->pkgcache_loaded || pkg == NULL) { return -1; } @@ -646,8 +596,6 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg) pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target) { - ALPM_LOG_FUNC; - if(db == NULL) { return NULL; } @@ -668,8 +616,6 @@ int _alpm_db_load_grpcache(pmdb_t *db) { alpm_list_t *lp; - ALPM_LOG_FUNC; - if(db == NULL) { return -1; } @@ -716,8 +662,6 @@ void _alpm_db_free_grpcache(pmdb_t *db) { alpm_list_t *lg; - ALPM_LOG_FUNC; - if(db == NULL || !db->grpcache_loaded) { return; } @@ -735,8 +679,6 @@ void _alpm_db_free_grpcache(pmdb_t *db) alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db) { - ALPM_LOG_FUNC; - if(db == NULL) { return NULL; } @@ -752,8 +694,6 @@ pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, const char *target) { alpm_list_t *i; - ALPM_LOG_FUNC; - if(db == NULL || target == NULL || strlen(target) == 0) { return NULL; } diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index d3213fd..cd23487 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c @@ -225,8 +225,6 @@ off_t _alpm_shortest_delta_path(alpm_list_t *deltas, alpm_list_t *vertices; off_t bestsize = LONG_MAX; - ALPM_LOG_FUNC; - if(deltas == NULL) { *path = NULL; return bestsize; diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index c5fb92e..2d6b5b3 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -48,8 +48,6 @@ static pmdepmissing_t *depmiss_new(const char *target, pmdepend_t *dep, { pmdepmissing_t *miss; - ALPM_LOG_FUNC; - MALLOC(miss, sizeof(pmdepmissing_t), RET_ERR(PM_ERR_MEMORY, NULL)); STRDUP(miss->target, target, RET_ERR(PM_ERR_MEMORY, NULL)); @@ -134,8 +132,6 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse) alpm_list_t *vptr; pmgraph_t *vertex; - ALPM_LOG_FUNC; - if(targets == NULL) { return NULL; } @@ -271,8 +267,6 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps, alpm_list_t *baddeps = NULL; int nodepversion; - ALPM_LOG_FUNC; - targets = alpm_list_join(alpm_list_copy(remove), alpm_list_copy(upgrade)); for(i = pkglist; i; i = i->next) { pmpkg_t *pkg = i->data; @@ -521,8 +515,6 @@ void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit) { alpm_list_t *i, *j; - ALPM_LOG_FUNC; - if(db == NULL || targs == NULL) { return; } @@ -696,8 +688,6 @@ int _alpm_resolvedeps(alpm_list_t *localpkgs, alpm_list_t *dbs_sync, pmpkg_t *pk alpm_list_t *deps = NULL; alpm_list_t *packages_copy; - ALPM_LOG_FUNC; - if(_alpm_pkg_find(*packages, pkg->name) != NULL) { return 0; } @@ -765,8 +755,6 @@ int _alpm_resolvedeps(alpm_list_t *localpkgs, alpm_list_t *dbs_sync, pmpkg_t *pk const char SYMEXPORT *alpm_miss_get_target(const pmdepmissing_t *miss) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(miss != NULL, return NULL); @@ -775,8 +763,6 @@ const char SYMEXPORT *alpm_miss_get_target(const pmdepmissing_t *miss) const char SYMEXPORT *alpm_miss_get_causingpkg(const pmdepmissing_t *miss) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(miss != NULL, return NULL); @@ -785,8 +771,6 @@ const char SYMEXPORT *alpm_miss_get_causingpkg(const pmdepmissing_t *miss) pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(miss != NULL, return NULL); @@ -795,8 +779,6 @@ pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss) pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(dep != NULL, return -1); @@ -805,8 +787,6 @@ pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep) const char SYMEXPORT *alpm_dep_get_name(const pmdepend_t *dep) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(dep != NULL, return NULL); @@ -815,8 +795,6 @@ const char SYMEXPORT *alpm_dep_get_name(const pmdepend_t *dep) const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(dep != NULL, return NULL); @@ -834,8 +812,6 @@ char SYMEXPORT *alpm_dep_compute_string(const pmdepend_t *dep) char *str; size_t len; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(dep != NULL, return NULL); diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 1825eed..9583b36 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -335,8 +335,6 @@ char SYMEXPORT *alpm_fetch_pkgurl(const char *url) const char *filename, *cachedir; int ret; - ALPM_LOG_FUNC; - filename = get_filename(url); /* find a valid cache dir to download to */ diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c index dbcc755..383d016 100644 --- a/lib/libalpm/group.c +++ b/lib/libalpm/group.c @@ -34,8 +34,6 @@ pmgrp_t *_alpm_grp_new(const char *name) { pmgrp_t* grp; - ALPM_LOG_FUNC; - CALLOC(grp, 1, sizeof(pmgrp_t), RET_ERR(PM_ERR_MEMORY, NULL)); STRDUP(grp->name, name, RET_ERR(PM_ERR_MEMORY, NULL)); @@ -44,8 +42,6 @@ pmgrp_t *_alpm_grp_new(const char *name) void _alpm_grp_free(pmgrp_t *grp) { - ALPM_LOG_FUNC; - if(grp == NULL) { return; } @@ -58,8 +54,6 @@ void _alpm_grp_free(pmgrp_t *grp) const char SYMEXPORT *alpm_grp_get_name(const pmgrp_t *grp) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(grp != NULL, return NULL); @@ -68,8 +62,6 @@ const char SYMEXPORT *alpm_grp_get_name(const pmgrp_t *grp) alpm_list_t SYMEXPORT *alpm_grp_get_pkgs(const pmgrp_t *grp) { - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(grp != NULL, return NULL); diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 39b3b60..e94528f 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -53,8 +53,6 @@ pmhandle_t *_alpm_handle_new() void _alpm_handle_free(pmhandle_t *handle) { - ALPM_LOG_FUNC; - if(handle == NULL) { return; } @@ -306,8 +304,6 @@ int SYMEXPORT alpm_option_set_root(const char *root) char *realroot; size_t rootlen; - ALPM_LOG_FUNC; - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); if(!root) { @@ -348,8 +344,6 @@ int SYMEXPORT alpm_option_set_dbpath(const char *dbpath) size_t dbpathlen, lockfilelen; const char *lf = "db.lck"; - ALPM_LOG_FUNC; - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); if(!dbpath) { pm_errno = PM_ERR_WRONG_ARGS; @@ -387,8 +381,6 @@ int SYMEXPORT alpm_option_add_cachedir(const char *cachedir) char *newcachedir; size_t cachedirlen; - ALPM_LOG_FUNC; - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); if(!cachedir) { pm_errno = PM_ERR_WRONG_ARGS; @@ -445,8 +437,6 @@ int SYMEXPORT alpm_option_set_logfile(const char *logfile) { char *oldlogfile = handle->logfile; - ALPM_LOG_FUNC; - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); if(!logfile) { pm_errno = PM_ERR_WRONG_ARGS; @@ -470,8 +460,6 @@ int SYMEXPORT alpm_option_set_logfile(const char *logfile) int SYMEXPORT alpm_option_set_signaturedir(const char *signaturedir) { - ALPM_LOG_FUNC; - if(!signaturedir) { pm_errno = PM_ERR_WRONG_ARGS; return -1; diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c index 9093af7..f500754 100644 --- a/lib/libalpm/log.c +++ b/lib/libalpm/log.c @@ -44,8 +44,6 @@ int SYMEXPORT alpm_logaction(const char *fmt, ...) int ret; va_list args; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); diff --git a/lib/libalpm/log.h b/lib/libalpm/log.h index 9a2961f..1fd66a6 100644 --- a/lib/libalpm/log.h +++ b/lib/libalpm/log.h @@ -22,13 +22,6 @@ #include "alpm.h" -#ifdef PACMAN_DEBUG -/* Log funtion entry points if debugging is enabled */ -#define ALPM_LOG_FUNC _alpm_log(PM_LOG_FUNCTION, "Enter %s\n", __func__) -#else -#define ALPM_LOG_FUNC -#endif - void _alpm_log(pmloglevel_t flag, const char *fmt, ...) __attribute__((format(printf,2,3))); #endif /* _ALPM_LOG_H */ diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 990f532..205bc10 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -45,8 +45,6 @@ /** Free a package. */ int SYMEXPORT alpm_pkg_free(pmpkg_t *pkg) { - ALPM_LOG_FUNC; - ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); /* Only free packages loaded in user space */ @@ -63,8 +61,6 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg) char *fpath; int retval; - ALPM_LOG_FUNC; - ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); /* We only inspect packages from sync repositories */ ASSERT(pkg->origin == PKG_FROM_SYNCDB, RET_ERR(PM_ERR_PKG_INVALID, -1)); @@ -370,8 +366,6 @@ pmpkg_t *_alpm_pkg_new(void) { pmpkg_t* pkg; - ALPM_LOG_FUNC; - CALLOC(pkg, 1, sizeof(pmpkg_t), RET_ERR(PM_ERR_MEMORY, NULL)); return pkg; @@ -382,8 +376,6 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) pmpkg_t *newpkg; alpm_list_t *i; - ALPM_LOG_FUNC; - CALLOC(newpkg, 1, sizeof(pmpkg_t), RET_ERR(PM_ERR_MEMORY, NULL)); newpkg->name_hash = pkg->name_hash; @@ -430,8 +422,6 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) void _alpm_pkg_free(pmpkg_t *pkg) { - ALPM_LOG_FUNC; - if(pkg == NULL) { return; } @@ -473,8 +463,6 @@ void _alpm_pkg_free(pmpkg_t *pkg) */ void _alpm_pkg_free_trans(pmpkg_t *pkg) { - ALPM_LOG_FUNC; - if(pkg == NULL) { return; } @@ -491,8 +479,6 @@ void _alpm_pkg_free_trans(pmpkg_t *pkg) /* Is spkg an upgrade for localpkg? */ int _alpm_pkg_compare_versions(pmpkg_t *spkg, pmpkg_t *localpkg) { - ALPM_LOG_FUNC; - return alpm_pkg_vercmp(alpm_pkg_get_version(spkg), alpm_pkg_get_version(localpkg)); } @@ -514,8 +500,6 @@ pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle) alpm_list_t *lp; unsigned long needle_hash; - ALPM_LOG_FUNC; - if(needle == NULL || haystack == NULL) { return NULL; } diff --git a/lib/libalpm/pkghash.c b/lib/libalpm/pkghash.c index f415330..7e5e1fc 100644 --- a/lib/libalpm/pkghash.c +++ b/lib/libalpm/pkghash.c @@ -304,8 +304,6 @@ pmpkg_t *_alpm_pkghash_find(pmpkghash_t *hash, const char *name) unsigned long name_hash; size_t position; - ALPM_LOG_FUNC; - if(name == NULL || hash == NULL) { return NULL; } diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 2d840ce..48348fa 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -49,8 +49,6 @@ int SYMEXPORT alpm_remove_pkg(pmpkg_t *pkg) pmtrans_t *trans; const char *pkgname; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); @@ -74,8 +72,6 @@ int SYMEXPORT alpm_remove_pkg(pmpkg_t *pkg) static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db, alpm_list_t *lp) { - ALPM_LOG_FUNC; - while(lp) { alpm_list_t *i; for(i = lp; i; i = i->next) { @@ -101,8 +97,6 @@ static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db, static void remove_prepare_keep_needed(pmtrans_t *trans, pmdb_t *db, alpm_list_t *lp) { - ALPM_LOG_FUNC; - /* Remove needed packages (which break dependencies) from target list */ while(lp != NULL) { alpm_list_t *i; @@ -140,8 +134,6 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) { alpm_list_t *lp; - ALPM_LOG_FUNC; - ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); @@ -227,8 +219,6 @@ static void unlink_file(pmpkg_t *info, char *filename, alpm_list_t *skip_remove, struct stat buf; char file[PATH_MAX+1]; - ALPM_LOG_FUNC; - snprintf(file, PATH_MAX, "%s%s", handle->root, filename); /* check the remove skip list before removing the file. @@ -297,8 +287,6 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, alpm_list_t *files = alpm_pkg_get_files(oldpkg); const char *pkgname = alpm_pkg_get_name(oldpkg); - ALPM_LOG_FUNC; - _alpm_log(PM_LOG_DEBUG, "removing old package first (%s-%s)\n", oldpkg->name, oldpkg->version); @@ -367,8 +355,6 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) alpm_list_t *targ, *lp; size_t pkg_count; - ALPM_LOG_FUNC; - ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index 9bb9d0a..f6a5a1a 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -111,8 +111,6 @@ static int gpgme_init(void) gpgme_error_t err; gpgme_engine_info_t enginfo; - ALPM_LOG_FUNC; - if(init) { /* we already successfully initialized the library */ return 0; @@ -213,8 +211,6 @@ int _alpm_gpgme_checksig(const char *path, const char *base64_sig) unsigned char *decoded_sigdata = NULL; FILE *file = NULL, *sigfile = NULL; - ALPM_LOG_FUNC; - if(!path || access(path, R_OK) != 0) { RET_ERR(PM_ERR_NOT_A_FILE, -1); } @@ -371,7 +367,6 @@ int _alpm_gpgme_checksig(const char *path, const char *base64_sig) */ pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db) { - ALPM_LOG_FUNC; ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, PM_PGP_VERIFY_UNKNOWN)); if(db->pgp_verify != PM_PGP_VERIFY_UNKNOWN) { @@ -388,7 +383,6 @@ pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db) */ int SYMEXPORT alpm_pkg_check_pgp_signature(pmpkg_t *pkg) { - ALPM_LOG_FUNC; ASSERT(pkg != NULL, return 0); return _alpm_gpgme_checksig(alpm_pkg_get_filename(pkg), pkg->base64_sig); @@ -401,7 +395,6 @@ int SYMEXPORT alpm_pkg_check_pgp_signature(pmpkg_t *pkg) */ int SYMEXPORT alpm_db_check_pgp_signature(pmdb_t *db) { - ALPM_LOG_FUNC; ASSERT(db != NULL, return 0); return _alpm_gpgme_checksig(_alpm_db_path(db), NULL); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 8dd51aa..b84d625 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -89,8 +89,6 @@ int SYMEXPORT alpm_sync_sysupgrade(int enable_downgrade) pmdb_t *db_local; alpm_list_t *dbs_sync; - ALPM_LOG_FUNC; - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); trans = handle->trans; db_local = handle->db_local; @@ -307,8 +305,6 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync alpm_list_t *remove = NULL; int ret = 0; - ALPM_LOG_FUNC; - ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); @@ -840,8 +836,6 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) size_t numtargs, current = 0, replaces = 0; int errors; - ALPM_LOG_FUNC; - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); if(download_files(trans, &deltas)) { diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 5ffb5df..31c5885 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -104,8 +104,6 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags, const int required_db_version = 2; int db_version; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1)); @@ -173,8 +171,6 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data) { pmtrans_t *trans; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(data != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); @@ -219,8 +215,6 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data) { pmtrans_t *trans; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); @@ -260,8 +254,6 @@ int SYMEXPORT alpm_trans_interrupt(void) { pmtrans_t *trans; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); @@ -280,8 +272,6 @@ int SYMEXPORT alpm_trans_release(void) { pmtrans_t *trans; - ALPM_LOG_FUNC; - /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); @@ -313,8 +303,6 @@ pmtrans_t *_alpm_trans_new(void) { pmtrans_t *trans; - ALPM_LOG_FUNC; - CALLOC(trans, 1, sizeof(pmtrans_t), RET_ERR(PM_ERR_MEMORY, NULL)); trans->state = STATE_IDLE; @@ -323,8 +311,6 @@ pmtrans_t *_alpm_trans_new(void) void _alpm_trans_free(pmtrans_t *trans) { - ALPM_LOG_FUNC; - if(trans == NULL) { return; } @@ -377,8 +363,6 @@ int _alpm_runscriptlet(const char *root, const char *installfn, int clean_tmpdir = 0; int retval = 0; - ALPM_LOG_FUNC; - if(access(installfn, R_OK)) { /* not found */ _alpm_log(PM_LOG_DEBUG, "scriptlet '%s' not found\n", installfn); diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 99dd3be..1918631 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -252,8 +252,6 @@ int _alpm_unpack(const char *archive, const char *prefix, alpm_list_t *list, int char cwd[PATH_MAX]; int restore_cwd = 0; - ALPM_LOG_FUNC; - if((_archive = archive_read_new()) == NULL) RET_ERR(PM_ERR_LIBARCHIVE, 1); @@ -425,8 +423,6 @@ int _alpm_run_chroot(const char *root, const char *path, char *const argv[]) int restore_cwd = 0; int retval = 0; - ALPM_LOG_FUNC; - /* save the cwd so we can restore it later */ if(getcwd(cwd, PATH_MAX) == NULL) { _alpm_log(PM_LOG_ERROR, _("could not get current working directory\n")); @@ -690,8 +686,6 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename) char *md5sum; int ret, i; - ALPM_LOG_FUNC; - ASSERT(filename != NULL, return NULL); /* allocate 32 chars plus 1 for null */ -- 1.7.5.2
These are simple accessor functions for a struct; the handle never even comes into play when calling these functions. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/conflict.c | 7 ------- lib/libalpm/db.c | 8 -------- 2 files changed, 0 insertions(+), 15 deletions(-) diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 995c6cb..12a68cf 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -508,7 +508,6 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, const char SYMEXPORT *alpm_conflict_get_package1(pmconflict_t *conflict) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); return conflict->package1; @@ -517,7 +516,6 @@ const char SYMEXPORT *alpm_conflict_get_package1(pmconflict_t *conflict) const char SYMEXPORT *alpm_conflict_get_package2(pmconflict_t *conflict) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); return conflict->package2; @@ -526,7 +524,6 @@ const char SYMEXPORT *alpm_conflict_get_package2(pmconflict_t *conflict) const char SYMEXPORT *alpm_conflict_get_reason(pmconflict_t *conflict) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); return conflict->reason; @@ -535,7 +532,6 @@ const char SYMEXPORT *alpm_conflict_get_reason(pmconflict_t *conflict) const char SYMEXPORT *alpm_fileconflict_get_target(pmfileconflict_t *conflict) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); return conflict->target; @@ -544,7 +540,6 @@ const char SYMEXPORT *alpm_fileconflict_get_target(pmfileconflict_t *conflict) pmfileconflicttype_t SYMEXPORT alpm_fileconflict_get_type(pmfileconflict_t *conflict) { /* Sanity checks */ - ASSERT(handle != NULL, return -1); ASSERT(conflict != NULL, return -1); return conflict->type; @@ -553,7 +548,6 @@ pmfileconflicttype_t SYMEXPORT alpm_fileconflict_get_type(pmfileconflict_t *conf const char SYMEXPORT *alpm_fileconflict_get_file(pmfileconflict_t *conflict) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); return conflict->file; @@ -562,7 +556,6 @@ const char SYMEXPORT *alpm_fileconflict_get_file(pmfileconflict_t *conflict) const char SYMEXPORT *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(conflict != NULL, return NULL); return conflict->ctarget; diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 94173a2..a158723 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -230,7 +230,6 @@ int SYMEXPORT alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify) const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); return db->treename; @@ -242,7 +241,6 @@ const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db) char *url; /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); ASSERT(db->servers != NULL, return NULL); @@ -256,7 +254,6 @@ const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db) pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); ASSERT(name != NULL && strlen(name) != 0, return NULL); @@ -267,7 +264,6 @@ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name) alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); return _alpm_db_get_pkgcache(db); @@ -277,7 +273,6 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db) pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); ASSERT(name != NULL && strlen(name) != 0, return NULL); @@ -288,7 +283,6 @@ pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name) alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); return _alpm_db_get_grpcache(db); @@ -298,7 +292,6 @@ alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db) alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles) { /* Sanity checks */ - ASSERT(handle != NULL, return NULL); ASSERT(db != NULL, return NULL); return _alpm_db_search(db, needles); @@ -308,7 +301,6 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles) int SYMEXPORT alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason) { /* Sanity checks */ - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(db != NULL && name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); pmpkg_t *pkg = _alpm_db_get_pkgfromcache(db, name); -- 1.7.5.2
Signing off all patches 2 -> 10, it will give me some more work to port pyalpm :) -- Rémy.
On Fri, Jun 3, 2011 at 1:27 PM, Rémy Oudompheng <remyoudompheng@gmail.com> wrote:
Signing off all patches 2 -> 10, it will give me some more work to port pyalpm :)
The eventual outcome is definitely some API changes, but I think it really moves it int he right direction. Unfortuantely, nearly every frontend will need to start tracking a handle object, but this is standard in most libraries (archive in libarchive, curl handle in curl, etc.). -Dan
This is the first step in a long process to remove our dependence on the global handle variable we currently share in libalpm, with the goal to make things a bit more thread-safe and re-entrant. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/alpm.h | 1 + lib/libalpm/be_local.c | 1 + lib/libalpm/be_sync.c | 1 + lib/libalpm/db.h | 1 + lib/libalpm/handle.h | 4 ++-- 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 5af843c..bc06cc0 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -74,6 +74,7 @@ typedef enum _pgp_verify_t { * Structures */ +typedef struct __pmhandle_t pmhandle_t; typedef struct __pmdb_t pmdb_t; typedef struct __pmpkg_t pmpkg_t; typedef struct __pmdelta_t pmdelta_t; diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index fc138e3..c470cba 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -952,6 +952,7 @@ pmdb_t *_alpm_db_register_local(void) RET_ERR(PM_ERR_DB_CREATE, NULL); } db->ops = &local_db_ops; + db->handle = handle; handle->db_local = db; return db; diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 77c9207..1d63398 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -513,6 +513,7 @@ pmdb_t *_alpm_db_register_sync(const char *treename) RET_ERR(PM_ERR_DB_CREATE, NULL); } db->ops = &sync_db_ops; + db->handle = handle; handle->dbs_sync = alpm_list_add(handle->dbs_sync, db); return db; diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index 399e2d5..8d92bd2 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -53,6 +53,7 @@ struct db_operations { /* Database */ struct __pmdb_t { + pmhandle_t *handle; char *treename; /* do not access directly, use _alpm_db_path(db) for lazy access */ char *_path; diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index aa00b6f..08dbe73 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -33,7 +33,7 @@ #include <curl/curl.h> #endif -typedef struct _pmhandle_t { +struct __pmhandle_t { /* internal usage */ pmdb_t *db_local; /* local db pointer */ alpm_list_t *dbs_sync; /* List of (pmdb_t *) */ @@ -73,7 +73,7 @@ typedef struct _pmhandle_t { int usedelta; /* Download deltas if possible */ int checkspace; /* Check disk space before installing */ pgp_verify_t sigverify; /* Default signature verification level */ -} pmhandle_t; +}; /* global handle variable */ extern pmhandle_t *handle; -- 1.7.5.2
Similar to what we just did for the database; this will make it easy to always know what handle a given package originated from. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/be_local.c | 1 + lib/libalpm/be_package.c | 2 ++ lib/libalpm/be_sync.c | 3 ++- lib/libalpm/package.c | 5 +++-- lib/libalpm/package.h | 3 ++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index c470cba..738bdfe 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -415,6 +415,7 @@ static int local_db_populate(pmdb_t *db) pkg->origin = PKG_FROM_LOCALDB; pkg->origin_data.db = db; pkg->ops = &local_pkg_ops; + pkg->handle = handle; /* explicitly read with only 'BASE' data, accessors will handle the rest */ if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) { diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 8da317f..a3d5304 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -32,6 +32,7 @@ #include "alpm_list.h" #include "util.h" #include "log.h" +#include "handle.h" #include "package.h" #include "deps.h" /* _alpm_splitdep */ @@ -350,6 +351,7 @@ pmpkg_t *_alpm_pkg_load_internal(const char *pkgfile, int full, newpkg->origin = PKG_FROM_FILE; newpkg->origin_data.file = strdup(pkgfile); newpkg->ops = get_file_pkg_ops(); + newpkg->handle = handle; if(full) { /* "checking for conflicts" requires a sorted list, ensure that here */ diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 1d63398..ab0001e 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -306,8 +306,9 @@ static int sync_db_populate(pmdb_t *db) } pkg->origin = PKG_FROM_SYNCDB; - pkg->ops = &default_pkg_ops; pkg->origin_data.db = db; + pkg->ops = &default_pkg_ops; + pkg->handle = handle; /* add to the collection */ _alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 205bc10..d19549d 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -408,14 +408,15 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) newpkg->deltas = alpm_list_copy_data(pkg->deltas, sizeof(pmdelta_t)); /* internal */ + newpkg->infolevel = pkg->infolevel; newpkg->origin = pkg->origin; - newpkg->ops = pkg->ops; if(newpkg->origin == PKG_FROM_FILE) { newpkg->origin_data.file = strdup(pkg->origin_data.file); } else { newpkg->origin_data.db = pkg->origin_data.db; } - newpkg->infolevel = pkg->infolevel; + newpkg->ops = pkg->ops; + newpkg->handle = handle; return newpkg; } diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index debb239..4e2dcf3 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -110,6 +110,7 @@ struct __pmpkg_t { int scriptlet; pmpkgreason_t reason; + pmdbinfrq_t infolevel; pmpkgfrom_t origin; /* origin == PKG_FROM_FILE, use pkg->origin_data.file * origin == PKG_FROM_*DB, use pkg->origin_data.db */ @@ -117,7 +118,7 @@ struct __pmpkg_t { pmdb_t *db; char *file; } origin_data; - pmdbinfrq_t infolevel; + pmhandle_t *handle; alpm_list_t *licenses; alpm_list_t *replaces; -- 1.7.5.2
This will make the patching process less invasive as we start to remove this variable from all source files. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/add.c | 3 +++ lib/libalpm/alpm.c | 1 + lib/libalpm/be_local.c | 2 ++ lib/libalpm/be_package.c | 3 +++ lib/libalpm/be_sync.c | 3 +++ lib/libalpm/conflict.c | 3 +++ lib/libalpm/db.c | 3 +++ lib/libalpm/deps.c | 3 +++ lib/libalpm/diskspace.c | 3 +++ lib/libalpm/dload.c | 3 +++ lib/libalpm/error.c | 3 +++ lib/libalpm/handle.h | 3 --- lib/libalpm/log.c | 3 +++ lib/libalpm/package.c | 3 +++ lib/libalpm/remove.c | 3 +++ lib/libalpm/sync.c | 3 +++ lib/libalpm/trans.c | 3 +++ lib/libalpm/util.c | 3 +++ 18 files changed, 48 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index e9dc7dc..13d3fc4 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -47,6 +47,9 @@ #include "remove.h" #include "handle.h" +/* global handle variable */ +extern pmhandle_t *handle; + /** Add a package to the transaction. */ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg) { diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index a13d653..17fe5cd 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -35,6 +35,7 @@ /* Globals */ enum _pmerrno_t pm_errno SYMEXPORT; +extern pmhandle_t *handle; /** \addtogroup alpm_interface Interface Functions * @brief Functions to initialize and release libalpm diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 738bdfe..1f509d1 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -41,6 +41,8 @@ #include "package.h" #include "deps.h" +/* global handle variable */ +extern pmhandle_t *handle; #define LAZY_LOAD(info, errret) \ do { \ diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index a3d5304..c70d1e9 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -36,6 +36,9 @@ #include "package.h" #include "deps.h" /* _alpm_splitdep */ +/* global handle variable */ +extern pmhandle_t *handle; + /** * Open a package changelog for reading. Similar to fopen in functionality, * except that the returned 'file stream' is from an archive. diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index ab0001e..2e472b3 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -37,6 +37,9 @@ #include "deps.h" #include "dload.h" +/* global handle variable */ +extern pmhandle_t *handle; + /** Update a package database * * An update of the package database \a db will be attempted. Unless diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 12a68cf..ae34785 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -40,6 +40,9 @@ #include "log.h" #include "deps.h" +/* global handle variable */ +extern pmhandle_t *handle; + pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2, const char *reason) { diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index a158723..c297bc6 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -39,6 +39,9 @@ #include "package.h" #include "group.h" +/* global handle variable */ +extern pmhandle_t *handle; + /** \addtogroup alpm_databases Database Functions * @brief Functions to query and manipulate the database of libalpm * @{ diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 2d6b5b3..27d0476 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -36,6 +36,9 @@ #include "db.h" #include "handle.h" +/* global handle variable */ +extern pmhandle_t *handle; + void _alpm_dep_free(pmdepend_t *dep) { FREE(dep->name); diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 102b42c..f864518 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -51,6 +51,9 @@ #include "trans.h" #include "handle.h" +/* global handle variable */ +extern pmhandle_t *handle; + static int mount_point_cmp(const void *p1, const void *p2) { const alpm_mountpoint_t *mp1 = p1; diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 9583b36..8591c9d 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -42,6 +42,9 @@ #include "util.h" #include "handle.h" +/* global handle variable */ +extern pmhandle_t *handle; + #ifdef HAVE_LIBCURL static double prevprogress; /* last download amount */ #endif diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c index 4d4a065..294ec21 100644 --- a/lib/libalpm/error.c +++ b/lib/libalpm/error.c @@ -29,6 +29,9 @@ #include "alpm.h" #include "handle.h" +/* global handle variable */ +extern pmhandle_t *handle; + const char SYMEXPORT *alpm_strerrorlast(void) { return alpm_strerror(pm_errno); diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index 08dbe73..129c8ca 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -75,9 +75,6 @@ struct __pmhandle_t { pgp_verify_t sigverify; /* Default signature verification level */ }; -/* global handle variable */ -extern pmhandle_t *handle; - pmhandle_t *_alpm_handle_new(void); void _alpm_handle_free(pmhandle_t *handle); diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c index f500754..20d1ec3 100644 --- a/lib/libalpm/log.c +++ b/lib/libalpm/log.c @@ -30,6 +30,9 @@ #include "util.h" #include "alpm.h" +/* global handle variable */ +extern pmhandle_t *handle; + /** \addtogroup alpm_log Logging Functions * @brief Functions to log using libalpm * @{ diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index d19549d..10ec82f 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -37,6 +37,9 @@ #include "handle.h" #include "deps.h" +/* global handle variable */ +extern pmhandle_t *handle; + /** \addtogroup alpm_packages Package Functions * @brief Functions to manipulate libalpm packages * @{ diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 48348fa..c983edb 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -44,6 +44,9 @@ #include "deps.h" #include "handle.h" +/* global handle variable */ +extern pmhandle_t *handle; + int SYMEXPORT alpm_remove_pkg(pmpkg_t *pkg) { pmtrans_t *trans; diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index b84d625..8390a2c 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -50,6 +50,9 @@ #include "diskspace.h" #include "signing.h" +/* global handle variable */ +extern pmhandle_t *handle; + /** Check for new version of pkg in sync repos * (only the first occurrence is considered in sync) */ diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 31c5885..50539c0 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -43,6 +43,9 @@ #include "sync.h" #include "alpm.h" +/* global handle variable */ +extern pmhandle_t *handle; + /** \addtogroup alpm_trans Transaction Functions * @brief Functions to manipulate libalpm transactions * @{ diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 1918631..6479f85 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -57,6 +57,9 @@ #include "alpm_list.h" #include "handle.h" +/* global handle variable */ +extern pmhandle_t *handle; + #ifndef HAVE_STRSEP /* This is a replacement for strsep which is not portable (missing on Solaris). * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */ -- 1.7.5.2
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/add.c | 18 +++++++++--------- lib/libalpm/remove.c | 10 +++++----- lib/libalpm/trans.c | 13 ++++++------- lib/libalpm/trans.h | 5 ++--- lib/libalpm/util.c | 23 +++++++++++------------ lib/libalpm/util.h | 5 +++-- 6 files changed, 36 insertions(+), 38 deletions(-) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 13d3fc4..a95f4bc 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -501,8 +501,8 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, /* pre_upgrade scriptlet */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - _alpm_runscriptlet(handle->root, newpkg->origin_data.file, - "pre_upgrade", newpkg->version, oldpkg->version, trans); + _alpm_runscriptlet(handle, newpkg->origin_data.file, + "pre_upgrade", newpkg->version, oldpkg->version); } } else { is_upgrade = 0; @@ -513,8 +513,8 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, /* pre_install scriptlet */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - _alpm_runscriptlet(handle->root, newpkg->origin_data.file, - "pre_install", newpkg->version, NULL, trans); + _alpm_runscriptlet(handle, newpkg->origin_data.file, + "pre_install", newpkg->version, NULL); } } @@ -681,12 +681,12 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { if(is_upgrade) { - _alpm_runscriptlet(handle->root, scriptlet, "post_upgrade", + _alpm_runscriptlet(handle, scriptlet, "post_upgrade", alpm_pkg_get_version(newpkg), - oldpkg ? alpm_pkg_get_version(oldpkg) : NULL, trans); + oldpkg ? alpm_pkg_get_version(oldpkg) : NULL); } else { - _alpm_runscriptlet(handle->root, scriptlet, "post_install", - alpm_pkg_get_version(newpkg), NULL, trans); + _alpm_runscriptlet(handle, scriptlet, "post_install", + alpm_pkg_get_version(newpkg), NULL); } } @@ -738,7 +738,7 @@ int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db) if(!skip_ldconfig) { /* run ldconfig if it exists */ - _alpm_ldconfig(handle->root); + _alpm_ldconfig(handle); } return ret; diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index c983edb..2adcd26 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -385,8 +385,8 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) /* run the pre-remove scriptlet if it exists */ if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - _alpm_runscriptlet(handle->root, scriptlet, "pre_remove", - alpm_pkg_get_version(info), NULL, trans); + _alpm_runscriptlet(handle, scriptlet, "pre_remove", + alpm_pkg_get_version(info), NULL); } if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) { @@ -430,8 +430,8 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) /* run the post-remove script if it exists */ if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - _alpm_runscriptlet(handle->root, scriptlet, "post_remove", - alpm_pkg_get_version(info), NULL, trans); + _alpm_runscriptlet(handle, scriptlet, "post_remove", + alpm_pkg_get_version(info), NULL); } /* remove the package from the database */ @@ -451,7 +451,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) } /* run ldconfig if it exists */ - _alpm_ldconfig(handle->root); + _alpm_ldconfig(handle); return 0; } diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 50539c0..19614f6 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -354,9 +354,8 @@ static int grep(const char *fn, const char *needle) return 0; } -int _alpm_runscriptlet(const char *root, const char *installfn, - const char *script, const char *ver, - const char *oldver, pmtrans_t UNUSED *trans) +int _alpm_runscriptlet(pmhandle_t *handle, const char *installfn, + const char *script, const char *ver, const char *oldver) { char scriptfn[PATH_MAX]; char cmdline[PATH_MAX]; @@ -373,11 +372,11 @@ int _alpm_runscriptlet(const char *root, const char *installfn, } /* creates a directory in $root/tmp/ for copying/extracting the scriptlet */ - snprintf(tmpdir, PATH_MAX, "%stmp/", root); + snprintf(tmpdir, PATH_MAX, "%stmp/", handle->root); if(access(tmpdir, F_OK) != 0) { _alpm_makepath_mode(tmpdir, 01777); } - snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root); + snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", handle->root); if(mkdtemp(tmpdir) == NULL) { _alpm_log(PM_LOG_ERROR, _("could not create temp directory\n")); return 1; @@ -402,7 +401,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn, } /* chop off the root so we can find the tmpdir in the chroot */ - scriptpath = scriptfn + strlen(root) - 1; + scriptpath = scriptfn + strlen(handle->root) - 1; if(!grep(scriptfn, script)) { /* script not found in scriptlet file */ @@ -419,7 +418,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn, _alpm_log(PM_LOG_DEBUG, "executing \"%s\"\n", cmdline); - retval = _alpm_run_chroot(root, "/bin/sh", argv); + retval = _alpm_run_chroot(handle, "/bin/sh", argv); cleanup: if(clean_tmpdir && _alpm_rmrf(tmpdir)) { diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h index 6702881..8c9e7fa 100644 --- a/lib/libalpm/trans.h +++ b/lib/libalpm/trans.h @@ -71,9 +71,8 @@ void _alpm_trans_free(pmtrans_t *trans); int _alpm_trans_init(pmtrans_t *trans, pmtransflag_t flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress); -int _alpm_runscriptlet(const char *root, const char *installfn, - const char *script, const char *ver, - const char *oldver, pmtrans_t *trans); +int _alpm_runscriptlet(pmhandle_t *handle, const char *installfn, + const char *script, const char *ver, const char *oldver); #endif /* _ALPM_TRANS_H */ diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 6479f85..e25e19d 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -57,9 +57,6 @@ #include "alpm_list.h" #include "handle.h" -/* global handle variable */ -extern pmhandle_t *handle; - #ifndef HAVE_STRSEP /* This is a replacement for strsep which is not portable (missing on Solaris). * Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> */ @@ -418,7 +415,7 @@ int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args) return ret; } -int _alpm_run_chroot(const char *root, const char *path, char *const argv[]) +int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[]) { char cwd[PATH_MAX]; pid_t pid; @@ -434,12 +431,14 @@ int _alpm_run_chroot(const char *root, const char *path, char *const argv[]) } /* just in case our cwd was removed in the upgrade operation */ - if(chdir(root) != 0) { - _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), root, strerror(errno)); + if(chdir(handle->root) != 0) { + _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), + handle->root, strerror(errno)); goto cleanup; } - _alpm_log(PM_LOG_DEBUG, "executing \"%s\" under chroot \"%s\"\n", path, root); + _alpm_log(PM_LOG_DEBUG, "executing \"%s\" under chroot \"%s\"\n", + path, handle->root); /* Flush open fds before fork() to avoid cloning buffers */ fflush(NULL); @@ -468,7 +467,7 @@ int _alpm_run_chroot(const char *root, const char *path, char *const argv[]) close(pipefd[1]); /* use fprintf instead of _alpm_log to send output through the parent */ - if(chroot(root) != 0) { + if(chroot(handle->root) != 0) { fprintf(stderr, _("could not change the root directory (%s)\n"), strerror(errno)); exit(1); } @@ -533,18 +532,18 @@ cleanup: return retval; } -int _alpm_ldconfig(const char *root) +int _alpm_ldconfig(pmhandle_t *handle) { char line[PATH_MAX]; _alpm_log(PM_LOG_DEBUG, "running ldconfig\n"); - snprintf(line, PATH_MAX, "%setc/ld.so.conf", root); + snprintf(line, PATH_MAX, "%setc/ld.so.conf", handle->root); if(access(line, F_OK) == 0) { - snprintf(line, PATH_MAX, "%ssbin/ldconfig", root); + snprintf(line, PATH_MAX, "%ssbin/ldconfig", handle->root); if(access(line, X_OK) == 0) { char *argv[] = { "ldconfig", NULL }; - _alpm_run_chroot(root, "/sbin/ldconfig", argv); + _alpm_run_chroot(handle, "/sbin/ldconfig", argv); } } diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 776cee4..c1a92a0 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -27,6 +27,7 @@ #include "config.h" #include "alpm_list.h" +#include "alpm.h" #include "package.h" /* pmpkg_t */ #include <stdio.h> @@ -93,8 +94,8 @@ int _alpm_unpack_single(const char *archive, const char *prefix, const char *fn) int _alpm_unpack(const char *archive, const char *prefix, alpm_list_t *list, int breakfirst); int _alpm_rmrf(const char *path); int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args); -int _alpm_run_chroot(const char *root, const char *path, char *const argv[]); -int _alpm_ldconfig(const char *root); +int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[]); +int _alpm_ldconfig(pmhandle_t *handle); int _alpm_str_cmp(const void *s1, const void *s2); char *_alpm_filecache_find(const char *filename); const char *_alpm_filecache_setup(void); -- 1.7.5.2
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/diskspace.c | 22 ++++++++++------------ lib/libalpm/diskspace.h | 2 +- lib/libalpm/sync.c | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index f864518..c6c0b98 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -51,9 +51,6 @@ #include "trans.h" #include "handle.h" -/* global handle variable */ -extern pmhandle_t *handle; - static int mount_point_cmp(const void *p1, const void *p2) { const alpm_mountpoint_t *mp1 = p1; @@ -151,8 +148,8 @@ static alpm_mountpoint_t *match_mount_point(const alpm_list_t *mount_points, return NULL; } -static int calculate_removed_size(const alpm_list_t *mount_points, - pmpkg_t *pkg) +static int calculate_removed_size(pmhandle_t *handle, + const alpm_list_t *mount_points, pmpkg_t *pkg) { alpm_list_t *file; @@ -188,8 +185,8 @@ static int calculate_removed_size(const alpm_list_t *mount_points, return 0; } -static int calculate_installed_size(const alpm_list_t *mount_points, - pmpkg_t *pkg) +static int calculate_installed_size(pmhandle_t *handle, + const alpm_list_t *mount_points, pmpkg_t *pkg) { int ret=0; struct archive *archive; @@ -260,13 +257,14 @@ cleanup: return ret; } -int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) +int _alpm_check_diskspace(pmhandle_t *handle) { alpm_list_t *mount_points, *i; alpm_mountpoint_t *root_mp; size_t replaces = 0, current = 0, numtargs; int abort = 0; alpm_list_t *targ; + pmtrans_t *trans = handle->trans; numtargs = alpm_list_count(trans->add); mount_points = mount_point_list(); @@ -291,7 +289,7 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) numtargs, current); local_pkg = targ->data; - calculate_removed_size(mount_points, local_pkg); + calculate_removed_size(handle, mount_points, local_pkg); } } @@ -303,11 +301,11 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) pkg = targ->data; /* is this package already installed? */ - local_pkg = _alpm_db_get_pkgfromcache(db_local, pkg->name); + local_pkg = _alpm_db_get_pkgfromcache(handle->db_local, pkg->name); if(local_pkg) { - calculate_removed_size(mount_points, local_pkg); + calculate_removed_size(handle, mount_points, local_pkg); } - calculate_installed_size(mount_points, pkg); + calculate_installed_size(handle, mount_points, pkg); for(i = mount_points; i; i = alpm_list_next(i)) { alpm_mountpoint_t *data = i->data; diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h index 2894a0c..28aca7e 100644 --- a/lib/libalpm/diskspace.h +++ b/lib/libalpm/diskspace.h @@ -46,7 +46,7 @@ typedef struct __alpm_mountpoint_t { FSSTATSTYPE fsp; } alpm_mountpoint_t; -int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local); +int _alpm_check_diskspace(pmhandle_t *handle); #endif /* _ALPM_DISKSPACE_H */ diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 8390a2c..32060d0 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -935,7 +935,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) EVENT(trans, PM_TRANS_EVT_DISKSPACE_START, NULL, NULL); _alpm_log(PM_LOG_DEBUG, "checking available disk space\n"); - if(_alpm_check_diskspace(trans, handle->db_local) == -1) { + if(_alpm_check_diskspace(handle) == -1) { _alpm_log(PM_LOG_ERROR, "%s\n", _("not enough free disk space")); return -1; } -- 1.7.5.2
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/alpm.c | 2 +- lib/libalpm/be_local.c | 20 ++------------------ lib/libalpm/be_sync.c | 10 +++------- lib/libalpm/db.c | 11 +++++------ lib/libalpm/db.h | 4 ++-- lib/libalpm/package.c | 11 ++++------- 6 files changed, 17 insertions(+), 41 deletions(-) diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 17fe5cd..2da3432 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -54,7 +54,7 @@ int SYMEXPORT alpm_initialize(void) if(handle == NULL) { RET_ERR(PM_ERR_MEMORY, -1); } - if(_alpm_db_register_local() == NULL) { + if(_alpm_db_register_local(handle) == NULL) { /* error code should be set */ _alpm_handle_free(handle); handle = NULL; diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 1f509d1..64af4b9 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -41,12 +41,8 @@ #include "package.h" #include "deps.h" -/* global handle variable */ -extern pmhandle_t *handle; - #define LAZY_LOAD(info, errret) \ do { \ - ASSERT(handle != NULL, return (errret)); \ if(pkg->origin != PKG_FROM_FILE && !(pkg->infolevel & info)) { \ _alpm_local_db_read(pkg->origin_data.db, pkg, info); \ } \ @@ -139,9 +135,6 @@ static alpm_list_t *_cache_get_groups(pmpkg_t *pkg) static int _cache_has_scriptlet(pmpkg_t *pkg) { - /* Sanity checks */ - ASSERT(handle != NULL, return -1); - if(!(pkg->infolevel & INFRQ_SCRIPTLET)) { _alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_SCRIPTLET); } @@ -186,9 +179,6 @@ static alpm_list_t *_cache_get_deltas(pmpkg_t UNUSED *pkg) static alpm_list_t *_cache_get_files(pmpkg_t *pkg) { - /* Sanity checks */ - ASSERT(handle != NULL, return NULL); - if(pkg->origin == PKG_FROM_LOCALDB && !(pkg->infolevel & INFRQ_FILES)) { _alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_FILES); @@ -198,9 +188,6 @@ static alpm_list_t *_cache_get_files(pmpkg_t *pkg) static alpm_list_t *_cache_get_backup(pmpkg_t *pkg) { - /* Sanity checks */ - ASSERT(handle != NULL, return NULL); - if(pkg->origin == PKG_FROM_LOCALDB && !(pkg->infolevel & INFRQ_FILES)) { _alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_FILES); @@ -216,9 +203,6 @@ static alpm_list_t *_cache_get_backup(pmpkg_t *pkg) */ static void *_cache_changelog_open(pmpkg_t *pkg) { - /* Sanity checks */ - ASSERT(handle != NULL, return NULL); - char clfile[PATH_MAX]; snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog", alpm_option_get_dbpath(), @@ -417,7 +401,7 @@ static int local_db_populate(pmdb_t *db) pkg->origin = PKG_FROM_LOCALDB; pkg->origin_data.db = db; pkg->ops = &local_pkg_ops; - pkg->handle = handle; + pkg->handle = db->handle; /* explicitly read with only 'BASE' data, accessors will handle the rest */ if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) { @@ -944,7 +928,7 @@ struct db_operations local_db_ops = { .version = local_db_version, }; -pmdb_t *_alpm_db_register_local(void) +pmdb_t *_alpm_db_register_local(pmhandle_t *handle) { pmdb_t *db; diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 2e472b3..953e4dc 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -37,9 +37,6 @@ #include "deps.h" #include "dload.h" -/* global handle variable */ -extern pmhandle_t *handle; - /** Update a package database * * An update of the package database \a db will be attempted. Unless @@ -91,8 +88,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) pgp_verify_t check_sig; /* Sanity checks */ - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - ASSERT(db != NULL && db != handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1)); + ASSERT(db != NULL && db != db->handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(db->servers != NULL, RET_ERR(PM_ERR_SERVER_NONE, -1)); dbpath = alpm_option_get_dbpath(); @@ -311,7 +307,7 @@ static int sync_db_populate(pmdb_t *db) pkg->origin = PKG_FROM_SYNCDB; pkg->origin_data.db = db; pkg->ops = &default_pkg_ops; - pkg->handle = handle; + pkg->handle = db->handle; /* add to the collection */ _alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", @@ -506,7 +502,7 @@ struct db_operations sync_db_ops = { .version = sync_db_version, }; -pmdb_t *_alpm_db_register_sync(const char *treename) +pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename) { pmdb_t *db; diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index c297bc6..9b1f4fb 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -56,7 +56,7 @@ pmdb_t SYMEXPORT *alpm_db_register_sync(const char *treename) /* Do not register a database if a transaction is on-going */ ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL)); - return _alpm_db_register_sync(treename); + return _alpm_db_register_sync(handle, treename); } /* Helper function for alpm_db_unregister{_all} */ @@ -97,13 +97,12 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db) int found = 0; /* Sanity checks */ - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); /* Do not unregister a database if a transaction is on-going */ - ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1)); + ASSERT(db->handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1)); - if(db == handle->db_local) { - handle->db_local = NULL; + if(db == db->handle->db_local) { + db->handle->db_local = NULL; found = 1; } else { /* Warning : this function shouldn't be used to unregister all sync @@ -111,7 +110,7 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db) * alpm_option_get_syncdbs, because the db is removed from that list here. */ void *data; - handle->dbs_sync = alpm_list_remove(handle->dbs_sync, + db->handle->dbs_sync = alpm_list_remove(db->handle->dbs_sync, db, _alpm_db_cmp, &data); if(data) { found = 1; diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index 8d92bd2..3a7ab72 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -77,8 +77,8 @@ const char *_alpm_db_path(pmdb_t *db); int _alpm_db_version(pmdb_t *db); int _alpm_db_cmp(const void *d1, const void *d2); alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles); -pmdb_t *_alpm_db_register_local(void); -pmdb_t *_alpm_db_register_sync(const char *treename); +pmdb_t *_alpm_db_register_local(pmhandle_t *handle); +pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename); void _alpm_db_unregister(pmdb_t *db); /* be_*.c, backend specific calls */ diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 10ec82f..d6edca1 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -37,9 +37,6 @@ #include "handle.h" #include "deps.h" -/* global handle variable */ -extern pmhandle_t *handle; - /** \addtogroup alpm_packages Package Functions * @brief Functions to manipulate libalpm packages * @{ @@ -353,7 +350,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg) if(db->is_local) { find_requiredby(pkg, db, &reqs); } else { - for(i = handle->dbs_sync; i; i = i->next) { + for(i = pkg->handle->dbs_sync; i; i = i->next) { db = i->data; find_requiredby(pkg, db, &reqs); } @@ -419,7 +416,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) newpkg->origin_data.db = pkg->origin_data.db; } newpkg->ops = pkg->ops; - newpkg->handle = handle; + newpkg->handle = pkg->handle; return newpkg; } @@ -542,12 +539,12 @@ int _alpm_pkg_should_ignore(pmpkg_t *pkg) alpm_list_t *groups = NULL; /* first see if the package is ignored */ - if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) { + if(alpm_list_find_str(pkg->handle->ignorepkg, alpm_pkg_get_name(pkg))) { return 1; } /* next see if the package is in a group that is ignored */ - for(groups = handle->ignoregrp; groups; groups = alpm_list_next(groups)) { + for(groups = pkg->handle->ignoregrp; groups; groups = alpm_list_next(groups)) { char *grp = (char *)alpm_list_getdata(groups); if(alpm_list_find_str(alpm_pkg_get_groups(pkg), grp)) { return 1; -- 1.7.5.2
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/add.c | 2 +- lib/libalpm/remove.c | 51 +++++++++++++++++++++---------------------------- lib/libalpm/remove.h | 7 +++-- lib/libalpm/sync.c | 2 +- lib/libalpm/trans.c | 4 +- 5 files changed, 30 insertions(+), 36 deletions(-) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index a95f4bc..500fbde 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -527,7 +527,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, if(oldpkg) { /* set up fake remove transaction */ - if(_alpm_upgraderemove_package(oldpkg, newpkg, trans) == -1) { + if(_alpm_upgraderemove_package(handle, oldpkg, newpkg) == -1) { pm_errno = PM_ERR_TRANS_ABORT; ret = -1; goto cleanup; diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 2adcd26..27305ae 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -44,9 +44,6 @@ #include "deps.h" #include "handle.h" -/* global handle variable */ -extern pmhandle_t *handle; - int SYMEXPORT alpm_remove_pkg(pmpkg_t *pkg) { pmtrans_t *trans; @@ -54,8 +51,7 @@ int SYMEXPORT alpm_remove_pkg(pmpkg_t *pkg) /* Sanity checks */ ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - trans = handle->trans; + trans = pkg->handle->trans; ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1)); @@ -129,16 +125,14 @@ static void remove_prepare_keep_needed(pmtrans_t *trans, pmdb_t *db, * This functions takes a pointer to a alpm_list_t which will be * filled with a list of pmdepmissing_t* objects representing * the packages blocking the transaction. - * @param trans the transaction object - * @param db the database of local packages + * @param handle the context handle * @param data a pointer to an alpm_list_t* to fill */ -int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) +int _alpm_remove_prepare(pmhandle_t *handle, alpm_list_t **data) { alpm_list_t *lp; - - ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); + pmtrans_t *trans = handle->trans; + pmdb_t *db = handle->db_local; if((trans->flags & PM_TRANS_FLAG_RECURSE) && !(trans->flags & PM_TRANS_FLAG_CASCADE)) { _alpm_log(PM_LOG_DEBUG, "finding removable dependencies\n"); @@ -190,7 +184,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) return 0; } -static int can_remove_file(const char *path, alpm_list_t *skip) +static int can_remove_file(pmhandle_t *handle, const char *path, alpm_list_t *skip) { char file[PATH_MAX+1]; @@ -217,7 +211,8 @@ static int can_remove_file(const char *path, alpm_list_t *skip) /* Helper function for iterating through a package's file and deleting them * Used by _alpm_remove_commit. */ -static void unlink_file(pmpkg_t *info, char *filename, alpm_list_t *skip_remove, int nosave) +static void unlink_file(pmhandle_t *handle, pmpkg_t *info, char *filename, + alpm_list_t *skip_remove, int nosave) { struct stat buf; char file[PATH_MAX+1]; @@ -281,8 +276,8 @@ static void unlink_file(pmpkg_t *info, char *filename, alpm_list_t *skip_remove, } } -int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, - pmtrans_t *trans) +int _alpm_upgraderemove_package(pmhandle_t *handle, + pmpkg_t *oldpkg, pmpkg_t *newpkg) { alpm_list_t *skip_remove, *b; alpm_list_t *newfiles, *lp; @@ -293,13 +288,13 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, _alpm_log(PM_LOG_DEBUG, "removing old package first (%s-%s)\n", oldpkg->name, oldpkg->version); - if(trans->flags & PM_TRANS_FLAG_DBONLY) { + if(handle->trans->flags & PM_TRANS_FLAG_DBONLY) { goto db; } /* copy the remove skiplist over */ skip_remove = alpm_list_join( - alpm_list_strdup(trans->skip_remove), + alpm_list_strdup(handle->trans->skip_remove), alpm_list_strdup(handle->noupgrade)); /* Add files in the NEW backup array to the skip_remove array * so this removal operation doesn't kill them */ @@ -317,7 +312,7 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, } for(lp = files; lp; lp = lp->next) { - if(!can_remove_file(lp->data, skip_remove)) { + if(!can_remove_file(handle, lp->data, skip_remove)) { _alpm_log(PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n", pkgname); RET_ERR(PM_ERR_PKG_CANT_REMOVE, -1); @@ -330,7 +325,7 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, /* iterate through the list backwards, unlinking files */ newfiles = alpm_list_reverse(files); for(lp = newfiles; lp; lp = alpm_list_next(lp)) { - unlink_file(oldpkg, lp->data, skip_remove, 0); + unlink_file(handle, oldpkg, lp->data, skip_remove, 0); } alpm_list_free(newfiles); FREELIST(skip_remove); @@ -352,14 +347,12 @@ db: return 0; } -int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) +int _alpm_remove_packages(pmhandle_t *handle) { pmpkg_t *info; alpm_list_t *targ, *lp; size_t pkg_count; - - ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); + pmtrans_t *trans = handle->trans; pkg_count = alpm_list_count(trans->remove); @@ -370,14 +363,14 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) const char *pkgname = NULL; size_t targcount = alpm_list_count(targ); - if(handle->trans->state == STATE_INTERRUPTED) { + if(trans->state == STATE_INTERRUPTED) { return 0; } /* get the name now so we can use it after package is removed */ pkgname = alpm_pkg_get_name(info); snprintf(scriptlet, PATH_MAX, "%s%s-%s/install", - _alpm_db_path(db), pkgname, alpm_pkg_get_version(info)); + _alpm_db_path(handle->db_local), pkgname, alpm_pkg_get_version(info)); EVENT(trans, PM_TRANS_EVT_REMOVE_START, info, NULL); _alpm_log(PM_LOG_DEBUG, "removing package %s-%s\n", @@ -395,7 +388,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) size_t filenum; for(lp = files; lp; lp = lp->next) { - if(!can_remove_file(lp->data, NULL)) { + if(!can_remove_file(handle, lp->data, NULL)) { _alpm_log(PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n", pkgname); RET_ERR(PM_ERR_PKG_CANT_REMOVE, -1); @@ -413,7 +406,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) newfiles = alpm_list_reverse(files); for(lp = newfiles; lp; lp = alpm_list_next(lp)) { int percent; - unlink_file(info, lp->data, NULL, trans->flags & PM_TRANS_FLAG_NOSAVE); + unlink_file(handle, info, lp->data, NULL, trans->flags & PM_TRANS_FLAG_NOSAVE); /* update progress bar after each file */ percent = (position * 100) / filenum; @@ -437,12 +430,12 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) /* remove the package from the database */ _alpm_log(PM_LOG_DEBUG, "updating database\n"); _alpm_log(PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname); - if(_alpm_local_db_remove(db, info) == -1) { + if(_alpm_local_db_remove(handle->db_local, info) == -1) { _alpm_log(PM_LOG_ERROR, _("could not remove database entry %s-%s\n"), pkgname, alpm_pkg_get_version(info)); } /* remove the package from the cache */ - if(_alpm_db_remove_pkgfromcache(db, info) == -1) { + if(_alpm_db_remove_pkgfromcache(handle->db_local, info) == -1) { _alpm_log(PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"), pkgname); } diff --git a/lib/libalpm/remove.h b/lib/libalpm/remove.h index a67e37a..5cab526 100644 --- a/lib/libalpm/remove.h +++ b/lib/libalpm/remove.h @@ -24,10 +24,11 @@ #include "alpm_list.h" #include "trans.h" -int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data); -int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db); +int _alpm_remove_prepare(pmhandle_t *handle, alpm_list_t **data); +int _alpm_remove_packages(pmhandle_t *handle); -int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *trans); +int _alpm_upgraderemove_package(pmhandle_t *handle, + pmpkg_t *oldpkg, pmpkg_t *newpkg); #endif /* _ALPM_REMOVE_H */ diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 32060d0..f0d9b91 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -947,7 +947,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) if(replaces) { _alpm_log(PM_LOG_DEBUG, "removing conflicting and to-be-replaced packages\n"); /* we want the frontend to be aware of commit details */ - if(_alpm_remove_packages(trans, handle->db_local) == -1) { + if(_alpm_remove_packages(handle) == -1) { _alpm_log(PM_LOG_ERROR, _("could not commit removal transaction\n")); return -1; } diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 19614f6..8e019cc 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -197,7 +197,7 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data) } if(trans->add == NULL) { - if(_alpm_remove_prepare(trans, handle->db_local, data) == -1) { + if(_alpm_remove_prepare(handle, data) == -1) { /* pm_errno is set by _alpm_remove_prepare() */ return -1; } @@ -236,7 +236,7 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data) trans->state = STATE_COMMITING; if(trans->add == NULL) { - if(_alpm_remove_packages(trans, handle->db_local) == -1) { + if(_alpm_remove_packages(handle) == -1) { /* pm_errno is set by _alpm_remove_commit() */ return -1; } -- 1.7.5.2
This kills a lot more global handle business off. sync.c still requires the handle declaration for one reference that can't be changed yet; it will be removed in a future patch which isolates all of the necesary API changes. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/add.c | 53 ++++++++++++++++++++--------------------------- lib/libalpm/add.h | 2 +- lib/libalpm/conflict.c | 16 ++++++-------- lib/libalpm/conflict.h | 4 +- lib/libalpm/sync.c | 38 ++++++++++++++++------------------ lib/libalpm/sync.h | 4 +- lib/libalpm/trans.c | 4 +- 7 files changed, 55 insertions(+), 66 deletions(-) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 500fbde..94ab112 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -47,9 +47,6 @@ #include "remove.h" #include "handle.h" -/* global handle variable */ -extern pmhandle_t *handle; - /** Add a package to the transaction. */ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg) { @@ -60,11 +57,10 @@ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg) /* Sanity checks */ ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - trans = handle->trans; + trans = pkg->handle->trans; ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1)); - db_local = handle->db_local; + db_local = pkg->handle->db_local; pkgname = pkg->name; pkgver = pkg->version; @@ -132,9 +128,8 @@ static int perform_extraction(struct archive *archive, return 0; } -static int extract_single_file(struct archive *archive, - struct archive_entry *entry, pmpkg_t *newpkg, pmpkg_t *oldpkg, - pmtrans_t *trans, pmdb_t *db) +static int extract_single_file(pmhandle_t *handle, struct archive *archive, + struct archive_entry *entry, pmpkg_t *newpkg, pmpkg_t *oldpkg) { const char *entryname; mode_t entrymode; @@ -152,12 +147,12 @@ static int extract_single_file(struct archive *archive, if(strcmp(entryname, ".INSTALL") == 0) { /* the install script goes inside the db */ snprintf(filename, PATH_MAX, "%s%s-%s/install", - _alpm_db_path(db), newpkg->name, newpkg->version); + _alpm_db_path(handle->db_local), newpkg->name, newpkg->version); archive_entry_set_perm(entry, 0644); } else if(strcmp(entryname, ".CHANGELOG") == 0) { /* the changelog goes inside the db */ snprintf(filename, PATH_MAX, "%s%s-%s/changelog", - _alpm_db_path(db), newpkg->name, newpkg->version); + _alpm_db_path(handle->db_local), newpkg->name, newpkg->version); archive_entry_set_perm(entry, 0644); } else if(*entryname == '.') { /* for now, ignore all files starting with '.' that haven't @@ -426,7 +421,7 @@ static int extract_single_file(struct archive *archive, _alpm_log(PM_LOG_DEBUG, "extracting %s\n", filename); } - if(trans->flags & PM_TRANS_FLAG_FORCE) { + if(handle->trans->flags & PM_TRANS_FLAG_FORCE) { /* if FORCE was used, unlink() each file (whether it's there * or not) before extracting. This prevents the old "Text file busy" * error that crops up if forcing a glibc or pacman upgrade. */ @@ -467,15 +462,15 @@ static int extract_single_file(struct archive *archive, return errors; } -static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, - size_t pkg_count, pmtrans_t *trans, pmdb_t *db) +static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg, + size_t pkg_current, size_t pkg_count) { int i, ret = 0, errors = 0; char scriptlet[PATH_MAX+1]; int is_upgrade = 0; pmpkg_t *oldpkg = NULL; - - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); + pmdb_t *db = handle->db_local; + pmtrans_t *trans = handle->trans; snprintf(scriptlet, PATH_MAX, "%s%s-%s/install", _alpm_db_path(db), alpm_pkg_get_name(newpkg), @@ -501,7 +496,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, /* pre_upgrade scriptlet */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - _alpm_runscriptlet(handle, newpkg->origin_data.file, + _alpm_runscriptlet(newpkg->handle, newpkg->origin_data.file, "pre_upgrade", newpkg->version, oldpkg->version); } } else { @@ -513,7 +508,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, /* pre_install scriptlet */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { - _alpm_runscriptlet(handle, newpkg->origin_data.file, + _alpm_runscriptlet(newpkg->handle, newpkg->origin_data.file, "pre_install", newpkg->version, NULL); } } @@ -527,7 +522,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, if(oldpkg) { /* set up fake remove transaction */ - if(_alpm_upgraderemove_package(handle, oldpkg, newpkg) == -1) { + if(_alpm_upgraderemove_package(newpkg->handle, oldpkg, newpkg) == -1) { pm_errno = PM_ERR_TRANS_ABORT; ret = -1; goto cleanup; @@ -577,8 +572,9 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, } /* libarchive requires this for extracting hard links */ - if(chdir(handle->root) != 0) { - _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), handle->root, strerror(errno)); + if(chdir(newpkg->handle->root) != 0) { + _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), + newpkg->handle->root, strerror(errno)); ret = -1; goto cleanup; } @@ -622,8 +618,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, } /* extract the next file from the archive */ - errors += extract_single_file(archive, entry, newpkg, oldpkg, - trans, db); + errors += extract_single_file(newpkg->handle, archive, entry, newpkg, oldpkg); } archive_read_finish(archive); @@ -681,11 +676,11 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) { if(is_upgrade) { - _alpm_runscriptlet(handle, scriptlet, "post_upgrade", + _alpm_runscriptlet(newpkg->handle, scriptlet, "post_upgrade", alpm_pkg_get_version(newpkg), oldpkg ? alpm_pkg_get_version(oldpkg) : NULL); } else { - _alpm_runscriptlet(handle, scriptlet, "post_install", + _alpm_runscriptlet(newpkg->handle, scriptlet, "post_install", alpm_pkg_get_version(newpkg), NULL); } } @@ -701,14 +696,12 @@ cleanup: return ret; } -int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db) +int _alpm_upgrade_packages(pmhandle_t *handle) { size_t pkg_count, pkg_current; int skip_ldconfig = 0, ret = 0; alpm_list_t *targ; - - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); - ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); + pmtrans_t *trans = handle->trans; if(trans->add == NULL) { return 0; @@ -724,7 +717,7 @@ int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db) } pmpkg_t *newpkg = (pmpkg_t *)targ->data; - if(commit_single_pkg(newpkg, pkg_current, pkg_count, trans, db)) { + if(commit_single_pkg(handle, newpkg, pkg_current, pkg_count)) { /* something screwed up on the commit, abort the trans */ trans->state = STATE_INTERRUPTED; pm_errno = PM_ERR_TRANS_ABORT; diff --git a/lib/libalpm/add.h b/lib/libalpm/add.h index afc7be2..1baab8d 100644 --- a/lib/libalpm/add.h +++ b/lib/libalpm/add.h @@ -24,7 +24,7 @@ #include "alpm_list.h" #include "trans.h" -int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db); +int _alpm_upgrade_packages(pmhandle_t *handle); #endif /* _ALPM_ADD_H */ diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index ae34785..8921470 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -40,9 +40,6 @@ #include "log.h" #include "deps.h" -/* global handle variable */ -extern pmhandle_t *handle; - pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2, const char *reason) { @@ -308,7 +305,7 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg) char abspath[PATH_MAX]; DIR *dir; - snprintf(abspath, PATH_MAX, "%s%s", handle->root, dirpath); + snprintf(abspath, PATH_MAX, "%s%s", pkg->handle->root, dirpath); dir = opendir(abspath); if(dir == NULL) { return 1; @@ -320,7 +317,7 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg) continue; } snprintf(path, PATH_MAX, "%s/%s", dirpath, name); - snprintf(abspath, PATH_MAX, "%s%s", handle->root, path); + snprintf(abspath, PATH_MAX, "%s%s", pkg->handle->root, path); if(stat(abspath, &sbuf) != 0) { continue; } @@ -347,14 +344,15 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg) /* Find file conflicts that may occur during the transaction with two checks: * 1: check every target against every target * 2: check every target against the filesystem */ -alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, +alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle, alpm_list_t *upgrade, alpm_list_t *remove) { alpm_list_t *i, *j, *conflicts = NULL; size_t numtargs = alpm_list_count(upgrade); size_t current; + pmtrans_t *trans = handle->trans; - if(db == NULL || upgrade == NULL || trans == NULL) { + if(!upgrade) { return NULL; } @@ -402,7 +400,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, /* CHECK 2: check every target against the filesystem */ _alpm_log(PM_LOG_DEBUG, "searching for filesystem conflicts: %s\n", p1->name); - dbpkg = _alpm_db_get_pkgfromcache(db, p1->name); + dbpkg = _alpm_db_get_pkgfromcache(handle->db_local, p1->name); /* Do two different checks here. If the package is currently installed, * then only check files that are new in the new package. If the package @@ -456,7 +454,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, if(!p2 || strcmp(p1->name, p2->name) == 0) { continue; } - pmpkg_t *localp2 = _alpm_db_get_pkgfromcache(db, p2->name); + pmpkg_t *localp2 = _alpm_db_get_pkgfromcache(handle->db_local, p2->name); /* localp2->files will be removed (target conflicts are handled by CHECK 1) */ if(localp2 && alpm_list_find_str(alpm_pkg_get_files(localp2), filestr)) { diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h index 418d3f6..d00314d 100644 --- a/lib/libalpm/conflict.h +++ b/lib/libalpm/conflict.h @@ -42,8 +42,8 @@ pmconflict_t *_alpm_conflict_dup(const pmconflict_t *conflict); void _alpm_conflict_free(pmconflict_t *conflict); alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages); alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages); -alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, - alpm_list_t *upgrade, alpm_list_t *remove); +alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle, + alpm_list_t *upgrade, alpm_list_t *remove); void _alpm_fileconflict_free(pmfileconflict_t *conflict); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index f0d9b91..7a33bc9 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -233,7 +233,7 @@ alpm_list_t SYMEXPORT *alpm_find_grp_pkgs(alpm_list_t *dbs, if(_alpm_pkg_should_ignore(pkg)) { ignorelist = alpm_list_add(ignorelist, pkg); int install = 0; - QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg, + QUESTION(db->handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg, NULL, NULL, &install); if(!install) continue; @@ -270,7 +270,7 @@ static int compute_download_size(pmpkg_t *newpkg) if(fpath) { FREE(fpath); size = 0; - } else if(handle->usedelta) { + } else if(newpkg->handle->usedelta) { off_t dltsize; off_t pkgsize = alpm_pkg_get_size(newpkg); @@ -300,16 +300,15 @@ static int compute_download_size(pmpkg_t *newpkg) return 0; } -int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data) +int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data) { alpm_list_t *deps = NULL; alpm_list_t *unresolvable = NULL; alpm_list_t *i, *j; alpm_list_t *remove = NULL; int ret = 0; - - ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); + pmtrans_t *trans = handle->trans; + pmdb_t *db_local = handle->db_local; if(data) { *data = NULL; @@ -340,7 +339,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync building up a list of packages which could not be resolved. */ for(i = trans->add; i; i = i->next) { pmpkg_t *pkg = i->data; - if(_alpm_resolvedeps(localpkgs, dbs_sync, pkg, trans->add, + if(_alpm_resolvedeps(localpkgs, handle->dbs_sync, pkg, trans->add, &resolved, remove, data) == -1) { unresolvable = alpm_list_add(unresolvable, pkg); } @@ -725,7 +724,7 @@ static int validate_deltas(pmtrans_t *trans, alpm_list_t *deltas, return ret; } -static int download_files(pmtrans_t *trans, alpm_list_t **deltas) +static int download_files(pmhandle_t *handle, alpm_list_t **deltas) { const char *cachedir; alpm_list_t *i, *j; @@ -733,7 +732,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas) int errors = 0; cachedir = _alpm_filecache_setup(); - trans->state = STATE_DOWNLOADING; + handle->trans->state = STATE_DOWNLOADING; /* Total progress - figure out the total download size if required to * pass to the callback. This function is called once, and it is up to the @@ -741,7 +740,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas) if(handle->totaldlcb) { off_t total_size = (off_t)0; /* sum up the download size for each package and store total */ - for(i = trans->add; i; i = i->next) { + for(i = handle->trans->add; i; i = i->next) { pmpkg_t *spkg = i->data; total_size += spkg->download_size; } @@ -752,7 +751,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas) for(i = handle->dbs_sync; i; i = i->next) { pmdb_t *current = i->data; - for(j = trans->add; j; j = j->next) { + for(j = handle->trans->add; j; j = j->next) { pmpkg_t *spkg = j->data; if(spkg->origin != PKG_FROM_FILE && current == spkg->origin_data.db) { @@ -781,7 +780,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas) } if(files) { - EVENT(trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL); + EVENT(handle->trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL); for(j = files; j; j = j->next) { const char *filename = j->data; alpm_list_t *server; @@ -819,7 +818,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas) } } - for(j = trans->add; j; j = j->next) { + for(j = handle->trans->add; j; j = j->next) { pmpkg_t *pkg = j->data; pkg->infolevel &= ~INFRQ_DSIZE; pkg->download_size = 0; @@ -832,16 +831,15 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas) return 0; } -int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) +int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data) { alpm_list_t *i; alpm_list_t *deltas = NULL; size_t numtargs, current = 0, replaces = 0; int errors; + pmtrans_t *trans = handle->trans; - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); - - if(download_files(trans, &deltas)) { + if(download_files(handle, &deltas)) { alpm_list_free(deltas); return -1; } @@ -915,8 +913,8 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL); _alpm_log(PM_LOG_DEBUG, "looking for file conflicts\n"); - alpm_list_t *conflict = _alpm_db_find_fileconflicts(db_local, trans, - trans->add, trans->remove); + alpm_list_t *conflict = _alpm_db_find_fileconflicts(handle, + trans->add, trans->remove); if(conflict) { if(data) { *data = conflict; @@ -955,7 +953,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) /* install targets */ _alpm_log(PM_LOG_DEBUG, "installing packages\n"); - if(_alpm_upgrade_packages(trans, handle->db_local) == -1) { + if(_alpm_upgrade_packages(handle) == -1) { _alpm_log(PM_LOG_ERROR, _("could not commit transaction\n")); return -1; } diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h index 90a2d40..3049dd2 100644 --- a/lib/libalpm/sync.h +++ b/lib/libalpm/sync.h @@ -24,8 +24,8 @@ #include "alpm.h" -int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data); -int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data); +int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data); +int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data); #endif /* _ALPM_SYNC_H */ diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 8e019cc..58bcc38 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -202,7 +202,7 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data) return -1; } } else { - if(_alpm_sync_prepare(trans, handle->db_local, handle->dbs_sync, data) == -1) { + if(_alpm_sync_prepare(handle, data) == -1) { /* pm_errno is set by _alpm_sync_prepare() */ return -1; } @@ -241,7 +241,7 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data) return -1; } } else { - if(_alpm_sync_commit(trans, handle->db_local, data) == -1) { + if(_alpm_sync_commit(handle, data) == -1) { /* pm_errno is set by _alpm_sync_commit() */ return -1; } -- 1.7.5.2
participants (3)
-
Dan McGee
-
Dan McGee
-
Rémy Oudompheng