#!/bin/bash source /usr/lib/mage/mage4.functions.sh source /usr/lib/mage/smage2.functions.sh # timeout in seconds LYNX_CONNECT_TIMEOUT=30 ## only for tests -> normally in /etc/rc.d/init.d/functions COLRED="\033[1;6m\033[31m" COLGREEN="\033[1;6m\033[32m" COLYELLOW="\033[1;6m\033[33m" COLBLUE="\033[1;6m\033[34m" COLMAGENTA="\033[1;6m\033[35m" COLWHITE="\033[1;6m\033[37m" COLGRAY="\033[0;6m\033[37m" COLBOLD="\033[1m" COLDEFAULT="\033[0m" if [[ ${NOCOLORS} = true ]] then COLRED="" COLGREEN="" COLYELLOW="" COLBLUE="" COLMAGENTA="" COLWHITE="" COLGRAY="" COLBOLD="" COLDEFAULT="" fi die() { echo "Error: $@"; exit 1; } sminclude() { true; } msetfeature() { true; } mqueryfeature() { true; } haskell_enable_feature() { true; } haskell_disable_feature() { true; } urlencode() { local uri="$@" # fix percent (do this first!!) uri=$(echo ${uri} | sed 's:%:%25:g') # fix spaces uri=$(echo ${uri} | sed 's:\ :%20:g') # fix less than uri=$(echo ${uri} | sed 's:<:%3C:g') # fix greater than uri=$(echo ${uri} | sed 's:>:%3E:g') # fix pound uri=$(echo ${uri} | sed 's:#:%23:g') # fix curly brace left uri=$(echo ${uri} | sed 's:{:%7B:g') # fix curly brace right uri=$(echo ${uri} | sed 's:}:%7D:g') # fix square bracket left uri=$(echo ${uri} | sed 's:\[:%5B:g') # fix square bracket right uri=$(echo ${uri} | sed 's:\]:%5D:g') # return echo "${uri}" } lasttarball() { local suffix=bz2 [[ ! -z $1 ]] && suffix="$1" case ${suffix} in tbz2|tgz) grep "\(\.${suffix}\)\(\$\|\#\)" | sed -n "s/.*-\(.*\)\(\.${suffix}\).*/\1/;$ p" ;; *) grep "\(\.tar\.${suffix}\)\(\$\|\#\)" | sed -n "s/.*-\(.*\)\(\.tar\.${suffix}\).*/\1/;$ p" ;; esac } firsttarball() { local suffix=bz2 [[ ! -z $1 ]] && suffix="$1" case ${suffix} in tbz2|tgz) grep "\(\.${suffix}\)\(\$\|\#\)" | sed "s/.*-\(.*\)\(\.${suffix}\).*/\1/;q" ;; *) grep "\(\.tar\.${suffix}\)\(\$\|\#\)" | sed "s/.*-\(.*\)\(\.tar\.${suffix}\).*/\1/;q" ;; esac } updatecmd() { local uppver local useragent [[ ! -z ${UP2USERAGENT} ]] && useragent="-useragent '${UP2USERAGENT}'" uppver=$(lynx -connect_timeout=${LYNX_CONNECT_TIMEOUT} -dump "${useragent}" $@) if [[ $? -ne 0 ]] then echo "Error connecting '$@'" sleep 1 return 1 fi if [[ ! -z ${UP2SUBSTITUTE} ]] then echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g" else echo "${uppver}" fi } updatecmd_gnu() { local pname=$1 local archive local tarball [[ -z ${pname} ]] && die "give me a \$PNAME" [[ ! -z $2 ]] && archive="$2" tarball="${pname}" [[ ! -z ${UP2TARBALL} ]] && tarball="${UP2TARBALL}" # remove 'latest' tarball too updatecmd "http://ftp.gnu.org/gnu/${pname}/?C=M;O=A" | grep ${tarball}- | sed '/latest/d' | lasttarball "${archive}" } updatecmd_sourceforge_old() { local projectname="$1" local pname="$2" local check_deep_release_id="$3" local archive local uri local group_id local package_link_id local package_id local package_name local release_link_id local release_id [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME" [[ -z ${pname} ]] && pname="${projectname}" case ${check_deep_release_id} in deep|release_id|releaseid) check_deep_release_id="true" ;; esac [[ ! -z $4 ]] && archive="$4" # project home uri uri="http://sourceforge.net/projects/${projectname}" group_id=$(updatecmd ${uri} | grep showfiles | sed 's/.*=\(.*\)/\1/;s/#downloads$//;q') # showfiles.php uri with group_id to get the latest files uri="http://sourceforge.net/project/showfiles.php?group_id=${group_id}" package_link_id=$(updatecmd ${uri} | grep "\[.*\]${pname} \[.*\].*Release.*" | sed "s/.*\[\(.*\)\]${pname}.*/\1/") package_id=$(updatecmd ${uri} | grep "${package_link_id}\..*showfiles.*" | sed 's/.*package_id=\(.*\)/\1/') # debug #echo group_id=${group_id} #echo package_link_id=${package_link_id} #echo package_id=${package_id} uri="http://sourceforge.net/project/showfiles.php?group_id=${group_id}&package_id=${package_id}" package_name=$(updatecmd "${uri}" | grep -m1 'Latest \[.*\]' | sed 's/.*]\(.*\) \[.*\].*/\1/') if [[ ${check_deep_release_id} = true ]] then # showfiles.php uri with group_id and package to get the latest released files uri="http://sourceforge.net/project/showfiles.php?group_id=${group_id}&package_id=${package_id}" release_link_id=$(updatecmd ${uri} | grep ".*Latest.*\[.*\]${package_name} \[.*\].*" | sed "s/.*\[\(.*\)\]${package_name}.*/\1/") release_id=$(updatecmd "${uri}" | grep "${release_link_id}\..*showfiles.*" | sed 's/.*release_id=\(.*\)/\1/') # debug #echo package_name=${package_name} #echo release_link_id=${release_link_id} #echo release_id=${release_id} uri="http://sourceforge.net/project/showfiles.php?group_id=${group_id}&package_id=${package_id}&release_id=${release_id}" case ${archive} in tbz2|tgz) updatecmd "${uri}" | grep "\(\.${suffix}\)" | sed -n "s/.*-\(.*\)\(\.${suffix}\).*/\1/;$ p" ;; *) updatecmd "${uri}" | grep "\(\.tar\.${archive}\)" | sed -n "s/.*-\(.*\)\(\.tar\.${archive}\).*/\1/;$ p" ;; esac else echo "${package_name}" fi } # new layout updatecmd_sourceforge2() { local projectname="$1" local pname="$2" local suffix local uri local package_link_id local package_seperator="-" local excluded [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME" [[ -z ${pname} ]] && pname="${projectname}" [[ ! -z $3 ]] && package_seperator="$3" # project home uri uri="http://sourceforge.net/projects/${projectname}/files" # list of file suffixes, which should be excluded excluded='(.asc|.md5)' # package file names has always the date and time at the end <---------| #package_link_id=$(updatecmd ${uri} | egrep -v ${excluded} | grep -v .md5 | grep -m1 "${pname}${package_seperator}[0-9].* [0-9]" | sed "s/.*\[\(.*\)\]${pname}.*/\1/") package_link_id=$(updatecmd ${uri} | egrep -v ${excluded} | grep -m1 "${pname}${package_seperator}[0-9].* [0-9]" | sed "s/.*\[\(.*\)\].*/\1/") echo DEBUG1:${package_link_id} # get the suffix suffix=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}.*\(\..*\)/\1/") # echo "DEBUG2:${suffix}" case ${suffix} in .tbz2|.tgz|.zip|.rar) #updatecmd ${uri} | grep -m1 "${pname}.*${suffix}" #| sed "s/.*${pname}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1" updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1" ;; *) #updatecmd ${uri} | grep -m1 "${pname}.*.tar${suffix}" | sed "s/.*${pname}\(.*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1" updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}\(.*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1" ;; esac } # new layout, only newest updatecmd_sourceforge_latest() { local projectname="$1" local pname="$2" local suffix local uri local package_link_id local package_seperator="-" local excluded local deep="no" local filename local uppver [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME" [[ -z ${pname} ]] && pname="${projectname}" [[ ! -z $3 ]] && package_seperator="$3" if [[ ! -z $4 ]] then deep="yes" filename="$4" fi # project home uri uri="http://sourceforge.net/projects/${projectname}/files" # list of file suffixes, which should be excluded excluded='(.asc|.md5)' # package file names has always the date and time at the end <---------| # 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/") package_link_id=$(updatecmd ${uri} | grep -A1 'Newest Files' | sed -n "s/.*\[\(.*\)\].*${pname}${package_seperator}.*/\1/;$ p") # if [[ ${deep} = yes ]] # then # #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/") # 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/") # else # #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/") # #package_link_id=$(updatecmd ${uri} | sed -n "/${pname}.*Subscribe.*/,/.*Subscribe.*/p" | grep -v ${excluded} | grep -m1 "${pname}\ \[.*\]" | sed "s/.*\[\(.*\)\].*/\1/") # package_link_id=$(updatecmd ${uri} | grep -A1 'Newest Files' | sed -n "s/.*\[\(.*\)\].*${pname}${package_seperator}.*/\1/;$ p") # fi # #echo DEBUG1:${package_link_id} # get the suffix #suffix=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}.*\(\..*\)\/download/\1/") suffix=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*\(\..*\)\/download/\1/") #echo "DEBUG2:${suffix}" case ${suffix} in .tbz2|.tgz|.zip|.rar|.7z) #updatecmd ${uri} | grep -m1 "${pname}.*${suffix}" #| sed "s/.*${pname}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1" #updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${pname}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1" #updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\(.*\)${suffix}.*/\1/;s/-/_/g;s/_//1" uppver=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\([0-9].*\)${suffix}.*/\1/;s/-/_/g;s/_//1") ;; *) #updatecmd ${uri} | grep -m1 "${pname}.*.tar${suffix}" | sed "s/.*${pname}\(.*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1" #updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\(.*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1" uppver=$(updatecmd -listonly ${uri} | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\([0-9].*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1") ;; esac if [[ ! -z ${UP2SUBSTITUTE} ]] then echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g" else echo "${uppver}" fi } # new layout, only newest updatecmd_sourceforge_lala() { local projectname="$1" local pname="$2" local suffix local uri local opts local package_link_id local package_seperator="-" local excluded local deep="no" local filename="${pname}" local uppver [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME" [[ -z ${pname} ]] && pname="${projectname}" if [[ ! -z $3 ]] then case $3 in null|NULL) package_seperator='' ;; *) package_seperator="$3" ;; esac fi if [[ ! -z $4 ]] then deep="yes" filename="$4" else filename="${pname}" fi # special opts like sort date asc if [[ ! -z ${UP2OPTS} ]] then opts="${UP2OPTS}" else opts='?sort=date&sortdir=asc' fi # project home uri # urlencode $pname uri="http://sourceforge.net/projects/${projectname}/files/$(urlencode ${pname})${opts}" # list of file suffixes, which should be excluded excluded='(.asc|.md5|.exe|.txt|.sign|.rpm|.html|.7z|.dmg)' package_link_id=$(updatecmd "${uri}" | grep "\[.*\]${filename}${package_seperator}" | egrep -v ${excluded} | sed -n "s/.*\[\(.*\)\].*${filename}${package_seperator}.*/\1/;$ p") # get the suffix suffix=$(updatecmd -listonly "${uri}" | grep "\ ${package_link_id}\." | sed "s/.*\(\..*\)\/download/\1/") #echo "DEBUG2:${suffix}" case ${suffix} in .tbz2|.tgz|.zip|.rar|.7z) uppver=$(updatecmd -listonly "${uri}" | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\([0-9].*\)${suffix}.*/\1/;s/-/_/g;s/_//1") ;; *) uppver=$(updatecmd -listonly "${uri}" | grep "\ ${package_link_id}\." | sed "s/.*${package_seperator}\([0-9].*\).tar${suffix}.*/\1/;s/-/_/g;s/_//1") ;; esac if [[ ! -z ${UP2SUBSTITUTE} ]] then echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g" else echo "${uppver}" fi } # new layout, only newest updatecmd_sourceforge_ftp_dir() { local projectname="$1" local pname="$2" local modifier="$3" local uppver # mesh works, kent not #local mirror="http://mesh.dl.sourceforge.net" local mirror="http://garr.dl.sourceforge.net" [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME" [[ -z ${pname} ]] && pname="${projectname}" case ${modifier} in date-asc) modifier='?C=M;O=A' ;; date-desc) modifier='?C=M;O=D' ;; name) modifier='' ;; *) modifier='' ;; esac # urlencode everything projectname=$(urlencode ${projectname}) pname=$(urlencode ${pname}) if [[ ! -z ${UP2EXCLUDE} ]] then uppver=$(updatecmd "${mirror}/project/${projectname}/${pname}/${modifier}" | grep -v -- "${UP2EXCLUDE}" | grep '[DIR].*\[[0-9].*\/' | sed -n 's/.*[0-9]\]\(.*\)\/.*/\1/;$ p') else uppver=$(updatecmd "${mirror}/project/${projectname}/${pname}/${modifier}" | grep '[DIR].*\[[0-9].*\/' | sed -n 's/.*[0-9]\]\(.*\)\/.*/\1/;$ p') fi if [[ ! -z ${UP2SUBSTITUTE} ]] then echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g" else echo "${uppver}" fi } # needs app-text/xmlstarlet updatecmd_sourceforge() { local projectname="$1" local subprojectname="$2" local archive="$3" local uri local project_id local tarballname local seperator local rss_limit=30 local tarballprefix local uppver local allver if [[ -z ${archive} ]] && [[ -n ${subprojectname} ]] then case ${subprojectname} in xz|gz|bz2|tbz|tbz2|txz|tgz|zip|rar|7z|jar) archive="${subprojectname}" unset subprojectname ;; esac fi [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME" [[ -z ${subprojectname} ]] && subprojectname="${projectname}" if [[ -z ${tarballname} ]] then if [[ ${subprojectname} != ${projectname} ]] then tarballname="${subprojectname}" else tarballname="${projectname}" fi fi [[ -z ${seperator} ]] && seperator="-" [[ -z ${archive} ]] && archive="bz2" # overrides [[ ! -z ${UP2TARBALL} ]] && tarballname="${UP2TARBALL}" [[ ! -z ${UP2SEPERATOR} ]] && seperator="${UP2SEPERATOR}" [[ ${UP2SEPERATOR} = NULL ]] && seperator="" uri="http://sourceforge.net/projects/${projectname}" project_id=$(updatecmd ${uri} | grep project-id | sed -e 's:.*project-id/::;s:/.*::') rss_uri="http://sourceforge.net/api/file/index/project-id/${project_id}/mtime/desc/limit/${rss_limit}/rss" case ${archive} in bz2|gz|xz) tarballprefix=".tar.${archive}" ;; tbz|tbz2|txz|tgz|zip|rar|7z|jar) tarballprefix=".${archive}" ;; *) tarballprefix="${archive}" ;; esac if [[ -x $(type -P xml) ]] then allver=$(updatecmd ${rss_uri} | xml sel -T -t -m //item -v title -n) else allver=$(updatecmd ${rss_uri}) fi if [[ ! -z ${UP2EXCLUDE} ]] then allver=$(echo "${allver}" | grep -v -- "${UP2EXCLUDE}") fi allver=$(echo "${allver}" | grep "/${subprojectname}.*/${tarballname}${seperator}.*${tarballprefix}" | sed -e "s:.*${tarballname}${seperator}::;s:${tarballprefix}.*::") #uppver=$(echo "${allver}" | sort -g | tac | head -n 1) uppver=$(echo "${allver}" | sort -g | tac | head -n 1) if [[ ! -z ${UP2SUBSTITUTE} ]] then echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g" else echo "${uppver}" fi } updatecmd_berlios() { local projectname="$1" local pname="$2" local uri local group_id [[ -z ${projectname} ]] && die "give me a \$PROJECTNAME" [[ -z ${pname} ]] && pname="${projectname}" uri="http://developer.berlios.de/projects/${projectname}" group_id=$(updatecmd "${uri}" | grep showfiles | sed 's/.*group_id=\(.*\)&.*/\1/;q') # debug # echo group_id=${group_id} # echo package_link_id=${package_link_id} # echo package_id=${package_id} uri="http://developer.berlios.de/project/showfiles.php?group_id=${group_id}" updatecmd "${uri}" | grep -A3 "^${pname}$" | sed -n 's/.*\[.*]\(.*\) .*[0-9]-.*/\1/;$ p' } updatecmd_freedesktop() { local pname=$1 local archive local subdir local tarballname [[ -z ${pname} ]] && die "give me a \$PNAME" [[ ! -z $2 ]] && archive="$2" [[ ! -z ${UP2SUBDIR} ]] && subdir="/${UP2SUBDIR}" tarballname="${pname}" [[ ! -z ${UP2TARBALL} ]] && tarballname="${UP2TARBALL}" # exclude rc versions! updatecmd "http://${pname}.freedesktop.org/releases${subdir}" | grep ${tarballname}- | grep -v rc[0-9] | lasttarball "${archive}" } updatecmd_xorg() { local pname=$1 local subdir local tarballname local pcat [[ -z ${pname} ]] && die "give me a \$PNAME" [[ ! -z $2 ]] && archive="$2" tarballname="${pname}-" if [[ ! -z ${PCAT} ]] then pcat="${PCAT}" else pcat="${PCATEGORIE}" fi subdir="$(echo ${pcat} | sed -e 's:x11-::' -e 's:media-::' -e 's/\(.*\)s$/\1/')" [[ ! -z ${UP2SUBDIR} ]] && subdir="${UP2SUBDIR}" [[ ! -z ${UP2TARBALL} ]] && tarballname="${UP2TARBALL}" updatecmd "http://xorg.freedesktop.org/archive/individual/${subdir}/?C=M;O=A" | grep "/${tarballname}" | lasttarball "${archive}" } updatecmd_perl() { local pname=$1 local archive local uppver [[ -z ${pname} ]] && die "give me a \$PNAME" [[ ! -z $2 ]] && archive="$2" uppver=$(updatecmd "http://search.cpan.org/dist/${pname}/" | lasttarball "${archive}") if [[ ! -z ${UP2SUBSTITUTE} ]] then echo "${uppver}" | sed "s:${UP2SUBSTITUTE}::g" else echo "${uppver}" fi } updatecmd_gnome() { local uri local pname="$1" [[ -z ${pname} ]] && die "give me a \$PNAME" uri="http://ftp.gnome.org/pub/gnome/sources/${pname}" 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/' } updatecmd_xfce() { local uri local pname="$1" local archive local subdir [[ -z ${pname} ]] && die "give me a \$PNAME" [[ ! -z $2 ]] && archive="$2" if [[ -n ${UP2SUBDIR} ]] then subdir="${UP2SUBDIR}" else subdir="xfce" fi uri="http://archive.xfce.org/src/${subdir}/${pname}" #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}" updatecmd ${uri}/$(updatecmd -source ${uri}'?C=M;O=A' | grep ${pname} |tail -n1 | sed -e 's/<\/a>.*//;s/.*>//') | lasttarball ${archive} } updatecmd_google() { local uri local pname="$1" local archive [[ -z ${pname} ]] && die "give me a \$PNAME" [[ ! -z $2 ]] && archive="$2" uri="http://code.google.com/p/${pname}/downloads/list" updatecmd --listonly "${uri}" | grep ${pname}- | firsttarball "${archive}" } updateme() { local smage="$1" local ONLY_PRINT_UPSTREAM if [[ $1 = --upstream ]] || [[ $1 = -u ]] then if [[ -z $2 ]] || [[ ${2##*.} != smage2 ]] then echo "you must give me a smagefile." exit 1 fi ONLY_PRINT_UPSTREAM=1 smage="$2" fi local PNAME local PCATEGORIE local PCAT local PVER local UP2DATE local UP2PVER local UP2TARBALL local UP2SUBDIR local UP2SUBSTITUTE local UP2USERAGENT local UP2EXCLUDE local UP2SEPERATOR local UP2OPTS local UPSTREAM_PVER PNAME="$(get_value_from_magefile PNAME ${smage})" PCATEGORIE="$(get_value_from_magefile PCATEGORIE ${smage})" PCAT="$(get_value_from_magefile PCAT ${smage})" PVER="$(get_value_from_magefile PVER ${smage})" UP2PVER="$(get_value_from_magefile UP2PVER ${smage})" UP2TARBALL="$(get_value_from_magefile UP2TARBALL ${smage})" UP2SUBDIR="$(get_value_from_magefile UP2SUBDIR ${smage})" UP2SUBSTITUTE="$(get_value_from_magefile UP2SUBSTITUTE ${smage})" UP2USERAGENT="$(get_value_from_magefile UP2USERAGENT ${smage})" UP2EXCLUDE="$(get_value_from_magefile UP2EXCLUDE ${smage})" UP2SEPERATOR="$(get_value_from_magefile UP2SEPERATOR ${smage})" UP2OPTS="$(get_value_from_magefile UP2OPTS ${smage})" [[ -z ${UP2PVER} ]] && UP2PVER="${PVER}" UP2DATE=$(get_value_from_magefile UP2DATE ${smage}) if [[ -z ${UP2DATE} ]] then #echo "\$UP2DATE is empty, skipping ..." continue fi #echo "UP2DATE=${UP2DATE}" #read UPSTREAM_PVER=$(eval "${UP2DATE}") if [[ ${ONLY_PRINT_UPSTREAM} = 1 ]] then echo "${UPSTREAM_PVER}" else # [[ ${UP2PVER} = ${UPSTREAM_PVER} ]] && echo -e "${PNAME}: ${COLGREEN}'${UP2PVER}' = '${UPSTREAM_PVER}'${COLDEFAULT}" # #[[ ${UP2PVER} != ${UPSTREAM_PVER} ]] && echo "${PNAME}: '${UP2PVER}' != '${UPSTREAM_PVER}'" # [[ ${UP2PVER} < ${UPSTREAM_PVER} ]] && echo -e "${PNAME}: ${COLRED}'${UP2PVER}' < '${UPSTREAM_PVER}'${COLDEFAULT}" # [[ ${UP2PVER} > ${UPSTREAM_PVER} ]] && echo -e "${PNAME}: ${COLYELLOW}'${UP2PVER}' > '${UPSTREAM_PVER}'${COLDEFAULT}" local retval retval=$(/home/tjoke/archlinux_version/vercomp "${UP2PVER}" "${UPSTREAM_PVER}") [ ${retval} -eq 0 ] && echo -e "${PNAME}: ${COLGREEN}'${UP2PVER}' = '${UPSTREAM_PVER}'${COLDEFAULT}" [ ${retval} -lt 0 ] && echo -e "${PNAME}: ${COLRED}'${UP2PVER}' < '${UPSTREAM_PVER}'${COLDEFAULT}" [ ${retval} -gt 0 ] && echo -e "${PNAME}: ${COLYELLOW}'${UP2PVER}' > '${UPSTREAM_PVER}'${COLDEFAULT}" fi } updateall() { #local REPOS local PACKAGE local smage local repo local UP2DATE_SLEEP_COUNT=15 local UP2DATE_SLEEP_TIMEOUT=3 local ONLY_PRINT_UPSTREAM=0 : ${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"} # REPOS="/home/tjoke/svn/smage/trunk/core /home/tjoke/svn/smage/trunk/extras" # REPOS="/home/tjoke/svn/smage/trunk/core" # PACKAGE="glibc-nptl" # PACKAGE="autoconf21" PACKAGE="*" [[ ! -z $1 ]] && PACKAGE="$1" if [[ $1 = --upstream ]] || [[ $1 = -u ]] then if [[ -z $2 ]] || [[ ${2##*.} != smage2 ]] then echo "you must give me a smagefile." exit 1 fi updateme $1 $2 return 0 fi ############################################################################## # recurse all depends if requested # if [[ $1 = --depend ]] || [[ $1 = -d ]] then if [[ -z $2 ]] || [[ ${2##*.} != smage2 ]] then echo "you must give me a smagefile." exit 1 fi SMAGEFILE="$2" PACKAGE="$(magename2pname ${SMAGEFILE})" echo "processing '${SMAGEFILE}' ..." echo "running dependency checks for package '${PACKAGE}'..." DEPEND=$(get_value_from_magefile DEPEND ${SMAGEFILE}) SDEPEND=$(get_value_from_magefile SDEPEND ${SMAGEFILE}) declare -i c=0 while read sign dep do case ${dep} in "") continue;; esac # sleep every 15 packages for 5 seconds (( c++ )) if [[ ${c} -eq ${UP2DATE_SLEEP_COUNT} ]] then declare -i c=0 echo "DEBUG: Sleep Count (${UP2DATE_SLEEP_COUNT}x) reached, sleeping for ${UP2DATE_SLEEP_TIMEOUT} seconds ..." sleep ${UP2DATE_SLEEP_TIMEOUT} fi #echo "debug: ${dep}" updateme "$(dep2pname ${dep})" done << EOF ${DEPEND} ${SDEPEND} EOF fi # # eof recurse ############################################################################## for repo in ${REPOS} do # exclude not existing [[ ${PACKAGE} != \* ]] && [[ ! -d ${repo}/${PACKAGE} ]] && continue declare -i c=0 for smage in ${repo}/${PACKAGE}/*.smage2 do updateme ${smage} # sleep every 15 packages for 5 seconds (( c++ )) if [[ ${c} -eq ${UP2DATE_SLEEP_COUNT} ]] then declare -i c=0 echo "DEBUG: Sleep Count (${UP2DATE_SLEEP_COUNT}x) reached, sleeping for ${UP2DATE_SLEEP_TIMEOUT} seconds ..." sleep ${UP2DATE_SLEEP_TIMEOUT} fi done done } updateall $@