diff options
author | Xavier Chantry <shiningxc@gmail.com> | 2009-07-15 19:14:01 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2009-09-09 05:17:41 +0200 |
commit | 8ff3b87066d35d3518a3cd0bef27b86c3a85e983 (patch) | |
tree | a91691dccfa92d3021229f263b616ca4e35b5deb /src | |
parent | 0da96abc900560f21c643b255c94a60232f4a24b (diff) | |
download | pacman-8ff3b87066d35d3518a3cd0bef27b86c3a85e983.tar.gz pacman-8ff3b87066d35d3518a3cd0bef27b86c3a85e983.tar.xz |
Remove transaction type
This basically started with this change :
/* Transaction */
struct __pmtrans_t {
- pmtranstype_t type;
pmtransflag_t flags;
pmtransstate_t state;
- alpm_list_t *packages; /* list of (pmpkg_t *) */
+ alpm_list_t *add; /* list of (pmpkg_t *) */
+ alpm_list_t *remove; /* list of (pmpkg_t *) */
And then I have to modify all the code accordingly.
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/remove.c | 10 | ||||
-rw-r--r-- | src/pacman/sync.c | 13 | ||||
-rw-r--r-- | src/pacman/upgrade.c | 10 | ||||
-rw-r--r-- | src/pacman/util.c | 35 | ||||
-rw-r--r-- | src/pacman/util.h | 3 |
5 files changed, 20 insertions, 51 deletions
diff --git a/src/pacman/remove.c b/src/pacman/remove.c index b5119fa5..258460c8 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -51,14 +51,14 @@ int pacman_remove(alpm_list_t *targets) } /* Step 0: create a new transaction */ - if(trans_init(PM_TRANS_TYPE_REMOVE, config->flags) == -1) { + if(trans_init(config->flags) == -1) { return(1); } /* 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_addtarget(targ) == -1) { + 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); @@ -79,7 +79,7 @@ int pacman_remove(alpm_list_t *targets) 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_addtarget(pkgn) == -1) { + if(alpm_trans_remove(pkgn) == -1) { pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, alpm_strerrorlast()); retval = 1; @@ -129,7 +129,7 @@ int pacman_remove(alpm_list_t *targets) /* Search for holdpkg in target list */ int holdpkg = 0; - for(i = alpm_trans_get_pkgs(); i; i = alpm_list_next(i)) { + for(i = alpm_trans_get_remove(); i; i = alpm_list_next(i)) { pmpkg_t *pkg = alpm_list_getdata(i); if(alpm_list_find_str(config->holdpkg, alpm_pkg_get_name(pkg))) { pm_printf(PM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"), @@ -146,7 +146,7 @@ int pacman_remove(alpm_list_t *targets) if(config->flags & PM_TRANS_FLAG_RECURSE || config->flags & PM_TRANS_FLAG_CASCADE) { /* list transaction targets */ - alpm_list_t *pkglist = alpm_trans_get_pkgs(); + alpm_list_t *pkglist = alpm_trans_get_remove(); display_targets(pkglist, 0); printf("\n"); diff --git a/src/pacman/sync.c b/src/pacman/sync.c index a1d407c0..180fbb40 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -242,7 +242,7 @@ static int sync_synctree(int level, alpm_list_t *syncs) alpm_list_t *i; int success = 0, ret; - if(trans_init(PM_TRANS_TYPE_SYNC, 0) == -1) { + if(trans_init(0) == -1) { return(0); } @@ -552,7 +552,7 @@ static int process_target(char *targ, alpm_list_t *targets) { alpm_list_t *sync_dbs = alpm_option_get_syncdbs(); - if(alpm_trans_addtarget(targ) == -1) { + if(alpm_trans_sync(targ) == -1) { pmgrp_t *grp = NULL; int found = 0; alpm_list_t *j; @@ -617,7 +617,7 @@ static int sync_trans(alpm_list_t *targets) alpm_list_t *i; /* Step 1: create a new transaction... */ - if(trans_init(PM_TRANS_TYPE_SYNC, config->flags) == -1) { + if(trans_init(config->flags) == -1) { return(1); } @@ -683,7 +683,7 @@ static int sync_trans(alpm_list_t *targets) goto cleanup; } - packages = alpm_trans_get_pkgs(); + packages = alpm_trans_get_add(); if(packages == NULL) { /* nothing to do: just exit without complaining */ printf(_(" local database is up to date\n")); @@ -711,7 +711,8 @@ static int sync_trans(alpm_list_t *targets) goto cleanup; } - display_synctargets(packages); + display_targets(alpm_trans_get_remove(), 0); + display_targets(alpm_trans_get_add(), 1); printf("\n"); int confirm; @@ -788,7 +789,7 @@ int pacman_sync(alpm_list_t *targets) if(config->op_s_clean) { int ret = 0; - if(trans_init(PM_TRANS_TYPE_SYNC, 0) == -1) { + if(trans_init(0) == -1) { return(1); } diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index dc82e4de..936e2592 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -42,7 +42,6 @@ int pacman_upgrade(alpm_list_t *targets) { alpm_list_t *i, *data = NULL; - pmtranstype_t transtype = PM_TRANS_TYPE_UPGRADE; int retval = 0; if(targets == NULL) { @@ -65,7 +64,7 @@ int pacman_upgrade(alpm_list_t *targets) } /* Step 1: create a new transaction */ - if(trans_init(transtype, config->flags) == -1) { + if(trans_init(config->flags) == -1) { return(1); } @@ -73,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_addtarget(targ) == -1) { + if(alpm_trans_add(targ) == -1) { pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, alpm_strerrorlast()); trans_release(); @@ -131,12 +130,13 @@ int pacman_upgrade(alpm_list_t *targets) /* Step 3: perform the installation */ /* print targets and ask user confirmation */ - alpm_list_t *packages = alpm_trans_get_pkgs(); + alpm_list_t *packages = alpm_trans_get_add(); if(packages == NULL) { /* we are done */ trans_release(); return(retval); } - display_synctargets(packages); + display_targets(alpm_trans_get_remove(), 0); + display_targets(alpm_trans_get_add(), 1); printf("\n"); int confirm = yesno(_("Proceed with installation?")); if(!confirm) { diff --git a/src/pacman/util.c b/src/pacman/util.c index 1e8515c6..353aae3a 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -45,9 +45,9 @@ #include "callback.h" -int trans_init(pmtranstype_t type, pmtransflag_t flags) +int trans_init(pmtransflag_t flags) { - if(alpm_trans_init(type, flags, cb_trans_evt, + if(alpm_trans_init(flags, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) { pm_fprintf(stderr, PM_LOG_ERROR, _("failed to init transaction (%s)\n"), alpm_strerrorlast()); @@ -584,37 +584,6 @@ void display_targets(const alpm_list_t *pkgs, int install) FREELIST(targets); } -/* Display a list of transaction targets. - * `pkgs` should be a list of pmpkg_t's, - * retrieved from a transaction object - */ -void display_synctargets(const alpm_list_t *syncpkgs) -{ - const alpm_list_t *i, *j; - alpm_list_t *pkglist = NULL, *rpkglist = NULL; - - for(i = syncpkgs; i; i = alpm_list_next(i)) { - pmpkg_t *pkg = alpm_list_getdata(i); - pkglist = alpm_list_add(pkglist, pkg); - - /* The removes member contains a list of packages to be removed - * due to the package that is being installed. */ - alpm_list_t *to_replace = alpm_pkg_get_removes(pkg); - - for(j = to_replace; j; j = alpm_list_next(j)) { - pmpkg_t *rp = alpm_list_getdata(j); - rpkglist = alpm_list_add(rpkglist, rp); - } - } - - /* start displaying information */ - display_targets(rpkglist, 0); - display_targets(pkglist, 1); - - alpm_list_free(pkglist); - alpm_list_free(rpkglist); -} - /* Helper function for comparing strings using the * alpm "compare func" signature */ int str_cmp(const void *s1, const void *s2) diff --git a/src/pacman/util.h b/src/pacman/util.h index 12824221..a71de2d7 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -37,7 +37,7 @@ /* update speed for the fill_progress based functions */ #define UPDATE_SPEED_SEC 0.2f -int trans_init(pmtranstype_t type, pmtransflag_t flags); +int trans_init(pmtransflag_t flags); int trans_release(void); int needs_root(void); int getcols(void); @@ -54,7 +54,6 @@ void string_display(const char *title, const char *string); void list_display(const char *title, const alpm_list_t *list); void list_display_linebreak(const char *title, const alpm_list_t *list); void display_targets(const alpm_list_t *pkgs, int install); -void display_synctargets(const alpm_list_t *syncpkgs); void display_new_optdepends(pmpkg_t *oldpkg, pmpkg_t *newpkg); void display_optdepends(pmpkg_t *pkg); int yesno(char *fmt, ...); |