libspec: new function 'specfile.check_syntax()'

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-12-08 23:32:54 +01:00
parent d5d2308272
commit 58edaf3373
4 changed files with 78 additions and 17 deletions

View File

@ -1,3 +1,13 @@
Changes in version 1.16.2
--- --- -- ---- Madrisan <davide.madrisan(a)gmail.com>
+ update
* lib/libspec.lib - Davide Madrisan:
New function 'specfile.check_syntax()' based on the code previously
located in the module pck-update (function 'infofile.create()').
-------------------------------------------------------------------------------
Changes in version 1.16.1
Sun Dec 02 2012 Davide Madrisan <davide.madrisan(a)gmail.com>

View File

@ -597,6 +597,67 @@ ${output_suffix}")
echo "$output"
}
function specfile.check_syntax() {
local ARGS
ARGS=`LC_ALL=C getopt -o s:o: \
--long specfile:,specfile-preprocessed:,rpmopts: \
-n "$FUNCNAME" -- "$@"`
[ $? = 0 ] || notify.error $"\
(bug)"" -- $FUNCNAME: "$"\`getopt' error"
eval set -- "$ARGS"
local specfile rpmbuild_opts line
local specfile_preprocessed="/dev/null"
while :; do
case "$1" in
-s|--specfile)
specfile="$2"; shift
notify.debug "$FUNCNAME: specfile = \"$specfile\""
;;
--specfile-preprocessed)
specfile_preprocessed="$2"; shift
notify.debug "\
$FUNCNAME: specfile_preprocessed = \"$specfile_preprocessed\""
;;
-o|--rpmopts)
rpm_options="$2"; shift
notify.debug "$FUNCNAME: rpm_options = \"$rpm_options\""
;;
--) shift; break ;;
*) notify.error $"\
(bug)"" -- $FUNCNAME: "$"\`getopt' error: bad command \`$1'" ;;
esac
shift
done
local tmpspreprerr=$(mktemp -q -t $me.XXXXXXXX)
[ $? -eq 0 ] ||
notify.error "$FUNCNAME: "$"can't create temporary files"
notify.debug "$FUNCNAME: tmpspreprerr = \`${NOTE}$tmpspreprerr${NORM}'"
notify.debug "\
$FUNCNAME: running: rpm -q $rpm_options --specfile --specedit $specfile ..."
eval "\
rpm -q $rpm_options --specfile --specedit $specfile \
> $specfile_preprocessed 2> $tmpspreprerr"
[ -s "$tmpspreprerr" ] &&
{ notify.warning $"specfile has errors:"
while read line; do
notify.warning " $line"
done < $tmpspreprerr
notify.warning $"error should be here:"
while read line; do
notify.warning " $line"
done < <(tail -n 3 $specfile_preprocessed)
notify.warning ">>"; }
rm -f $tmpspreprerr
}
# function specfile.getvars
# set the variable(s) given as argument to the value(s) found

View File

@ -493,26 +493,13 @@ done)"
# create the specfile_preprocessed only once
if [ ! -s "$specfile_preprocessed" ]; then
local tmpspreprerr=$(mktemp -q -t $me.XXXXXXXX)
[ $? -eq 0 ] || notify.error $"can't create temporary files"
notify.debug "tmpspreprerr = \`${NOTE}$tmpspreprerr${NORM}'"
local rpmbuild_opts="\
--define=\"%_specdir $spec_dir\" --define=\"%_sourcedir $source_dir\""
notify.debug "running: rpm -q $rpmbuild_opts $USER_RPMDEFINE_OPTS \
--specfile --specedit $SRPM_SPECFILE_WITH_PATH ..."
eval "\
rpm -q $rpmbuild_opts $USER_RPMDEFINE_OPTS --specfile --specedit\
$SRPM_SPECFILE_WITH_PATH \
2> $tmpspreprerr >> $specfile_preprocessed"
[ -s "$tmpspreprerr" ] &&
{ notify.warning $"specfile has errors:"
while read line; do
notify.warning " $line"
done < $tmpspreprerr; }
rm -f $tmpspreprerr
specfile.check_syntax \
--rpmopts "$rpmbuild_opts" \
--specfile "$SRPM_SPECFILE_WITH_PATH" \
--specfile-preprocessed "$specfile_preprocessed"
fi
SPECFILE_PREPROCESSED="$specfile_preprocessed"

View File

@ -544,6 +544,9 @@ msgstr "specfile in formato non supportato"
msgid "specfile has errors:"
msgstr "lo specfile contiene degli errori"
msgid "error should be here:"
msgstr "l'errore dovrebbe essere qui:"
msgid "release number: unsupported format"
msgstr "numero di release: formato non supportato"