+ sed -e 's/@//g' < ceph.spec.in > $OUTFILE
+ # http://rpm.org/user_doc/conditional_builds.html
+ if $with_seastar; then
+ sed -i -e 's/%bcond_with seastar/%bcond_without seastar/g' $OUTFILE
+ fi
+ if $with_zbd; then
+ sed -i -e 's/%bcond_with zbd/%bcond_without zbd/g' $OUTFILE
+ fi
+ if $for_make_check; then
+ sed -i -e 's/%bcond_with make_check/%bcond_without make_check/g' $OUTFILE
+ fi
+}
+
+function munge_debian_control {
+ local version=$1
+ shift
+ local control=$1
+ case "$version" in
+ *squeeze*|*wheezy*)
+ control="/tmp/control.$$"
+ grep -v babeltrace debian/control > $control
+ ;;
+ esac
+ echo $control
+}
+
+function ensure_decent_gcc_on_ubuntu {
+ in_jenkins && echo "CI_DEBUG: Start ensure_decent_gcc_on_ubuntu() in install-deps.sh"
+ # point gcc to the one offered by g++-7 if the used one is not
+ # new enough
+ local old=$(gcc -dumpfullversion -dumpversion)
+ local new=$1
+ local codename=$2
+ if dpkg --compare-versions $old ge ${new}.0; then
+ return
+ fi
+
+ if [ ! -f /usr/bin/g++-${new} ]; then
+ $SUDO tee /etc/apt/sources.list.d/ubuntu-toolchain-r.list <<EOF
+deb [lang=none] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main
+deb [arch=amd64 lang=none] http://mirror.nullivex.com/ppa/ubuntu-toolchain-r-test $codename main
+EOF
+ # import PPA's signing key into APT's keyring
+ cat << ENDOFKEY | $SUDO apt-key add -
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: SKS 1.1.6
+Comment: Hostname: keyserver.ubuntu.com
+
+mI0ESuBvRwEEAMi4cDba7xlKaaoXjO1n1HX8RKrkW+HEIl79nSOSJyvzysajs7zUow/OzCQp
+9NswqrDmNuH1+lPTTRNAGtK8r2ouq2rnXT1mTl23dpgHZ9spseR73s4ZBGw/ag4bpU5dNUSt
+vfmHhIjVCuiSpNn7cyy1JSSvSs3N2mxteKjXLBf7ABEBAAG0GkxhdW5jaHBhZCBUb29sY2hh
+aW4gYnVpbGRziLYEEwECACAFAkrgb0cCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAe
+k3eiup7yfzGKA/4xzUqNACSlB+k+DxFFHqkwKa/ziFiAlkLQyyhm+iqz80htRZr7Ls/ZRYZl
+0aSU56/hLe0V+TviJ1s8qdN2lamkKdXIAFfavA04nOnTzyIBJ82EAUT3Nh45skMxo4z4iZMN
+msyaQpNl/m/lNtOLhR64v5ZybofB2EWkMxUzX8D/FQ==
+=LcUQ
+-----END PGP PUBLIC KEY BLOCK-----
+ENDOFKEY
+ $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true
+ $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-${new}
+ fi
+}
+
+function ensure_python3_sphinx_on_ubuntu {
+ in_jenkins && echo "CI_DEBUG: Running ensure_python3_sphinx_on_ubuntu() in install-deps.sh"
+ local sphinx_command=/usr/bin/sphinx-build
+ # python-sphinx points $sphinx_command to
+ # ../share/sphinx/scripts/python2/sphinx-build when it's installed
+ # let's "correct" this
+ if test -e $sphinx_command && head -n1 $sphinx_command | grep -q python$; then
+ $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove python-sphinx
+ fi
+}
+
+function install_pkg_on_ubuntu {
+ in_jenkins && echo "CI_DEBUG: Running install_pkg_on_ubuntu() in install-deps.sh"
+ local project=$1
+ shift
+ local sha1=$1
+ shift
+ local codename=$1
+ shift
+ local force=$1
+ shift
+ local pkgs=$@
+ local missing_pkgs
+ if [ $force = "force" ]; then
+ missing_pkgs="$@"
+ else
+ for pkg in $pkgs; do
+ if ! apt -qq list $pkg 2>/dev/null | grep -q installed; then
+ missing_pkgs+=" $pkg"
+ in_jenkins && echo "CI_DEBUG: missing_pkgs=$missing_pkgs"
+ fi
+ done
+ fi
+ if test -n "$missing_pkgs"; then
+ local shaman_url="https://shaman.ceph.com/api/repos/${project}/master/${sha1}/ubuntu/${codename}/repo"
+ in_jenkins && echo -n "CI_DEBUG: Downloading $shaman_url ... "
+ $SUDO curl --silent --fail --write-out "%{http_code}" --location $shaman_url --output /etc/apt/sources.list.d/$project.list
+ $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y -o Acquire::Languages=none -o Acquire::Translation=none || true
+ $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install --allow-unauthenticated -y $missing_pkgs
+ fi
+}
+
+boost_ver=1.79
+
+function clean_boost_on_ubuntu {
+ in_jenkins && echo "CI_DEBUG: Running clean_boost_on_ubuntu() in install-deps.sh"
+ # Find currently installed version. If there are multiple
+ # versions, they end up newline separated
+ local installed_ver=$(apt -qq list --installed ceph-libboost*-dev 2>/dev/null |
+ cut -d' ' -f2 |
+ cut -d'.' -f1,2 |
+ sort -u)
+ # If installed_ver contains whitespace, we can't really count on it,
+ # but otherwise, bail out if the version installed is the version
+ # we want.
+ if test -n "$installed_ver" &&
+ echo -n "$installed_ver" | tr '[:space:]' ' ' | grep -v -q ' '; then
+ if echo "$installed_ver" | grep -q "^$boost_ver"; then
+ return
+ fi
+ fi
+
+ # Historical packages
+ $SUDO rm -f /etc/apt/sources.list.d/ceph-libboost*.list
+ # Currently used
+ $SUDO rm -f /etc/apt/sources.list.d/libboost.list
+ # Refresh package list so things aren't in the available list.
+ $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true
+ # Remove all ceph-libboost packages. We have an early return if
+ # the desired version is already (and the only) version installed,
+ # so no need to spare it.
+ if test -n "$installed_ver"; then
+ $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y --fix-missing remove "ceph-libboost*"
+ fi
+}
+
+function install_boost_on_ubuntu {
+ in_jenkins && echo "CI_DEBUG: Running install_boost_on_ubuntu() in install-deps.sh"
+ # Once we get to this point, clean_boost_on_ubuntu() should ensure
+ # that there is no more than one installed version.
+ local installed_ver=$(apt -qq list --installed ceph-libboost*-dev 2>/dev/null |
+ grep -e 'libboost[0-9].[0-9]\+-dev' |
+ cut -d' ' -f2 |
+ cut -d'.' -f1,2)
+ if test -n "$installed_ver"; then
+ if echo "$installed_ver" | grep -q "^$boost_ver"; then
+ return
+ fi
+ fi
+ local codename=$1
+ local project=libboost
+ local sha1=892ab89e76b91b505ffbf083f6fb7f2a666d4132
+ install_pkg_on_ubuntu \
+ $project \
+ $sha1 \
+ $codename \
+ check \
+ ceph-libboost-atomic${boost_ver}-dev \
+ ceph-libboost-chrono${boost_ver}-dev \
+ ceph-libboost-container${boost_ver}-dev \
+ ceph-libboost-context${boost_ver}-dev \
+ ceph-libboost-coroutine${boost_ver}-dev \
+ ceph-libboost-date-time${boost_ver}-dev \
+ ceph-libboost-filesystem${boost_ver}-dev \
+ ceph-libboost-iostreams${boost_ver}-dev \
+ ceph-libboost-program-options${boost_ver}-dev \
+ ceph-libboost-python${boost_ver}-dev \
+ ceph-libboost-random${boost_ver}-dev \
+ ceph-libboost-regex${boost_ver}-dev \
+ ceph-libboost-system${boost_ver}-dev \
+ ceph-libboost-test${boost_ver}-dev \
+ ceph-libboost-thread${boost_ver}-dev \
+ ceph-libboost-timer${boost_ver}-dev
+}
+
+function install_libzbd_on_ubuntu {
+ in_jenkins && echo "CI_DEBUG: Running install_libzbd_on_ubuntu() in install-deps.sh"
+ local codename=$1
+ local project=libzbd
+ local sha1=1fadde94b08fab574b17637c2bebd2b1e7f9127b
+ install_pkg_on_ubuntu \
+ $project \
+ $sha1 \
+ $codename \
+ check \
+ libzbd-dev
+}
+
+motr_pkgs_url='https://github.com/Seagate/cortx-motr/releases/download/2.0.0-rgw'
+
+function install_cortx_motr_on_ubuntu {
+ if dpkg -l cortx-motr-dev &> /dev/null; then
+ return
+ fi
+ if [ "$(lsb_release -sc)" = "jammy" ]; then
+ install_pkg_on_ubuntu \
+ cortx-motr \
+ 39f89fa1c6945040433a913f2687c4b4e6cbeb3f \
+ jammy \
+ check \
+ cortx-motr \
+ cortx-motr-dev
+ else
+ local deb_arch=$(dpkg --print-architecture)
+ local motr_pkg="cortx-motr_2.0.0.git3252d623_$deb_arch.deb"
+ local motr_dev_pkg="cortx-motr-dev_2.0.0.git3252d623_$deb_arch.deb"
+ $SUDO curl -sL -o/var/cache/apt/archives/$motr_pkg $motr_pkgs_url/$motr_pkg
+ $SUDO curl -sL -o/var/cache/apt/archives/$motr_dev_pkg $motr_pkgs_url/$motr_dev_pkg
+ # For some reason libfabric pkg is not available in arm64 version
+ # of Ubuntu 20.04 (Focal Fossa), so we borrow it from more recent
+ # versions for now.
+ if [[ "$deb_arch" == 'arm64' ]]; then
+ local lf_pkg='libfabric1_1.11.0-2_arm64.deb'
+ $SUDO curl -sL -o/var/cache/apt/archives/$lf_pkg http://ports.ubuntu.com/pool/universe/libf/libfabric/$lf_pkg
+ $SUDO apt-get install -y /var/cache/apt/archives/$lf_pkg
+ fi
+ $SUDO apt-get install -y /var/cache/apt/archives/{$motr_pkg,$motr_dev_pkg}
+ $SUDO apt-get install -y libisal-dev
+ fi
+}
+
+function version_lt {
+ test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1)
+}
+
+function ensure_decent_gcc_on_rh {
+ local old=$(gcc -dumpversion)
+ local dts_ver=$1
+ if version_lt $old $dts_ver; then
+ if test -t 1; then
+ # interactive shell
+ cat <<EOF
+Your GCC is too old. Please run following command to add DTS to your environment:
+
+scl enable gcc-toolset-$dts_ver bash
+
+Or add the following line to the end of ~/.bashrc and run "source ~/.bashrc" to add it permanently:
+
+source scl_source enable gcc-toolset-$dts_ver
+EOF
+ else
+ # non-interactive shell
+ source /opt/rh/gcc-toolset-$dts_ver/enable
+ fi
+ fi