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 \ rpm -q $rpm_options --specfile --specedit $specfile \
> $specfile_preprocessed 2> $tmpspreprerr" > $specfile_preprocessed 2> $tmpspreprerr"
[[ -s "$tmpspreprerr" || if [ -s "$tmpspreprerr" ]; then
$(cat $specfile_preprocessed | wc -l) -lt \ notify.warning $"the specfile has some syntax errors:"
$(cat $specfile | wc -l) ]] &&
{ notify.warning $"specfile has errors:"
while read line; do while read line; do
notify.warning " $line" notify.warning " $line"
done < $tmpspreprerr 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 while read line; do
notify.warning " $line" notify.warning " $line"
done < <(tail -n 3 $specfile_preprocessed) done < <(tail -n 3 $specfile_preprocessed)
notify.warning ">>" notify.warning ">>"
notify.warning " "$"the error should be here!"; } notify.warning " "$"the error should be here!"
fi
rm -f $tmpspreprerr rm -f $tmpspreprerr
} }

View File

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