diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-18 12:01:37 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-18 12:01:37 +0200 |
commit | 20eb553c3ac2187e8347f093f6ba480ceb85627b (patch) | |
tree | ab8d581d8d4b073fcf58e1b685090ee925fad5c9 /lib/Plugins/CCpp.cpp | |
parent | ff471a5ddd37d463848f9168638b397f98c59e65 (diff) | |
download | abrt-20eb553c3ac2187e8347f093f6ba480ceb85627b.tar.gz abrt-20eb553c3ac2187e8347f093f6ba480ceb85627b.tar.xz abrt-20eb553c3ac2187e8347f093f6ba480ceb85627b.zip |
simplify parsing of debuginfo-install output
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Plugins/CCpp.cpp')
-rw-r--r-- | lib/Plugins/CCpp.cpp | 75 |
1 files changed, 26 insertions, 49 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 8068feb2..fec1e570 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -98,62 +98,52 @@ static void InstallDebugInfos(const std::string& pPackage) } if (child == 0) { - if (pipein[0] != STDIN_FILENO) - { - dup2(pipein[0], STDIN_FILENO); - close(pipein[0]); - } - if (pipeout[1] != STDOUT_FILENO) - { - dup2(pipeout[1], STDOUT_FILENO); - close(pipeout[1]); - } + close(pipein[1]); + close(pipeout[0]); + xmove_fd(pipein[0], STDIN_FILENO); + xmove_fd(pipeout[1], STDOUT_FILENO); /* Not a good idea, we won't see any error messages */ /*close(STDERR_FILENO);*/ setsid(); - execlp("debuginfo-install", "debuginfo-install", pPackage.c_str(), NULL); + execlp("debuginfo-install", "debuginfo-install", "-y", "--", pPackage.c_str(), NULL); exit(0); } close(pipein[0]); close(pipeout[1]); + /* Should not be needed (we use -y option), but just in case: */ + safe_write(pipein[1], "y\n", sizeof("y\n")-1); + + comm_layer_inner_status("Downloading and installing debug-info packages..."); bool already_installed = false; int r; - while ((r = read(pipeout[0], buff, sizeof(buff) - 1)) > 0) + while ((r = safe_read(pipeout[0], buff, sizeof(buff) - 1)) > 0) { -/* Was before read, does not seem to be needed - fd_set rsfd; - FD_ZERO(&rsfd); - struct timeval delay; - - FD_SET(pipeout[0], &rsfd); - - delay.tv_sec = 1; - delay.tv_usec = 0; - - if (select(FD_SETSIZE, &rsfd, NULL, NULL, &delay) <= 0) - continue; - if (!FD_ISSET(pipeout[0], &rsfd)) - continue; -*/ buff[r] = '\0'; comm_layer_inner_debug(buff); comm_layer_inner_status(buff); - if (strstr(buff, packageName.c_str()) != NULL && - strstr(buff, "already installed and latest version") != NULL) - { - char* ii = strstr(buff, packageName.c_str()); - char* jj = strstr(ii, "\n"); - char* kk = strstr(ii, "already installed and latest version"); - if (jj > kk) + if (!already_installed) + { + /* "Package foo-debuginfo-1.2-5.ARCH already installed and latest version" */ + char* pn = strstr(buff, packageName.c_str()); + if (pn) { - already_installed = true; + char* already_str = strstr(pn, "already installed and latest version"); + if (already_str) + { + char* jj = strchr(pn, '\n'); + if (jj && jj > already_str) + { + already_installed = true; + } + } } } + if (already_installed == false && (strstr(buff, "No debuginfo packages available to install") != NULL || strstr(buff, "Could not find debuginfo for main pkg") != NULL || @@ -165,23 +155,10 @@ static void InstallDebugInfos(const std::string& pPackage) wait(NULL); throw CABRTException(EXCEP_PLUGIN, std::string(__func__) + ": cannot install debuginfos for " + pPackage); } - if (strstr(buff, "Total download size") != NULL) - { - int r = write(pipein[1], "y\n", sizeof("y\n")-1); - if (r != sizeof("y\n")-1) - { - close(pipein[1]); - close(pipeout[0]); - kill(child, SIGTERM); - wait(NULL); - throw CABRTException(EXCEP_PLUGIN, std::string(__func__) + ": cannot install debuginfos for " + pPackage); - } - comm_layer_inner_status("Downloading and installing debug-info packages..."); - } } + close(pipein[1]); close(pipeout[0]); - wait(NULL); } |