Magellan Linux

Annotation of /trunk/pkgtools/up2date.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *