+# set version to $version in $specfile and build the package
+update_version() {
+ local specfile="$1" version="$2" out
+
+ # update version
+ sed -i -e "
+ s/^\(Version:[ \t]\+\)[.0-9]\+\$/\1$version/
+ s/^\(Release:[ \t]\+\)[.0-9]\+\$/\11/
+ " $specfile
+
+ rm *.zip *.gz *.xz
+ # update md5
+ out=$(md5 -p1 $specfile 2>&1) || echo "$out"
+
+ # build it
+ out=$(builder -bb $specfile 2>&1) || echo "$out"
+}
+
+commit_vcs() {
+ local specfile="$1" version="$2"
+
+ git commit -m "updated to $version" $specfile
+ git push || echo push failed
+}
+
+# get version from package files
+# set $version variable
+version_from_files() {
+ local pkg=$1 url fn dt d
+ shift
+
+ for url in "$@"; do
+ # take output filename (anything after last slash)
+ fn=${url##*/}
+ # skip inexistent files
+ test -e "$fn" || continue
+
+ d=$(filedate "$fn")
+ if [ "$(echo $d | tr -d -)" -gt "$(echo $dt | tr -d -)" ]; then
+ dt=$d
+ fi
+ done