2016-04-30 07:40:40 +00:00
|
|
|
#!/bin/bash -e
|
2015-10-25 00:14:56 +09:00
|
|
|
|
2018-08-28 10:04:44 +09:00
|
|
|
PRODUCT=scylla
|
|
|
|
|
2017-06-15 19:02:30 +09:00
|
|
|
. /etc/os-release
|
|
|
|
print_usage() {
|
|
|
|
echo "build_deb.sh -target <codename>"
|
|
|
|
echo " --target target distribution codename"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
TARGET=
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
"--target")
|
|
|
|
TARGET=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
print_usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
is_redhat_variant() {
|
|
|
|
[ -f /etc/redhat-release ]
|
|
|
|
}
|
|
|
|
is_debian_variant() {
|
|
|
|
[ -f /etc/debian_version ]
|
|
|
|
}
|
2018-07-04 03:32:11 +09:00
|
|
|
is_debian() {
|
|
|
|
case "$1" in
|
|
|
|
jessie|stretch) return 0;;
|
|
|
|
*) return 1;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
is_ubuntu() {
|
|
|
|
case "$1" in
|
|
|
|
trusty|xenial|bionic) return 0;;
|
|
|
|
*) return 1;;
|
|
|
|
esac
|
|
|
|
}
|
2017-06-15 19:02:30 +09:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-02-08 18:48:52 +09:00
|
|
|
if [ ! -e dist/debian/build_deb.sh ]; then
|
2015-10-25 00:14:56 +09:00
|
|
|
echo "run build_deb.sh in top of scylla dir"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-06-15 19:02:30 +09:00
|
|
|
if [ "$(arch)" != "x86_64" ]; then
|
|
|
|
echo "Unsupported architecture: $(arch)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-10-25 00:14:56 +09:00
|
|
|
|
2017-06-15 19:02:30 +09:00
|
|
|
if [ -e debian ] || [ -e build/release ]; then
|
2017-12-04 16:52:21 +09:00
|
|
|
sudo rm -rf debian build
|
2017-06-15 19:02:30 +09:00
|
|
|
mkdir build
|
2015-11-25 01:57:53 +09:00
|
|
|
fi
|
2017-06-15 19:02:30 +09:00
|
|
|
if is_debian_variant; then
|
|
|
|
sudo apt-get -y update
|
2016-12-29 18:33:56 +09:00
|
|
|
fi
|
2017-06-15 19:02:30 +09: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-20 01:53:31 +09:00
|
|
|
sudo yum install -y git
|
2017-06-15 19:02:30 +09:00
|
|
|
fi
|
|
|
|
if [ ! -f /usr/bin/git ]; then
|
|
|
|
pkg_install git
|
2016-12-29 18:33:56 +09:00
|
|
|
fi
|
2017-02-14 15:38:23 +09:00
|
|
|
if [ ! -f /usr/bin/python ]; then
|
2017-06-15 19:02:30 +09:00
|
|
|
pkg_install python
|
2017-02-14 15:38:23 +09:00
|
|
|
fi
|
2017-06-15 19:02:30 +09:00
|
|
|
if [ ! -f /usr/sbin/pbuilder ]; then
|
|
|
|
pkg_install pbuilder
|
|
|
|
fi
|
|
|
|
if [ ! -f /usr/bin/mvn ]; then
|
|
|
|
pkg_install maven
|
|
|
|
fi
|
|
|
|
if [ ! -f /usr/bin/dh_testdir ]; then
|
|
|
|
pkg_install debhelper
|
2017-01-03 02:24:38 +09:00
|
|
|
fi
|
2018-06-07 03:31:13 +09:00
|
|
|
if [ ! -f /usr/bin/pystache ]; then
|
|
|
|
if is_redhat_variant; then
|
2018-07-04 03:32:11 +09:00
|
|
|
sudo yum install -y /usr/bin/pystache
|
2018-06-07 03:31:13 +09:00
|
|
|
elif is_debian_variant; then
|
|
|
|
sudo apt-get install -y python-pystache
|
|
|
|
fi
|
|
|
|
fi
|
2017-01-03 02:24:38 +09:00
|
|
|
|
2017-06-15 19:02:30 +09:00
|
|
|
|
|
|
|
if [ -z "$TARGET" ]; then
|
|
|
|
if is_debian_variant; then
|
|
|
|
if [ ! -f /usr/bin/lsb_release ]; then
|
|
|
|
pkg_install lsb-release
|
|
|
|
fi
|
|
|
|
TARGET=`lsb_release -c|awk '{print $2}'`
|
|
|
|
else
|
|
|
|
echo "Please specify target"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-01-03 02:24:38 +09:00
|
|
|
fi
|
|
|
|
|
2015-11-07 05:10:51 +09:00
|
|
|
VERSION=$(./SCYLLA-VERSION-GEN)
|
2016-03-22 12:23:48 +02:00
|
|
|
SCYLLA_VERSION=$(cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/')
|
2015-11-07 05:10:51 +09:00
|
|
|
SCYLLA_RELEASE=$(cat build/SCYLLA-RELEASE-FILE)
|
2015-11-25 01:57:53 +09:00
|
|
|
echo $VERSION > version
|
2018-08-28 10:04:44 +09:00
|
|
|
./scripts/git-archive-all --extra version --force-submodules --prefix $PRODUCT-jmx ../$PRODUCT-jmx_$SCYLLA_VERSION-$SCYLLA_RELEASE.orig.tar.gz
|
2015-11-25 01:57:53 +09:00
|
|
|
|
2017-02-08 18:48:52 +09:00
|
|
|
cp -a dist/debian/debian debian
|
2018-08-28 10:04:44 +09:00
|
|
|
if [ "$PRODUCT" != "scylla" ]; then
|
|
|
|
for i in debian/scylla-*;do
|
|
|
|
mv $i ${i/scylla-/$PRODUCT-}
|
|
|
|
done
|
|
|
|
fi
|
2018-07-04 03:32:11 +09:00
|
|
|
if is_debian $TARGET; then
|
2018-06-07 03:31:13 +09:00
|
|
|
REVISION="1~$TARGET"
|
2018-07-04 03:32:11 +09:00
|
|
|
elif is_ubuntu $TARGET; then
|
2018-06-07 03:31:13 +09:00
|
|
|
REVISION="0ubuntu1~$TARGET"
|
2017-01-04 12:06:01 +09:00
|
|
|
else
|
2018-06-07 03:31:13 +09:00
|
|
|
echo "Unknown distribution: $TARGET"
|
2017-01-04 12:06:01 +09:00
|
|
|
fi
|
2018-06-07 03:31:13 +09:00
|
|
|
|
2018-08-28 10:04:44 +09: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-07 03:31:13 +09:00
|
|
|
pystache dist/debian/rules.mustache "{ $MUSTACHE_DIST }" > debian/rules
|
|
|
|
chmod a+rx debian/rules
|
2018-08-28 10:04:44 +09:00
|
|
|
pystache dist/debian/control.mustache "{ $MUSTACHE_DIST }" > debian/control
|
2018-06-07 03:31:13 +09:00
|
|
|
|
|
|
|
if [ "$TARGET" != "trusty" ]; then
|
|
|
|
pystache dist/common/systemd/scylla-jmx.service.mustache "{ $MUSTACHE_DIST }" > debian/scylla-jmx.service
|
2016-04-30 07:47:09 +00:00
|
|
|
fi
|
2015-11-07 05:10:51 +09:00
|
|
|
|
2018-08-28 10:04:44 +09:00
|
|
|
sudo rm -fv /var/cache/pbuilder/$PRODUCT-jmx-$TARGET.tgz
|
|
|
|
sudo PRODUCT=$PRODUCT DIST=$TARGET /usr/sbin/pbuilder clean --configfile ./dist/debian/pbuilderrc
|
2019-03-27 21:09:16 +09:00
|
|
|
sudo PRODUCT=$PRODUCT DIST=$TARGET /usr/sbin/pbuilder create --configfile ./dist/debian/pbuilderrc --aptconfdir dist/debian/apt
|
2018-08-28 10:04:44 +09:00
|
|
|
sudo PRODUCT=$PRODUCT DIST=$TARGET /usr/sbin/pbuilder update --configfile ./dist/debian/pbuilderrc
|
2017-06-16 12:51:30 +09:00
|
|
|
if [ "$TARGET" = "jessie" ]; then
|
2017-06-15 19:02:30 +09:00
|
|
|
echo "apt-get install -y -t jessie-backports ca-certificates-java" > build/jessie-pkginst.sh
|
|
|
|
chmod a+rx build/jessie-pkginst.sh
|
2018-08-28 10:04:44 +09:00
|
|
|
sudo PRODUCT=$PRODUCT DIST=$TARGET /usr/sbin/pbuilder execute --configfile ./dist/debian/pbuilderrc build/jessie-pkginst.sh
|
2018-06-01 18:29:54 +09:00
|
|
|
elif [ "$TARGET" = "bionic" ]; then
|
|
|
|
echo "apt-get install -y ca-certificates-java openjdk-8-jdk-headless" > build/bionic-workaround.sh
|
|
|
|
echo "update-ca-certificates -f" >> build/bionic-workaround.sh
|
|
|
|
chmod a+rx build/bionic-workaround.sh
|
2018-08-28 10:04:44 +09:00
|
|
|
sudo PRODUCT=$PRODUCT DIST=$TARGET /usr/sbin/pbuilder execute --configfile ./dist/debian/pbuilderrc --save-after-exec build/bionic-workaround.sh
|
2017-06-15 19:02:30 +09:00
|
|
|
fi
|
2018-08-28 10:04:44 +09:00
|
|
|
sudo PRODUCT=$PRODUCT DIST=$TARGET pdebuild --configfile ./dist/debian/pbuilderrc --buildresult build/debs
|