summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorXavier Chantry <chantry.xavier@gmail.com>2010-10-17 19:45:31 +0200
committerXavier Chantry <chantry.xavier@gmail.com>2011-01-29 19:40:08 +0100
commite263cf7231c5d6ec41a15cd6230dbd794b58287a (patch)
tree1a543942b5a575af1193fd86b3b20ef7e999dac0 /lib/libalpm/sync.c
parent05f2abfba9d9e9055c5a2d0d7ae92d24f0dd1a2f (diff)
downloadpacman-e263cf7231c5d6ec41a15cd6230dbd794b58287a.tar.gz
pacman-e263cf7231c5d6ec41a15cd6230dbd794b58287a.tar.xz
alpm: drop old target interfaces
It's likely that these interfaces will break sooner or later, now that pacman no longer uses them. So better force the two people who use them to migrate their code to the new add_pkg/remove_pkg interface, which is very easy anyway. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c173
1 files changed, 0 insertions, 173 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 63cd4b7c..9f5bec3b 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -202,179 +202,6 @@ int SYMEXPORT alpm_sync_sysupgrade(int enable_downgrade)
return(0);
}
-static int sync_pkg(pmpkg_t *spkg, alpm_list_t *pkg_list)
-{
- pmtrans_t *trans;
- pmdb_t *db_local;
- pmpkg_t *local;
-
- ALPM_LOG_FUNC;
-
- trans = handle->trans;
- db_local = handle->db_local;
-
- if(_alpm_pkg_find(pkg_list, alpm_pkg_get_name(spkg))) {
- RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
- }
-
- local = _alpm_db_get_pkgfromcache(db_local, alpm_pkg_get_name(spkg));
- if(local) {
- int cmp = _alpm_pkg_compare_versions(spkg, local);
- if(cmp == 0) {
- if(trans->flags & PM_TRANS_FLAG_NEEDED) {
- /* with the NEEDED flag, packages up to date are not reinstalled */
- _alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"),
- alpm_pkg_get_name(local), alpm_pkg_get_version(local));
- return(0);
- } else {
- _alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- reinstalling\n"),
- alpm_pkg_get_name(local), alpm_pkg_get_version(local));
-
- }
- } else if(cmp < 0) {
- /* local version is newer */
- _alpm_log(PM_LOG_WARNING, _("downgrading package %s (%s => %s)\n"),
- alpm_pkg_get_name(local), alpm_pkg_get_version(local),
- alpm_pkg_get_version(spkg));
- }
- }
-
- /* add the package to the transaction */
- spkg->reason = PM_PKG_REASON_EXPLICIT;
- _alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
- alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
- trans->add = alpm_list_add(trans->add, spkg);
-
- return(0);
-}
-
-static int sync_group(alpm_list_t *dbs_sync, const char *target)
-{
- alpm_list_t *i, *j;
- alpm_list_t *known_pkgs = NULL;
- pmgrp_t *grp;
- int found = 0;
-
- ALPM_LOG_FUNC;
-
- _alpm_log(PM_LOG_DEBUG, "%s package not found, searching for group...\n", target);
- for(i = dbs_sync; i; i = i->next) {
- pmdb_t *db = i->data;
- grp = alpm_db_readgrp(db, target);
- if(grp) {
- found = 1;
- for(j = alpm_grp_get_pkgs(grp); j; j = j->next) {
- pmpkg_t *pkg = j->data;
-
- /* check if group member is ignored */
- if(_alpm_pkg_should_ignore(pkg)) {
- int install = 0;
- QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
- NULL, NULL, &install);
- if(install == 0) {
- _alpm_log(PM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg));
- continue;
- }
- }
-
- if(sync_pkg(pkg, known_pkgs) == -1) {
- if(pm_errno == PM_ERR_TRANS_DUP_TARGET || pm_errno == PM_ERR_PKG_IGNORED) {
- /* just skip duplicate or ignored targets */
- continue;
- } else {
- alpm_list_free(known_pkgs);
- return(-1);
- }
- }
- known_pkgs = alpm_list_add(known_pkgs, pkg);
- }
- }
- }
- alpm_list_free(known_pkgs);
-
- if(!found) {
- /* pass through any 'found but ignored' errors */
- if(pm_errno != PM_ERR_PKG_IGNORED) {
- pm_errno = PM_ERR_PKG_NOT_FOUND;
- }
- return(-1);
- }
-
- return(0);
-}
-
-static int sync_target(alpm_list_t *dbs_sync, const char *target)
-{
- pmpkg_t *spkg;
- pmdepend_t *dep; /* provisions and dependencies are also allowed */
-
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(target != NULL && strlen(target) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
-
- dep = _alpm_splitdep(target);
- spkg = _alpm_resolvedep(dep, dbs_sync, NULL, 1);
- _alpm_dep_free(dep);
-
- if(spkg != NULL) {
- return(sync_pkg(spkg, handle->trans->add));
- }
-
- return(sync_group(dbs_sync, target));
-}
-
-/** Add a sync target to the transaction.
- * @param target the name of the sync target to add
- * @return 0 on success, -1 on error (pm_errno is set accordingly)
- */
-int SYMEXPORT alpm_sync_dbtarget(const char *dbname, const char *target)
-{
- alpm_list_t *i;
- alpm_list_t *dbs_sync;
-
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
- dbs_sync = handle->dbs_sync;
-
- /* we are looking for a package in a specific database */
- alpm_list_t *dbs = NULL;
- _alpm_log(PM_LOG_DEBUG, "searching for target '%s' in repo '%s'\n", target, dbname);
- for(i = dbs_sync; i; i = i->next) {
- pmdb_t *db = i->data;
- if(strcmp(db->treename, dbname) == 0) {
- dbs = alpm_list_add(NULL, db);
- break;
- }
- }
- if(dbs == NULL) {
- RET_ERR(PM_ERR_PKG_REPO_NOT_FOUND, -1);
- }
- int ret = sync_target(dbs, target);
- alpm_list_free(dbs);
- return(ret);
-}
-
-/** Add a sync target to the transaction.
- * @param target the name of the sync target to add
- * @return 0 on success, -1 on error (pm_errno is set accordingly)
- */
-int SYMEXPORT alpm_sync_target(const char *target)
-{
- alpm_list_t *dbs_sync;
-
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
- dbs_sync = handle->dbs_sync;
-
- return(sync_target(dbs_sync,target));
-}
-
/** Find group members across a list of databases.
* If a member exists in several databases, only the first database is used.
* IgnorePkg is also handled.