From 25966f56ac0824a4a864fc40c6d3e5ee743f8b4a Mon Sep 17 00:00:00 2001 From: Tj Hariharan Date: Sat, 28 Nov 2009 09:26:13 -0500 Subject: [PATCH] Signed-off-by: Tj Hariharan dirty patch for bug #11639: pacman fails miserably when the disk gets full. This is (as the commentors at the bug report have pointed out) by no means a permanent or really good fix. This patch does pretty much what Jens Adam (byte) suggested in his/her comment. --- src/pacman/sync.c | 6 +++--- src/pacman/util.c | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index a2ef616..879904e 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -687,9 +687,9 @@ static int sync_trans(alpm_list_t *targets) /* we are done */ goto cleanup; } - + display_targets(alpm_trans_get_remove(), 0); - display_targets(alpm_trans_get_add(), 1); + int target_returncode=display_targets(alpm_trans_get_add(), 1); printf("\n"); int confirm; @@ -698,7 +698,7 @@ static int sync_trans(alpm_list_t *targets) } else { confirm = yesno(_("Proceed with installation?")); } - if(!confirm) { + if(!confirm || (!config->op_s_downloadonly && target_returncode)) { goto cleanup; } diff --git a/src/pacman/util.c b/src/pacman/util.c index 115b367..d219e21 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -492,12 +492,13 @@ void list_display_linebreak(const char *title, const alpm_list_t *list) } } /* prepare a list of pkgs to display */ -void display_targets(const alpm_list_t *pkgs, int install) +int display_targets(const alpm_list_t *pkgs, int install) { char *str; const alpm_list_t *i; off_t isize = 0, dlsize = 0; double mbisize = 0.0, mbdlsize = 0.0; + int free; alpm_list_t *targets = NULL; if(!pkgs) { @@ -528,7 +529,7 @@ void display_targets(const alpm_list_t *pkgs, int install) /* Convert byte sizes to MB */ mbdlsize = dlsize / (1024.0 * 1024.0); mbisize = isize / (1024.0 * 1024.0); - + if(install) { asprintf(&str, _("Targets (%d):"), alpm_list_count(targets)); list_display(str, targets); @@ -537,6 +538,13 @@ void display_targets(const alpm_list_t *pkgs, int install) printf(_("Total Download Size: %.2f MB\n"), mbdlsize); printf(_("Total Installed Size: %.2f MB\n"), mbisize); + + //system call for disk size, I am having issue with statvfs and its reported sizes. + FILE *df_stream; + df_stream=popen("df -h --block-size=M /|awk '/\\// {print $4}'","r"); + fscanf(df_stream,"%d",&free); + pclose(df_stream); + // } else { asprintf(&str, _("Remove (%d):"), alpm_list_count(targets)); list_display(str, targets); @@ -545,8 +553,14 @@ void display_targets(const alpm_list_t *pkgs, int install) printf(_("Total Removed Size: %.2f MB\n"), mbisize); } - + FREELIST(targets); + if(install && (free