libspec.lib: better error reporting when the specfile has syntax errors

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-12-09 18:05:40 +01:00
parent a176e54cee
commit 3c4d5b7880
2 changed files with 11 additions and 8 deletions

View File

@ -644,19 +644,22 @@ $FUNCNAME: running: rpm -q $rpm_options --specfile --specedit $specfile ..."
rpm -q $rpm_options --specfile --specedit $specfile \
> $specfile_preprocessed 2> $tmpspreprerr"
[[ -s "$tmpspreprerr" ||
$(cat $specfile_preprocessed | wc -l) -lt \
$(cat $specfile | wc -l) ]] &&
{ notify.warning $"specfile has errors:"
if [ -s "$tmpspreprerr" ]; then
notify.warning $"the specfile has some syntax errors:"
while read line; do
notify.warning " $line"
done < $tmpspreprerr
elif [ -z "$(grep "^%changelog" $specfile_preprocessed 2>/dev/null)" ]; then
# try to catch some other syntax errors even if rpm exit with
# a zero return code and no messages are sent to stderr
# FIXME: we assume "%changelog" is the last part of the specfile
notify.warning $"the specfile has some syntax errors:"
while read line; do
notify.warning " $line"
done < <(tail -n 3 $specfile_preprocessed)
notify.warning ">>"
notify.warning " "$"the error should be here!"; }
notify.warning " "$"the error should be here!"
fi
rm -f $tmpspreprerr
}

View File

@ -550,8 +550,8 @@ msgstr "specfile con fine linea CR"
msgid "specfile with an unsupported format"
msgstr "specfile in formato non supportato"
msgid "specfile has errors:"
msgstr "lo specfile contiene degli errori:"
msgid "the specfile has some syntax errors:"
msgstr "lo specfile ha degli errori di sintassi:"
msgid "the error should be here!"
msgstr "l'errore dovrebbe essere qui!"