Paul de Vrieze wrote:
>On Thursday 30 June 2005 23:11, Dan Armak wrote:
>
>
>>Instead of 'exit 1', qt_min_version should use die. I use that in
>>deprange and it does work inside $DEPEND.
>>
>>
>
>Wouldn't this be a good time to implement actual dependency ranges in
>portage. Btw. I normally use the following hack that portage might
>actually be made to understand:
>
>DEPEND="<x11-libs/qt-4.0 !<x11-libs/qt-3.2.1"
>
>Paul
>
>
>
Hum ranges ? This remember me something ... ahh yes I've written a pair
of function to apply patches only for ranges of versions, pure bash
inheriting versionator.eclass .
Here they are:
# this function use "version_compare" to check if a version number
# fall inside a range.
# the range may include or not the extremes, a square bracket mean
# that the extreme is included, a round one mean that the extreme
# fall outside the range.
# examples:
# with $PVR=3 these ones evaluates as _true_:
# [2,4] [3,4] [2,3] [,4] [2,]
# (2,4)
# (,4) (2,) [3,3] [3,4) (2,3]
# with $PVR=3 these ones evaluates as _false_:
# [8,9]
# (3,4) (2,3) (8,9)
# (3,3)
check_version_range() {
local range_s="${1}"
local have_s="${2:-${PVR}}"
[[ -z "$range_s" ]] && return 1
local bound kind vc
bound=${range_s%%,*}
bound=${bound:1}
bound=${bound:-0}
local kind=${range_s:0:1}
case "$kind" in
'[') kind=2;;
'(') kind=1;;
*) die "check_version_range left kind error: \"${range_s}\""
return 50;;
esac
version_compare "${bound}" "${have_s}"
[[ $? -gt $kind ]] && return 2
local bound=${range_s##*,}
bound=${bound:0:$(( ${#bound} -1 ))}
bound=${bound:-99999}
local kind=${range_s:$(( ${#range_s} -1 ))}
case "$kind" in
']') kind=2;;
')') kind=3;;
*) die "check_version_range right kind error: \"${range_s}\""
return 50;;
esac
#'
version_compare "${bound}" "${have_s}"
vt=$?
[[ $vt -lt $kind ]] && return 3
return 0
}
# Find all the applicable patch files in a directory and move them in
# EPATCH_SOURCE (yes EPATCH_SOURCE here is a /destination/)
# two optional arguments are accepted:
# 1) directory where find the candidate patches (default to $FILESDIR)
# 2) version on which check applicable patches (default to $PVR)
# the file examined must have one or more line starting with the string
# "###MY_VER_RANGE" and followed from one or two version numbers (VN).
# For every of the so formatted lines the function will check if our
# version is greatest or equal to the first VN and less than the second
# VN (defaulted to infinite if empty)
# example:
###MY_VER_RANGE 4.0 4.0.16
###MY_VER_RANGE 4.1 4.1.4
###MY_VER_RANGE 5.0
# if a patch contains these three lines then:
# all version >= 4.0 but < 4.0.16,
# all version >= 4.1 but < 4.0.16,
# all version >= 5.0 will be affected by this patch
#
# bug uses version_compare declared experimental
# <[EMAIL PROTECTED]> (2005-05-18)
copy_applicable_patches() {
local filesdir="${1:-${FILESDIR}}"
local have_s="${2:-${PVR}}"
[[ -d "${EPATCH_SOURCE}" ]] || die "\$EPATCH_SOURCE must be a directory"
[[ -d "${filesdir}" ]] || die 'sourcedir must be a directory'
local filecandidates=""
filecandidates="$( ls ${filesdir}/*.${EPATCH_SUFFIX} 2>/dev/null )"
if [[ -z $filecandidates ]] ; then
einfo "No candidate patches found (lucky version?)"
return 0
fi
local ver_ranges use_flags
local has_ver=1 has_use=1
local apply=1
local filelist=""
for x in ${filecandidates} ; do
# Gater data
ver_ranges=$( head -n50 "${x}" | sed '/^###MY_VER_RANGE/'\!'d; s///;q' )
use_flags=$( head -n50 "${x}" | sed '/^###MY_USE_FLAG/'\!'d; s///;q' )
if [[ -n "${ver_ranges}" || -n "${use_flags}" ]] ; then
if [[ -z "${ver_ranges}" ]] ; then
has_ver=0
else
has_ver=1
for y in ${ver_ranges} ; do
if check_version_range "${y}" "${have_s}" ; then
has_ver=0
continue
fi
done
fi
if [[ -z "${use_flags}" ]] ; then
has_use=0
else
has_use=1
for y in ${use_flags} ; do
if [[ "${y:0:1}" == "-" ]] ; then
if ! useq "${y:1}" ; then
has_use=0
continue
fi
else
if useq "${y}" ; then
has_use=0
continue
fi
fi
done
fi
if [[ $has_ver -eq 0 && $has_use -eq 0 ]] ; then
filelist="${filelist} ${x}"
einfo "adding $(basename ${x}) ${ver_ranges} ${use_flags}"
else
einfo "skipping $(basename ${x}) ${ver_ranges} ${use_flags}"
fi
fi
done
filelist="${filelist:1}"
[[ -n "$filelist" ]] && cp $filelist "${EPATCH_SOURCE}"
}
--
[email protected] mailing list