From bdf00d3dbd19c3def6127f3d372d630930a26abb Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 16 Jun 2011 11:27:44 -0500 Subject: Make pmfileconflict_t type public This removes the need to write accessor methods for every type we have, and simplifies the API. Any type that doesn't need magic* can be converted in this fashion to make it easier for frontend applications to use, as well as make it less of a pain to introduce new such structs in the future. * "magic" meaning something like pmpkg_t where values can be lazy loaded. Signed-off-by: Dan McGee --- lib/libalpm/alpm.h | 36 +++++++++++++++++++----------------- lib/libalpm/conflict.c | 24 ------------------------ lib/libalpm/conflict.h | 7 ------- src/pacman/sync.c | 9 +++------ src/pacman/upgrade.c | 9 +++------ 5 files changed, 25 insertions(+), 60 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index bfc01e5c..4c44a361 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -50,7 +50,7 @@ extern "C" { */ /** - * Install reasons + * Install reasons. * Why the package was installed. */ typedef enum _pmpkgreason_t { @@ -60,6 +60,16 @@ typedef enum _pmpkgreason_t { PM_PKG_REASON_DEPEND = 1 } pmpkgreason_t; +/** + * File conflict type. + * Whether the conflict results from a file existing on the filesystem, or with + * another target in the transaction. + */ +typedef enum _pmfileconflicttype_t { + PM_FILECONFLICT_TARGET = 1, + PM_FILECONFLICT_FILESYSTEM +} pmfileconflicttype_t; + /** * GPG signature verification options */ @@ -83,7 +93,14 @@ typedef struct __pmtrans_t pmtrans_t; typedef struct __pmdepend_t pmdepend_t; typedef struct __pmdepmissing_t pmdepmissing_t; typedef struct __pmconflict_t pmconflict_t; -typedef struct __pmfileconflict_t pmfileconflict_t; + +/** File conflict */ +typedef struct _pmfileconflict_t { + char *target; + pmfileconflicttype_t type; + char *file; + char *ctarget; +} pmfileconflict_t; /* * Logging facilities @@ -944,21 +961,6 @@ char *alpm_dep_compute_string(const pmdepend_t *dep); /** @} */ -/** @addtogroup alpm_api_fileconflicts File Conflicts Functions - * Functions to manipulate file conflict information. - * @{ - */ - -typedef enum _pmfileconflicttype_t { - PM_FILECONFLICT_TARGET = 1, - PM_FILECONFLICT_FILESYSTEM -} pmfileconflicttype_t; - -const char *alpm_fileconflict_get_target(pmfileconflict_t *conflict); -pmfileconflicttype_t alpm_fileconflict_get_type(pmfileconflict_t *conflict); -const char *alpm_fileconflict_get_file(pmfileconflict_t *conflict); -const char *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict); - /** @} */ /* diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index a6bbe093..d9a0b7ca 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -565,28 +565,4 @@ const char SYMEXPORT *alpm_conflict_get_reason(pmconflict_t *conflict) return conflict->reason; } -const char SYMEXPORT *alpm_fileconflict_get_target(pmfileconflict_t *conflict) -{ - ASSERT(conflict != NULL, return NULL); - return conflict->target; -} - -pmfileconflicttype_t SYMEXPORT alpm_fileconflict_get_type(pmfileconflict_t *conflict) -{ - ASSERT(conflict != NULL, return -1); - return conflict->type; -} - -const char SYMEXPORT *alpm_fileconflict_get_file(pmfileconflict_t *conflict) -{ - ASSERT(conflict != NULL, return NULL); - return conflict->file; -} - -const char SYMEXPORT *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict) -{ - ASSERT(conflict != NULL, return NULL); - return conflict->ctarget; -} - /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h index 7a3784a2..a9d3e27b 100644 --- a/lib/libalpm/conflict.h +++ b/lib/libalpm/conflict.h @@ -30,13 +30,6 @@ struct __pmconflict_t { char *reason; }; -struct __pmfileconflict_t { - char *target; - pmfileconflicttype_t type; - char *file; - char *ctarget; -}; - pmconflict_t *_alpm_conflict_dup(const pmconflict_t *conflict); void _alpm_conflict_free(pmconflict_t *conflict); alpm_list_t *_alpm_innerconflicts(pmhandle_t *handle, alpm_list_t *packages); diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 37b9d6e3..2c21d573 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -849,17 +849,14 @@ static int sync_trans(alpm_list_t *targets) case PM_ERR_FILE_CONFLICTS: for(i = data; i; i = alpm_list_next(i)) { pmfileconflict_t *conflict = alpm_list_getdata(i); - switch(alpm_fileconflict_get_type(conflict)) { + switch(conflict->type) { case PM_FILECONFLICT_TARGET: printf(_("%s exists in both '%s' and '%s'\n"), - alpm_fileconflict_get_file(conflict), - alpm_fileconflict_get_target(conflict), - alpm_fileconflict_get_ctarget(conflict)); + conflict->file, conflict->target, conflict->ctarget); break; case PM_FILECONFLICT_FILESYSTEM: printf(_("%s: %s exists in filesystem\n"), - alpm_fileconflict_get_target(conflict), - alpm_fileconflict_get_file(conflict)); + conflict->target, conflict->file); break; } } diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index c0466456..37cf7007 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -173,17 +173,14 @@ int pacman_upgrade(alpm_list_t *targets) case PM_ERR_FILE_CONFLICTS: for(i = data; i; i = alpm_list_next(i)) { pmfileconflict_t *conflict = alpm_list_getdata(i); - switch(alpm_fileconflict_get_type(conflict)) { + switch(conflict->type) { case PM_FILECONFLICT_TARGET: printf(_("%s exists in both '%s' and '%s'\n"), - alpm_fileconflict_get_file(conflict), - alpm_fileconflict_get_target(conflict), - alpm_fileconflict_get_ctarget(conflict)); + conflict->file, conflict->target, conflict->ctarget); break; case PM_FILECONFLICT_FILESYSTEM: printf(_("%s: %s exists in filesystem\n"), - alpm_fileconflict_get_target(conflict), - alpm_fileconflict_get_file(conflict)); + conflict->target, conflict->file); break; } } -- cgit v1.2.3-70-g09d2 From 19fcc7401666cd892f7b8a5a49854a1b2eb9988b Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 16 Jun 2011 11:33:20 -0500 Subject: Make struct pmconflict_t public Signed-off-by: Dan McGee --- lib/libalpm/alpm.h | 12 +++++++----- lib/libalpm/conflict.c | 18 ------------------ lib/libalpm/conflict.h | 6 ------ src/pacman/sync.c | 12 ++++++------ src/pacman/upgrade.c | 13 ++++++------- src/util/testdb.c | 4 ++-- 6 files changed, 21 insertions(+), 44 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 4c44a361..0fd6f37e 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -92,7 +92,13 @@ typedef struct __pmgrp_t pmgrp_t; typedef struct __pmtrans_t pmtrans_t; typedef struct __pmdepend_t pmdepend_t; typedef struct __pmdepmissing_t pmdepmissing_t; -typedef struct __pmconflict_t pmconflict_t; + +/** Conflict */ +typedef struct _pmconflict_t { + char *package1; + char *package2; + char *reason; +} pmconflict_t; /** File conflict */ typedef struct _pmfileconflict_t { @@ -928,10 +934,6 @@ const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss); alpm_list_t *alpm_checkconflicts(pmhandle_t *handle, alpm_list_t *pkglist); -const char *alpm_conflict_get_package1(pmconflict_t *conflict); -const char *alpm_conflict_get_package2(pmconflict_t *conflict); -const char *alpm_conflict_get_reason(pmconflict_t *conflict); - /** Returns the type of version constraint. * @param dep a dependency info structure * @return the type of version constraint (PM_DEP_MOD_ANY if no version diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index d9a0b7ca..39f42bfe 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -547,22 +547,4 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle, return conflicts; } -const char SYMEXPORT *alpm_conflict_get_package1(pmconflict_t *conflict) -{ - ASSERT(conflict != NULL, return NULL); - return conflict->package1; -} - -const char SYMEXPORT *alpm_conflict_get_package2(pmconflict_t *conflict) -{ - ASSERT(conflict != NULL, return NULL); - return conflict->package2; -} - -const char SYMEXPORT *alpm_conflict_get_reason(pmconflict_t *conflict) -{ - ASSERT(conflict != NULL, return NULL); - return conflict->reason; -} - /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h index a9d3e27b..546a2820 100644 --- a/lib/libalpm/conflict.h +++ b/lib/libalpm/conflict.h @@ -24,12 +24,6 @@ #include "db.h" #include "package.h" -struct __pmconflict_t { - char *package1; - char *package2; - char *reason; -}; - pmconflict_t *_alpm_conflict_dup(const pmconflict_t *conflict); void _alpm_conflict_free(pmconflict_t *conflict); alpm_list_t *_alpm_innerconflicts(pmhandle_t *handle, alpm_list_t *packages); diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2c21d573..254117a7 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -795,14 +795,14 @@ static int sync_trans(alpm_list_t *targets) case PM_ERR_CONFLICTING_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmconflict_t *conflict = alpm_list_getdata(i); - const char *package1 = alpm_conflict_get_package1(conflict); - const char *package2 = alpm_conflict_get_package2(conflict); - const char *reason = alpm_conflict_get_reason(conflict); /* only print reason if it contains new information */ - if(strcmp(package1, reason) == 0 || strcmp(package2, reason) == 0) { - printf(_(":: %s and %s are in conflict\n"), package1, package2); + if(strcmp(conflict->package1, conflict->reason) == 0 || + strcmp(conflict->package2, conflict->reason) == 0) { + printf(_(":: %s and %s are in conflict\n"), + conflict->package1, conflict->package2); } else { - printf(_(":: %s and %s are in conflict (%s)\n"), package1, package2, reason); + printf(_(":: %s and %s are in conflict (%s)\n"), + conflict->package1, conflict->package2, conflict->reason); } } break; diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 37cf7007..0abcbe4e 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -121,14 +121,13 @@ int pacman_upgrade(alpm_list_t *targets) case PM_ERR_CONFLICTING_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmconflict_t *conflict = alpm_list_getdata(i); - const char *package1 = alpm_conflict_get_package1(conflict); - const char *package2 = alpm_conflict_get_package2(conflict); - const char *reason = alpm_conflict_get_reason(conflict); - /* only print reason if it contains new information */ - if(strcmp(package1, reason) == 0 || strcmp(package2, reason) == 0) { - printf(_(":: %s and %s are in conflict\n"), package1, package2); + if(strcmp(conflict->package1, conflict->reason) == 0 || + strcmp(conflict->package2, conflict->reason) == 0) { + printf(_(":: %s and %s are in conflict\n"), + conflict->package1, conflict->package2); } else { - printf(_(":: %s and %s are in conflict (%s)\n"), package1, package2, reason); + printf(_(":: %s and %s are in conflict (%s)\n"), + conflict->package1, conflict->package2, conflict->reason); } } break; diff --git a/src/util/testdb.c b/src/util/testdb.c index 0bd78202..aeccdb7c 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -120,8 +120,8 @@ static int checkconflicts(alpm_list_t *pkglist) data = alpm_checkconflicts(handle, pkglist); for(i = data; i; i = i->next) { pmconflict_t *conflict = alpm_list_getdata(i); - printf("%s conflicts with %s\n", alpm_conflict_get_package1(conflict), - alpm_conflict_get_package2(conflict)); + printf("%s conflicts with %s\n", + conflict->package1, conflict->package2); ret++; } FREELIST(data); -- cgit v1.2.3-70-g09d2 From 7f6c1a76c66fb718fad2ecce68f99ee13d18ff15 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 16 Jun 2011 11:42:10 -0500 Subject: Make pmdepend_t and pmdepmissing_t public Signed-off-by: Dan McGee --- lib/libalpm/alpm.h | 75 ++++++++++++++++++++++------------------------------ lib/libalpm/deps.c | 38 +------------------------- lib/libalpm/deps.h | 15 ----------- src/pacman/remove.c | 6 ++--- src/pacman/sync.c | 6 ++--- src/pacman/upgrade.c | 6 ++--- src/util/pactree.c | 8 +++--- src/util/testdb.c | 5 ++-- 8 files changed, 45 insertions(+), 114 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 0fd6f37e..08a7a1f3 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -60,6 +60,22 @@ typedef enum _pmpkgreason_t { PM_PKG_REASON_DEPEND = 1 } pmpkgreason_t; +/** Types of version constraints in dependency specs. */ +typedef enum _pmdepmod_t { + /** No version constraint */ + PM_DEP_MOD_ANY = 1, + /** Test version equality (package=x.y.z) */ + PM_DEP_MOD_EQ, + /** Test for at least a version (package>=x.y.z) */ + PM_DEP_MOD_GE, + /** Test for at most a version (package<=x.y.z) */ + PM_DEP_MOD_LE, + /** Test for greater than some version (package>x.y.z) */ + PM_DEP_MOD_GT, + /** Test for less than some version (package=x.y.z) */ - PM_DEP_MOD_GE, - /** Test for at most a version (package<=x.y.z) */ - PM_DEP_MOD_LE, - /** Test for greater than some version (package>x.y.z) */ - PM_DEP_MOD_GT, - /** Test for less than some version (package=2.12" diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 10c0009d..085e6ca9 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -719,7 +719,7 @@ int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg, for(j = deps; j; j = j->next) { pmdepmissing_t *miss = j->data; - pmdepend_t *missdep = alpm_miss_get_dep(miss); + pmdepend_t *missdep = miss->depend; /* check if one of the packages in the [*packages] list already satisfies * this dependency */ if(find_dep_satisfier(*packages, missdep)) { @@ -764,42 +764,6 @@ int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg, return ret; } -const char SYMEXPORT *alpm_miss_get_target(const pmdepmissing_t *miss) -{ - ASSERT(miss != NULL, return NULL); - return miss->target; -} - -const char SYMEXPORT *alpm_miss_get_causingpkg(const pmdepmissing_t *miss) -{ - ASSERT(miss != NULL, return NULL); - return miss->causingpkg; -} - -pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss) -{ - ASSERT(miss != NULL, return NULL); - return miss->depend; -} - -pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep) -{ - ASSERT(dep != NULL, return -1); - return dep->mod; -} - -const char SYMEXPORT *alpm_dep_get_name(const pmdepend_t *dep) -{ - ASSERT(dep != NULL, return NULL); - return dep->name; -} - -const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep) -{ - ASSERT(dep != NULL, return NULL); - return dep->version; -} - /** Reverse of splitdep; make a dep string from a pmdepend_t struct. * The string must be freed! * @param dep the depend to turn into a string diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h index 97c0918e..ecc3b92c 100644 --- a/lib/libalpm/deps.h +++ b/lib/libalpm/deps.h @@ -27,21 +27,6 @@ #include "package.h" #include "alpm.h" -/* Dependency */ -struct __pmdepend_t { - char *name; - char *version; - unsigned long name_hash; - pmdepmod_t mod; -}; - -/* Missing dependency */ -struct __pmdepmissing_t { - char *target; - pmdepend_t *depend; - char *causingpkg; /* this is used in case of remove dependency error only */ -}; - void _alpm_dep_free(pmdepend_t *dep); pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep); void _alpm_depmiss_free(pmdepmissing_t *miss); diff --git a/src/pacman/remove.c b/src/pacman/remove.c index a4e18941..2ce33b8a 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -115,10 +115,8 @@ int pacman_remove(alpm_list_t *targets) case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); - pmdepend_t *dep = alpm_miss_get_dep(miss); - char *depstring = alpm_dep_compute_string(dep); - printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), - depstring); + char *depstring = alpm_dep_compute_string(miss->depend); + printf(_(":: %s: requires %s\n"), miss->target, depstring); free(depstring); } break; diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 254117a7..177eab64 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -785,10 +785,8 @@ static int sync_trans(alpm_list_t *targets) case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); - pmdepend_t *dep = alpm_miss_get_dep(miss); - char *depstring = alpm_dep_compute_string(dep); - printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), - depstring); + char *depstring = alpm_dep_compute_string(miss->depend); + printf(_(":: %s: requires %s\n"), miss->target, depstring); free(depstring); } break; diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 0abcbe4e..6587671b 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -107,14 +107,12 @@ int pacman_upgrade(alpm_list_t *targets) case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); - pmdepend_t *dep = alpm_miss_get_dep(miss); - char *depstring = alpm_dep_compute_string(dep); + char *depstring = alpm_dep_compute_string(miss->depend); /* TODO indicate if the error was a virtual package or not: * :: %s: requires %s, provided by %s */ - printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), - depstring); + printf(_(":: %s: requires %s\n"), miss->target, depstring); free(depstring); } break; diff --git a/src/util/pactree.c b/src/util/pactree.c index 1dee61bf..6b29d935 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -290,7 +290,7 @@ static void walk_deps(pmpkg_t *pkg, int depth) for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) { pmdepend_t *depend = alpm_list_getdata(i); pmpkg_t *provider = alpm_find_satisfier(alpm_db_get_pkgcache(db_local), - alpm_dep_get_name(depend)); + depend->name); if(provider) { const char *provname = alpm_pkg_get_name(provider); @@ -299,15 +299,15 @@ static void walk_deps(pmpkg_t *pkg, int depth) /* if we've already seen this package, don't print in "unique" output * and don't recurse */ if(!unique) { - print(alpm_pkg_get_name(pkg), provname, alpm_dep_get_name(depend), depth); + print(alpm_pkg_get_name(pkg), provname, depend->name, depth); } } else { - print(alpm_pkg_get_name(pkg), provname, alpm_dep_get_name(depend), depth); + print(alpm_pkg_get_name(pkg), provname, depend->name, depth); walk_deps(provider, depth + 1); } } else { /* unresolvable package */ - print(alpm_pkg_get_name(pkg), NULL, alpm_dep_get_name(depend), depth); + print(alpm_pkg_get_name(pkg), NULL, depend->name, depth); } } } diff --git a/src/util/testdb.c b/src/util/testdb.c index aeccdb7c..4937480d 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -101,9 +101,8 @@ static int checkdeps(alpm_list_t *pkglist) data = alpm_checkdeps(handle, pkglist, NULL, pkglist, 0); for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); - pmdepend_t *dep = alpm_miss_get_dep(miss); - char *depstring = alpm_dep_compute_string(dep); - printf("missing dependency for %s : %s\n", alpm_miss_get_target(miss), + char *depstring = alpm_dep_compute_string(miss->depend); + printf("missing dependency for %s : %s\n", miss->target, depstring); free(depstring); ret++; -- cgit v1.2.3-70-g09d2 From 51359e6d33cf2f3f3acf95ad526c5b22e39d86cf Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 16 Jun 2011 11:49:34 -0500 Subject: Make pmdelta_t public Signed-off-by: Dan McGee --- lib/libalpm/alpm.h | 27 ++++++++++++++++----------- lib/libalpm/delta.c | 43 ++++++------------------------------------- lib/libalpm/delta.h | 15 --------------- lib/libalpm/sync.c | 8 +++----- 4 files changed, 25 insertions(+), 68 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 08a7a1f3..17194f0d 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -103,7 +103,6 @@ typedef enum _pgp_verify_t { typedef struct __pmhandle_t pmhandle_t; typedef struct __pmdb_t pmdb_t; typedef struct __pmpkg_t pmpkg_t; -typedef struct __pmdelta_t pmdelta_t; typedef struct __pmgrp_t pmgrp_t; typedef struct __pmtrans_t pmtrans_t; @@ -138,6 +137,22 @@ typedef struct _pmfileconflict_t { char *ctarget; } pmfileconflict_t; +/** Package upgrade delta */ +typedef struct _pmdelta_t { + /** filename of the delta patch */ + char *delta; + /** md5sum of the delta file */ + char *delta_md5; + /** filename of the 'before' file */ + char *from; + /** filename of the 'after' file */ + char *to; + /** filesize of the delta file */ + off_t delta_size; + /** download filesize of the delta file */ + off_t download_size; +} pmdelta_t; + /* * Logging facilities */ @@ -666,16 +681,6 @@ int alpm_pkg_check_pgp_signature(pmpkg_t *pkg); int alpm_db_check_pgp_signature(pmdb_t *db); int alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify); -/* - * Deltas - */ - -const char *alpm_delta_get_from(pmdelta_t *delta); -const char *alpm_delta_get_to(pmdelta_t *delta); -const char *alpm_delta_get_filename(pmdelta_t *delta); -const char *alpm_delta_get_md5sum(pmdelta_t *delta); -off_t alpm_delta_get_size(pmdelta_t *delta); - /* * Groups */ diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index aa76b492..fed84f45 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c @@ -34,43 +34,6 @@ #include "log.h" #include "graph.h" -/** \addtogroup alpm_deltas Delta Functions - * @brief Functions to manipulate libalpm deltas - * @{ - */ - -const char SYMEXPORT *alpm_delta_get_from(pmdelta_t *delta) -{ - ASSERT(delta != NULL, return NULL); - return delta->from; -} - -const char SYMEXPORT *alpm_delta_get_to(pmdelta_t *delta) -{ - ASSERT(delta != NULL, return NULL); - return delta->to; -} - -const char SYMEXPORT *alpm_delta_get_filename(pmdelta_t *delta) -{ - ASSERT(delta != NULL, return NULL); - return delta->delta; -} - -const char SYMEXPORT *alpm_delta_get_md5sum(pmdelta_t *delta) -{ - ASSERT(delta != NULL, return NULL); - return delta->delta_md5; -} - -off_t SYMEXPORT alpm_delta_get_size(pmdelta_t *delta) -{ - ASSERT(delta != NULL, return -1); - return delta->delta_size; -} - -/** @} */ - static alpm_list_t *graph_init(alpm_list_t *deltas, int reverse) { alpm_list_t *i, *j; @@ -279,6 +242,11 @@ static alpm_list_t *find_unused(alpm_list_t *deltas, const char *to, off_t quota return unused; } +/** \addtogroup alpm_deltas Delta Functions + * @brief Functions to manipulate libalpm deltas + * @{ + */ + alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(pmpkg_t *pkg) { off_t pkgsize = alpm_pkg_get_size(pkg); @@ -289,6 +257,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(pmpkg_t *pkg) return unused; } +/** @} */ /** Parses the string representation of a pmdelta_t object. * This function assumes that the string is in the correct format. diff --git a/lib/libalpm/delta.h b/lib/libalpm/delta.h index d7725f5a..87869256 100644 --- a/lib/libalpm/delta.h +++ b/lib/libalpm/delta.h @@ -26,21 +26,6 @@ #include "alpm.h" -struct __pmdelta_t { - /** filename of the delta patch */ - char *delta; - /** md5sum of the delta file */ - char *delta_md5; - /** filename of the 'before' file */ - char *from; - /** filename of the 'after' file */ - char *to; - /** filesize of the delta file */ - off_t delta_size; - /** download filesize of the delta file */ - off_t download_size; -}; - pmdelta_t *_alpm_delta_parse(char *line); void _alpm_delta_free(pmdelta_t *delta); off_t _alpm_shortest_delta_path(pmhandle_t *handle, alpm_list_t *deltas, diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 05735730..6b3ddfe8 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -705,13 +705,11 @@ static int validate_deltas(pmhandle_t *handle, alpm_list_t *deltas, for(i = deltas; i; i = i->next) { pmdelta_t *d = alpm_list_getdata(i); - const char *filename = alpm_delta_get_filename(d); - char *filepath = _alpm_filecache_find(handle, filename); - const char *md5sum = alpm_delta_get_md5sum(d); + char *filepath = _alpm_filecache_find(handle, d->delta); - if(test_md5sum(trans, filepath, md5sum) != 0) { + if(test_md5sum(trans, filepath, d->delta_md5) != 0) { errors++; - *data = alpm_list_add(*data, strdup(filename)); + *data = alpm_list_add(*data, strdup(d->delta)); } FREE(filepath); } -- cgit v1.2.3-70-g09d2 From 25b7df4dab61e908a0f86e3aad51f1f5c9ed2ccb Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 16 Jun 2011 11:55:26 -0500 Subject: Make pmgrp_t public Signed-off-by: Dan McGee --- lib/libalpm/alpm.h | 12 +++++++++--- lib/libalpm/group.c | 12 ------------ lib/libalpm/group.h | 7 ------- lib/libalpm/sync.c | 2 +- src/pacman/query.c | 15 ++++++--------- src/pacman/remove.c | 2 +- src/pacman/sync.c | 9 ++++----- 7 files changed, 21 insertions(+), 38 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 17194f0d..d1faf7fe 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -103,7 +103,6 @@ typedef enum _pgp_verify_t { typedef struct __pmhandle_t pmhandle_t; typedef struct __pmdb_t pmdb_t; typedef struct __pmpkg_t pmpkg_t; -typedef struct __pmgrp_t pmgrp_t; typedef struct __pmtrans_t pmtrans_t; /** Dependency */ @@ -137,6 +136,14 @@ typedef struct _pmfileconflict_t { char *ctarget; } pmfileconflict_t; +/** Package group */ +typedef struct _pmgrp_t { + /** group name */ + char *name; + /** list of pmpkg_t packages */ + alpm_list_t *packages; +} pmgrp_t; + /** Package upgrade delta */ typedef struct _pmdelta_t { /** filename of the delta patch */ @@ -684,8 +691,7 @@ int alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify); /* * Groups */ -const char *alpm_grp_get_name(const pmgrp_t *grp); -alpm_list_t *alpm_grp_get_pkgs(const pmgrp_t *grp); + alpm_list_t *alpm_find_grp_pkgs(alpm_list_t *dbs, const char *name); /* diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c index 13a216ee..07acfa89 100644 --- a/lib/libalpm/group.c +++ b/lib/libalpm/group.c @@ -52,16 +52,4 @@ void _alpm_grp_free(pmgrp_t *grp) FREE(grp); } -const char SYMEXPORT *alpm_grp_get_name(const pmgrp_t *grp) -{ - ASSERT(grp != NULL, return NULL); - return grp->name; -} - -alpm_list_t SYMEXPORT *alpm_grp_get_pkgs(const pmgrp_t *grp) -{ - ASSERT(grp != NULL, return NULL); - return grp->packages; -} - /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libalpm/group.h b/lib/libalpm/group.h index c92684e3..f2a67ca9 100644 --- a/lib/libalpm/group.h +++ b/lib/libalpm/group.h @@ -22,13 +22,6 @@ #include "alpm.h" -struct __pmgrp_t { - /** group name */ - char *name; - /** list of pmpkg_t packages */ - alpm_list_t *packages; -}; - pmgrp_t *_alpm_grp_new(const char *name); void _alpm_grp_free(pmgrp_t *grp); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 6b3ddfe8..15f135ba 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -225,7 +225,7 @@ alpm_list_t SYMEXPORT *alpm_find_grp_pkgs(alpm_list_t *dbs, if(!grp) continue; - for(j = alpm_grp_get_pkgs(grp); j; j = j->next) { + for(j = grp->packages; j; j = j->next) { pmpkg_t *pkg = j->data; if(_alpm_pkg_find(ignorelist, alpm_pkg_get_name(pkg))) { diff --git a/src/pacman/query.c b/src/pacman/query.c index 06fd704a..aa779075 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -304,14 +304,11 @@ static int query_group(alpm_list_t *targets) if(targets == NULL) { for(j = alpm_db_get_grpcache(db_local); j; j = alpm_list_next(j)) { pmgrp_t *grp = alpm_list_getdata(j); - const alpm_list_t *p, *packages; - const char *grpname; + const alpm_list_t *p; - grpname = alpm_grp_get_name(grp); - packages = alpm_grp_get_pkgs(grp); - - for(p = packages; p; p = alpm_list_next(p)) { - printf("%s %s\n", grpname, alpm_pkg_get_name(alpm_list_getdata(p))); + for(p = grp->packages; p; p = alpm_list_next(p)) { + pmpkg_t *pkg = alpm_list_getdata(p); + printf("%s %s\n", grp->name, alpm_pkg_get_name(pkg)); } } } else { @@ -320,8 +317,8 @@ static int query_group(alpm_list_t *targets) grpname = alpm_list_getdata(i); grp = alpm_db_readgrp(db_local, grpname); if(grp) { - const alpm_list_t *p, *packages = alpm_grp_get_pkgs(grp); - for(p = packages; p; p = alpm_list_next(p)) { + const alpm_list_t *p; + for(p = grp->packages; p; p = alpm_list_next(p)) { if(!config->quiet) { printf("%s %s\n", grpname, alpm_pkg_get_name(alpm_list_getdata(p))); diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 2ce33b8a..60027ae2 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -52,7 +52,7 @@ static int remove_target(const char *target) pm_fprintf(stderr, PM_LOG_ERROR, "'%s': target not found\n", target); return -1; } - for(p = alpm_grp_get_pkgs(grp); p; p = alpm_list_next(p)) { + for(p = grp->packages; p; p = alpm_list_next(p)) { pmpkg_t *pkg = alpm_list_getdata(p); if(alpm_remove_pkg(config->handle, pkg) == -1) { pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 177eab64..acb8a333 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -409,7 +409,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) if(grp) { /* get names of packages in group */ - for(k = alpm_grp_get_pkgs(grp); k; k = alpm_list_next(k)) { + for(k = grp->packages; k; k = alpm_list_next(k)) { if(!config->quiet) { printf("%s %s\n", grpname, alpm_pkg_get_name(alpm_list_getdata(k))); @@ -426,16 +426,15 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) for(j = alpm_db_get_grpcache(db); j; j = alpm_list_next(j)) { pmgrp_t *grp = alpm_list_getdata(j); - const char *grpname = alpm_grp_get_name(grp); if(level > 1) { - for(k = alpm_grp_get_pkgs(grp); k; k = alpm_list_next(k)) { - printf("%s %s\n", grpname, + for(k = grp->packages; k; k = alpm_list_next(k)) { + printf("%s %s\n", grp->name, alpm_pkg_get_name(alpm_list_getdata(k))); } } else { /* print grp names only, no package names */ - printf("%s\n", grpname); + printf("%s\n", grp->name); } } } -- cgit v1.2.3-70-g09d2