-
Notifications
You must be signed in to change notification settings - Fork 9
/
build-gems
executable file
·86 lines (76 loc) · 2.28 KB
/
build-gems
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
GEM_PREFIX="${GEM_PREFIX-$(ruby -rubygems -e 'puts Gem.dir')}"
GEM_BIN_PATH="${GEM_BIN_PATH-/usr/bin}"
RUBY_ABI_DEP="${RUBY_ABI_DEP-ruby(abi) = 1.8}"
if [ "$1"x != "x" ]; then
TARGET="$1";
else
TARGET="${TARGET-gem-list}"
fi
if [ ! -f $TARGET ]; then
echo "The specified file with targets does not exist: '$TARGET'";
exit 1;
fi
count=`cat $TARGET| grep -v '^#' | wc -l`
cl=`echo $count | wc -c`
i=0;
[ -f failed.txt ] && rm failed.txt
[ -d BUILD ] || mkdir -p BUILD
while read gem
do
RETVAL=0
let 'i++';
echo $gem | grep -q ':' || gem="${gem}:"
prefix="`printf "[%${cl}d/%d]" $i $count`";
echo "$prefix Parsing line '${gem}'";
basename=`echo $gem | cut -d':' -f 1 `
version=`echo $gem | cut -d':' -f 2 `
arch=`echo $gem | cut -d':' -f 3 `
extra_args=`echo $gem | cut -d':' -f 4- `
cd BUILD
if [ x$version == 'x' ]; then
echo "$prefix Building latest $basename"
elif [ $version == 'pre' ]; then
echo "$prefix Getting latest prerelease $basename"
gemfile="`gem fetch --pre $basename | grep Downloaded`";
RETVAL=$?
version=`echo $gemfile | sed -e "s/Downloaded ${basename}-//"`;
basename="./${basename}-${version}.gem"
else
echo "$prefix Building $basename version $version"
extra_args="-v $version $extra_args"
fi
extra_args="--gem-bin-path $GEM_BIN_PATH --vendor Inuits --prefix $GEM_PREFIX $extra_args"
extra_args="-d 'ruby(rubygems)' -d '$RUBY_ABI_DEP' $extra_args"
if [ "$arch" == 'arch' ]; then
echo "$prefix not specifying noarch to build!"
else
extra_args="-a noarch $extra_args";
fi;
if [[ x$RETVAL == 'x' || $RETVAL == 0 ]]; then
eval fpm -t rpm -s gem $extra_args $basename | tee currentbuild.txt
RETVAL=$?
fi;
echo "$prefix Build of $basename returned with $RETVAL"
if [ $RETVAL -ne 0 ]; then
if cat currentbuild.txt | grep -q 'File already exists, refusing to continue'; then
echo "$prefix File already exists: skipping (OVERRIDES ERROR)",
else
echo $gem >> ../failed.txt
fi
fi
cd ../
done < <(cat $TARGET| grep -v '^#' | grep -v '^$' )
if [ -d ARTEFACTS ]
then
rm -rf ARTEFACTS
fi
mkdir ARTEFACTS
mv BUILD/*.rpm ARTEFACTS
rm -rf BUILD
if [ -f failed.txt ]; then
errcount=`cat failed.txt | wc -l`
if [ $errcount -gt 0 ]; then
exit 1;
fi;
fi;