Magellan Linux

Contents of /branches/mage-next/src/up2date/sourceforge.sh.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2591 - (show annotations) (download)
Tue Mar 4 08:35:27 2014 UTC (10 years, 2 months ago) by niro
File size: 2202 byte(s)
-split function into single includes
1 # needs app-text/xmlstarlet
2 updatecmd_sourceforge()
3 {
4 local projectname="$1"
5 local subprojectname="$2"
6 local archive="$3"
7 local uri
8 local project_id
9 local tarballname
10 local seperator
11 local rss_limit=50
12 local tarballprefix
13 local uppver
14 local allver
15
16 if [[ -z ${archive} ]] && [[ -n ${subprojectname} ]]
17 then
18 case ${subprojectname} in
19 xz|gz|bz2|tbz|tbz2|txz|tgz|zip|rar|7z|jar)
20 archive="${subprojectname}"
21 unset subprojectname
22 ;;
23 esac
24 fi
25
26 [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME"
27 [[ -z ${subprojectname} ]] && subprojectname="${projectname}"
28 if [[ -z ${tarballname} ]]
29 then
30 if [[ ${subprojectname} != ${projectname} ]]
31 then
32 tarballname="${subprojectname}"
33 else
34 tarballname="${projectname}"
35 fi
36 fi
37 [[ -z ${seperator} ]] && seperator="-"
38 [[ -z ${archive} ]] && archive="bz2"
39
40 # overrides
41 [[ ! -z ${UP2TARBALL} ]] && tarballname="${UP2TARBALL}"
42 [[ ! -z ${UP2SEPERATOR} ]] && seperator="${UP2SEPERATOR}"
43 [[ ${UP2SEPERATOR} = NULL ]] && seperator=""
44
45 uri="http://sourceforge.net/projects/${projectname}"
46 project_id=$(updatecmd ${uri} | grep project-id | sed -e 's:.*project-id/::;s:/.*::')
47 rss_uri="http://sourceforge.net/api/file/index/project-id/${project_id}/mtime/desc/limit/${rss_limit}/rss"
48
49 case ${archive} in
50 bz2|gz|xz) tarballprefix=".tar.${archive}" ;;
51 archive-bz2|archive-gz|archive-xz) tarballprefix=".${archive/archive-/}" ;;
52 tbz|tbz2|txz|tgz|zip|rar|7z|jar) tarballprefix=".${archive}" ;;
53 *) tarballprefix=".${archive}" ;;
54 esac
55
56 if [[ -x $(type -P xml) ]]
57 then
58 allver=$(updatecmd ${rss_uri} | xml sel -T -t -m //item -v title -n)
59 else
60 allver=$(updatecmd ${rss_uri})
61 fi
62
63 if [[ ! -z ${UP2EXCLUDE} ]]
64 then
65 allver=$(echo "${allver}" | grep -v -- "${UP2EXCLUDE}")
66 fi
67
68 allver=$(echo "${allver}" | grep "/${subprojectname}.*/${tarballname}${seperator}.*${tarballprefix}" | sed -e "s:.*${tarballname}${seperator}::;s:${tarballprefix}.*::")
69 #uppver=$(echo "${allver}" | sort -g | tac | head -n 1)
70 #uppver=$(echo "${allver}" | sort -n | tac | head -n 1)
71 uppver=$(upsort "${allver}")
72
73 if [[ ! -z ${UP2SUBSTITUTE} ]]
74 then
75 echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g"
76 else
77 echo "${uppver}"
78 fi
79 }