]>
Commit | Line | Data |
---|---|---|
6fb3305d | 1 | #!/bin/awk -f |
d4089f30 | 2 | # $Revision$, $Date$ |
b52a0a12 | 3 | # |
2675159e | 4 | # Copyright (C) 2000-2010 PLD-Team <feedback@pld-linux.org> |
b52a0a12 JB |
5 | # Authors: |
6 | # Sebastian Zagrodzki <zagrodzki@pld-linux.org> | |
7 | # Jacek Konieczny <jajcus@pld-linux.org> | |
8 | # Andrzej Krzysztofowicz <ankry@pld-linux.org> | |
9 | # Jakub Bogusz <qboosh@pld-linux.org> | |
10 | # Elan Ruusamäe <glen@pld-linux.org> | |
11 | # | |
12 | # See cvs log pldnotify.awk for list of contributors | |
13 | # | |
14 | # TODO: | |
15 | # - "SourceXDownload" support (use given URLs if present instead of cut-down SourceX URLs) | |
16 | # - "SourceXActiveFTP" support | |
3ca67c5b | 17 | |
72446964 ER |
18 | |
19 | function d(s) { | |
20 | if (!DEBUG) { | |
21 | return | |
22 | } | |
23 | print s >> "/dev/stderr" | |
24 | } | |
25 | ||
2aba2068 SZ |
26 | function fixedsub(s1,s2,t, ind) { |
27 | # substitutes fixed strings (not regexps) | |
28 | if (ind = index(t,s1)) { | |
29 | t = substr(t, 1, ind-1) s2 substr(t, ind+length(s1)) | |
30 | } | |
31 | return t | |
32 | } | |
6fb3305d | 33 | |
e3c5f324 JB |
34 | function ispre(s) { |
35 | if ((s~"pre")||(s~"PRE")||(s~"beta")||(s~"BETA")||(s~"alpha")||(s~"ALPHA")||(s~"rc")||(s~"RC")) { | |
72446964 | 36 | d("pre-version") |
e3c5f324 JB |
37 | return 1 |
38 | } else { | |
39 | return 0 | |
40 | } | |
41 | } | |
f0c5c231 | 42 | |
70a5e8d4 SZ |
43 | function compare_ver(v1,v2) { |
44 | # compares version numbers | |
45 | while (match(v1,/[a-zA-Z][0-9]|[0-9][a-zA-Z]/)) | |
46 | v1=(substr(v1,1,RSTART) "." substr(v1,RSTART+RLENGTH-1)) | |
47 | while (match(v2,/[a-zA-Z][0-9]|[0-9][a-zA-Z]/)) | |
48 | v2=(substr(v2,1,RSTART) "." substr(v2,RSTART+RLENGTH-1)) | |
49 | sub("^0*","",v1) | |
50 | sub("^0*","",v2) | |
e2ebf07c JB |
51 | gsub("\.0*",".",v1) |
52 | gsub("\.0*",".",v2) | |
72446964 ER |
53 | d("v1 == " v1) |
54 | d("v2 == " v2) | |
70a5e8d4 SZ |
55 | count=split(v1,v1a,"\.") |
56 | count2=split(v2,v2a,"\.") | |
f0c5c231 ER |
57 | |
58 | if (count<count2) mincount=count | |
70a5e8d4 | 59 | else mincount=count2 |
f0c5c231 | 60 | |
70a5e8d4 | 61 | for (i=1; i<=mincount; i++) { |
db83adc3 SZ |
62 | if (v1a[i]=="") v1a[i]=0 |
63 | if (v2a[i]=="") v2a[i]=0 | |
72446964 ER |
64 | d("i == " i) |
65 | d("v1[i] == " v1a[i]) | |
66 | d("v2[i] == " v2a[i]) | |
70a5e8d4 SZ |
67 | if ((v1a[i]~/[0-9]/)&&(v2a[i]~/[0-9]/)) { |
68 | if (length(v2a[i])>length(v1a[i])) | |
69 | return 1 | |
70 | else if (v2a[i]>v1a[i]) | |
71 | return 1 | |
72 | else if (length(v1a[i])>length(v2a[i])) | |
73 | return 0 | |
74 | else if (v1a[i]>v2a[i]) | |
75 | return 0 | |
76 | } else if ((v1a[i]~/[A-Za-z]/)&&(v2a[i]~/[A-Za-z]/)) { | |
77 | if (v2a[i]>v1a[i]) | |
78 | return 1 | |
79 | else if (v1a[i]>v2a[i]) | |
80 | return 0 | |
e3c5f324 | 81 | } else if (ispre(v1a[i]) == 1) |
70a5e8d4 SZ |
82 | return 1 |
83 | else | |
84 | return 0 | |
85 | } | |
86 | if ((count2==mincount)&&(count!=count2)) { | |
87 | for (i=count2+1; i<=count; i++) | |
e3c5f324 | 88 | if (ispre(v1a[i]) == 1) |
70a5e8d4 SZ |
89 | return 1 |
90 | return 0 | |
91 | } else if (count!=count2) { | |
92 | for (i=count+1; i<=count2; i++) | |
e3c5f324 | 93 | if (ispre(v2a[i]) == 1) |
70a5e8d4 SZ |
94 | return 0 |
95 | return 1 | |
96 | } | |
db4f445e | 97 | return 0 |
70a5e8d4 SZ |
98 | } |
99 | ||
f11b5a76 | 100 | function compare_ver_dec(v1,v2) { |
b8b1ac2a | 101 | # compares version numbers as decimal floats |
f11b5a76 | 102 | while (match(v1,/[0-9][a-zA-Z]/)) |
103 | v1=(substr(v1,1,RSTART) "." substr(v1,RSTART+RLENGTH-1)) | |
104 | while (match(v2,/[0-9][a-zA-Z]/)) | |
105 | v2=(substr(v2,1,RSTART) "." substr(v2,RSTART+RLENGTH-1)) | |
106 | sub("^0*","",v1) | |
107 | sub("^0*","",v2) | |
72446964 ER |
108 | d("v1 == " v1) |
109 | d("v2 == " v2) | |
f11b5a76 | 110 | count=split(v1,v1a,"\.") |
111 | count2=split(v2,v2a,"\.") | |
f0c5c231 ER |
112 | |
113 | if (count<count2) mincount=count | |
f11b5a76 | 114 | else mincount=count2 |
f0c5c231 | 115 | |
f11b5a76 | 116 | for (i=1; i<=mincount; i++) { |
117 | if (v1a[i]=="") v1a[i]=0 | |
118 | if (v2a[i]=="") v2a[i]=0 | |
72446964 ER |
119 | d("i == " i) |
120 | d("v1[i] == " v1a[i]) | |
121 | d("v2[i] == " v2a[i]) | |
f11b5a76 | 122 | if ((v1a[i]~/[0-9]/)&&(v2a[i]~/[0-9]/)) { |
123 | if (i==2) { | |
124 | if (0+("." v2a[i])>0+("." v1a[i])) | |
125 | return 1 | |
126 | else if (0+("." v1a[i])>0+("." v2a[i])) | |
127 | return 0 | |
128 | } else { | |
129 | if (length(v2a[i])>length(v1a[i])) | |
130 | return 1 | |
131 | else if (v2a[i]>v1a[i]) | |
132 | return 1 | |
133 | else if (length(v1a[i])>length(v2a[i])) | |
134 | return 0 | |
135 | else if (v1a[i]>v2a[i]) | |
136 | return 0 | |
137 | } | |
138 | } else if ((v1a[i]~/[A-Za-z]/)&&(v2a[i]~/[A-Za-z]/)) { | |
139 | if (v2a[i]>v1a[i]) | |
140 | return 1 | |
141 | else if (v1a[i]>v2a[i]) | |
142 | return 0 | |
e3c5f324 | 143 | } else if (ispre(v1a[i]) == 1) |
f11b5a76 | 144 | return 1 |
145 | else | |
146 | return 0 | |
147 | } | |
148 | if ((count2==mincount)&&(count!=count2)) { | |
149 | for (i=count2+1; i<=count; i++) | |
e3c5f324 | 150 | if (ispre(v1a[i]) == 1) |
f11b5a76 | 151 | return 1 |
152 | return 0 | |
153 | } else if (count!=count2) { | |
154 | for (i=count+1; i<=count2; i++) | |
e3c5f324 | 155 | if (ispre(v2a[i]) == 1) |
f11b5a76 | 156 | return 0 |
157 | return 1 | |
158 | } | |
159 | return 0 | |
160 | } | |
161 | ||
371e7443 AM |
162 | function link_seen(link) { |
163 | for (seenlink in frameseen) { | |
164 | if (seenlink == link) { | |
72446964 | 165 | d("Link: [" link "] seen already, skipping...") |
371e7443 AM |
166 | return 1 |
167 | } | |
168 | } | |
169 | frameseen[link]=1 | |
170 | return 0 | |
171 | } | |
172 | ||
deed2eef ER |
173 | function mktemp( _cmd, _tmpfile) { |
174 | _cmd = "mktemp /tmp/XXXXXX" | |
175 | _cmd | getline _tmpfile | |
176 | close(_cmd) | |
177 | return _tmpfile | |
178 | } | |
179 | ||
6ca0a958 AM |
180 | # fix link to artificial one that will be recognized rest of this script |
181 | function postfix_link(url, link) { | |
182 | oldlink = link | |
183 | if ((url ~/^(http|https):\/\/github.com\//) && (link ~ /.*\/tarball\//)) { | |
184 | gsub(".*\/tarball\/", "", link) | |
185 | link = link ".tar.gz" | |
186 | } | |
72446964 | 187 | d("POST FIXING URL [ " oldlink " ] to [ " link " ]") |
6ca0a958 AM |
188 | return link |
189 | } | |
190 | ||
70a5e8d4 | 191 | # get all <A HREF=..> tags from specified URL |
d5697af2 | 192 | function get_links(url,filename, errno,link,oneline,retval,odp,wholeodp,lowerodp,tmpfile,cmd) { |
8fef61cd AM |
193 | |
194 | wholeerr="" | |
195 | ||
deed2eef ER |
196 | tmpfile = mktemp() |
197 | tmpfileerr = mktemp() | |
8fef61cd | 198 | |
ea4c106c ER |
199 | if (url ~ /^http:\/\/(download|dl).(sf|sourceforge).net\//) { |
200 | gsub("^http://(download|dl).(sf|sourceforge).net/", "", url) | |
d6aee61e AM |
201 | gsub("/.*", "", url) |
202 | url = "http://sourceforge.net/projects/" url "/files/" | |
72446964 | 203 | d("sf url, mungled url to: " url) |
356ec898 | 204 | } |
f0c5c231 | 205 | |
109ec22a | 206 | if (url ~ /^http:\/\/(.*)\.googlecode\.com\/files\//) { |
3836b919 AM |
207 | gsub("^http://", "", url) |
208 | gsub("\..*", "", url) | |
b3df8960 | 209 | url = "http://code.google.com/p/" url "/downloads/list" |
72446964 | 210 | d("googlecode url, mungled url to: " url) |
3836b919 AM |
211 | } |
212 | ||
0ed4cd23 AM |
213 | if (url ~ /^http:\/\/pecl.php.net\/get\//) { |
214 | gsub("-.*", "", filename) | |
215 | url = "http://pecl.php.net/package/" filename | |
72446964 | 216 | d("pecl.php.net url, mungled url to: " url) |
0ed4cd23 AM |
217 | } |
218 | ||
fbf290ff AM |
219 | if (url ~ /^(http|ftp):\/\/mysql.*\/Downloads\/MySQL-5.1\//) { |
220 | url = "http://dev.mysql.com/downloads/mysql/5.1.html#source" | |
72446964 | 221 | d("mysql 5.1 url, mungled url to: " url) |
fbf290ff AM |
222 | } |
223 | ||
eb6fb288 AM |
224 | if (url ~/^(http|https):\/\/launchpad\.net\/(.*)\//) { |
225 | gsub("^(http|https):\/\/launchpad\.net\/", "", url) | |
226 | gsub("\/.*/", "", url) | |
227 | url = "https://code.launchpad.net/" url "/+download" | |
72446964 | 228 | d("main launchpad url, mungled url to: " url) |
eb6fb288 AM |
229 | } |
230 | ||
231 | if (url ~/^(http|https):\/\/edge\.launchpad\.net\/(.*)\//) { | |
232 | gsub("^(http|https):\/\/edge\.launchpad\.net\/", "", url) | |
233 | gsub("\/.*/", "", url) | |
234 | url = "https://edge.launchpad.net/" url "/+download" | |
72446964 | 235 | d("edge launchpad url, mungled url to: " url) |
eb6fb288 AM |
236 | } |
237 | ||
c12742eb AM |
238 | if (url ~/^(http|https):\/\/github.com\/.*\/(.*)\/tarball\//) { |
239 | gsub("\/tarball\/.*", "/downloads", url) | |
72446964 | 240 | d("github tarball url, mungled url to: " url) |
c12742eb AM |
241 | } |
242 | ||
fbf290ff | 243 | |
72446964 | 244 | d("Retrieving: " url) |
b1bb9185 | 245 | cmd = "wget --user-agent \"Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100129 PLD/3.0 (Th) Iceweasel/3.6\" -nv -O - \"" url "\" -t 2 -T 45 --passive-ftp --no-check-certificate > " tmpfile " 2> " tmpfileerr |
72446964 | 246 | d("Execute: " cmd) |
d5697af2 | 247 | errno = system(cmd) |
72446964 | 248 | d("Execute done") |
f0c5c231 | 249 | |
3f63995d | 250 | if (errno==0) { |
2675159e | 251 | wholeodp = "" |
72446964 | 252 | d("Reading succeess response...") |
7f460828 | 253 | while (getline oneline < tmpfile) |
fc589c7e | 254 | wholeodp=(wholeodp " " oneline) |
72446964 | 255 | # d("Response: " wholeodp) |
8fef61cd | 256 | } else { |
72446964 | 257 | d("Reading failure response...") |
8fef61cd AM |
258 | wholeerr = "" |
259 | while (getline oneline < tmpfileerr) | |
260 | wholeerr=(wholeerr " " oneline) | |
72446964 | 261 | d("Error Response: " wholeerr) |
70a5e8d4 | 262 | } |
f0c5c231 | 263 | |
2e301ef5 | 264 | system("rm -f " tmpfile) |
8fef61cd AM |
265 | system("rm -f " tmpfileerr) |
266 | ||
55658186 JB |
267 | urldir=url; |
268 | sub(/[^\/]+$/,"",urldir) | |
fc589c7e | 269 | |
3f63995d | 270 | if ( errno==0) { |
fc589c7e | 271 | while (match(wholeodp, /<([aA]|[fF][rR][aA][mM][eE])[ \t][^>]*>/) > 0) { |
72446964 | 272 | d("Processing links...") |
fc589c7e JB |
273 | odp=substr(wholeodp,RSTART,RLENGTH); |
274 | wholeodp=substr(wholeodp,RSTART+RLENGTH); | |
275 | ||
276 | lowerodp=tolower(odp); | |
277 | if (lowerodp ~ /<frame[ \t]/) { | |
278 | sub(/[sS][rR][cC]=[ \t]*/,"src=",odp); | |
279 | match(odp,/src="[^"]+"/) | |
280 | newurl=substr(odp,RSTART+5,RLENGTH-6) | |
72446964 | 281 | d("Frame: " newurl) |
55658186 JB |
282 | if (newurl !~ /\//) { |
283 | newurl=(urldir newurl) | |
72446964 | 284 | d("Frame->: " newurl) |
55658186 | 285 | } |
371e7443 AM |
286 | |
287 | if (link_seen(newurl)) { | |
288 | newurl="" | |
289 | continue | |
290 | } | |
291 | ||
2e301ef5 | 292 | retval=(retval " " get_links(newurl)) |
fc589c7e | 293 | } else if (lowerodp ~ /href=[ \t]*"[^"]*"/) { |
b5e77f8f | 294 | sub(/[hH][rR][eE][fF]=[ \t]*"/,"href=\"",odp) |
95fcfc77 | 295 | match(odp,/href="[^"]*"/) |
b5e77f8f JB |
296 | link=substr(odp,RSTART,RLENGTH) |
297 | odp=substr(odp,1,RSTART) substr(odp,RSTART+RLENGTH) | |
298 | link=substr(link,7,length(link)-7) | |
6ca0a958 | 299 | link=postfix_link(url, link) |
371e7443 AM |
300 | |
301 | if (link_seen(link)) { | |
302 | link="" | |
303 | continue | |
304 | } | |
305 | ||
b5e77f8f | 306 | retval=(retval " " link) |
72446964 | 307 | d("href(\"\"): " link) |
fc589c7e | 308 | } else if (lowerodp ~ /href=[ \t]*'[^']*'/) { |
b5e77f8f | 309 | sub(/[hH][rR][eE][fF]=[ \t]*'/,"href='",odp) |
95fcfc77 | 310 | match(odp,/href='[^']*'/) |
93c3b403 | 311 | link=substr(odp,RSTART,RLENGTH) |
b5e77f8f | 312 | odp=substr(odp,1,RSTART) substr(odp,RSTART+RLENGTH) |
93c3b403 | 313 | link=substr(link,7,length(link)-7) |
6ca0a958 | 314 | link=postfix_link(url, link) |
371e7443 AM |
315 | |
316 | if (link_seen(link)) { | |
317 | link="" | |
318 | continue | |
319 | } | |
320 | ||
93c3b403 | 321 | retval=(retval " " link) |
72446964 | 322 | d("href(''): " link) |
fc589c7e | 323 | } else if (lowerodp ~ /href=[ \t]*[^ \t>]*/) { |
4dde5541 | 324 | sub(/[hH][rR][eE][fF]=[ \t]*/,"href=",odp) |
95fcfc77 | 325 | match(odp,/href=[^ \t>]*/) |
8dfac79d | 326 | link=substr(odp,RSTART,RLENGTH) |
b5e77f8f | 327 | odp=substr(odp,1,RSTART) substr(odp,RSTART+RLENGTH) |
8dfac79d | 328 | link=substr(link,6,length(link)-5) |
371e7443 AM |
329 | |
330 | if (link_seen(link)) { | |
331 | link="" | |
332 | continue | |
333 | } | |
334 | ||
8dfac79d | 335 | retval=(retval " " link) |
72446964 | 336 | d("href(): " link) |
6f57d45d | 337 | } else { |
fc589c7e | 338 | # <a ...> but not href - skip |
72446964 | 339 | d("skipping <a > without href: " odp) |
93c3b403 | 340 | } |
3f63995d SZ |
341 | } |
342 | } else { | |
8fef61cd | 343 | retval=("WGET ERROR: " errno ": " wholeerr) |
3f63995d | 344 | } |
f0c5c231 ER |
345 | |
346 | ||
72446964 | 347 | d("Returning: " retval) |
db4f445e | 348 | return retval |
70a5e8d4 SZ |
349 | } |
350 | ||
6fb3305d | 351 | function subst_defines(var,defs) { |
3255b4c7 | 352 | # substitute all possible RPM macros |
6fb3305d SZ |
353 | while ((var ~ /%{.*}/) || (var ~ /%[A-Za-z0-9_]+/)) { |
354 | oldvar=var | |
355 | for (j in defs) { | |
356 | gsub("%{" j "}", defs[j], var) | |
357 | gsub("%" j , defs[j], var) | |
358 | } | |
359 | if (var==oldvar) { | |
72446964 ER |
360 | if (DEBUG) { |
361 | for (i in defs) { | |
362 | d(i " == " defs[i]) | |
363 | } | |
364 | } | |
6fb3305d SZ |
365 | return var |
366 | } | |
367 | } | |
368 | return var | |
369 | } | |
370 | ||
c0bee1bc JK |
371 | function find_mirror(url) { |
372 | ||
c54fbfc1 MK |
373 | while (succ = (getline line < "mirrors")) { |
374 | if (succ==-1) { return url } | |
c0bee1bc | 375 | nf=split(line,fields,"|") |
a6f2cc98 | 376 | if (nf>1){ |
c0bee1bc JK |
377 | origin=fields[1] |
378 | mirror=fields[2] | |
379 | mname=fields[3] | |
380 | prefix=substr(url,1,length(origin)) | |
381 | if (prefix==origin){ | |
72446964 | 382 | d("Mirror fount at " mname) |
c0bee1bc | 383 | close("mirrors") |
21b99dbc | 384 | return mirror substr(url,length(origin)+1) |
c0bee1bc JK |
385 | } |
386 | } | |
387 | } | |
388 | ||
389 | return url | |
390 | } | |
391 | ||
32aede2f | 392 | function process_source(number,lurl,name,version) { |
3255b4c7 | 393 | # fetches file list, and compares version numbers |
72446964 | 394 | d("Processing " lurl) |
3f63995d SZ |
395 | |
396 | if ( index(lurl,version)==0 ) { | |
72446964 | 397 | d("There is no version number.") |
3f63995d SZ |
398 | return 0 |
399 | } | |
400 | ||
6fb3305d SZ |
401 | sub("://",":",lurl) |
402 | sub("/",":/",lurl) | |
403 | gsub("[^/]*$",":&",lurl) | |
404 | split(lurl,url,":") | |
405 | acc=url[1] | |
406 | host=url[2] | |
407 | dir=url[3] | |
70a5e8d4 SZ |
408 | filename=url[4] |
409 | ||
3f63995d | 410 | if (index(dir,version)) { |
60ded487 AM |
411 | # directory name as version maching mode: |
412 | # if /something/version/name-version.tarball then check | |
413 | # in /something/ looking for newer directory | |
70a5e8d4 SZ |
414 | dir=substr(dir,1,index(dir,version)-1) |
415 | sub("[^/]*$","",dir) | |
c396da00 | 416 | sub("(\.tar\.(bz|bz2|gz|lzma|xz)|zip)$","",filename) |
70a5e8d4 | 417 | } |
3f63995d | 418 | |
72446964 ER |
419 | d("Will check a directory: " dir) |
420 | d("and a file: " filename) | |
60ded487 | 421 | |
70a5e8d4 SZ |
422 | filenameexp=filename |
423 | gsub("\+","\\+",filenameexp) | |
0269da83 | 424 | sub(version,"[A-Za-z0-9.]+",filenameexp) |
e12bdf15 | 425 | gsub("\.","\\.",filenameexp) |
72446964 | 426 | d("Expression: " filenameexp) |
70a5e8d4 SZ |
427 | match(filename,version) |
428 | prever=substr(filename,1,RSTART-1) | |
429 | postver=substr(filename,RSTART+RLENGTH) | |
72446964 ER |
430 | d("Before number: " prever) |
431 | d("and after: " postver) | |
f0c5c231 | 432 | newurl=find_mirror(acc "://" host dir) |
c54fbfc1 MK |
433 | #print acc "://" host dir |
434 | #newurl=url[1]"://"url[2]url[3]url[4] | |
435 | #newurl=acc "://" host dir filename | |
72446964 | 436 | d("Looking at " newurl) |
f0c5c231 | 437 | |
6fb3305d | 438 | references=0 |
db83adc3 | 439 | finished=0 |
db4f445e | 440 | oldversion=version |
0ed4cd23 | 441 | odp=get_links(newurl,filename) |
3f63995d SZ |
442 | if( odp ~ "ERROR: ") { |
443 | print name "(" number ") " odp | |
188dc51f | 444 | } else { |
72446964 | 445 | d("WebPage downloaded") |
188dc51f SZ |
446 | c=split(odp,linki) |
447 | for (nr=1; nr<=c; nr++) { | |
448 | addr=linki[nr] | |
6ca0a958 | 449 | |
72446964 | 450 | d("Found link: " addr) |
6ca0a958 AM |
451 | |
452 | # github has very different tarball links that clash with this safe check | |
453 | if (!(newurl ~/^(http|https):\/\/github.com\/.*\/tarball/)) { | |
454 | if (addr ~ "[-_.0-9A-Za-z~]" filenameexp) { | |
455 | continue | |
456 | } | |
457 | } | |
458 | ||
459 | if (addr ~ filenameexp) { | |
188dc51f SZ |
460 | match(addr,filenameexp) |
461 | newfilename=substr(addr,RSTART,RLENGTH) | |
72446964 | 462 | d("Hypothetical new: " newfilename) |
2aba2068 SZ |
463 | newfilename=fixedsub(prever,"",newfilename) |
464 | newfilename=fixedsub(postver,"",newfilename) | |
72446964 | 465 | d("Version: " newfilename) |
eb6fb288 | 466 | if (newfilename ~ /\.(asc|sig|pkg|bin|binary|built)$/) continue |
60ded487 | 467 | # strip ending (happens when in directiory name as version matching mode) |
c396da00 | 468 | sub("(\.tar\.(bz|bz2|gz|lzma|xz)|zip)$","",newfilename) |
f11b5a76 | 469 | if (NUMERIC) { |
470 | if ( compare_ver_dec(version, newfilename)==1 ) { | |
72446964 | 471 | d("Yes, there is new one") |
f11b5a76 | 472 | version=newfilename |
473 | finished=1 | |
474 | } | |
475 | } else if ( compare_ver(version, newfilename)==1 ) { | |
72446964 | 476 | d("Yes, there is new one") |
188dc51f SZ |
477 | version=newfilename |
478 | finished=1 | |
479 | } | |
70a5e8d4 | 480 | } |
6fb3305d | 481 | } |
188dc51f | 482 | if (finished==0) |
f1b8a975 | 483 | print name "(" number ") seems ok: " oldversion |
188dc51f SZ |
484 | else |
485 | print name "(" number ") [OLD] " oldversion " [NEW] " version | |
6fb3305d SZ |
486 | } |
487 | } | |
eae5334c ER |
488 | |
489 | # upgrade check for pear package using PEAR CLI | |
3d29ff34 | 490 | function pear_upgrade(name, ver, pname, pearcmd, nver) { |
eae5334c ER |
491 | pname = name; |
492 | sub(/^php-pear-/, "", pname); | |
493 | ||
494 | pearcmd = "pear remote-info " pname " | awk '/^Latest/{print $NF}'" | |
72446964 | 495 | d("pearcmd: " pearcmd) |
eae5334c ER |
496 | pearcmd | getline nver |
497 | close(pearcmd) | |
498 | ||
499 | if (compare_ver(ver, nver)) { | |
500 | print name " [OLD] " ver " [NEW] " nver | |
501 | } else { | |
502 | print name " seems ok: " ver | |
503 | } | |
504 | ||
505 | return | |
506 | } | |
f0c5c231 | 507 | |
3d29ff34 ER |
508 | function vim_upgrade(name, ver, mver, nver, vimcmd) { |
509 | # %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.2/7.2.%03g 1 %{patchlevel} | |
510 | mver = substr(ver, 0, 4) | |
511 | vimcmd = "wget -q -O - ftp://ftp.vim.org/pub/editors/vim/patches/"mver"/MD5SUMS|grep -vF .gz|tail -n1|awk '{print $2}'" | |
72446964 | 512 | d("vimcmd: " vimcmd) |
3d29ff34 ER |
513 | vimcmd | getline nver |
514 | close(vimcmd) | |
515 | ||
516 | if (compare_ver(ver, nver)) { | |
517 | print name " [OLD] " ver " [NEW] " nver | |
518 | } else { | |
519 | print name " seems ok: " ver | |
520 | } | |
521 | } | |
522 | ||
3255b4c7 | 523 | function process_data(name,ver,rel,src) { |
eae5334c ER |
524 | if (name ~ /^php-pear-/) { |
525 | return pear_upgrade(name, ver); | |
526 | } | |
3d29ff34 ER |
527 | if (name == "vim") { |
528 | return vim_upgrade(name, ver); | |
529 | } | |
eae5334c | 530 | |
3255b4c7 SZ |
531 | # this function checks if substitutions were valid, and if true: |
532 | # processes each URL and tries to get current file list | |
6fb3305d | 533 | for (i in src) { |
254a5f0b AM |
534 | if ( src[i] ~ /%{nil}/ ) { |
535 | gsub(/\%\{nil\}/, "", src[i]) | |
536 | } | |
6fb3305d | 537 | if ( src[i] !~ /%{.*}/ && src[i] !~ /%[A-Za-z0-9_]/ ) { |
72446964 | 538 | d("Source: " src[i]) |
32aede2f | 539 | process_source(i,src[i],name,ver) |
6fb3305d | 540 | } else { |
c4a1f100 | 541 | print FNAME ":" i ": impossible substitution: " src[i] |
6fb3305d SZ |
542 | } |
543 | } | |
544 | } | |
545 | ||
546 | BEGIN { | |
547 | # if U want to use DEBUG, run script with "-v DEBUG=1" | |
548 | # or uncomment the line below | |
70a5e8d4 | 549 | # DEBUG = 1 |
2e301ef5 SZ |
550 | |
551 | errno=system("wget --help > /dev/null 2>&1") | |
552 | if (errno) { | |
553 | print "No wget installed!" | |
554 | exit 1 | |
555 | } | |
f11b5a76 | 556 | if (ARGC>=3 && ARGV[2]=="-n") { |
557 | NUMERIC=1 | |
f0c5c231 | 558 | for (i=3; i<ARGC; i++) ARGV[i-1]=ARGV[i] |
f11b5a76 | 559 | ARGC=ARGC-1 |
560 | } | |
6fb3305d SZ |
561 | } |
562 | ||
563 | FNR==1 { | |
564 | if ( ARGIND != 1 ) { | |
6aab34d4 AM |
565 | # clean frameseen for each ARG |
566 | for (i in frameseen) { | |
567 | delete frameseen[i] | |
568 | } | |
569 | frameseen[0] = 1 | |
570 | ||
3255b4c7 | 571 | process_data(NAME,VER,REL,SRC) |
6fb3305d SZ |
572 | NAME="" ; VER="" ; REL="" |
573 | for (i in DEFS) delete DEFS[i] | |
574 | for (i in SRC) delete SRC[i] | |
575 | } | |
576 | FNAME=FILENAME | |
f6c65bb7 | 577 | DEFS["_alt_kernel"]="" |
892e6dad | 578 | DEFS["20"]="\\ " |
6fb3305d SZ |
579 | } |
580 | ||
3255b4c7 | 581 | /^[Uu][Rr][Ll]:/&&(URL=="") { URL=subst_defines($2,DEFS) ; DEFS["url"]=URL } |
6fb3305d SZ |
582 | /^[Nn]ame:/&&(NAME=="") { NAME=subst_defines($2,DEFS) ; DEFS["name"]=NAME } |
583 | /^[Vv]ersion:/&&(VER=="") { VER=subst_defines($2,DEFS) ; DEFS["version"]=VER } | |
584 | /^[Rr]elease:/&&(REL=="") { REL=subst_defines($2,DEFS) ; DEFS["release"]=REL } | |
a10d5bbe | 585 | /^[Ss]ource[0-9]*:/ { if (/(ftp|http|https):\/\//) SRC[FNR]=subst_defines($2,DEFS) } |
6fb3305d SZ |
586 | /%define/ { DEFS[$2]=subst_defines($3,DEFS) } |
587 | ||
588 | END { | |
3255b4c7 | 589 | process_data(NAME,VER,REL,SRC) |
6fb3305d | 590 | } |