From f9b0a29defd1a6cbddd0acaaa5cbf658228d4d13 Mon Sep 17 00:00:00 2001 From: Takuya ASADA Date: Thu, 28 Jul 2016 01:19:37 +0900 Subject: [PATCH] dist/ami: setup correct repository when --localrpm specified There was no way to setup correct repo when AMI is building by --localrpm option, since AMI does not have access to 'version' file, and we don't passed repo URL to the AMI. So detect optimal repo path when starting build AMI, passes repo URL to the AMI, setup it correctly. Note: this changes behavor of build_ami.sh/scylla_install_pkg's --repo option. It was repository URL, but now become .repo/.list file URL. This is optimal for the distribution which requires 3rdparty packages to install scylla, like CentOS7. Existing shell scripts which invoking build_ami.sh are need to change in new way, such as our Jenkins jobs. Fixes #1414 Signed-off-by: Takuya ASADA Message-Id: <1469636377-17828-1-git-send-email-syuu@scylladb.com> (cherry picked from commit d3746298ae5fac58ddf1594ec1f35594e8957e62) --- dist/ami/build_ami.sh | 5 +++-- scripts/scylla_current_repo | 37 +++++++++++++++++++++++++++++++++++++ scripts/scylla_install_pkg | 29 +++++++++++------------------ 3 files changed, 51 insertions(+), 20 deletions(-) create mode 100755 scripts/scylla_current_repo diff --git a/dist/ami/build_ami.sh b/dist/ami/build_ami.sh index f8e1a9ed64..828a4e673d 100755 --- a/dist/ami/build_ami.sh +++ b/dist/ami/build_ami.sh @@ -8,7 +8,7 @@ fi print_usage() { echo "build_ami.sh --localrpm --repo [URL]" echo " --localrpm deploy locally built rpms" - echo " --repo specify repository URL" + echo " --repo specify .repo/.list file URL" exit 1 } LOCALRPM=0 @@ -16,7 +16,8 @@ while [ $# -gt 0 ]; do case "$1" in "--localrpm") LOCALRPM=1 - INSTALL_ARGS="$INSTALL_ARGS --localrpm" + REPO=`./scripts/scylla_current_repo` + INSTALL_ARGS="$INSTALL_ARGS --localrpm --repo $REPO" shift 1 ;; "--repo") diff --git a/scripts/scylla_current_repo b/scripts/scylla_current_repo new file mode 100755 index 0000000000..72c1eaa70e --- /dev/null +++ b/scripts/scylla_current_repo @@ -0,0 +1,37 @@ +#!/bin/bash + +VERSION=$(./SCYLLA-VERSION-GEN) +SCYLLA_VERSION=$(cat build/SCYLLA-VERSION-FILE) +SCYLLA_RELEASE=$(cat build/SCYLLA-RELEASE-FILE) + +. /etc/os-release + +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 https://downloads.scylladb.com/deb/unstable/$CODENAME/master/latest/scylla.list + elif [ "$ID" = "centos" ]; then + echo https://downloads.scylladb.com/rpm/unstable/centos/master/latest/scylla.repo + elif [ "$ID" = "fedora" ]; then + echo https://downloads.scylladb.com/rpm/unstable/fedora/master/latest/scylla.repo + else + echo "Unsupported distribution." + exit 1 + 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 + 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 + fi +fi diff --git a/scripts/scylla_install_pkg b/scripts/scylla_install_pkg index 2b7bf46f63..2a319770eb 100755 --- a/scripts/scylla_install_pkg +++ b/scripts/scylla_install_pkg @@ -10,7 +10,7 @@ fi print_usage() { echo "scylla_install_pkg --local-pkg /home/scylla/rpms --repo [URL]" echo " --local-pkg install locally built .rpm/.deb on specified directory" - echo " --repo specify repository URL" + echo " --repo specify .repo/.list file URL" exit 1 } @@ -42,10 +42,8 @@ if [ "$ID" = "ubuntu" ]; then chmod +x /usr/sbin/policy-rc.d cp /etc/hosts /etc/hosts.orig echo 127.0.0.1 `hostname` >> /etc/hosts - if [ "$REPO" = "" ]; then - echo "deb http://s3.amazonaws.com/downloads.scylladb.com/deb/ubuntu trusty/scylladb multiverse" > /etc/apt/sources.list.d/scylla.list - else - echo "deb $REPO trusty/scylladb multiverse" > /etc/apt/sources.list.d/scylla.list + if [ "$REPO" != "" ]; then + curl -o /etc/apt/sources.list.d/scylla.list $REPO fi apt-get update if [ "$LOCAL_PKG" = "" ]; then @@ -62,19 +60,14 @@ if [ "$ID" = "ubuntu" ]; then mv /etc/hosts.orig /etc/hosts rm /usr/sbin/policy-rc.d else - if [ "$ID" = "fedora" ]; then - if [ "$REPO" = "" ]; then - curl http://downloads.scylladb.com/rpm/fedora/scylla.repo > /etc/yum.repos.d/scylla.repo - else - curl $REPO > /etc/yum.repos.d/scylla.repo - fi - elif [ "$ID" = "centos" ] || [ "$ID" = "rhel" ]; then - if [ "$REPO" = "" ]; then - curl http://downloads.scylladb.com/rpm/centos/scylla.repo > /etc/yum.repos.d/scylla.repo - else - curl $REPO > /etc/yum.repos.d/scylla.repo - fi - yum install -y epel-release + if [ "$REPO" != "" ]; then + curl -o /etc/yum.repos.d/scylla.repo $REPO + fi + + if [ "$ID" = "centos" ]; then + yum install -y epel-release + elif [ "$ID" = "rhel" ]; then + rpm -ivh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-7.noarch.rpm else echo "Unsupported distribution" exit 1