Browse Source

ensure generation of valid EDSP error stanzas

The crude way of preparing a message to be a multiline value failed at
generation valid deb822 in case the error message ended with a new line
like the resolving errors from apt do. apt itself can parse these, but
other tools like grep-dctrl choke on it, so be nice and print valid.

Reported-By: Johannes 'josch' Schauer on IRC
tags/debian/1.4_beta3
David Kalnischkies 4 years ago
parent
commit
0161280405
2 changed files with 16 additions and 3 deletions
  1. +6
    -2
      apt-pkg/edsp.cc
  2. +10
    -1
      test/integration/test-external-dependency-solver-protocol

+ 6
- 2
apt-pkg/edsp.cc View File

@@ -931,14 +931,18 @@ bool EDSP::WriteProgress(unsigned short const percent, const char* const message
}
/*}}}*/
// EDSP::WriteError - format an error message to be send to file descriptor /*{{{*/
static std::string formatMessage(std::string const &msg)
{
return SubstVar(SubstVar(APT::String::Strip(msg), "\n\n", "\n.\n"), "\n", "\n ");
}
bool EDSP::WriteError(char const * const uuid, std::string const &message, FILE* output) {
fprintf(output, "Error: %s\n", uuid);
fprintf(output, "Message: %s\n\n", SubstVar(SubstVar(message, "\n\n", "\n.\n"), "\n", "\n ").c_str());
fprintf(output, "Message: %s\n\n", formatMessage(message).c_str());
return true;
}
bool EDSP::WriteError(char const * const uuid, std::string const &message, FileFd &output) {
return WriteOkay(output, "Error: ", uuid, "\n",
"Message: ", SubstVar(SubstVar(message, "\n\n", "\n.\n"), "\n", "\n "),
"Message: ", formatMessage(message),
"\n\n");
}
/*}}}*/


+ 10
- 1
test/integration/test-external-dependency-solver-protocol View File

@@ -148,7 +148,16 @@ testsuccess aptget upgrade -s --solver apt
testfailure aptget install awesome badstuff -s
testfailure aptget install awesome badstuff -s --solver apt
testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output

msgtest 'A resolving error is format as' 'valid parseable EDSP error'
if dpkg-checkbuilddeps -d 'dctrl-tools' /dev/null >/dev/null 2>&1; then
if apthelper cat-file rootdir/var/log/apt/edsp.last.xz | aptinternalsolver > solver.result 2>&1; then
testsuccess --nomsg grep-dctrl -FError ERR -- solver.result
else
msgfail
fi
else
msgskip 'dctrl-tools not installed'
fi
configarchitecture 'armel'
testfailure aptget install --solver apt awesomecoolstuff:i386 -s
msgtest 'An invalid EDSP file generates a' 'hard error'


Loading…
Cancel
Save