2016-04-30 09:40:40 +02:00
|
|
|
#!/bin/bash -e
|
2015-09-01 21:32:54 +02:00
|
|
|
|
2018-08-22 09:21:04 +02:00
|
|
|
PRODUCT=scylla
|
|
|
|
|
2017-05-22 10:17:59 +02:00
|
|
|
. /etc/os-release
|
|
|
|
print_usage() {
|
2018-10-24 04:04:47 +02:00
|
|
|
echo "build_rpm.sh --reloc-pkg build/scylla-jmx-package.tar.gz"
|
2017-05-22 10:17:59 +02:00
|
|
|
echo " --target target distribution in mock cfg name"
|
|
|
|
exit 1
|
|
|
|
}
|
2018-10-24 04:04:47 +02:00
|
|
|
RELOC_PKG=
|
2017-05-22 10:17:59 +02:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
2018-10-24 04:04:47 +02:00
|
|
|
"--reloc-pkg")
|
|
|
|
RELOC_PKG=$2
|
2017-05-22 10:17:59 +02:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
print_usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
is_redhat_variant() {
|
|
|
|
[ -f /etc/redhat-release ]
|
|
|
|
}
|
|
|
|
pkg_install() {
|
|
|
|
if is_redhat_variant; then
|
|
|
|
sudo yum install -y $1
|
|
|
|
else
|
|
|
|
echo "Requires to install following command: $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-10-24 04:04:47 +02:00
|
|
|
if [ ! -e SCYLLA-RELOCATABLE-FILE ]; then
|
|
|
|
echo "do not directly execute build_rpm.sh, use reloc/build_rpm.sh instead."
|
2015-09-01 21:32:54 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2015-10-12 22:39:47 +02:00
|
|
|
|
2018-10-24 04:04:47 +02:00
|
|
|
if [ -z "$RELOC_PKG" ]; then
|
|
|
|
print_usage
|
2017-05-22 10:17:59 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-10-24 04:04:47 +02:00
|
|
|
if [ ! -f "$RELOC_PKG" ]; then
|
|
|
|
echo "$RELOC_PKG is not found."
|
|
|
|
exit 1
|
2018-04-08 14:21:38 +02:00
|
|
|
fi
|
|
|
|
|
2017-05-22 10:17:59 +02:00
|
|
|
if [ ! -f /usr/bin/git ]; then
|
|
|
|
pkg_install git
|
2015-09-01 21:32:54 +02:00
|
|
|
fi
|
2018-06-06 20:31:13 +02:00
|
|
|
if [ ! -f /usr/bin/pystache ]; then
|
|
|
|
if is_redhat_variant; then
|
|
|
|
sudo yum install -y python2-pystache || sudo yum install -y pystache
|
|
|
|
elif is_debian_variant; then
|
|
|
|
sudo apt-get install -y python-pystache
|
|
|
|
fi
|
|
|
|
fi
|
2015-10-12 22:39:47 +02:00
|
|
|
|
2018-10-24 04:04:47 +02:00
|
|
|
SCYLLA_VERSION=$(cat SCYLLA-VERSION-FILE)
|
|
|
|
SCYLLA_RELEASE=$(cat SCYLLA-RELEASE-FILE)
|
|
|
|
VERSION=$SCYLLA_VERSION-$SCYLLA_RELEASE
|
2017-05-22 10:17:59 +02:00
|
|
|
|
2018-10-24 04:04:47 +02:00
|
|
|
RPMBUILD=$(readlink -f ../)
|
|
|
|
mkdir -p $RPMBUILD/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
|
|
|
|
|
|
|
|
ln -fv $RELOC_PKG $RPMBUILD/SOURCES/
|
|
|
|
pystache dist/redhat/scylla-jmx.spec.mustache "{ \"version\": \"$SCYLLA_VERSION\", \"release\": \"$SCYLLA_RELEASE\", \"product\": \"$PRODUCT\", \"$PRODUCT\": true }" > $RPMBUILD/SPECS/scylla-jmx.spec
|
2018-07-19 18:32:58 +02:00
|
|
|
|
2018-10-24 04:04:47 +02:00
|
|
|
# this rpm can be install on both fedora / centos7, so drop distribution name from the file name
|
|
|
|
rpmbuild -ba --define "_topdir $RPMBUILD" --undefine "dist" $RPM_JOBS_OPTS $RPMBUILD/SPECS/scylla-jmx.spec
|