Magellan Linux

Contents of /trunk/pkgtools/up2date.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2106 - (show annotations) (download) (as text)
Mon May 13 11:35:14 2013 UTC (10 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 23763 byte(s)
-change timeout to 10 seconds and honor UP2EXCLUDE on more places
1 #!/bin/bash
2
3 source /usr/lib/mage/mage4.functions.sh
4 source /usr/lib/mage/smage2.functions.sh
5
6 # timeout in seconds
7 LYNX_CONNECT_TIMEOUT=10
8
9 ## only for tests -> normally in /etc/rc.d/init.d/functions
10 COLRED="\033[1;6m\033[31m"
11 COLGREEN="\033[1;6m\033[32m"
12 COLYELLOW="\033[1;6m\033[33m"
13 COLBLUE="\033[1;6m\033[34m"
14 COLMAGENTA="\033[1;6m\033[35m"
15 COLWHITE="\033[1;6m\033[37m"
16 COLGRAY="\033[0;6m\033[37m"
17 COLBOLD="\033[1m"
18 COLDEFAULT="\033[0m"
19
20 if [[ ${NOCOLORS} = true ]]
21 then
22 COLRED=""
23 COLGREEN=""
24 COLYELLOW=""
25 COLBLUE=""
26 COLMAGENTA=""
27 COLWHITE=""
28 COLGRAY=""
29 COLBOLD=""
30 COLDEFAULT=""
31 fi
32
33 die() { echo "Error: $@"; exit 1; }
34
35 sminclude() { true; }
36 msetfeature() { true; }
37 mqueryfeature() { true; }
38 haskell_enable_feature() { true; }
39 haskell_disable_feature() { true; }
40
41 urlencode()
42 {
43 local uri="$@"
44
45 # fix percent (do this first!!)
46 uri=$(echo ${uri} | sed 's:%:%25:g')
47
48 # fix spaces
49 uri=$(echo ${uri} | sed 's:\ :%20:g')
50
51 # fix less than
52 uri=$(echo ${uri} | sed 's:<:%3C:g')
53
54 # fix greater than
55 uri=$(echo ${uri} | sed 's:>:%3E:g')
56
57 # fix pound
58 uri=$(echo ${uri} | sed 's:#:%23:g')
59
60 # fix curly brace left
61 uri=$(echo ${uri} | sed 's:{:%7B:g')
62
63 # fix curly brace right
64 uri=$(echo ${uri} | sed 's:}:%7D:g')
65
66 # fix square bracket left
67 uri=$(echo ${uri} | sed 's:\[:%5B:g')
68
69 # fix square bracket right
70 uri=$(echo ${uri} | sed 's:\]:%5D:g')
71
72
73 # return
74 echo "${uri}"
75 }
76
77 lasttarball()
78 {
79 local suffix=bz2
80 [[ ! -z $1 ]] && suffix="$1"
81
82 case ${suffix} in
83 tbz2|tgz)
84 if [[ ! -z ${UP2EXCLUDE} ]]
85 then
86 grep "\(\.${suffix}\)\(\$\|\#\)" | grep -v -- "${UP2EXCLUDE}" | sed -n "s/.*-\(.*\)\(\.${suffix}\).*/\1/;$ p"
87 else
88 grep "\(\.${suffix}\)\(\$\|\#\)" | sed -n "s/.*-\(.*\)\(\.${suffix}\).*/\1/;$ p"
89 fi
90 ;;
91 *)
92 if [[ ! -z ${UP2EXCLUDE} ]]
93 then
94 grep "\(\.tar\.${suffix}\)\(\$\|\#\)" | grep -v -- "${UP2EXCLUDE}" | sed -n "s/.*-\(.*\)\(\.tar\.${suffix}\).*/\1/;$ p"
95 else
96 grep "\(\.tar\.${suffix}\)\(\$\|\#\)" | sed -n "s/.*-\(.*\)\(\.tar\.${suffix}\).*/\1/;$ p"
97 fi
98 ;;
99 esac
100 }
101
102 firsttarball()
103 {
104 local suffix=bz2
105 [[ ! -z $1 ]] && suffix="$1"
106
107 case ${suffix} in
108 tbz2|tgz)
109 if [[ ! -z ${UP2EXCLUDE} ]]
110 then
111 grep "\(\.${suffix}\)\(\$\|\#\)" | grep -v -- "${UP2EXCLUDE}" | sed "s/.*-\(.*\)\(\.${suffix}\).*/\1/;q"
112 else
113 grep "\(\.${suffix}\)\(\$\|\#\)" | sed "s/.*-\(.*\)\(\.${suffix}\).*/\1/;q"
114 fi
115 ;;
116 *)
117 if [[ ! -z ${UP2EXCLUDE} ]]
118 then
119 grep "\(\.tar\.${suffix}\)\(\$\|\#\)" | grep -v -- "${UP2EXCLUDE}" | sed "s/.*-\(.*\)\(\.tar\.${suffix}\).*/\1/;q"
120 else
121 grep "\(\.tar\.${suffix}\)\(\$\|\#\)" | sed "s/.*-\(.*\)\(\.tar\.${suffix}\).*/\1/;q"
122 fi
123 ;;
124 esac
125 }
126
127 updatecmd()
128 {
129 local uppver
130 local useragent
131 [[ ! -z ${UP2USERAGENT} ]] && useragent="-useragent '${UP2USERAGENT}'"
132
133 uppver=$(lynx -connect_timeout=${LYNX_CONNECT_TIMEOUT} -dump "${useragent}" $@)
134 if [[ $? -ne 0 ]]
135 then
136 echo "Error connecting '$@'"
137 sleep 1
138 return 1
139 fi
140
141 if [[ ! -z ${UP2SUBSTITUTE} ]]
142 then
143 echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g"
144 else
145 echo "${uppver}"
146 fi
147 }
148
149 updatecmd_gnu()
150 {
151 local pname=$1
152 local archive
153 local tarball
154
155 [[ -z ${pname} ]] && die "give me a \$PNAME"
156 [[ ! -z $2 ]] && archive="$2"
157
158 tarball="${pname}"
159 [[ ! -z ${UP2TARBALL} ]] && tarball="${UP2TARBALL}"
160
161 # remove 'latest' tarball too
162 updatecmd "http://ftp.gnu.org/gnu/${pname}/?C=M;O=A" | grep ${tarball}- | sed '/latest/d' | lasttarball "${archive}"
163 }
164
165 updatecmd_sourceforge_old()
166 {
167 local projectname="$1"
168 local pname="$2"
169 local check_deep_release_id="$3"
170 local archive
171 local uri
172 local group_id
173 local package_link_id
174 local package_id
175 local package_name
176 local release_link_id
177 local release_id
178
179 [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME"
180 [[ -z ${pname} ]] && pname="${projectname}"
181 case ${check_deep_release_id} in
182 deep|release_id|releaseid) check_deep_release_id="true" ;;
183 esac
184 [[ ! -z $4 ]] && archive="$4"
185
186 # project home uri
187 uri="http://sourceforge.net/projects/${projectname}"
188 group_id=$(updatecmd ${uri} | grep showfiles | sed 's/.*=\(.*\)/\1/;s/#downloads$//;q')
189
190 # showfiles.php uri with group_id to get the latest files
191 uri="http://sourceforge.net/project/showfiles.php?group_id=${group_id}"
192
193 package_link_id=$(updatecmd ${uri} | grep "\[.*\]${pname} \[.*\].*Release.*" | sed "s/.*\[\(.*\)\]${pname}.*/\1/")
194 package_id=$(updatecmd ${uri} | grep "${package_link_id}\..*showfiles.*" | sed 's/.*package_id=\(.*\)/\1/')
195
196 # debug
197 #echo group_id=${group_id}
198 #echo package_link_id=${package_link_id}
199 #echo package_id=${package_id}
200
201 uri="http://sourceforge.net/project/showfiles.php?group_id=${group_id}&package_id=${package_id}"
202 package_name=$(updatecmd "${uri}" | grep -m1 'Latest \[.*\]' | sed 's/.*]\(.*\) \[.*\].*/\1/')
203
204 if [[ ${check_deep_release_id} = true ]]
205 then
206 # showfiles.php uri with group_id and package to get the latest released files
207 uri="http://sourceforge.net/project/showfiles.php?group_id=${group_id}&package_id=${package_id}"
208 release_link_id=$(updatecmd ${uri} | grep ".*Latest.*\[.*\]${package_name} \[.*\].*" | sed "s/.*\[\(.*\)\]${package_name}.*/\1/")
209 release_id=$(updatecmd "${uri}" | grep "${release_link_id}\..*showfiles.*" | sed 's/.*release_id=\(.*\)/\1/')
210
211 # debug
212 #echo package_name=${package_name}
213 #echo release_link_id=${release_link_id}
214 #echo release_id=${release_id}
215
216 uri="http://sourceforge.net/project/showfiles.php?group_id=${group_id}&package_id=${package_id}&release_id=${release_id}"
217 case ${archive} in
218 tbz2|tgz)
219 updatecmd "${uri}" | grep "\(\.${suffix}\)" | sed -n "s/.*-\(.*\)\(\.${suffix}\).*/\1/;$ p"
220 ;;
221 *)
222 updatecmd "${uri}" | grep "\(\.tar\.${archive}\)" | sed -n "s/.*-\(.*\)\(\.tar\.${archive}\).*/\1/;$ p"
223 ;;
224 esac
225 else
226 echo "${package_name}"
227 fi
228 }
229
230 # new layout
231 updatecmd_sourceforge2()
232 {
233 local projectname="$1"
234 local pname="$2"
235 local suffix
236 local uri
237 local package_link_id
238 local package_seperator="-"
239 local excluded
240
241 [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME"
242 [[ -z ${pname} ]] && pname="${projectname}"
243 [[ ! -z $3 ]] && package_seperator="$3"
244
245 # project home uri
246 uri="http://sourceforge.net/projects/${projectname}/files"
247 # list of file suffixes, which should be excluded
248 excluded='(.asc|.md5)'
249 # package file names has always the date and time at the end <---------|
250 #package_link_id=$(updatecmd ${uri} | egrep -v ${excluded} | grep -v .md5 | grep -m1 "${pname}${package_seperator}[0-9].* [0-9]" | sed "s/.*\[\(.*\)\]${pname}.*/\1/")
251 package_link_id=$(updatecmd ${uri} | egrep -v ${excluded} | grep -m1 "${pname}${package_seperator}[0-9].* [0-9]" | sed "s/.*\[\(.*\)\].*/\1/")
252 echo DEBUG1:${package_link_id}
253
254 # get the suffix
255 suffix=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}.*\(\..*\)/\1/")
256 # echo "DEBUG2:${suffix}"
257
258 case ${suffix} in
259 .tbz2|.tgz|.zip|.rar)
260 #updatecmd ${uri} | grep -m1 "${pname}.*${suffix}" #| sed "s/.*${pname}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1"
261 updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1"
262 ;;
263 *)
264 #updatecmd ${uri} | grep -m1 "${pname}.*.tar${suffix}" | sed "s/.*${pname}\(.*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1"
265 updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}\(.*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1"
266 ;;
267 esac
268 }
269
270 # new layout, only newest
271 updatecmd_sourceforge_latest()
272 {
273 local projectname="$1"
274 local pname="$2"
275 local suffix
276 local uri
277 local package_link_id
278 local package_seperator="-"
279 local excluded
280 local deep="no"
281 local filename
282 local uppver
283
284 [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME"
285 [[ -z ${pname} ]] && pname="${projectname}"
286 [[ ! -z $3 ]] && package_seperator="$3"
287 if [[ ! -z $4 ]]
288 then
289 deep="yes"
290 filename="$4"
291 fi
292
293 # project home uri
294 uri="http://sourceforge.net/projects/${projectname}/files"
295 # list of file suffixes, which should be excluded
296 excluded='(.asc|.md5)'
297 # package file names has always the date and time at the end <---------|
298 # package_link_id=$(updatecmd ${uri} | sed -n '/Newest Files/,/All Files/p' | grep -v ${excluded} | grep -m1 "${pname}${package_seperator}[0-9].* [0-9]" | sed "s/.*\[\(.*\)\].*/\1/")
299 package_link_id=$(updatecmd ${uri} | grep -A1 'Newest Files' | sed -n "s/.*\[\(.*\)\].*${pname}${package_seperator}.*/\1/;$ p")
300 # if [[ ${deep} = yes ]]
301 # then
302 # #package_link_id=$(updatecmd ${uri} | sed -n "/${pname}.*Subscribe.*/,/.*Subscribe.*/p" | sed -n "/${filename}.*Release Notes.*/,/.*Release Notes/p" | grep -v ${excluded} | grep -m1 ".*${package_seperator}[0-9].* [0-9]" | sed "s/.*\[\(.*\)\].*/\1/")
303 # package_link_id=$(updatecmd ${uri} | sed -n "/${pname}.*Subscribe.*/,/.*Subscribe.*/p" | sed -n "/${filename}.*Release Notes.*/,/.*Release Notes/p" | grep -v ${excluded} | grep -m1 "${pname}\ \[.*\]" | sed "s/.*\[\(.*\)\].*/\1/")
304 # else
305 # #package_link_id=$(updatecmd ${uri} | sed -n "/${pname}.*Subscribe.*/,/.*Subscribe.*/p" | grep -v ${excluded} | grep -m1 ".*${package_seperator}[0-9].* [0-9]" | sed "s/.*\[\(.*\)\].*/\1/")
306 # #package_link_id=$(updatecmd ${uri} | sed -n "/${pname}.*Subscribe.*/,/.*Subscribe.*/p" | grep -v ${excluded} | grep -m1 "${pname}\ \[.*\]" | sed "s/.*\[\(.*\)\].*/\1/")
307 # package_link_id=$(updatecmd ${uri} | grep -A1 'Newest Files' | sed -n "s/.*\[\(.*\)\].*${pname}${package_seperator}.*/\1/;$ p")
308 # fi
309 # #echo DEBUG1:${package_link_id}
310
311 # get the suffix
312 #suffix=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}.*\(\..*\)\/download/\1/")
313 suffix=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*\(\..*\)\/download/\1/")
314 #echo "DEBUG2:${suffix}"
315
316 case ${suffix} in
317 .tbz2|.tgz|.zip|.rar|.7z)
318 #updatecmd ${uri} | grep -m1 "${pname}.*${suffix}" #| sed "s/.*${pname}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1"
319 #updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1"
320 #updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1"
321 uppver=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\([0-9].*\)${suffix}.*/\1/;s/-/_/g;s/_//1")
322 ;;
323 *)
324 #updatecmd ${uri} | grep -m1 "${pname}.*.tar${suffix}" | sed "s/.*${pname}\(.*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1"
325 #updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\(.*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1"
326 uppver=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\([0-9].*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1")
327 ;;
328 esac
329
330 if [[ ! -z ${UP2SUBSTITUTE} ]]
331 then
332 echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g"
333 else
334 echo "${uppver}"
335 fi
336 }
337
338
339 # new layout, only newest
340 updatecmd_sourceforge_lala()
341 {
342 local projectname="$1"
343 local pname="$2"
344 local suffix
345 local uri
346 local opts
347 local package_link_id
348 local package_seperator="-"
349 local excluded
350 local deep="no"
351 local filename="${pname}"
352 local uppver
353
354 [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME"
355 [[ -z ${pname} ]] && pname="${projectname}"
356 if [[ ! -z $3 ]]
357 then
358 case $3 in
359 null|NULL) package_seperator='' ;;
360 *) package_seperator="$3" ;;
361 esac
362 fi
363 if [[ ! -z $4 ]]
364 then
365 deep="yes"
366 filename="$4"
367 else
368 filename="${pname}"
369 fi
370
371 # special opts like sort date asc
372 if [[ ! -z ${UP2OPTS} ]]
373 then
374 opts="${UP2OPTS}"
375 else
376 opts='?sort=date&sortdir=asc'
377 fi
378 # project home uri # urlencode $pname
379 uri="http://sourceforge.net/projects/${projectname}/files/$(urlencode ${pname})${opts}"
380 # list of file suffixes, which should be excluded
381 excluded='(.asc|.md5|.exe|.txt|.sign|.rpm|.html|.7z|.dmg)'
382 package_link_id=$(updatecmd "${uri}" | grep "\[.*\]${filename}${package_seperator}" | egrep -v ${excluded} | sed -n "s/.*\[\(.*\)\].*${filename}${package_seperator}.*/\1/;$ p")
383
384 # get the suffix
385 suffix=$(updatecmd -listonly "${uri}" | grep "\ ${package_link_id}\." | sed "s/.*\(\..*\)\/download/\1/")
386 #echo "DEBUG2:${suffix}"
387
388 case ${suffix} in
389 .tbz2|.tgz|.zip|.rar|.7z)
390 uppver=$(updatecmd -listonly "${uri}" | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\([0-9].*\)${suffix}.*/\1/;s/-/_/g;s/_//1")
391 ;;
392 *)
393 uppver=$(updatecmd -listonly "${uri}" | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\([0-9].*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1")
394 ;;
395 esac
396
397 if [[ ! -z ${UP2SUBSTITUTE} ]]
398 then
399 echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g"
400 else
401 echo "${uppver}"
402 fi
403 }
404
405 # new layout, only newest
406 updatecmd_sourceforge_ftp_dir()
407 {
408 local projectname="$1"
409 local pname="$2"
410 local modifier="$3"
411 local uppver
412
413 # mesh works, kent not
414 #local mirror="http://mesh.dl.sourceforge.net"
415 local mirror="http://garr.dl.sourceforge.net"
416
417 [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME"
418 [[ -z ${pname} ]] && pname="${projectname}"
419 case ${modifier} in
420 date-asc) modifier='?C=M;O=A' ;;
421 date-desc) modifier='?C=M;O=D' ;;
422 name) modifier='' ;;
423 *) modifier='' ;;
424 esac
425
426 # urlencode everything
427 projectname=$(urlencode ${projectname})
428 pname=$(urlencode ${pname})
429
430 if [[ ! -z ${UP2EXCLUDE} ]]
431 then
432 uppver=$(updatecmd "${mirror}/project/${projectname}/${pname}/${modifier}" | grep -v -- "${UP2EXCLUDE}" | grep '[DIR].*\[[0-9].*\/' | sed -n 's/.*[0-9]\]\(.*\)\/.*/\1/;$ p')
433 else
434 uppver=$(updatecmd "${mirror}/project/${projectname}/${pname}/${modifier}" | grep '[DIR].*\[[0-9].*\/' | sed -n 's/.*[0-9]\]\(.*\)\/.*/\1/;$ p')
435 fi
436
437 if [[ ! -z ${UP2SUBSTITUTE} ]]
438 then
439 echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g"
440 else
441 echo "${uppver}"
442 fi
443 }
444
445 # needs app-text/xmlstarlet
446 updatecmd_sourceforge()
447 {
448 local projectname="$1"
449 local subprojectname="$2"
450 local archive="$3"
451 local uri
452 local project_id
453 local tarballname
454 local seperator
455 local rss_limit=30
456 local tarballprefix
457 local uppver
458 local allver
459
460 if [[ -z ${archive} ]] && [[ -n ${subprojectname} ]]
461 then
462 case ${subprojectname} in
463 xz|gz|bz2|tbz|tbz2|txz|tgz|zip|rar|7z|jar)
464 archive="${subprojectname}"
465 unset subprojectname
466 ;;
467 esac
468 fi
469
470 [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME"
471 [[ -z ${subprojectname} ]] && subprojectname="${projectname}"
472 if [[ -z ${tarballname} ]]
473 then
474 if [[ ${subprojectname} != ${projectname} ]]
475 then
476 tarballname="${subprojectname}"
477 else
478 tarballname="${projectname}"
479 fi
480 fi
481 [[ -z ${seperator} ]] && seperator="-"
482 [[ -z ${archive} ]] && archive="bz2"
483
484 # overrides
485 [[ ! -z ${UP2TARBALL} ]] && tarballname="${UP2TARBALL}"
486 [[ ! -z ${UP2SEPERATOR} ]] && seperator="${UP2SEPERATOR}"
487 [[ ${UP2SEPERATOR} = NULL ]] && seperator=""
488
489 uri="http://sourceforge.net/projects/${projectname}"
490 project_id=$(updatecmd ${uri} | grep project-id | sed -e 's:.*project-id/::;s:/.*::')
491 rss_uri="http://sourceforge.net/api/file/index/project-id/${project_id}/mtime/desc/limit/${rss_limit}/rss"
492
493 case ${archive} in
494 bz2|gz|xz) tarballprefix=".tar.${archive}" ;;
495 tbz|tbz2|txz|tgz|zip|rar|7z|jar) tarballprefix=".${archive}" ;;
496 *) tarballprefix="${archive}" ;;
497 esac
498
499 if [[ -x $(type -P xml) ]]
500 then
501 allver=$(updatecmd ${rss_uri} | xml sel -T -t -m //item -v title -n)
502 else
503 allver=$(updatecmd ${rss_uri})
504 fi
505
506 if [[ ! -z ${UP2EXCLUDE} ]]
507 then
508 allver=$(echo "${allver}" | grep -v -- "${UP2EXCLUDE}")
509 fi
510
511 allver=$(echo "${allver}" | grep "/${subprojectname}.*/${tarballname}${seperator}.*${tarballprefix}" | sed -e "s:.*${tarballname}${seperator}::;s:${tarballprefix}.*::")
512 #uppver=$(echo "${allver}" | sort -g | tac | head -n 1)
513 uppver=$(echo "${allver}" | sort -g | tac | head -n 1)
514
515 if [[ ! -z ${UP2SUBSTITUTE} ]]
516 then
517 echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g"
518 else
519 echo "${uppver}"
520 fi
521 }
522
523 updatecmd_berlios()
524 {
525 local projectname="$1"
526 local pname="$2"
527 local uri
528 local group_id
529
530 [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME"
531 [[ -z ${pname} ]] && pname="${projectname}"
532
533 uri="http://developer.berlios.de/projects/${projectname}"
534 group_id=$(updatecmd "${uri}" | grep showfiles | sed 's/.*group_id=\(.*\)&.*/\1/;q')
535
536 # debug
537 # echo group_id=${group_id}
538 # echo package_link_id=${package_link_id}
539 # echo package_id=${package_id}
540
541 uri="http://developer.berlios.de/project/showfiles.php?group_id=${group_id}"
542 updatecmd "${uri}" | grep -A3 "^${pname}$" | sed -n 's/.*\[.*]\(.*\) .*[0-9]-.*/\1/;$ p'
543 }
544
545 updatecmd_freedesktop()
546 {
547 local pname=$1
548 local archive
549 local subdir
550 local tarballname
551
552 [[ -z ${pname} ]] && die "give me a \$PNAME"
553 [[ ! -z $2 ]] && archive="$2"
554 [[ ! -z ${UP2SUBDIR} ]] && subdir="/${UP2SUBDIR}"
555 tarballname="${pname}"
556 [[ ! -z ${UP2TARBALL} ]] && tarballname="${UP2TARBALL}"
557
558 # exclude rc versions!
559 updatecmd "http://${pname}.freedesktop.org/releases${subdir}" | grep ${tarballname}- | grep -v rc[0-9] | lasttarball "${archive}"
560 }
561
562 updatecmd_xorg()
563 {
564 local pname=$1
565 local subdir
566 local tarballname
567 local pcat
568
569 [[ -z ${pname} ]] && die "give me a \$PNAME"
570 [[ ! -z $2 ]] && archive="$2"
571 tarballname="${pname}-"
572 if [[ ! -z ${PCAT} ]]
573 then
574 pcat="${PCAT}"
575 else
576 pcat="${PCATEGORIE}"
577 fi
578 subdir="$(echo ${pcat} | sed -e 's:x11-::' -e 's:media-::' -e 's/\(.*\)s$/\1/')"
579 [[ ! -z ${UP2SUBDIR} ]] && subdir="${UP2SUBDIR}"
580 [[ ! -z ${UP2TARBALL} ]] && tarballname="${UP2TARBALL}"
581
582 updatecmd "http://xorg.freedesktop.org/archive/individual/${subdir}/?C=M;O=A" | grep "/${tarballname}" | lasttarball "${archive}"
583 }
584
585 updatecmd_perl()
586 {
587 local pname=$1
588 local archive
589 local uppver
590
591 [[ -z ${pname} ]] && die "give me a \$PNAME"
592 [[ ! -z $2 ]] && archive="$2"
593
594 uppver=$(updatecmd "http://search.cpan.org/dist/${pname}/" | lasttarball "${archive}")
595
596 if [[ ! -z ${UP2SUBSTITUTE} ]]
597 then
598 echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g"
599 else
600 echo "${uppver}"
601 fi
602 }
603
604 updatecmd_gnome()
605 {
606 local uri
607 local pname="$1"
608
609 [[ -z ${pname} ]] && die "give me a \$PNAME"
610
611 uri="http://ftp.gnome.org/pub/gnome/sources/${pname}"
612 updatecmd ${uri}/$(updatecmd "${uri}"/?C=N\;O=D | grep '[0-9]\.[0-9]*[02468]/' | sed -ne 's|.*]\(.*\)/.*|\1|' -e '1 p')/ | grep ]LA | sed 's/.*S-\([0-9\.]*\).*/\1/'
613 }
614
615 updatecmd_xfce()
616 {
617 local uri
618 local pname="$1"
619 local archive
620 local subdir
621
622 [[ -z ${pname} ]] && die "give me a \$PNAME"
623 [[ ! -z $2 ]] && archive="$2"
624 if [[ -n ${UP2SUBDIR} ]]
625 then
626 subdir="${UP2SUBDIR}"
627 else
628 subdir="xfce"
629 fi
630
631 uri="http://archive.xfce.org/src/${subdir}/${pname}"
632 #updatecmd ${uri}/$(updatecmd "${uri}"/?C=N\;O=D | grep '[0-9]\.[0-9]*[02468]/' | sed -ne 's|.*]\(.*\)/.*|\1|' -e '1 p')/?C=M\;O=A | lasttarball "${archive}"
633 updatecmd ${uri}/$(updatecmd -source ${uri}'?C=M;O=A' | grep ${pname} |tail -n1 | sed -e 's/<\/a>.*//;s/.*>//') | lasttarball ${archive}
634 }
635
636 updatecmd_google()
637 {
638 local uri
639 local pname="$1"
640 local archive
641
642 [[ -z ${pname} ]] && die "give me a \$PNAME"
643 [[ ! -z $2 ]] && archive="$2"
644
645 uri="http://code.google.com/p/${pname}/downloads/list"
646 updatecmd --listonly "${uri}" | grep ${pname}- | firsttarball "${archive}"
647 }
648
649 updateme()
650 {
651 local smage="$1"
652 local ONLY_PRINT_UPSTREAM
653
654 if [[ $1 = --upstream ]] || [[ $1 = -u ]]
655 then
656 if [[ -z $2 ]] || [[ ${2##*.} != smage2 ]]
657 then
658 echo "you must give me a smagefile."
659 exit 1
660 fi
661 ONLY_PRINT_UPSTREAM=1
662 smage="$2"
663 fi
664
665 local PNAME
666 local PCATEGORIE
667 local PCAT
668 local PVER
669 local UP2DATE
670 local UP2PVER
671 local UP2TARBALL
672 local UP2SUBDIR
673 local UP2SUBSTITUTE
674 local UP2USERAGENT
675 local UP2EXCLUDE
676 local UP2SEPERATOR
677 local UP2OPTS
678 local UPSTREAM_PVER
679
680 PNAME="$(get_value_from_magefile PNAME ${smage})"
681 PCATEGORIE="$(get_value_from_magefile PCATEGORIE ${smage})"
682 PCAT="$(get_value_from_magefile PCAT ${smage})"
683 PVER="$(get_value_from_magefile PVER ${smage})"
684 UP2PVER="$(get_value_from_magefile UP2PVER ${smage})"
685 UP2TARBALL="$(get_value_from_magefile UP2TARBALL ${smage})"
686 UP2SUBDIR="$(get_value_from_magefile UP2SUBDIR ${smage})"
687 UP2SUBSTITUTE="$(get_value_from_magefile UP2SUBSTITUTE ${smage})"
688 UP2USERAGENT="$(get_value_from_magefile UP2USERAGENT ${smage})"
689 UP2EXCLUDE="$(get_value_from_magefile UP2EXCLUDE ${smage})"
690 UP2SEPERATOR="$(get_value_from_magefile UP2SEPERATOR ${smage})"
691 UP2OPTS="$(get_value_from_magefile UP2OPTS ${smage})"
692
693 [[ -z ${UP2PVER} ]] && UP2PVER="${PVER}"
694
695 UP2DATE=$(get_value_from_magefile UP2DATE ${smage})
696
697 if [[ -z ${UP2DATE} ]]
698 then
699 #echo "\$UP2DATE is empty, skipping ..."
700 continue
701 fi
702
703 #echo "UP2DATE=${UP2DATE}"
704 #read
705 UPSTREAM_PVER=$(eval "${UP2DATE}")
706 if [[ ${ONLY_PRINT_UPSTREAM} = 1 ]]
707 then
708 echo "${UPSTREAM_PVER}"
709 else
710 # [[ ${UP2PVER} = ${UPSTREAM_PVER} ]] && echo -e "${PNAME}: ${COLGREEN}'${UP2PVER}' = '${UPSTREAM_PVER}'${COLDEFAULT}"
711 # #[[ ${UP2PVER} != ${UPSTREAM_PVER} ]] && echo "${PNAME}: '${UP2PVER}' != '${UPSTREAM_PVER}'"
712 # [[ ${UP2PVER} < ${UPSTREAM_PVER} ]] && echo -e "${PNAME}: ${COLRED}'${UP2PVER}' < '${UPSTREAM_PVER}'${COLDEFAULT}"
713 # [[ ${UP2PVER} > ${UPSTREAM_PVER} ]] && echo -e "${PNAME}: ${COLYELLOW}'${UP2PVER}' > '${UPSTREAM_PVER}'${COLDEFAULT}"
714 local retval
715 retval=$(/home/tjoke/archlinux_version/vercomp "${UP2PVER}" "${UPSTREAM_PVER}")
716 [ ${retval} -eq 0 ] && echo -e "${PNAME}: ${COLGREEN}'${UP2PVER}' = '${UPSTREAM_PVER}'${COLDEFAULT}"
717 [ ${retval} -lt 0 ] && echo -e "${PNAME}: ${COLRED}'${UP2PVER}' < '${UPSTREAM_PVER}'${COLDEFAULT}"
718 [ ${retval} -gt 0 ] && echo -e "${PNAME}: ${COLYELLOW}'${UP2PVER}' > '${UPSTREAM_PVER}'${COLDEFAULT}"
719 fi
720 }
721
722 updateall()
723 {
724 #local REPOS
725 local PACKAGE
726 local smage
727 local repo
728 local UP2DATE_SLEEP_COUNT=15
729 local UP2DATE_SLEEP_TIMEOUT=3
730 local ONLY_PRINT_UPSTREAM=0
731
732 : ${REPOS="/home/tjoke/svn/smage/trunk/core /home/tjoke/svn/smage/trunk/extras /home/tjoke/svn/smage/trunk/nonfree /home/tjoke/svn/smage/trunk/todo"}
733 # REPOS="/home/tjoke/svn/smage/trunk/core /home/tjoke/svn/smage/trunk/extras"
734 # REPOS="/home/tjoke/svn/smage/trunk/core"
735 # PACKAGE="glibc-nptl"
736 # PACKAGE="autoconf21"
737 PACKAGE="*"
738 [[ ! -z $1 ]] && PACKAGE="$1"
739
740 if [[ $1 = --upstream ]] || [[ $1 = -u ]]
741 then
742 if [[ -z $2 ]] || [[ ${2##*.} != smage2 ]]
743 then
744 echo "you must give me a smagefile."
745 exit 1
746 fi
747 updateme $1 $2
748 return 0
749 fi
750
751 ##############################################################################
752 # recurse all depends if requested
753 #
754 if [[ $1 = --depend ]] || [[ $1 = -d ]]
755 then
756 if [[ -z $2 ]] || [[ ${2##*.} != smage2 ]]
757 then
758 echo "you must give me a smagefile."
759 exit 1
760 fi
761
762 SMAGEFILE="$2"
763 PACKAGE="$(magename2pname ${SMAGEFILE})"
764
765 echo "processing '${SMAGEFILE}' ..."
766 echo "running dependency checks for package '${PACKAGE}'..."
767
768 DEPEND=$(get_value_from_magefile DEPEND ${SMAGEFILE})
769 SDEPEND=$(get_value_from_magefile SDEPEND ${SMAGEFILE})
770
771 declare -i c=0
772 while read sign dep
773 do
774 case ${dep} in
775 "") continue;;
776 esac
777
778 # sleep every 15 packages for 5 seconds
779 (( c++ ))
780 if [[ ${c} -eq ${UP2DATE_SLEEP_COUNT} ]]
781 then
782 declare -i c=0
783 echo "DEBUG: Sleep Count (${UP2DATE_SLEEP_COUNT}x) reached, sleeping for ${UP2DATE_SLEEP_TIMEOUT} seconds ..."
784 sleep ${UP2DATE_SLEEP_TIMEOUT}
785 fi
786 #echo "debug: ${dep}"
787 updateme "$(dep2pname ${dep})"
788 done << EOF
789 ${DEPEND}
790 ${SDEPEND}
791 EOF
792 fi
793 #
794 # eof recurse
795 ##############################################################################
796
797 for repo in ${REPOS}
798 do
799 # exclude not existing
800 [[ ${PACKAGE} != \* ]] && [[ ! -d ${repo}/${PACKAGE} ]] && continue
801
802 declare -i c=0
803 for smage in ${repo}/${PACKAGE}/*.smage2
804 do
805 updateme ${smage}
806
807 # sleep every 15 packages for 5 seconds
808 (( c++ ))
809 if [[ ${c} -eq ${UP2DATE_SLEEP_COUNT} ]]
810 then
811 declare -i c=0
812 echo "DEBUG: Sleep Count (${UP2DATE_SLEEP_COUNT}x) reached, sleeping for ${UP2DATE_SLEEP_TIMEOUT} seconds ..."
813 sleep ${UP2DATE_SLEEP_TIMEOUT}
814 fi
815 done
816 done
817 }
818
819 updateall $@

Properties

Name Value
svn:executable *