diff options
author | Dan McGee <dan@archlinux.org> | 2011-09-03 05:07:06 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-09-03 05:07:06 +0200 |
commit | 7ea1ea88bbca64514d5aad64fe199191f0f2eea1 (patch) | |
tree | c4dfe60e65540a2606fb0d704e8b9b7a05ccb24a /lib/libalpm | |
parent | 7c956d5d4bdf89bfece1244baa56a92f83bd9161 (diff) | |
download | pacman-7ea1ea88bbca64514d5aad64fe199191f0f2eea1.tar.gz pacman-7ea1ea88bbca64514d5aad64fe199191f0f2eea1.tar.xz |
More package operations cleanup
Neither deltas nor filename attributes are ever present in the local
database, so we can remove all of the indirection for accessing these
attributes.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r-- | lib/libalpm/be_local.c | 14 | ||||
-rw-r--r-- | lib/libalpm/delta.c | 5 | ||||
-rw-r--r-- | lib/libalpm/package.c | 11 | ||||
-rw-r--r-- | lib/libalpm/package.h | 7 | ||||
-rw-r--r-- | lib/libalpm/signing.c | 2 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 18 |
6 files changed, 12 insertions, 45 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index ba415448..80711df7 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -57,12 +57,6 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq); * initialized. */ -static const char *_cache_get_filename(alpm_pkg_t *pkg) -{ - LAZY_LOAD(INFRQ_DESC, NULL); - return pkg->filename; -} - static const char *_cache_get_desc(alpm_pkg_t *pkg) { LAZY_LOAD(INFRQ_DESC, NULL); @@ -159,12 +153,6 @@ static alpm_list_t *_cache_get_replaces(alpm_pkg_t *pkg) return pkg->replaces; } -/* local packages can not have deltas */ -static alpm_list_t *_cache_get_deltas(alpm_pkg_t UNUSED *pkg) -{ - return NULL; -} - static alpm_filelist_t *_cache_get_files(alpm_pkg_t *pkg) { LAZY_LOAD(INFRQ_FILES, NULL); @@ -230,7 +218,6 @@ static int _cache_force_load(alpm_pkg_t *pkg) * logic. */ static struct pkg_operations local_pkg_ops = { - .get_filename = _cache_get_filename, .get_desc = _cache_get_desc, .get_url = _cache_get_url, .get_builddate = _cache_get_builddate, @@ -247,7 +234,6 @@ static struct pkg_operations local_pkg_ops = { .get_conflicts = _cache_get_conflicts, .get_provides = _cache_get_provides, .get_replaces = _cache_get_replaces, - .get_deltas = _cache_get_deltas, .get_files = _cache_get_files, .get_backup = _cache_get_backup, diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index 1dd2bf44..1ff4fde6 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c @@ -250,10 +250,7 @@ static alpm_list_t *find_unused(alpm_list_t *deltas, const char *to, off_t quota alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return NULL); - return find_unused( - alpm_pkg_get_deltas(pkg), - alpm_pkg_get_filename(pkg), - pkg->size * MAX_DELTA_RATIO); + return find_unused(pkg->deltas, pkg->filename, pkg->size * MAX_DELTA_RATIO); } /** @} */ diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 56788808..30458576 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -67,7 +67,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg) ASSERT(pkg->origin == PKG_FROM_SYNCDB, RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1)); - fpath = _alpm_filecache_find(pkg->handle, alpm_pkg_get_filename(pkg)); + fpath = _alpm_filecache_find(pkg->handle, pkg->filename); retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_CSUM_MD5); @@ -85,7 +85,6 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg) * backend logic that needs lazy access, such as the local database through * a lazy-load cache. However, the defaults will work just fine for fully- * populated package structures. */ -static const char *_pkg_get_filename(alpm_pkg_t *pkg) { return pkg->filename; } static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; } static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; } static time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; } @@ -103,7 +102,6 @@ static alpm_list_t *_pkg_get_optdepends(alpm_pkg_t *pkg) { return pkg->optdepend static alpm_list_t *_pkg_get_conflicts(alpm_pkg_t *pkg) { return pkg->conflicts; } static alpm_list_t *_pkg_get_provides(alpm_pkg_t *pkg) { return pkg->provides; } static alpm_list_t *_pkg_get_replaces(alpm_pkg_t *pkg) { return pkg->replaces; } -static alpm_list_t *_pkg_get_deltas(alpm_pkg_t *pkg) { return pkg->deltas; } static alpm_filelist_t *_pkg_get_files(alpm_pkg_t *pkg) { return &(pkg->files); } static alpm_list_t *_pkg_get_backup(alpm_pkg_t *pkg) { return pkg->backup; } @@ -130,7 +128,6 @@ static int _pkg_force_load(alpm_pkg_t UNUSED *pkg) { return 0; } * struct itself with no abstraction layer or any type of lazy loading. */ struct pkg_operations default_pkg_ops = { - .get_filename = _pkg_get_filename, .get_desc = _pkg_get_desc, .get_url = _pkg_get_url, .get_builddate = _pkg_get_builddate, @@ -148,7 +145,6 @@ struct pkg_operations default_pkg_ops = { .get_conflicts = _pkg_get_conflicts, .get_provides = _pkg_get_provides, .get_replaces = _pkg_get_replaces, - .get_deltas = _pkg_get_deltas, .get_files = _pkg_get_files, .get_backup = _pkg_get_backup, @@ -166,7 +162,7 @@ const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return NULL); pkg->handle->pm_errno = 0; - return pkg->ops->get_filename(pkg); + return pkg->filename; } const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg) @@ -256,6 +252,7 @@ const char SYMEXPORT *alpm_pkg_get_arch(alpm_pkg_t *pkg) off_t SYMEXPORT alpm_pkg_get_size(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return -1); + pkg->handle->pm_errno = 0; return pkg->size; } @@ -326,7 +323,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_deltas(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return NULL); pkg->handle->pm_errno = 0; - return pkg->ops->get_deltas(pkg); + return pkg->deltas; } alpm_filelist_t SYMEXPORT *alpm_pkg_get_files(alpm_pkg_t *pkg) diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 4680375a..41dd84b9 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -42,7 +42,6 @@ * defined default_pkg_ops struct to work just fine for their needs. */ struct pkg_operations { - const char *(*get_filename) (alpm_pkg_t *); const char *(*get_desc) (alpm_pkg_t *); const char *(*get_url) (alpm_pkg_t *); time_t (*get_builddate) (alpm_pkg_t *); @@ -60,7 +59,6 @@ struct pkg_operations { alpm_list_t *(*get_conflicts) (alpm_pkg_t *); alpm_list_t *(*get_provides) (alpm_pkg_t *); alpm_list_t *(*get_replaces) (alpm_pkg_t *); - alpm_list_t *(*get_deltas) (alpm_pkg_t *); alpm_filelist_t *(*get_files) (alpm_pkg_t *); alpm_list_t *(*get_backup) (alpm_pkg_t *); @@ -69,11 +67,6 @@ struct pkg_operations { int (*changelog_close) (const alpm_pkg_t *, void *); int (*force_load) (alpm_pkg_t *); - - /* still to add: - * checkmd5sum() ? - * compute_requiredby() - */ }; /** The standard package operations struct. get fields directly from the diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index 349de491..b7e8c9a8 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -511,7 +511,7 @@ int SYMEXPORT alpm_pkg_check_pgp_signature(alpm_pkg_t *pkg, ASSERT(siglist != NULL, RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1)); pkg->handle->pm_errno = 0; - return _alpm_gpgme_checksig(pkg->handle, alpm_pkg_get_filename(pkg), + return _alpm_gpgme_checksig(pkg->handle, pkg->filename, pkg->base64_sig, siglist); } diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index d50ae842..e2562c08 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -284,7 +284,6 @@ alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs, */ static int compute_download_size(alpm_pkg_t *newpkg) { - const char *fname; char *fpath; off_t size = 0; alpm_handle_t *handle = newpkg->handle; @@ -295,9 +294,8 @@ static int compute_download_size(alpm_pkg_t *newpkg) return 0; } - fname = alpm_pkg_get_filename(newpkg); - ASSERT(fname != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1)); - fpath = _alpm_filecache_find(handle, fname); + ASSERT(newpkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1)); + fpath = _alpm_filecache_find(handle, newpkg->filename); if(fpath) { FREE(fpath); @@ -305,10 +303,8 @@ static int compute_download_size(alpm_pkg_t *newpkg) } else if(handle->usedelta) { off_t dltsize; - dltsize = _alpm_shortest_delta_path(handle, - alpm_pkg_get_deltas(newpkg), - alpm_pkg_get_filename(newpkg), - &newpkg->delta_path); + dltsize = _alpm_shortest_delta_path(handle, newpkg->deltas, + newpkg->filename, &newpkg->delta_path); if(newpkg->delta_path && (dltsize < newpkg->size * MAX_DELTA_RATIO)) { _alpm_log(handle, ALPM_LOG_DEBUG, "using delta size\n"); @@ -934,7 +930,6 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) for(i = trans->add; i; i = i->next, current++) { alpm_pkg_t *spkg = i->data; - const char *filename; char *filepath; alpm_siglevel_t level; int percent = (int)(((double)current_bytes / total_bytes) * 100); @@ -946,8 +941,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) } current_bytes += spkg->size; - filename = alpm_pkg_get_filename(spkg); - filepath = _alpm_filecache_find(handle, filename); + filepath = _alpm_filecache_find(handle, spkg->filename); alpm_db_t *sdb = alpm_pkg_get_db(spkg); level = alpm_db_get_siglevel(sdb); @@ -960,7 +954,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) if(!pkgfile) { prompt_to_delete(handle, filepath, handle->pm_errno); errors++; - *data = alpm_list_add(*data, strdup(filename)); + *data = alpm_list_add(*data, strdup(spkg->filename)); FREE(filepath); continue; } |