dist/ami: support AMI cross build
Now we can cross build our .rpm/.deb packages, so let's extend AMI build script to support cross build, too. Also Ubuntu 16.04 support added, since it's latest Ubuntu LTS release. Signed-off-by: Takuya ASADA <syuu@scylladb.com> Message-Id: <1510247204-2899-1-git-send-email-syuu@scylladb.com>
This commit is contained in:
84
dist/ami/build_ami.sh
vendored
84
dist/ami/build_ami.sh
vendored
@@ -6,20 +6,20 @@ if [ ! -e dist/ami/build_ami.sh ]; then
|
||||
fi
|
||||
|
||||
print_usage() {
|
||||
echo "build_ami.sh --localrpm --repo [URL]"
|
||||
echo "build_ami.sh --localrpm --repo [URL] --target [distribution]"
|
||||
echo " --localrpm deploy locally built rpms"
|
||||
echo " --repo repository for both install and update, specify .repo/.list file URL"
|
||||
echo " --repo-for-install repository for install, specify .repo/.list file URL"
|
||||
echo " --repo-for-update repository for update, specify .repo/.list file URL"
|
||||
echo " --target specify target distribution"
|
||||
exit 1
|
||||
}
|
||||
LOCALRPM=0
|
||||
TARGET=centos
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
"--localrpm")
|
||||
LOCALRPM=1
|
||||
REPO=`./scripts/scylla_current_repo`
|
||||
INSTALL_ARGS="$INSTALL_ARGS --localrpm --repo $REPO"
|
||||
shift 1
|
||||
;;
|
||||
"--repo")
|
||||
@@ -34,37 +34,67 @@ while [ $# -gt 0 ]; do
|
||||
INSTALL_ARGS="$INSTALL_ARGS --repo-for-update $2"
|
||||
shift 2
|
||||
;;
|
||||
"--target")
|
||||
TARGET="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
print_usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
. /etc/os-release
|
||||
case "$ID" in
|
||||
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
|
||||
}
|
||||
|
||||
case "$TARGET" in
|
||||
"centos")
|
||||
AMI=ami-46bf8a51
|
||||
REGION=us-east-1
|
||||
SSH_USERNAME=centos
|
||||
;;
|
||||
"ubuntu")
|
||||
"trusty")
|
||||
AMI=ami-ff427095
|
||||
REGION=us-east-1
|
||||
SSH_USERNAME=ubuntu
|
||||
;;
|
||||
"xenial")
|
||||
AMI=ami-da05a4a0
|
||||
REGION=us-east-1
|
||||
SSH_USERNAME=ubuntu
|
||||
;;
|
||||
*)
|
||||
echo "build_ami.sh does not supported this distribution."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
if [ $LOCALRPM -eq 1 ]; then
|
||||
if [ "$ID" = "centos" ]; then
|
||||
sudo rm -rf build/*
|
||||
sudo yum -y install git
|
||||
sudo rm -rf build/*
|
||||
REPO=`./scripts/scylla_current_repo --target $TARGET`
|
||||
INSTALL_ARGS="$INSTALL_ARGS --localrpm --repo $REPO"
|
||||
if [ ! -f /usr/bin/git ]; then
|
||||
pkg_install git
|
||||
fi
|
||||
|
||||
if [ "$TARGET" = "centos" ]; then
|
||||
if [ ! -f dist/ami/files/scylla.x86_64.rpm ] || [ ! -f dist/ami/files/scylla-kernel-conf.x86_64.rpm ] || [ ! -f dist/ami/files/scylla-conf.x86_64.rpm ] || [ ! -f dist/ami/files/scylla-server.x86_64.rpm ] || [ ! -f dist/ami/files/scylla-debuginfo.x86_64.rpm ]; then
|
||||
dist/redhat/build_rpm.sh
|
||||
dist/redhat/build_rpm.sh --dist --target epel-7-x86_64
|
||||
cp build/rpms/scylla-`cat build/SCYLLA-VERSION-FILE`-`cat build/SCYLLA-RELEASE-FILE`.*.x86_64.rpm dist/ami/files/scylla.x86_64.rpm
|
||||
cp build/rpms/scylla-kernel-conf-`cat build/SCYLLA-VERSION-FILE`-`cat build/SCYLLA-RELEASE-FILE`.*.x86_64.rpm dist/ami/files/scylla-kernel-conf.x86_64.rpm
|
||||
cp build/rpms/scylla-conf-`cat build/SCYLLA-VERSION-FILE`-`cat build/SCYLLA-RELEASE-FILE`.*.x86_64.rpm dist/ami/files/scylla-conf.x86_64.rpm
|
||||
@@ -75,7 +105,7 @@ if [ $LOCALRPM -eq 1 ]; then
|
||||
cd build
|
||||
git clone --depth 1 https://github.com/scylladb/scylla-jmx.git
|
||||
cd scylla-jmx
|
||||
sh -x -e dist/redhat/build_rpm.sh $*
|
||||
dist/redhat/build_rpm.sh --target epel-7-x86_64
|
||||
cd ../..
|
||||
cp build/scylla-jmx/build/rpms/scylla-jmx-`cat build/scylla-jmx/build/SCYLLA-VERSION-FILE`-`cat build/scylla-jmx/build/SCYLLA-RELEASE-FILE`.*.noarch.rpm dist/ami/files/scylla-jmx.noarch.rpm
|
||||
fi
|
||||
@@ -83,39 +113,39 @@ if [ $LOCALRPM -eq 1 ]; then
|
||||
cd build
|
||||
git clone --depth 1 https://github.com/scylladb/scylla-tools-java.git
|
||||
cd scylla-tools-java
|
||||
sh -x -e dist/redhat/build_rpm.sh
|
||||
dist/redhat/build_rpm.sh --target epel-7-x86_64
|
||||
cd ../..
|
||||
cp build/scylla-tools-java/build/rpms/scylla-tools-`cat build/scylla-tools-java/build/SCYLLA-VERSION-FILE`-`cat build/scylla-tools-java/build/SCYLLA-RELEASE-FILE`.*.noarch.rpm dist/ami/files/scylla-tools.noarch.rpm
|
||||
cp build/scylla-tools-java/build/rpms/scylla-tools-core-`cat build/scylla-tools-java/build/SCYLLA-VERSION-FILE`-`cat build/scylla-tools-java/build/SCYLLA-RELEASE-FILE`.*.noarch.rpm dist/ami/files/scylla-tools-core.noarch.rpm
|
||||
fi
|
||||
else
|
||||
sudo apt-get install -y git
|
||||
if [ ! -f dist/ami/files/scylla-server_amd64.deb ]; then
|
||||
if [ ! -f ../scylla-server_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-ubuntu1_amd64.deb ]; then
|
||||
echo "Build .deb before running build_ami.sh"
|
||||
exit 1
|
||||
fi
|
||||
cp ../scylla_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-ubuntu1_amd64.deb dist/ami/files/scylla_amd64.deb
|
||||
cp ../scylla-kernel-conf_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-ubuntu1_amd64.deb dist/ami/files/scylla-kernel-conf_amd64.deb
|
||||
cp ../scylla-conf_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-ubuntu1_amd64.deb dist/ami/files/scylla-conf_amd64.deb
|
||||
cp ../scylla-server_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-ubuntu1_amd64.deb dist/ami/files/scylla-server_amd64.deb
|
||||
cp ../scylla-server-dbg_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-ubuntu1_amd64.deb dist/ami/files/scylla-server-dbg_amd64.deb
|
||||
./scripts/git-archive-all --force-submodules --prefix scylla build/scylla.tar
|
||||
tar -C build/ -xvpf build/scylla.tar
|
||||
cd build/scylla
|
||||
dist/debian/build_deb.sh --dist --target $TARGET
|
||||
cd ../..
|
||||
cp build/scylla/build/debs/scylla_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-0ubuntu1~${TARGET}_amd64.deb dist/ami/files/scylla_amd64.deb
|
||||
cp build/scylla/build/debs/scylla-kernel-conf_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-0ubuntu1~${TARGET}_amd64.deb dist/ami/files/scylla-kernel-conf_amd64.deb
|
||||
cp build/scylla/build/debs/scylla-conf_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-0ubuntu1~${TARGET}_amd64.deb dist/ami/files/scylla-conf_amd64.deb
|
||||
cp build/scylla/build/debs/scylla-server_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-0ubuntu1~${TARGET}_amd64.deb dist/ami/files/scylla-server_amd64.deb
|
||||
cp build/scylla/build/debs/scylla-server-dbg_`cat build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/SCYLLA-RELEASE-FILE`-0ubuntu1~${TARGET}_amd64.deb dist/ami/files/scylla-server-dbg_amd64.deb
|
||||
fi
|
||||
if [ ! -f dist/ami/files/scylla-jmx_all.deb ]; then
|
||||
cd build
|
||||
git clone --depth 1 https://github.com/scylladb/scylla-jmx.git
|
||||
cd scylla-jmx
|
||||
sh -x -e dist/debian/build_deb.sh $*
|
||||
dist/debian/build_deb.sh --target $TARGET
|
||||
cd ../..
|
||||
cp build/scylla-jmx_`cat build/scylla-jmx/build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/scylla-jmx/build/SCYLLA-RELEASE-FILE`-ubuntu1_all.deb dist/ami/files/scylla-jmx_all.deb
|
||||
cp build/scylla-jmx/build/debs/scylla-jmx_`cat build/scylla-jmx/build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/scylla-jmx/build/SCYLLA-RELEASE-FILE`-0ubuntu1~${TARGET}_all.deb dist/ami/files/scylla-jmx_all.deb
|
||||
fi
|
||||
if [ ! -f dist/ami/files/scylla-tools_all.deb ]; then
|
||||
cd build
|
||||
git clone --depth 1 https://github.com/scylladb/scylla-tools-java.git
|
||||
cd scylla-tools-java
|
||||
sh -x -e dist/debian/build_deb.sh $*
|
||||
dist/debian/build_deb.sh --target $TARGET
|
||||
cd ../..
|
||||
cp build/scylla-tools_`cat build/scylla-tools-java/build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/scylla-tools-java/build/SCYLLA-RELEASE-FILE`-ubuntu1_all.deb dist/ami/files/scylla-tools_all.deb
|
||||
cp build/scylla-tools-java/build/debs/scylla-tools_`cat build/scylla-tools-java/build/SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/'`-`cat build/scylla-tools-java/build/SCYLLA-RELEASE-FILE`-0ubuntu1~${TARGET}_all.deb dist/ami/files/scylla-tools_all.deb
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
8
dist/ami/files/.bash_profile
vendored
8
dist/ami/files/.bash_profile
vendored
@@ -34,7 +34,7 @@ echo 'By default, Scylla sends certain information about this node to a data col
|
||||
echo
|
||||
|
||||
SETUP=
|
||||
if [ "$ID" != "ubuntu" ]; then
|
||||
if is_systemd; then
|
||||
SETUP=`systemctl is-active scylla-ami-setup`
|
||||
fi
|
||||
if [ "$SETUP" == "activating" ]; then
|
||||
@@ -60,7 +60,7 @@ elif [ "$SETUP" == "failed" ]; then
|
||||
echo " 'systemctl status scylla-ami-setup'"
|
||||
echo
|
||||
else
|
||||
if [ "$ID" != "ubuntu" ]; then
|
||||
if is_systemd; then
|
||||
SCYLLA=`systemctl is-active scylla-server`
|
||||
else
|
||||
if [ "`initctl status scylla-server|grep "running, process"`" != "" ]; then
|
||||
@@ -95,7 +95,7 @@ else
|
||||
echo " $TYPE is not supported instance type!"
|
||||
tput sgr0
|
||||
echo -n "To continue startup ScyllaDB on this instance, run 'sudo scylla_io_setup' "
|
||||
if [ "$ID" = "ubuntu" ]; then
|
||||
if ! is_systemd; then
|
||||
echo "then 'initctl start scylla-server'."
|
||||
else
|
||||
echo "then 'systemctl start scylla-server'."
|
||||
@@ -107,7 +107,7 @@ else
|
||||
echo " ScyllaDB is not started!"
|
||||
tput sgr0
|
||||
echo "Please wait for startup. To see status of ScyllaDB, run "
|
||||
if [ "$ID" = "ubuntu" ]; then
|
||||
if ! is_systemd; then
|
||||
echo " 'initctl status scylla-server'"
|
||||
echo "and"
|
||||
echo " 'sudo cat /var/log/upstart/scylla-server.log'"
|
||||
|
||||
@@ -4,18 +4,40 @@ VERSION=$(./SCYLLA-VERSION-GEN)
|
||||
SCYLLA_VERSION=$(cat build/SCYLLA-VERSION-FILE)
|
||||
SCYLLA_RELEASE=$(cat build/SCYLLA-RELEASE-FILE)
|
||||
|
||||
|
||||
. /etc/os-release
|
||||
print_usage() {
|
||||
echo "scylla_current_repo --target [distribution]"
|
||||
echo " --target specify target distribution"
|
||||
exit 1
|
||||
}
|
||||
TARGET=
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
"--target")
|
||||
TARGET="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
print_usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$TARGET" ]; then
|
||||
TARGET=$ID
|
||||
fi
|
||||
|
||||
if [ "$SCYLLA_VERSION" = "666.development" ]; then
|
||||
if [ "$ID" = "ubuntu" ]; then
|
||||
CODENAME=`lsb_release -c|awk '{print $2}'`
|
||||
if [ "$CODENAME" = "trusty" ]; then
|
||||
CODENAME=ubuntu
|
||||
fi
|
||||
echo http://downloads.scylladb.com/deb/unstable/$CODENAME/master/latest/scylla.list
|
||||
elif [ "$ID" = "centos" ]; then
|
||||
if [ "$TARGET" = "ubuntu" ] || [ "$TARGET" = "debian" ]; then
|
||||
TARGET=`lsb_release -c|awk '{print $2}'`
|
||||
fi
|
||||
if [ "$TARGET" = "trusty" ]; then
|
||||
echo http://downloads.scylladb.com/deb/unstable/ubuntu/master/latest/scylla.list
|
||||
elif [ "$TARGET" = "xenial" ]; then
|
||||
echo http://downloads.scylladb.com/deb/unstable/xenial/master/latest/scylladb/scylla.list
|
||||
elif [ "$TARGET" = "centos" ]; then
|
||||
echo http://downloads.scylladb.com/rpm/unstable/centos/master/latest/scylla.repo
|
||||
elif [ "$ID" = "fedora" ]; then
|
||||
elif [ "$TARGET" = "fedora" ]; then
|
||||
echo http://downloads.scylladb.com/rpm/unstable/fedora/master/latest/scylla.repo
|
||||
else
|
||||
echo "Unsupported distribution."
|
||||
@@ -23,13 +45,15 @@ if [ "$SCYLLA_VERSION" = "666.development" ]; then
|
||||
fi
|
||||
else
|
||||
REPO_VERSION=$(echo $SCYLLA_VERSION |sed -e "s/^\([0-9]*\.[0-9]*\).*/\1/")
|
||||
if [ "$ID" = "ubuntu" ]; then
|
||||
CODENAME=`lsb_release -c|awk '{print $2}'`
|
||||
echo http://downloads.scylladb.com/deb/ubuntu/scylla-$REPO_VERSION-$CODENAME.list
|
||||
elif [ "$ID" = "centos" ]; then
|
||||
if [ "$TARGET" = "ubuntu" ] || [ "$TARGET" = "debian" ]; then
|
||||
TARGET=`lsb_release -c|awk '{print $2}'`
|
||||
fi
|
||||
if [ "$TARGET" = "trusty" ] || [ "$TARGET" = "xenial" ]; then
|
||||
echo http://downloads.scylladb.com/deb/ubuntu/scylla-$REPO_VERSION-$TARGET.list
|
||||
elif [ "$TARGET" = "jessie" ]; then
|
||||
echo http://downloads.scylladb.com/deb/debian/scylla-$REPO_VERSION-$TARGET.list
|
||||
elif [ "$TARGET" = "centos" ]; then
|
||||
echo http://downloads.scylladb.com/rpm/centos/scylla-$REPO_VERSION.repo
|
||||
elif [ "$ID" = "fedora" ]; then
|
||||
echo http://downloads.scylladb.com/rpm/fedora/scylla-$REPO_VERSION.repo
|
||||
else
|
||||
echo "Unsupported distribution."
|
||||
exit 1
|
||||
|
||||
@@ -57,9 +57,11 @@ if [ -f /etc/debian_version ]; then
|
||||
if [ "$REPO_FOR_INSTALL" != "" ]; then
|
||||
curl -o /etc/apt/sources.list.d/scylla_install.list $REPO_FOR_INSTALL
|
||||
fi
|
||||
apt-get update
|
||||
apt-get -o Acquire::AllowInsecureRepositories=true \
|
||||
-o Acquire::AllowDowngradeToInsecureRepositories=true update
|
||||
if [ "$LOCAL_PKG" = "" ]; then
|
||||
apt-get install -y --force-yes scylla
|
||||
apt-get install -o APT::Get::AllowUnauthenticated=true \
|
||||
-y --force-yes scylla
|
||||
else
|
||||
if [ ! -f /usr/bin/gdebi ]; then
|
||||
apt-get install -y --force-yes gdebi-core
|
||||
@@ -78,7 +80,8 @@ if [ -f /etc/debian_version ]; then
|
||||
if [ "$REPO_FOR_UPDATE" != "" ]; then
|
||||
curl -o /etc/apt/sources.list.d/scylla.list $REPO_FOR_UPDATE
|
||||
fi
|
||||
apt-get update
|
||||
apt-get -o Acquire::AllowInsecureRepositories=true \
|
||||
-o Acquire::AllowDowngradeToInsecureRepositories=true update
|
||||
else
|
||||
if [ "$REPO_FOR_INSTALL" != "" ]; then
|
||||
curl -o /etc/yum.repos.d/scylla_install.repo $REPO_FOR_INSTALL
|
||||
|
||||
Reference in New Issue
Block a user