autospec/patches/autospec-1.4.8-libapse_candidate_versions.patch
2011-04-26 21:39:44 +02:00

94 lines
3.1 KiB
Diff

--- lib/libapse.lib.in 2009-10-16 11:50:55.000000000 +0200
+++ lib/libapse.lib.in 2009-07-23 00:16:29.000000000 +0200
@@ -12,6 +12,12 @@
. /usr/share/autospec/lib/libmsgmng.lib
+[ -r /usr/share/autospec/lib/libspec.lib ] ||
+ { echo "$me: "$"library not found"": /usr/share/autospec/lib/libspec.lib" 1>&2
+ exit 1; }
+
+. /usr/share/autospec/lib/libspec.lib
+
if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then
. /etc/sysconfig/i18n
[ "$LANG" ] && export LANG
@@ -317,24 +323,66 @@
*) notify.warning $"curl error (exit code: $retval)" ;;
esac
- local pcknameregexp=$(echo $pcknameverbatim | sed "\
- s,%[{]*name[}]*,$specname,
- s,%[{]*version[}]*,\\\([A-Za-z0-9._]*\\\),
- s,%[{]*.*[}]*,[A-Za-z0-9._]*,
- s,\.gz$,.,
- s,\.tgz$,.,
- s,\.bz2$,.,
- s,\.lzma$,.,")
+ local svar svalue spck candidate_version
+ # filter "?var:" expressions
+ spck=`echo $pcknameverbatim | sed "s,%{?[A-Za-z0-9_]*:.*\(%[A-Za-z0-9_]*\)},\1,"`
+
+ while true; do
+ svar=`echo $spck | sed "\
+ s,.*%[{]*\([A-Za-z0-9_]*\)[}]*.*,\1,"`
+ [ "$svar" = "$spck" ] && break
+ if [ "$svar" = "version" ]; then
+ svalue="\\\([A-Za-z0-9._]*\\\)"
+ else
+ svalue=`rpmvars.solve "%$svar" "$spec_dir/$specname.spec"`
+ [ "$svalue" = "%$svar" ] && svalue=
+ fi
+ spck=`echo $spck | sed "\
+ s,%[{]*$svar[}]*,$svalue,"`
+ done
+ # remove archiver extension from rexexp to match changes
+ local pcknameregexp=$(echo [^A-Za-z0-9._-]$spck | sed "\
+ s,\.gz$,\\\.,
+ s,\.tgz$,\\\.,
+ s,\.bz2$,\\\.,
+ s,\.lzma$,\\\.,
+ s,\.lz$,\\\.,
+ s,\.tbz2$,\\\.,")
+#echo $pcknameregexp
if [ $? -eq 0 ]; then
if [ "${pcknameregexp/(/}" = "${pcknameregexp}" ]; then
notify.warning "* "$"not parametric source0 name; cannot update"
else
- new_version=$(\
+ candidate_versions=($(\
grep -i "$pcknameregexp" $fcurlout | \
sed "\
-s,.*$pcknameregexp.*,\1,g" | \
-sort -t. -n -r -k1 -k2 -k3 -k4 -k5 -k6 -k7 -k8 -k9 -k10 | head -n1)
+s,.*$pcknameregexp.*,\1,g
+s,.*\.md5,,
+s,\.zip$,,
+s,\.tar\.gz$,,
+s,\.tar\.bz2$,,
+s,\.gz$,,
+s,\.tgz$,,
+s,\.bz2$,,
+s,\.lzma$,,
+s,\.i386$,,
+s,\.bin$,,
+s,\.exe$,,
+s,\.dmg$,,
+s,\.tbz2$,,
+s,\.lz$,," |
+sort -t. -n -r -k1 -k2 -k3 -k4 -k5 -k6 -k7 -k8 -k9 -k10 ))
+
+ local curr_version_dots new_version_dots candidate_version
+ curr_version_dots=`echo $SPEC_VERSION | tr -d [0-9][A-Z][a-z]_`
+ for candidate_version in ${candidate_versions[*]}; do
+ # skip version with no dots if current version has at least one (e.g. date release like 20000110)
+ new_version_dots=`echo $candidate_version | tr -d [0-9][A-Z][a-z]_`
+ [ ${#new_version_dots} = 0 -a ${#curr_version_dots} -gt 0 ] && continue
+ new_version=$candidate_version
+ break
+ done
fi
fi