pck-update: check specfiles for CR and CRLF line terminators; they can mislead the specfile parser

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-05-06 21:02:14 +02:00
parent fac975675c
commit 223e904242
2 changed files with 27 additions and 0 deletions

View File

@ -25,6 +25,11 @@ Changes in version 1.10.1
* Makefile, Makefile.env, conf/* - Davide Madrisan:
Split autospec.conf into several configuration files.
+ improvement
* pck-update - Davide Madrisan:
Check specfiles for CR and CRLF line terminators.
They can mislead the specfile parser.
-------------------------------------------------------------------------------
Changes in version 1.10.0

View File

@ -430,6 +430,28 @@ assuming as specfile"": \`$spec_dir/$SRPM_SPECFILE'"
[ -f "$SRPM_SPECFILE_WITH_PATH" ] ||
notify.error $"specfile not found"": \`$SRPM_SPECFILE_WITH_PATH'"
local specfile_mimetype
specfile_mimetype="$(LC_ALL=C file -p --brief "$SRPM_SPECFILE_WITH_PATH")"
notify.debug "$FUNCNAME: specfile_mimetype: $specfile_mimetype"
case "$specfile_mimetype" in
# Microsoft line terminators... not good for the parser
*"with CRLF"*"line terminators"*)
notify.error $"\
specfile with CRLF line terminators"": $SRPM_SPECFILE_WITH_PATH"
;;
# MAC line terminators
*"with CR"*"line terminators"*)
notify.error $"\
specfile with CR line terminators"": $SRPM_SPECFILE_WITH_PATH"
;;
*"text"*) : ;;
*) notify.error "\
specfile with an unsupported format"" ($specfile_mimetype)""\
: $SRPM_SPECFILE_WITH_PATH"
;;
esac
echo "SRPM_SPECFILE_WITH_PATH=\"$SRPM_SPECFILE_WITH_PATH\"" >> $infofile
notify.debug "SRPM_SPECFILE_WITH_PATH = \"$SRPM_SPECFILE_WITH_PATH\""