Magellan Linux

Annotation of /trunk/pkgtools/up2date.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *