Files
MSYS2-packages/pacman/0001-more-debugging-info.patch
2014-10-23 14:02:47 +04:00

59 lines
2.0 KiB
Diff

From df107840c82d70745a3f22721162bf2cfcec5776 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Fri, 13 Jun 2014 00:12:33 +0100
Subject: [PATCH 1/4] more debugging info
---
lib/libalpm/util.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index ebccc39..d565fdb 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -300,6 +300,23 @@ int _alpm_unpack_single(alpm_handle_t *handle, const char *archive,
return ret;
}
+char *get_command_line(const char* cmd, char *const argv[])
+{
+ size_t len = strlen(cmd) + 1;
+ size_t nargs = 0;
+ while (argv[nargs] != NULL) {
+ len += strlen(argv[nargs++]) + 1;
+ }
+ char *result = malloc(len) + 1;
+ strcpy(result, cmd);
+ strcat(result, " ");
+ for (size_t arg = 0; arg < nargs; ++arg) {
+ strcat(result, argv[arg]);
+ strcat(result, " ");
+ }
+ return result;
+}
+
/** Unpack a list of files in an archive.
* @param handle the context handle
* @param path the archive to unpack
@@ -557,7 +574,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[])
umask(0022);
execv(cmd, argv);
/* execv only returns if there was an error */
- fprintf(stderr, _("call to execv failed (%s)\n"), strerror(errno));
+ fprintf(stderr, _("call to execv (%s) failed (%s)\n"), get_command_line(cmd, argv), strerror(errno));
exit(1);
} else {
/* this code runs for the parent only (wait on the child) */
@@ -602,7 +619,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[])
if(WIFEXITED(status)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "call to waitpid succeeded\n");
if(WEXITSTATUS(status) != 0) {
- _alpm_log(handle, ALPM_LOG_ERROR, _("command failed to execute correctly\n"));
+ _alpm_log(handle, ALPM_LOG_ERROR, _("command (%s) failed to execute correctly\n"), get_command_line(cmd, argv));
retval = 1;
}
} else if(WIFSIGNALED(status) != 0) {
--
2.1.2