]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - relup.sh
- more
[packages/rpm-build-tools.git] / relup.sh
index 852bceef434fed688dc43f4d322a32e1a8c13a41..7557ba619b1282596364914aa6d253ba8159fbea 100755 (executable)
--- a/relup.sh
+++ b/relup.sh
@@ -17,13 +17,15 @@ get_dump() {
 }
 
 usage="Usage:
-${0##*/} [-i] [-u] [-t] [-n] [-m <MESSAGE>] <SPECLIST>
+${0##*/} [-i] [-g] [-u] [-t|-n] [-m <MESSAGE>] <SPECLIST>
 
 Options:
 -i
   Try to increment package release
+-g
+ get packages if missing, do nothing else
 -u
-  git pull first
+ update packages (git pull)
 -t | -n
   Test mode (dry-run). do not commit
 -m
@@ -75,6 +77,8 @@ bump_release() {
 package_name() {
        local specfile="${1%/}" package
 
+       # strip branch
+       specfile=${specfile%:*}
        # basename
        specfile=${specfile##*/}
        # strip .spec
@@ -83,12 +87,24 @@ package_name() {
        echo $package
 }
 
+get_branch() {
+       local specfile="${1%/}" branch
+
+       branch=${specfile#*:}
+
+       if [ "$branch" != "$specfile" ]; then
+               echo "$branch"
+       else
+               echo ""
+       fi
+}
+
 if [ ! -x /usr/bin/getopt ]; then
        echo >&1 "You need to install util-linux to use relup.sh"
        exit 1
 fi
 
-t=$(getopt -o 'm:inuth' -n "${0##*/}" -- "$@") || exit $?
+t=$(getopt -o 'm:inguth' -n "${0##*/}" -- "$@") || exit $?
 # Note the quotes around `$t': they are essential!
 eval set -- "$t"
 
@@ -100,6 +116,9 @@ while true; do
        -u)
                update=1
                ;;
+       -g)
+               get=1
+               ;;
        -t | -n)
                test=1
                ;;
@@ -130,6 +149,7 @@ n="${n%%n}"
 
 cd "$topdir"
 for pkg in "$@"; do
+       branch=$(get_branch "$pkg")
        # pkg: package %{name}
        pkg=$(package_name "$pkg")
 
@@ -144,13 +164,25 @@ for pkg in "$@"; do
        specname=${spec##*/}
 
        # start real work
-       echo "$pkg ..."
+       if [ -n "$branch" ]; then
+               echo "$pkg:$branch ..."
+       else
+               echo "$pkg ..."
+       fi
 
        # get package
-       if [ "$update" = "1" ]; then
-               ./builder -g -ns "$spec"
+       [ "$get" = 1 -a -d "$pkgdir" ] && continue
+
+       if [ "$update" = "1" -o "$get" = "1" ]; then
+               if [ -n "$branch" ]; then
+                       ./builder -g -ns "$spec" -r $branch
+               else
+                       ./builder -g -ns "$spec"
+               fi
        fi
 
+       [ "$get" = 1 ] && continue
+
        # update .spec files
        rel=$(get_release "$spec")
        if [ "$inc" = 1 ]; then
@@ -162,6 +194,9 @@ for pkg in "$@"; do
                        newrel=$(bump_release ${rel})
                        set_release "$spec" $rel $newrel
                fi
+
+               # refetch release
+               rel=$(get_release "$spec")
        fi
 
        # commit the changes
This page took 0.038564 seconds and 4 git commands to generate.