-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild-rpms.sh
executable file
·108 lines (86 loc) · 4.21 KB
/
build-rpms.sh
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Copyright (C) 2013-2014 Computer Sciences Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
function build_rpm() {
spec_file=$1
rpmbuild --quiet --define="_topdir $PWD/rpmbuild" -bb rpmbuild/SPECS/$spec_file
}
echo "Creating RPM build directories"
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
echo "Creating/Downloading source tarballs"
git archive \
--format=tar \
--prefix java-thriftrunner-cartridge.git/ \
HEAD:openshift-cartridges/java-thriftrunner-cartridge/ | \
gzip > rpmbuild/SOURCES/java-thriftrunner-cartridge.tar.gz
git archive \
--format=tar \
--prefix logstash-cartridge/ \
HEAD:openshift-cartridges/logstash-cartridge/ | \
gzip > rpmbuild/SOURCES/logstash-cartridge.tar.gz
git archive \
--format=tar \
--prefix play-framework-cartridge.git/ \
HEAD:openshift-cartridges/play-framework-cartridge/ | \
gzip > rpmbuild/SOURCES/play-framework-cartridge.tar.gz
git archive \
--format=tar \
--prefix ezbake-logstash-helper.git/ \
HEAD:logstash-helper/ | \
gzip > rpmbuild/SOURCES/ezbake-logstash-helper.tar.gz
wildfly_gitrev=$(grep -E '^%global gitrev ' openshift-cartridges/wildfly-cartridge-rpm/openshift-origin-cartridge-wildfly.spec | cut -d' ' -f3)
if [ ! -f rpmbuild/SOURCES/$wildfly_gitrev.tar.gz ]; then
wget https://github.com/openshift-cartridges/openshift-wildfly-cartridge/archive/$wildfly_gitrev.tar.gz \
-O rpmbuild/SOURCES/$wildfly_gitrev.tar.gz
fi
THRIFT_VERSION="0.9.1"
thrift_tarball=thrift-$THRIFT_VERSION.tar.gz
if [ ! -f rpmbuild/SOURCES/$thrift_tarball ]; then
wget https://archive.apache.org/dist/thrift/$THRIFT_VERSION/$thrift_tarball \
-O rpmbuild/SOURCES/$thrift_tarball
fi
echo "Copying spec files to RPM build directory"
cp openshift-cartridges/java-thriftrunner-cartridge/openshift-origin-cartridge-java-thriftrunner.spec \
rpmbuild/SPECS/openshift-origin-cartridge-java-thriftrunner.spec
cp openshift-cartridges/logstash-cartridge/openshift-origin-cartridge-logstash.spec \
rpmbuild/SPECS/openshift-origin-cartridge-logstash.spec
cp openshift-cartridges/play-framework-cartridge/openshift-origin-cartridge-play-framework.spec \
rpmbuild/SPECS/openshift-origin-cartridge-play-framework.spec
cp openshift-cartridges/wildfly-cartridge-rpm/openshift-origin-cartridge-wildfly.spec \
rpmbuild/SPECS/openshift-origin-cartridge-wildfly.spec
cp thrift-rpm/thrift.spec rpmbuild/SPECS/thrift.spec
cp logstash-helper/ezbake_logstash_helper.spec rpmbuild/SPECS/ezbake_logstash_helper.spec
echo "Modifying spec files"
sed -i \
-e "s/^\%global gitrev [0-9a-f]*$/\%global gitrev $(git rev-parse --short HEAD)/" \
-e "s/Release: [0-9]*\./Release: $(git show -s --format="%ct" HEAD)\./" \
rpmbuild/SPECS/openshift-origin-cartridge-java-thriftrunner.spec
sed -r -i \
-e "s/^\%global gitrev [0-9a-f]*$/\%global gitrev $(git rev-parse --short HEAD)/" \
-e "s/Release:[[:space:]]*[0-9]+\./Release: $(git show -s --format="%ct" HEAD)\./" \
rpmbuild/SPECS/openshift-origin-cartridge-play-framework.spec
sed -r -i \
-e "s/Release:[[:space:]]*[0-9]+\./Release: $(git show -s --format="%ct" HEAD)\./" \
rpmbuild/SPECS/openshift-origin-cartridge-wildfly.spec
sed -i \
-e "s/^\%global gitrev [0-9a-f]*$/\%global gitrev $(git rev-parse --short HEAD)/" \
-e "s/Release: [0-9]*\./Release: $(git show -s --format="%ct" HEAD)\./" \
rpmbuild/SPECS/ezbake_logstash_helper.spec
echo "Building RPMs"
build_rpm openshift-origin-cartridge-java-thriftrunner.spec
build_rpm openshift-origin-cartridge-logstash.spec
build_rpm openshift-origin-cartridge-play-framework.spec
build_rpm openshift-origin-cartridge-wildfly.spec
build_rpm thrift.spec
build_rpm ezbake_logstash_helper.spec