1 |
Paul de Vrieze wrote: |
2 |
|
3 |
>On Thursday 30 June 2005 23:11, Dan Armak wrote: |
4 |
> |
5 |
> |
6 |
>>Instead of 'exit 1', qt_min_version should use die. I use that in |
7 |
>>deprange and it does work inside $DEPEND. |
8 |
>> |
9 |
>> |
10 |
> |
11 |
>Wouldn't this be a good time to implement actual dependency ranges in |
12 |
>portage. Btw. I normally use the following hack that portage might |
13 |
>actually be made to understand: |
14 |
> |
15 |
>DEPEND="<x11-libs/qt-4.0 !<x11-libs/qt-3.2.1" |
16 |
> |
17 |
>Paul |
18 |
> |
19 |
> |
20 |
> |
21 |
Hum ranges ? This remember me something ... ahh yes I've written a pair |
22 |
of function to apply patches only for ranges of versions, pure bash |
23 |
inheriting versionator.eclass . |
24 |
|
25 |
Here they are: |
26 |
|
27 |
# this function use "version_compare" to check if a version number |
28 |
# fall inside a range. |
29 |
# the range may include or not the extremes, a square bracket mean |
30 |
# that the extreme is included, a round one mean that the extreme |
31 |
# fall outside the range. |
32 |
# examples: |
33 |
# with $PVR=3 these ones evaluates as _true_: |
34 |
# [2,4] [3,4] [2,3] [,4] [2,] |
35 |
# (2,4) |
36 |
# (,4) (2,) [3,3] [3,4) (2,3] |
37 |
# with $PVR=3 these ones evaluates as _false_: |
38 |
# [8,9] |
39 |
# (3,4) (2,3) (8,9) |
40 |
# (3,3) |
41 |
check_version_range() { |
42 |
local range_s="${1}" |
43 |
local have_s="${2:-${PVR}}" |
44 |
[[ -z "$range_s" ]] && return 1 |
45 |
local bound kind vc |
46 |
|
47 |
bound=${range_s%%,*} |
48 |
bound=${bound:1} |
49 |
bound=${bound:-0} |
50 |
local kind=${range_s:0:1} |
51 |
case "$kind" in |
52 |
'[') kind=2;; |
53 |
'(') kind=1;; |
54 |
*) die "check_version_range left kind error: \"${range_s}\"" |
55 |
return 50;; |
56 |
esac |
57 |
version_compare "${bound}" "${have_s}" |
58 |
[[ $? -gt $kind ]] && return 2 |
59 |
|
60 |
local bound=${range_s##*,} |
61 |
bound=${bound:0:$(( ${#bound} -1 ))} |
62 |
bound=${bound:-99999} |
63 |
local kind=${range_s:$(( ${#range_s} -1 ))} |
64 |
case "$kind" in |
65 |
']') kind=2;; |
66 |
')') kind=3;; |
67 |
*) die "check_version_range right kind error: \"${range_s}\"" |
68 |
return 50;; |
69 |
esac |
70 |
#' |
71 |
version_compare "${bound}" "${have_s}" |
72 |
vt=$? |
73 |
[[ $vt -lt $kind ]] && return 3 |
74 |
|
75 |
return 0 |
76 |
} |
77 |
|
78 |
|
79 |
# Find all the applicable patch files in a directory and move them in |
80 |
# EPATCH_SOURCE (yes EPATCH_SOURCE here is a /destination/) |
81 |
# two optional arguments are accepted: |
82 |
# 1) directory where find the candidate patches (default to $FILESDIR) |
83 |
# 2) version on which check applicable patches (default to $PVR) |
84 |
# the file examined must have one or more line starting with the string |
85 |
# "###MY_VER_RANGE" and followed from one or two version numbers (VN). |
86 |
# For every of the so formatted lines the function will check if our |
87 |
# version is greatest or equal to the first VN and less than the second |
88 |
# VN (defaulted to infinite if empty) |
89 |
# example: |
90 |
###MY_VER_RANGE 4.0 4.0.16 |
91 |
###MY_VER_RANGE 4.1 4.1.4 |
92 |
###MY_VER_RANGE 5.0 |
93 |
# if a patch contains these three lines then: |
94 |
# all version >= 4.0 but < 4.0.16, |
95 |
# all version >= 4.1 but < 4.0.16, |
96 |
# all version >= 5.0 will be affected by this patch |
97 |
# |
98 |
# bug uses version_compare declared experimental |
99 |
# <vivo@g.o> (2005-05-18) |
100 |
copy_applicable_patches() { |
101 |
local filesdir="${1:-${FILESDIR}}" |
102 |
local have_s="${2:-${PVR}}" |
103 |
|
104 |
[[ -d "${EPATCH_SOURCE}" ]] || die "\$EPATCH_SOURCE must be a directory" |
105 |
[[ -d "${filesdir}" ]] || die 'sourcedir must be a directory' |
106 |
|
107 |
local filecandidates="" |
108 |
filecandidates="$( ls ${filesdir}/*.${EPATCH_SUFFIX} 2>/dev/null )" |
109 |
if [[ -z $filecandidates ]] ; then |
110 |
einfo "No candidate patches found (lucky version?)" |
111 |
return 0 |
112 |
fi |
113 |
|
114 |
local ver_ranges use_flags |
115 |
local has_ver=1 has_use=1 |
116 |
local apply=1 |
117 |
local filelist="" |
118 |
|
119 |
for x in ${filecandidates} ; do |
120 |
|
121 |
# Gater data |
122 |
ver_ranges=$( head -n50 "${x}" | sed '/^###MY_VER_RANGE/'\!'d; s///;q' ) |
123 |
use_flags=$( head -n50 "${x}" | sed '/^###MY_USE_FLAG/'\!'d; s///;q' ) |
124 |
|
125 |
if [[ -n "${ver_ranges}" || -n "${use_flags}" ]] ; then |
126 |
if [[ -z "${ver_ranges}" ]] ; then |
127 |
has_ver=0 |
128 |
else |
129 |
has_ver=1 |
130 |
for y in ${ver_ranges} ; do |
131 |
if check_version_range "${y}" "${have_s}" ; then |
132 |
has_ver=0 |
133 |
continue |
134 |
fi |
135 |
done |
136 |
fi |
137 |
|
138 |
if [[ -z "${use_flags}" ]] ; then |
139 |
has_use=0 |
140 |
else |
141 |
has_use=1 |
142 |
for y in ${use_flags} ; do |
143 |
if [[ "${y:0:1}" == "-" ]] ; then |
144 |
if ! useq "${y:1}" ; then |
145 |
has_use=0 |
146 |
continue |
147 |
fi |
148 |
else |
149 |
if useq "${y}" ; then |
150 |
has_use=0 |
151 |
continue |
152 |
fi |
153 |
fi |
154 |
done |
155 |
fi |
156 |
|
157 |
if [[ $has_ver -eq 0 && $has_use -eq 0 ]] ; then |
158 |
filelist="${filelist} ${x}" |
159 |
einfo "adding $(basename ${x}) ${ver_ranges} ${use_flags}" |
160 |
else |
161 |
einfo "skipping $(basename ${x}) ${ver_ranges} ${use_flags}" |
162 |
fi |
163 |
|
164 |
fi |
165 |
done |
166 |
filelist="${filelist:1}" |
167 |
[[ -n "$filelist" ]] && cp $filelist "${EPATCH_SOURCE}" |
168 |
} |
169 |
|
170 |
-- |
171 |
gentoo-dev@g.o mailing list |