-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrailsbuild-update-pkgs
executable file
·69 lines (58 loc) · 1.86 KB
/
railsbuild-update-pkgs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Prepare the update of all Rails gems at once in Fedora git
# repositories at:
# ~/.railsbuild/f$FEDORA_VERSION/rubygem-$gem
#
# Usage:
# ./railsbuild-update-pkgs FEDORA_VERSION OLD_VERSION NEW_VERSION
. $(dirname $(readlink -f "$0"))/railsbuild-common
FEDORA_VERSION=$1
OLD_VERSION=$2
NEW_VERSION=$3
for gem in "${GEMS[@]}"
do
echo "Updating $gem:"
pushd ~/.railsbuild/f$FEDORA_VERSION/rubygem-$gem/
git pull
if [ "$FEDORA_VERSION" = "$FEDORA_RAWHIDE" ]; then
git checkout master
else
git checkout f$FEDORA_VERSION
fi
gem fetch $gem --version $NEW_VERSION
UPDATED=`cat ./rubygem-$gem.spec | grep "Version: $NEW_VERSION"`
if [ "$UPDATED" == "Version: $NEW_VERSION" ]; then
echo "$gem: already updated"
continue
fi
EPOCH=`cat ./rubygem-$gem.spec | grep -E "Epoch:(.*)" | sed 's/Epoch: //'`
if [ "$EPOCH" ]; then
epoch_prefix="$EPOCH:"
else
epoch_prefix=""
fi
sed -i -e "s/git checkout v$OLD_VERSION/git checkout v$NEW_VERSION/" rubygem-$gem.spec
sed -i -e "s/$OLD_VERSION-tests.tgz/$NEW_VERSION-tests.tgz/" rubygem-$gem.spec
sed -i -e "s/Version:.*$OLD_VERSION/Version: $NEW_VERSION/g" rubygem-$gem.spec
sed -i -e "s/Release:.*/Release: 1%{?dist}/g" rubygem-$gem.spec
# Set to default locale for the changelog date format
export LC_ALL=C
CHANGELOG='* '
CHANGELOG+=`date +'%a %b %d %Y'`
CHANGELOG+=" "
CHANGELOG+=`rpmdev-packager`
CHANGELOG+=" - $epoch_prefix$NEW_VERSION-1\n"
CHANGELOG+="- Update to $gem $NEW_VERSION"
sed -i -e "s/%changelog/%changelog\n$CHANGELOG\n/g" rubygem-$gem.spec
echo "$gem: rubygem-$gem.spec updated"
popd
done
# Mark bootsrapping
for gem in "${BOOTSTRAPPED_GEMS[@]}"
do
pushd ~/.railsbuild/f$FEDORA_VERSION/rubygem-$gem/
# Enable bootstrapping if necessary
sed -i -e "s/%global bootstrap 0/%global bootstrap 1/" rubygem-$gem.spec
touch .bootstrapped
popd
done