Merge branch 'dev-3.5.4'
[packages/eventum.git] / update-source.sh
1 #!/bin/sh
2 set -e
3 dropin=
4 repo_url=https://github.com/eventum/eventum
5 specfile=eventum.spec
6
7 # Work in package dir
8 dir=$(dirname "$0")
9 cd "$dir"
10
11 if [ -f "$1" ]; then
12         rev=$1
13         rev=${rev#eventum-*-}
14         rev=${rev%.tar.gz}
15 elif [ "$1" ]; then
16         rev=$1
17 else
18         # use tarball from "snapshot" build
19         git fetch "$repo_url" refs/tags/snapshot
20         # save this under some local ref, so repeated calls don't have to fetch everything
21         git update-ref refs/keep-around/snapshot FETCH_HEAD
22         out=$(git show FETCH_HEAD -s)
23         tarball=$(echo "$out" | grep -o 'eventum-.*\.tar.gz')
24         url="$repo_url/releases/download/snapshot/$tarball"
25         test -f "$tarball" || wget -c $url
26         exec "$0" "$tarball"
27 fi
28
29 subver=${rev%-*}
30 githash=${rev#*-g}
31
32 echo "Using $rev (subver: $subver, githash: $githash)..."
33
34 oldsubver=$(awk '/^%define[\t ]+subver[\t ]+/{print $NF}' $specfile)
35 oldgithash=$(awk '/^%define[\t ]+githash[\t ]+/{print $NF}' $specfile)
36 if [ "$oldsubver" = "$subver" -a "$oldgithash" = "$githash" ]; then
37         echo "Already up to date"
38         exit 0
39 fi
40
41 echo "Updating $specfile for $rev (subver: $subver, githash: $githash)..."
42 sed -i -re "
43         s/^[#%](define[ \t]+subver[ \t]+)[0-9]+\$/%\1$subver/
44         s/^[#%](define[ \t]+githash[ \t]+)[0-9a-fg]+\$/%\1$githash/
45 " $specfile
46 ../builder -ncs -5 $specfile
This page took 0.050385 seconds and 3 git commands to generate.