2016-04-30 09:40:40 +02:00
|
|
|
#!/bin/bash -e
|
2015-10-24 17:14:56 +02:00
|
|
|
|
2018-08-28 03:04:44 +02:00
|
|
|
PRODUCT=scylla
|
|
|
|
|
2017-06-15 12:02:30 +02:00
|
|
|
. /etc/os-release
|
|
|
|
print_usage() {
|
2018-10-24 04:45:11 +02:00
|
|
|
echo "build_deb.sh --reloc-pkg build/scylla-jmx-package.tar.gz"
|
|
|
|
echo " --reloc-pkg specify relocatable package path"
|
2017-06-15 12:02:30 +02:00
|
|
|
exit 1
|
|
|
|
}
|
2018-10-24 04:45:11 +02:00
|
|
|
TARGET=stable
|
|
|
|
RELOC_PKG=
|
2017-06-15 12:02:30 +02:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
2018-10-24 04:45:11 +02:00
|
|
|
"--reloc-pkg")
|
|
|
|
RELOC_PKG=$2
|
2017-06-15 12:02:30 +02:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
print_usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
is_redhat_variant() {
|
|
|
|
[ -f /etc/redhat-release ]
|
|
|
|
}
|
|
|
|
is_debian_variant() {
|
|
|
|
[ -f /etc/debian_version ]
|
|
|
|
}
|
|
|
|
pkg_install() {
|
|
|
|
if is_redhat_variant; then
|
|
|
|
sudo yum install -y $1
|
|
|
|
elif is_debian_variant; then
|
|
|
|
sudo apt-get install -y $1
|
|
|
|
else
|
|
|
|
echo "Requires to install following command: $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-10-24 04:45:11 +02:00
|
|
|
if [ ! -e SCYLLA-RELOCATABLE-FILE ]; then
|
|
|
|
echo "do not directly execute build_rpm.sh, use reloc/build_rpm.sh instead."
|
2015-10-24 17:14:56 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-10-24 04:45:11 +02:00
|
|
|
|
2017-06-15 12:02:30 +02:00
|
|
|
if [ "$(arch)" != "x86_64" ]; then
|
|
|
|
echo "Unsupported architecture: $(arch)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-10-24 17:14:56 +02:00
|
|
|
|
2018-10-24 04:45:11 +02:00
|
|
|
if [ -z "$RELOC_PKG" ]; then
|
|
|
|
print_usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! -f "$RELOC_PKG" ]; then
|
|
|
|
echo "$RELOC_PKG is not found."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-06-15 12:02:30 +02:00
|
|
|
if [ -e debian ] || [ -e build/release ]; then
|
2017-12-04 08:52:21 +01:00
|
|
|
sudo rm -rf debian build
|
2017-06-15 12:02:30 +02:00
|
|
|
mkdir build
|
2015-11-24 17:57:53 +01:00
|
|
|
fi
|
2017-06-15 12:02:30 +02:00
|
|
|
if is_debian_variant; then
|
|
|
|
sudo apt-get -y update
|
2016-12-29 10:33:56 +01:00
|
|
|
fi
|
2017-06-15 12:02:30 +02:00
|
|
|
# this hack is needed since some environment installs 'git-core' package, it's
|
|
|
|
# subset of the git command and doesn't works for our git-archive-all script.
|
|
|
|
if is_redhat_variant && [ ! -f /usr/libexec/git-core/git-submodule ]; then
|
2017-06-19 18:53:31 +02:00
|
|
|
sudo yum install -y git
|
2017-06-15 12:02:30 +02:00
|
|
|
fi
|
|
|
|
if [ ! -f /usr/bin/git ]; then
|
|
|
|
pkg_install git
|
2016-12-29 10:33:56 +01:00
|
|
|
fi
|
2017-02-14 07:38:23 +01:00
|
|
|
if [ ! -f /usr/bin/python ]; then
|
2017-06-15 12:02:30 +02:00
|
|
|
pkg_install python
|
2017-02-14 07:38:23 +01:00
|
|
|
fi
|
2018-10-24 04:45:11 +02:00
|
|
|
if [ ! -f /usr/sbin/debuild ]; then
|
|
|
|
pkg_install devscripts
|
2017-06-15 12:02:30 +02:00
|
|
|
fi
|
|
|
|
if [ ! -f /usr/bin/dh_testdir ]; then
|
|
|
|
pkg_install debhelper
|
2017-01-02 18:24:38 +01:00
|
|
|
fi
|
2018-10-24 04:45:11 +02:00
|
|
|
if [ ! -f /usr/bin/fakeroot ]; then
|
|
|
|
pkg_install fakeroot
|
|
|
|
fi
|
2018-06-06 20:31:13 +02:00
|
|
|
if [ ! -f /usr/bin/pystache ]; then
|
|
|
|
if is_redhat_variant; then
|
2018-07-03 20:32:11 +02:00
|
|
|
sudo yum install -y /usr/bin/pystache
|
2018-06-06 20:31:13 +02:00
|
|
|
elif is_debian_variant; then
|
|
|
|
sudo apt-get install -y python-pystache
|
|
|
|
fi
|
|
|
|
fi
|
2017-01-02 18:24:38 +01:00
|
|
|
|
2018-10-08 13:07:24 +02:00
|
|
|
if [ "$ID" = "ubuntu" ] && [ ! -f /usr/share/keyrings/debian-archive-keyring.gpg ]; then
|
|
|
|
sudo apt-get install -y debian-archive-keyring
|
|
|
|
fi
|
|
|
|
if [ "$ID" = "debian" ] && [ ! -f /usr/share/keyrings/ubuntu-archive-keyring.gpg ]; then
|
|
|
|
sudo apt-get install -y ubuntu-archive-keyring
|
|
|
|
fi
|
2017-06-15 12:02:30 +02:00
|
|
|
|
2018-10-24 04:45:11 +02:00
|
|
|
RELOC_PKG_FULLPATH=$(readlink -f $RELOC_PKG)
|
|
|
|
RELOC_PKG_BASENAME=$(basename $RELOC_PKG)
|
|
|
|
SCYLLA_VERSION=$(cat SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/')
|
|
|
|
SCYLLA_RELEASE=$(cat SCYLLA-RELEASE-FILE)
|
2017-01-02 18:24:38 +01:00
|
|
|
|
2018-10-24 04:45:11 +02:00
|
|
|
ln -fv $RELOC_PKG_FULLPATH ../$PRODUCT-jmx_$SCYLLA_VERSION-$SCYLLA_RELEASE.orig.tar.gz
|
2015-11-24 17:57:53 +01:00
|
|
|
|
2018-10-24 04:45:11 +02:00
|
|
|
cp -al dist/debian/debian debian
|
2018-08-28 03:04:44 +02:00
|
|
|
if [ "$PRODUCT" != "scylla" ]; then
|
|
|
|
for i in debian/scylla-*;do
|
|
|
|
mv $i ${i/scylla-/$PRODUCT-}
|
|
|
|
done
|
|
|
|
fi
|
2018-06-06 20:31:13 +02:00
|
|
|
|
2018-10-24 04:45:11 +02:00
|
|
|
REVISION="1"
|
2018-08-28 03:04:44 +02:00
|
|
|
MUSTACHE_DIST="\"debian\": true, \"$TARGET\": true, \"product\": \"$PRODUCT\", \"$PRODUCT\": true"
|
|
|
|
pystache dist/debian/changelog.mustache "{ $MUSTACHE_DIST, \"version\": \"$SCYLLA_VERSION\", \"release\": \"$SCYLLA_RELEASE\", \"revision\": \"$REVISION\", \"codename\": \"$TARGET\" }" > debian/changelog
|
2018-06-06 20:31:13 +02:00
|
|
|
pystache dist/debian/rules.mustache "{ $MUSTACHE_DIST }" > debian/rules
|
|
|
|
chmod a+rx debian/rules
|
2018-08-28 03:04:44 +02:00
|
|
|
pystache dist/debian/control.mustache "{ $MUSTACHE_DIST }" > debian/control
|
2018-06-06 20:31:13 +02:00
|
|
|
|
2018-10-24 04:45:11 +02:00
|
|
|
pystache dist/common/systemd/scylla-jmx.service.mustache "{ $MUSTACHE_DIST }" > debian/scylla-jmx.service
|
|
|
|
|
|
|
|
debuild -rfakeroot -us -uc
|