summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libalpm/add.c29
-rw-r--r--lib/libalpm/add.h1
-rw-r--r--lib/libalpm/alpm.h10
-rw-r--r--lib/libalpm/remove.c42
-rw-r--r--lib/libalpm/remove.h2
-rw-r--r--lib/libalpm/sync.c164
-rw-r--r--lib/libalpm/sync.h3
-rw-r--r--lib/libalpm/trans.c94
-rw-r--r--src/pacman/remove.c49
-rw-r--r--src/pacman/sync.c76
-rw-r--r--src/pacman/upgrade.c2
11 files changed, 205 insertions, 267 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 1609c5c3..268ecd7d 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -50,21 +50,30 @@
#include "remove.h"
#include "handle.h"
-int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
+/** Add a file target to the transaction.
+ * @param target the name of the file target to add
+ * @return 0 on success, -1 on error (pm_errno is set accordingly)
+ */
+int SYMEXPORT alpm_add_target(char *target)
{
pmpkg_t *pkg = NULL;
const char *pkgname, *pkgver;
alpm_list_t *i;
+ pmtrans_t *trans;
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));
+ trans = 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));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
- ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
- ASSERT(name != NULL && strlen(name) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- _alpm_log(PM_LOG_DEBUG, "loading target '%s'\n", name);
+ _alpm_log(PM_LOG_DEBUG, "loading target '%s'\n", target);
- if(alpm_pkg_load(name, 1, &pkg) != 0) {
+ if(alpm_pkg_load(target, 1, &pkg) != 0) {
goto error;
}
pkgname = alpm_pkg_get_name(pkg);
@@ -76,13 +85,15 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
pmpkg_t *transpkg = i->data;
if(strcmp(transpkg->name, pkgname) == 0) {
if(alpm_pkg_vercmp(transpkg->version, pkgver) < 0) {
- _alpm_log(PM_LOG_WARNING, _("replacing older version %s-%s by %s in target list\n"),
- transpkg->name, transpkg->version, pkgver);
+ _alpm_log(PM_LOG_WARNING,
+ _("replacing older version %s-%s by %s in target list\n"),
+ transpkg->name, transpkg->version, pkgver);
_alpm_pkg_free(i->data);
i->data = pkg;
} else {
- _alpm_log(PM_LOG_WARNING, _("skipping %s-%s because newer version %s is in the target list\n"),
- pkgname, pkgver, transpkg->version);
+ _alpm_log(PM_LOG_WARNING,
+ _("skipping %s-%s because newer version %s is in the target list\n"),
+ pkgname, pkgver, transpkg->version);
_alpm_pkg_free(pkg);
}
return(0);
diff --git a/lib/libalpm/add.h b/lib/libalpm/add.h
index 1a3b799d..b0467507 100644
--- a/lib/libalpm/add.h
+++ b/lib/libalpm/add.h
@@ -24,7 +24,6 @@
#include "alpm_list.h"
#include "trans.h"
-int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name);
int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db);
#endif /* _ALPM_ADD_H */
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 661df453..e9fadca2 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -401,15 +401,17 @@ alpm_list_t * alpm_trans_get_remove();
int alpm_trans_init(pmtransflag_t flags,
alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress cb_progress);
-int alpm_trans_sysupgrade(int enable_downgrade);
-int alpm_trans_sync(char *target);
-int alpm_trans_add(char *target);
-int alpm_trans_remove(char *target);
int alpm_trans_prepare(alpm_list_t **data);
int alpm_trans_commit(alpm_list_t **data);
int alpm_trans_interrupt(void);
int alpm_trans_release(void);
+int alpm_sync_sysupgrade(int enable_downgrade);
+int alpm_sync_target(char *target);
+int alpm_sync_dbtarget(char *db, char *target);
+int alpm_add_target(char *target);
+int alpm_remove_target(char *target);
+
/*
* Dependencies and conflicts
*/
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 4bebe3e5..af2ce943 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -47,35 +47,45 @@
#include "handle.h"
#include "alpm.h"
-int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
+int SYMEXPORT alpm_remove_target(char *target)
{
pmpkg_t *info;
- const char *targ;
+ pmtrans_t *trans;
+ pmdb_t *db_local;
+ alpm_list_t *p;
ALPM_LOG_FUNC;
- ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
+ /* 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));
+ trans = handle->trans;
+ db_local = handle->db_local;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
- ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+ ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
+ ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
- targ = strchr(name, '/');
- if(targ && strncmp(name, "local", 5) == 0) {
- targ++;
- } else {
- targ = name;
- }
- if(_alpm_pkg_find(trans->remove, targ)) {
+ if(_alpm_pkg_find(trans->remove, target)) {
RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
}
- if((info = _alpm_db_get_pkgfromcache(db, targ)) == NULL) {
- _alpm_log(PM_LOG_DEBUG, "could not find %s in database\n", targ);
- RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
+ if((info = _alpm_db_get_pkgfromcache(db_local, target)) != NULL) {
+ _alpm_log(PM_LOG_DEBUG, "adding %s in the targets list\n", info->name);
+ trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(info));
+ return(0);
}
- _alpm_log(PM_LOG_DEBUG, "adding %s in the targets list\n", info->name);
- trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(info));
+ _alpm_log(PM_LOG_DEBUG, "could not find %s in database\n", target);
+ pmgrp_t *grp = alpm_db_readgrp(db_local, target);
+ if(grp == NULL) {
+ RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
+ }
+ for(p = alpm_grp_get_pkgs(grp); p; p = alpm_list_next(p)) {
+ pmpkg_t *pkg = alpm_list_getdata(p);
+ _alpm_log(PM_LOG_DEBUG, "adding %s in the targets list\n", pkg->name);
+ trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(pkg));
+ }
return(0);
}
diff --git a/lib/libalpm/remove.h b/lib/libalpm/remove.h
index 9697f8c3..fbbaa169 100644
--- a/lib/libalpm/remove.h
+++ b/lib/libalpm/remove.h
@@ -24,13 +24,11 @@
#include "alpm_list.h"
#include "trans.h"
-int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name);
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_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *trans);
-
#endif /* _ALPM_REMOVE_H */
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index d676778b..28e63fd4 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -82,12 +82,25 @@ pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
return(NULL);
}
-int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, int enable_downgrade)
+/** Search for packages to upgrade and add them to the transaction.
+ * @return 0 on success, -1 on error (pm_errno is set accordingly)
+ */
+int SYMEXPORT alpm_sync_sysupgrade(int enable_downgrade)
{
alpm_list_t *i, *j, *k;
+ pmtrans_t *trans;
+ 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;
+ dbs_sync = handle->dbs_sync;
+ ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
+ ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
+
_alpm_log(PM_LOG_DEBUG, "checking for package upgrades\n");
for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) {
pmpkg_t *lpkg = i->data;
@@ -189,55 +202,16 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s
return(0);
}
-int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name)
+int _alpm_sync_pkg(pmpkg_t *spkg)
{
- char *targline;
- char *targ;
- alpm_list_t *j;
- pmpkg_t *local, *spkg;
- pmdepend_t *dep; /* provisions and dependencies are also allowed */
+ pmtrans_t *trans;
+ pmdb_t *db_local;
+ pmpkg_t *local;
ALPM_LOG_FUNC;
- ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
- ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
- ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
-
- STRDUP(targline, name, RET_ERR(PM_ERR_MEMORY, -1));
- targ = strchr(targline, '/');
- if(targ) {
- /* we are looking for a package in a specific database */
- alpm_list_t *dbs = NULL;
- *targ = '\0';
- targ++;
- _alpm_log(PM_LOG_DEBUG, "searching for target '%s' in repo '%s'\n", targ, targline);
- for(j = dbs_sync; j; j = j->next) {
- pmdb_t *db = j->data;
- if(strcmp(db->treename, targline) == 0) {
- dbs = alpm_list_add(NULL, db);
- break;
- }
- }
- if(dbs == NULL) {
- _alpm_log(PM_LOG_ERROR, _("repository '%s' not found\n"), targline);
- FREE(targline);
- RET_ERR(PM_ERR_PKG_REPO_NOT_FOUND, -1);
- }
- dep = _alpm_splitdep(targ);
- spkg = _alpm_resolvedep(dep, dbs, NULL, 1);
- _alpm_dep_free(dep);
- alpm_list_free(dbs);
- } else {
- dep = _alpm_splitdep(targline);
- spkg = _alpm_resolvedep(dep, dbs_sync, NULL, 1);
- _alpm_dep_free(dep);
- }
- FREE(targline);
-
- if(spkg == NULL) {
- /* pm_errno is set by _alpm_resolvedep */
- return(-1);
- }
+ trans = handle->trans;
+ db_local = handle->db_local;
if(_alpm_pkg_find(trans->add, alpm_pkg_get_name(spkg))) {
RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
@@ -274,6 +248,104 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
return(0);
}
+int _alpm_sync_target(alpm_list_t *dbs_sync, char *target)
+{
+ alpm_list_t *i, *j;
+ pmpkg_t *spkg;
+ pmdepend_t *dep; /* provisions and dependencies are also allowed */
+ pmgrp_t *grp;
+ int found = 0;
+
+ 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(_alpm_sync_pkg(spkg));
+ }
+
+ _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;
+ if(_alpm_sync_pkg(pkg) == -1) {
+ if(pm_errno == PM_ERR_TRANS_DUP_TARGET || pm_errno == PM_ERR_PKG_IGNORED) {
+ /* just skip duplicate or ignored targets */
+ continue;
+ } else {
+ return(-1);
+ }
+ }
+ }
+ }
+ }
+
+ if(!found) {
+ RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
+ }
+
+ return(0);
+}
+
+/** 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(char *dbname, 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) {
+ _alpm_log(PM_LOG_ERROR, _("repository '%s' not found\n"), dbname);
+ RET_ERR(PM_ERR_PKG_REPO_NOT_FOUND, -1);
+ }
+ return(_alpm_sync_target(dbs, 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_target(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(_alpm_sync_target(dbs_sync,target));
+}
+
/** Compute the size of the files that will be downloaded to install a
* package.
* @param newpkg the new package to upgrade to
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index c2905a45..b432b69e 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -24,9 +24,6 @@
#include "alpm.h"
-int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, int enable_downgrade);
-
-int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name);
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);
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 74ce418a..c99f5964 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -95,100 +95,6 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
return(0);
}
-/** Search for packages to upgrade and add them to the transaction.
- * @return 0 on success, -1 on error (pm_errno is set accordingly)
- */
-int SYMEXPORT alpm_trans_sysupgrade(int enable_downgrade)
-{
- pmtrans_t *trans;
-
- ALPM_LOG_FUNC;
-
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
-
- trans = 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));
-
- return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync, enable_downgrade));
-}
-
-/** Add a file target to the transaction.
- * @param target the name of the file target to add
- * @return 0 on success, -1 on error (pm_errno is set accordingly)
- */
-int SYMEXPORT alpm_trans_add(char *target)
-{
- pmtrans_t *trans;
-
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
- ASSERT(target != NULL && strlen(target) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
-
- trans = 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));
-
- if(_alpm_add_loadtarget(trans, handle->db_local, target) == -1) {
- /* pm_errno is set by _alpm_add_loadtarget() */
- return(-1);
- }
-
- return(0);
-}
-
-/** 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_trans_sync(char *target)
-{
- pmtrans_t *trans;
-
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
- ASSERT(target != NULL && strlen(target) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
-
- trans = 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));
-
- if(_alpm_sync_addtarget(trans, handle->db_local, handle->dbs_sync, target) == -1) {
- /* pm_errno is set by _alpm_sync_loadtarget() */
- return(-1);
- }
-
- return(0);
-}
-
-int SYMEXPORT alpm_trans_remove(char *target)
-{
- ALPM_LOG_FUNC;
-
- pmtrans_t *trans;
-
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
- ASSERT(target != NULL && strlen(target) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
-
- trans = 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));
-
- if(_alpm_remove_loadtarget(trans, handle->db_local, target) == -1) {
- /* pm_errno is set by _alpm_remove_loadtarget() */
- return(-1);
- }
-
- return(0);
-}
-
static alpm_list_t *check_arch(alpm_list_t *pkgs)
{
alpm_list_t *i;
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 258460c8..ced4e12f 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -57,44 +57,17 @@ int pacman_remove(alpm_list_t *targets)
/* Step 1: add targets to the created transaction */
for(i = targets; i; i = alpm_list_next(i)) {
- char *targ = alpm_list_getdata(i);
- if(alpm_trans_remove(targ) == -1) {
- if(pm_errno == PM_ERR_PKG_NOT_FOUND) {
- printf(_("%s not found, searching for group...\n"), targ);
- pmgrp_t *grp = alpm_db_readgrp(db_local, targ);
- if(grp == NULL) {
- pm_fprintf(stderr, PM_LOG_ERROR, _("'%s': not found in local db\n"), targ);
- retval = 1;
- goto cleanup;
- } else {
- alpm_list_t *p, *pkgnames = NULL;
- /* convert packages to package names */
- for(p = alpm_grp_get_pkgs(grp); p; p = alpm_list_next(p)) {
- pmpkg_t *pkg = alpm_list_getdata(p);
- pkgnames = alpm_list_add(pkgnames, (void *)alpm_pkg_get_name(pkg));
- }
- printf(_(":: group %s:\n"), targ);
- list_display(" ", pkgnames);
- int all = yesno(_(" Remove whole content?"));
- for(p = pkgnames; p; p = alpm_list_next(p)) {
- char *pkgn = alpm_list_getdata(p);
- if(all || yesno(_(":: Remove %s from group %s?"), pkgn, targ)) {
- if(alpm_trans_remove(pkgn) == -1) {
- pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ,
- alpm_strerrorlast());
- retval = 1;
- alpm_list_free(pkgnames);
- goto cleanup;
- }
- }
- }
- alpm_list_free(pkgnames);
- }
- } else {
- pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, alpm_strerrorlast());
- retval = 1;
- goto cleanup;
- }
+ char *target = alpm_list_getdata(i);
+ char *targ = strchr(target, '/');
+ if(targ && strncmp(target, "local", 5) == 0) {
+ targ++;
+ } else {
+ targ = target;
+ }
+ if(alpm_remove_target(targ) == -1) {
+ pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, alpm_strerrorlast());
+ retval = 1;
+ goto cleanup;
}
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 180fbb40..b23a9633 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -548,64 +548,34 @@ static alpm_list_t *syncfirst() {
return(res);
}
-static int process_target(char *targ, alpm_list_t *targets)
+static int process_target(char *target)
{
- alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
-
- if(alpm_trans_sync(targ) == -1) {
- pmgrp_t *grp = NULL;
- int found = 0;
- alpm_list_t *j;
+ /* process targets */
+ char *targ = strchr(target, '/');
+ char *db = NULL;
+ int ret;
+ if(targ) {
+ *targ = '\0';
+ targ++;
+ db = target;
+ ret = alpm_sync_dbtarget(db,targ);
+ } else {
+ targ = target;
+ ret = alpm_sync_target(targ);
+ }
- if(pm_errno == PM_ERR_TRANS_DUP_TARGET || pm_errno == PM_ERR_PKG_IGNORED) {
+ if(ret == -1) {
+ if(pm_errno == PM_ERR_TRANS_DUP_TARGET
+ || pm_errno == PM_ERR_PKG_IGNORED) {
/* just skip duplicate or ignored targets */
pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), targ);
return(0);
}
- if(pm_errno != PM_ERR_PKG_NOT_FOUND) {
- pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",
- targ, alpm_strerrorlast());
- return(1);
- }
- /* target not found: check if it's a group */
- printf(_("%s package not found, searching for group...\n"), targ);
- for(j = sync_dbs; j; j = alpm_list_next(j)) {
- pmdb_t *db = alpm_list_getdata(j);
- grp = alpm_db_readgrp(db, targ);
- if(grp) {
- alpm_list_t *k, *pkgnames = NULL;
-
- found++;
- printf(_(":: group %s (including ignored packages):\n"), targ);
- /* remove dupe entries in case a package exists in multiple repos */
- alpm_list_t *grppkgs = alpm_grp_get_pkgs(grp);
- alpm_list_t *pkgs = alpm_list_remove_dupes(grppkgs);
- for(k = pkgs; k; k = alpm_list_next(k)) {
- pkgnames = alpm_list_add(pkgnames,
- (char*)alpm_pkg_get_name(k->data));
- }
- list_display(" ", pkgnames);
- if(yesno(_(":: Install whole content?"))) {
- for(k = pkgnames; k; k = alpm_list_next(k)) {
- targets = alpm_list_add(targets, strdup(alpm_list_getdata(k)));
- }
- } else {
- for(k = pkgnames; k; k = alpm_list_next(k)) {
- char *pkgname = alpm_list_getdata(k);
- if(yesno(_(":: Install %s from group %s?"), pkgname, targ)) {
- targets = alpm_list_add(targets, strdup(pkgname));
- }
- }
- }
- alpm_list_free(pkgnames);
- alpm_list_free(pkgs);
- }
- }
- if(!found) {
- pm_fprintf(stderr, PM_LOG_ERROR, _("'%s': not found in sync db\n"), targ);
- return(1);
- }
+ pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",
+ targ, alpm_strerrorlast());
+ return(1);
}
+
return(0);
}
@@ -624,7 +594,7 @@ static int sync_trans(alpm_list_t *targets)
/* process targets */
for(i = targets; i; i = alpm_list_next(i)) {
char *targ = alpm_list_getdata(i);
- if(process_target(targ, targets) == 1) {
+ if(process_target(targ) == 1) {
retval = 1;
goto cleanup;
}
@@ -633,7 +603,7 @@ static int sync_trans(alpm_list_t *targets)
if(config->op_s_upgrade) {
printf(_(":: Starting full system upgrade...\n"));
alpm_logaction("starting full system upgrade\n");
- if(alpm_trans_sysupgrade(config->op_s_upgrade >= 2) == -1) {
+ if(alpm_sync_sysupgrade(config->op_s_upgrade >= 2) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, "%s\n", alpm_strerrorlast());
retval = 1;
goto cleanup;
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 936e2592..57c7b790 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -72,7 +72,7 @@ int pacman_upgrade(alpm_list_t *targets)
printf(_("loading package data...\n"));
for(i = targets; i; i = alpm_list_next(i)) {
char *targ = alpm_list_getdata(i);
- if(alpm_trans_add(targ) == -1) {
+ if(alpm_add_target(targ) == -1) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",
targ, alpm_strerrorlast());
trans_release();