131 lines
5.0 KiB
Diff
131 lines
5.0 KiB
Diff
|
diff -Nru autospec-1.4.17.org//lib/libspec.lib.in autospec-1.4.17/lib/libspec.lib.in
|
||
|
--- autospec-1.4.17.org//lib/libspec.lib.in 2010-05-02 22:17:42.000000000 +0200
|
||
|
+++ autospec-1.4.17/lib/libspec.lib.in 2010-07-02 23:06:02.245892733 +0200
|
||
|
@@ -657,6 +657,18 @@
|
||
|
{ # 'return' required if 'EXIT_FUNC' == 'return'
|
||
|
notify.error $"specfile not found"": \`$specfile'"; return; }
|
||
|
|
||
|
+ # use rpm --specfile --specedit to create a preprocessed specfile
|
||
|
+ local specfile_preprocessed=$(mktemp -q -t libspec.XXXXXXXX) ||
|
||
|
+ notify.error $"can't create temporary files"
|
||
|
+
|
||
|
+ local rpmdefine_opts="\
|
||
|
+$(for i in `seq 1 1 ${#define_list_name[*]}`; do
|
||
|
+echo -n " --define=\"${define_list_name[$i-1]} ${define_list_value[$i-1]}\""
|
||
|
+done)"
|
||
|
+
|
||
|
+ eval "rpm -q --specfile --specedit $specfile $rpmdefine_opts >> $specfile_preprocessed" ||
|
||
|
+ notify.error $"rpm exited with error code \`$?'"
|
||
|
+
|
||
|
[ -r "$infofile" ] && . $infofile
|
||
|
|
||
|
# when this library is used by external scripts this assertion always fails
|
||
|
@@ -889,7 +901,7 @@
|
||
|
;;
|
||
|
SPEC_TARGET)
|
||
|
[ "$SPEC_TARGET" ] && continue
|
||
|
- [ "$SPEC_NAME" ] || specfile.getvars -s "$specfile" SPEC_NAME
|
||
|
+ [ "$SPEC_NAME" ] || specfile.getvars -s "$specfile_preprocessed" SPEC_NAME
|
||
|
|
||
|
local ifexpr ifexpr_level level boolexpr tok toksave filesname
|
||
|
let "ifexpr_level = 0" # level of nested %if statements
|
||
|
@@ -920,7 +932,7 @@
|
||
|
|
||
|
case ${tok[0]} in
|
||
|
%if)
|
||
|
- #ifexpr=$(rpmvars.solve "${tok2}${fromtok3}" "$specfile")
|
||
|
+ #ifexpr=$(rpmvars.solve "${tok2}${fromtok3}" "$specfile_preprocessed")
|
||
|
# note: if <%var> is undefined (not present) or set to "0"
|
||
|
# then the conditional expression is false else is true
|
||
|
let "ifexpr_level += 1"
|
||
|
@@ -993,7 +1005,7 @@
|
||
|
notify.debug "\
|
||
|
$FUNCNAME: %file block found (${tok[*]})[line#$linenum]"
|
||
|
filesname="$( \
|
||
|
- rpmvars.solve "${tok[*]}" "$specfile" | \
|
||
|
+ rpmvars.solve "${tok[*]}" "$specfile_preprocessed" | \
|
||
|
sed -n '
|
||
|
# remove "%files" and "-f file-name" option if present
|
||
|
s,%files[ \t]*,,;s,-f[ \t]\+[^ ]*[ \t]*,,;p' )"
|
||
|
@@ -1006,11 +1018,11 @@
|
||
|
filesname="$(echo $filesname | sed 's,-n[ \t]\+,,')"
|
||
|
SPEC_TARGET=( \
|
||
|
${SPEC_TARGET[*]} \
|
||
|
-"$(rpmvars.solve "$filesname" "$specfile")" )
|
||
|
+"$(rpmvars.solve "$filesname" "$specfile_preprocessed")" )
|
||
|
;;
|
||
|
*) SPEC_TARGET=(\
|
||
|
${SPEC_TARGET[*]} "$SPEC_NAME-$(\
|
||
|
-rpmvars.solve "$filesname" "$specfile")" )
|
||
|
+rpmvars.solve "$filesname" "$specfile_preprocessed")" )
|
||
|
;;
|
||
|
esac
|
||
|
notify.debug "$FUNCNAME: $var = ( ${SPEC_TARGET[*]} )"
|
||
|
@@ -1023,7 +1035,7 @@
|
||
|
fi
|
||
|
;;
|
||
|
esac
|
||
|
- done < $specfile
|
||
|
+ done < $specfile_preprocessed
|
||
|
#notify.debug "$FUNCNAME: $var = ( ${SPEC_TARGET[*]} )"
|
||
|
;;
|
||
|
SPEC_OBSOLETES)
|
||
|
@@ -1032,7 +1044,7 @@
|
||
|
# entries when no obsolete labels are found
|
||
|
|
||
|
[ "$SPEC_OBSOLETES" ] && continue
|
||
|
- [ "$SPEC_NAME" ] || specfile.getvars -s "$specfile" SPEC_NAME
|
||
|
+ [ "$SPEC_NAME" ] || specfile.getvars -s "$specfile_preprocessed" SPEC_NAME
|
||
|
|
||
|
local linenum=0
|
||
|
while read -r -a tok; do
|
||
|
@@ -1062,19 +1074,19 @@
|
||
|
notify.debug "\
|
||
|
$FUNCNAME: * entry found at line $linenum: \"${tok[*]}\""
|
||
|
SPEC_OBSOLETES[${#SPEC_OBSOLETES[*]}]="\
|
||
|
-$(rpmvars.solve "${tok[*]}" "$specfile")"
|
||
|
+$(rpmvars.solve "${tok[*]}" "$specfile_preprocessed")"
|
||
|
|
||
|
notify.debug "\
|
||
|
$FUNCNAME: SPEC_OBSOLETES = ( ${SPEC_OBSOLETES[*]} )"
|
||
|
;;
|
||
|
esac
|
||
|
- done < $specfile
|
||
|
+ done < $specfile_preprocessed
|
||
|
|
||
|
# SPEC_OBSOLETES=($(sed -n "\
|
||
|
# /^[ \t]*Obsoletes[ \t]*:/{
|
||
|
# s,[ \t]*Obsoletes[ \t]*:[ \t]*,,
|
||
|
# s,%[{]*name[}]*,$SPEC_NAME,;p}" \
|
||
|
- # $specfile))
|
||
|
+ # $specfile_preprocessed))
|
||
|
|
||
|
notify.debug "$FUNCNAME: $var = ( ${SPEC_OBSOLETES[*]} )"
|
||
|
;;
|
||
|
@@ -1095,7 +1107,7 @@
|
||
|
[ "$SPEC_BUILDREQUIRES" ] && continue
|
||
|
local f rpm_provided_by
|
||
|
SPEC_BUILDREQUIRES=(`sed -n \
|
||
|
-'/^BuildRequires/{s,BuildRequires[ \t]*:[ \t]*,,p}' $specfile | \
|
||
|
+'/^BuildRequires/{s,BuildRequires[ \t]*:[ \t]*,,p}' $specfile_preprocessed | \
|
||
|
(IFS="$IFS,"; while read -a buildreqs; do
|
||
|
let "isver = 0"
|
||
|
for f in ${buildreqs[@]}; do
|
||
|
@@ -1107,7 +1119,7 @@
|
||
|
let "isver = 1"
|
||
|
;;
|
||
|
*%*) # rpm variable(s) (ex. '%{__install_info}')
|
||
|
- echo "$(rpmvars.solve "$f" $specfile) "
|
||
|
+ echo "$(rpmvars.solve "$f" $specfile_preprocessed) "
|
||
|
;;
|
||
|
*) echo "$f " ;;
|
||
|
esac
|
||
|
@@ -1154,6 +1166,7 @@
|
||
|
;;
|
||
|
esac
|
||
|
done
|
||
|
+ [ -e $specfile_preprocessed ] && rm -f $specfile_preprocessed
|
||
|
}
|
||
|
|
||
|
|