summaryrefslogtreecommitdiffstats
path: root/src/pacman/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-07-22 19:12:18 +0200
committerDan McGee <dan@archlinux.org>2011-07-27 19:46:15 +0200
commit9929a34a6d493c94bd176b66198bdbd734678043 (patch)
tree6ce511c1809183651732d4307aae4ba3c513a17b /src/pacman/sync.c
parentccdb2fa800f3e89641d371056961fa1d654f363d (diff)
downloadpacman-9929a34a6d493c94bd176b66198bdbd734678043.tar.gz
pacman-9929a34a6d493c94bd176b66198bdbd734678043.tar.xz
Remove duplicate code shared between sync and upgrade
Pacman did a great job of having almost (but not quite) duplicate code paths through the sync and upgrade code. We can use the same logic in both upgrade in sync once the targets are resolved, so extract a function and delete a bunch of code. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/sync.c')
-rw-r--r--src/pacman/sync.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 5e1643e4..42a99020 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -712,9 +712,6 @@ cleanup:
static int sync_trans(alpm_list_t *targets)
{
- int retval = 0;
- alpm_list_t *data = NULL;
- alpm_list_t *packages = NULL;
alpm_list_t *i;
/* Step 1: create a new transaction... */
@@ -726,8 +723,8 @@ static int sync_trans(alpm_list_t *targets)
for(i = targets; i; i = alpm_list_next(i)) {
char *targ = alpm_list_getdata(i);
if(process_target(targ) == 1) {
- retval = 1;
- goto cleanup;
+ trans_release();
+ return 1;
}
}
@@ -736,11 +733,19 @@ static int sync_trans(alpm_list_t *targets)
alpm_logaction(config->handle, "starting full system upgrade\n");
if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle)));
- retval = 1;
- goto cleanup;
+ trans_release();
+ return 1;
}
}
+ return sync_prepare_execute();
+}
+
+int sync_prepare_execute(void)
+{
+ alpm_list_t *i, *packages, *data = NULL;
+ int retval = 0;
+
/* Step 2: "compute" the transaction based on targets and flags */
if(alpm_trans_prepare(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle);