summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2009-07-16 14:55:45 +0200
committerXavier Chantry <shiningxc@gmail.com>2009-09-12 13:06:43 +0200
commitb4317a740ac2d4f5e4d1aa56a97171c52be70d02 (patch)
tree824a2c012b505700d77291a389d27ff851bade8e /src
parent19e07eb8e84dd117061a600abdd9c8fed7391a07 (diff)
downloadpacman-b4317a740ac2d4f5e4d1aa56a97171c52be70d02.tar.xz
Change the interface for target loading
-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_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); * functions renaming * add new sync_dbtarget which allows to specify the db * repo/ syntax handling is moved to frontend ( should implement FS#15141) * group handling is moved to backend ( see http://www.archlinux.org/pipermail/pacman-dev/2009-June/008847.html )
Diffstat (limited to 'src')
-rw-r--r--src/pacman/remove.c49
-rw-r--r--src/pacman/sync.c76
-rw-r--r--src/pacman/upgrade.c2
3 files changed, 35 insertions, 92 deletions
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();