Fix #184 segfault caused by trying to copy copyright files

This commit is contained in:
probonopd
2017-11-15 19:28:29 +01:00
committed by GitHub
parent 002f1e62a9
commit f135499521
+11 -3
View File
@@ -290,6 +290,13 @@ bool copyCopyrightFile(QString libPath){
return false; return false;
} }
QString dpkgQueryPath;
dpkgQueryPath = QStandardPaths::findExecutable("dpkg");
if(dpkgQueryPath == ""){
LogNormal() << "dpkg-query not found, hence not deploying copyright files";
return false;
}
QString copyrightFilePath; QString copyrightFilePath;
/* Find out which package the file being deployed belongs to */ /* Find out which package the file being deployed belongs to */
@@ -304,8 +311,8 @@ bool copyCopyrightFile(QString libPath){
if(strOut == "") return false; if(strOut == "") return false;
/* Find out the copyright file in that package */ /* Find out the copyright file in that package */
program = "dpkg-query";
arguments << "-S" << strOut; arguments << "-L" << strOut;
myProcess->start(program, arguments); myProcess->start(program, arguments);
myProcess->waitForFinished(); myProcess->waitForFinished();
strOut = myProcess->readAllStandardOutput(); strOut = myProcess->readAllStandardOutput();
@@ -313,8 +320,9 @@ bool copyCopyrightFile(QString libPath){
QStringList outputLines = strOut.split("\n", QString::SkipEmptyParts); QStringList outputLines = strOut.split("\n", QString::SkipEmptyParts);
foreach (QString outputLine, outputLines) { foreach (QString outputLine, outputLines) {
if((outputLine.contains("usr/share/doc")) && (outputLine.contains("/copyright"))){ if((outputLine.contains("usr/share/doc")) && (outputLine.contains("/copyright")) && (outputLine.contains(" "))){
copyrightFilePath = outputLine.split(' ')[1]; copyrightFilePath = outputLine.split(' ')[1];
break;
} }
} }