From 58edaf3373589aaa8c13aa1d1b85b761e2c4e259 Mon Sep 17 00:00:00 2001 From: Davide Madrisan Date: Sat, 8 Dec 2012 23:32:54 +0100 Subject: [PATCH] libspec: new function 'specfile.check_syntax()' Signed-off-by: Davide Madrisan --- ChangeLog | 10 +++++++ lib/libspec.lib.in | 61 +++++++++++++++++++++++++++++++++++++++++++ plugins/pck-update.in | 21 +++------------ po/it/autospec.po | 3 +++ 4 files changed, 78 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index e783f66..675923a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Changes in version 1.16.2 +--- --- -- ---- Madrisan + ++ 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 diff --git a/lib/libspec.lib.in b/lib/libspec.lib.in index 264d9f4..16e913e 100644 --- a/lib/libspec.lib.in +++ b/lib/libspec.lib.in @@ -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 diff --git a/plugins/pck-update.in b/plugins/pck-update.in index 8a06dd6..982c8c3 100644 --- a/plugins/pck-update.in +++ b/plugins/pck-update.in @@ -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" diff --git a/po/it/autospec.po b/po/it/autospec.po index fb587c6..0ce0f1c 100644 --- a/po/it/autospec.po +++ b/po/it/autospec.po @@ -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"