|
| 1 | +#!/bin/bash -ex |
| 2 | +# ---------------------------------------------------------------------------- |
| 3 | +# |
| 4 | +# Package : milvus |
| 5 | +# Version : 2.4.11 |
| 6 | +# Source repo : https://github.com/milvus-io/milvus |
| 7 | +# Tested on : UBI 9.3 (docker) |
| 8 | +# Language : C++, Go |
| 9 | +# Travis-Check : False |
| 10 | +# Script License: Apache License, Version 2 or later |
| 11 | +# Maintainer : Sumit Dubey <[email protected]> |
| 12 | +# |
| 13 | +# Disclaimer: This script has been tested in root mode on given |
| 14 | +# ========== platform using the mentioned version of the package. |
| 15 | +# It may not work as expected with newer versions of the |
| 16 | +# package and/or distribution. In such case, please |
| 17 | +# contact "Maintainer" of this script. |
| 18 | +# |
| 19 | +# ---------------------------------------------------------------------------- |
| 20 | + |
| 21 | +SCRIPT_PACKAGE_VERSION=v2.5.3 |
| 22 | +PACKAGE_NAME=milvus |
| 23 | +PACKAGE_VERSION=${SCRIPT_PACKAGE_VERSION} |
| 24 | +PACKAGE_URL=https://github.com/milvus-io/${PACKAGE_NAME} |
| 25 | +CMAKE_VERSION=3.30.5 |
| 26 | +CMAKE_REQUIRED_VERSION=3.30.5 |
| 27 | +PYTHON_VERSION=3.10.2 |
| 28 | +GO_VERSION=1.22.6 |
| 29 | +SCRIPT_PATH=$(dirname $(realpath $0)) |
| 30 | +wdir=`pwd` |
| 31 | + |
| 32 | +for i in "$@"; do |
| 33 | + case $i in |
| 34 | + --power10) |
| 35 | + APPLYMCPU=1 |
| 36 | + echo "Optimizing for Power 10" |
| 37 | + shift |
| 38 | + ;; |
| 39 | + -*|--*) |
| 40 | + echo "Unknown option $i" |
| 41 | + exit 3 |
| 42 | + ;; |
| 43 | + *) |
| 44 | + PACKAGE_VERSION=$i |
| 45 | + echo "Building ${PACKAGE_NAME} ${PACKAGE_VERSION}" |
| 46 | + ;; |
| 47 | + esac |
| 48 | +done |
| 49 | + |
| 50 | +create_cmake_conanfile() |
| 51 | +{ |
| 52 | +touch /usr/local/cmake/conanfile.py |
| 53 | +cat <<EOT >> /usr/local/cmake/conanfile.py |
| 54 | +from conans import ConanFile, tools |
| 55 | +class CmakeConan(ConanFile): |
| 56 | + name = "cmake" |
| 57 | + package_type = "application" |
| 58 | + version = "${CMAKE_REQUIRED_VERSION}" |
| 59 | + description = "CMake, the cross-platform, open-source build system." |
| 60 | + homepage = "https://github.com/Kitware/CMake" |
| 61 | + license = "BSD-3-Clause" |
| 62 | + topics = ("build", "installer") |
| 63 | + settings = "os", "arch" |
| 64 | + def package(self): |
| 65 | + self.copy("*") |
| 66 | + def package_info(self): |
| 67 | + self.cpp_info.libs = tools.collect_libs(self) |
| 68 | +EOT |
| 69 | +} |
| 70 | + |
| 71 | +#Install centos and epel repos |
| 72 | +yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/CRB/ppc64le/os |
| 73 | +yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/AppStream//ppc64le/os |
| 74 | +yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/BaseOS/ppc64le/os |
| 75 | +#rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official |
| 76 | +rpm --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official |
| 77 | +dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm |
| 78 | + |
| 79 | +#Install and setup deps |
| 80 | +yum install -y --allowerasing make wget git sudo curl zip unzip tar pkg-config perl-IPC-Cmd perl-Digest-SHA perl-FindBin perl-File-Compare openssl-devel scl-utils openblas-devel rust cargo gcc gcc-c++ libstdc++-static which libaio libuuid-devel ncurses-devel ccache libtool m4 autoconf automake ninja-build zlib-devel libffi-devel java-11-openjdk-devel gfortran yum-utils patchelf hdf5-devel sqlite-devel bzip2-devel xz-devel perl-open.noarch texinfo diffutils |
| 81 | +export JAVA_HOME=$(compgen -G '/usr/lib/jvm/java-11-openjdk-*') |
| 82 | +export JRE_HOME=${JAVA_HOME}/jre |
| 83 | +export PATH=${JAVA_HOME}/bin:$PATH |
| 84 | + |
| 85 | +#Install cmake |
| 86 | +cd $wdir |
| 87 | +if [ -z "$(ls -A $wdir/cmake-${CMAKE_VERSION})" ]; then |
| 88 | + wget -c https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz |
| 89 | + tar -zxvf cmake-${CMAKE_VERSION}.tar.gz |
| 90 | + rm -rf cmake-${CMAKE_VERSION}.tar.gz |
| 91 | + cd cmake-${CMAKE_VERSION} |
| 92 | + ./bootstrap --prefix=/usr/local/cmake --parallel=2 -- -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON |
| 93 | +else |
| 94 | + cd cmake-${CMAKE_VERSION} |
| 95 | +fi |
| 96 | +make install -j$(nproc) |
| 97 | +export PATH=/usr/local/cmake/bin:$PATH |
| 98 | +cmake --version |
| 99 | + |
| 100 | +#Install Python from source |
| 101 | +cd $wdir |
| 102 | +if [ -z "$(ls -A $wdir/Python-${PYTHON_VERSION})" ]; then |
| 103 | + wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz |
| 104 | + tar xzf Python-${PYTHON_VERSION}.tgz |
| 105 | + rm -rf Python-${PYTHON_VERSION}.tgz |
| 106 | + cd Python-${PYTHON_VERSION} |
| 107 | + ./configure --enable-loadable-sqlite-extensions |
| 108 | + make -j ${nproc} |
| 109 | +else |
| 110 | + cd Python-${PYTHON_VERSION} |
| 111 | +fi |
| 112 | +make altinstall |
| 113 | +ln -sf $(which python3.10) /usr/bin/python3 |
| 114 | +ln -sf $(which python3.10) /usr/bin/python |
| 115 | +ln -sf $(which pip3.10) /usr/bin/pip3 |
| 116 | +python3 -V && pip3 -V |
| 117 | + |
| 118 | +#Install Python dependencies |
| 119 | +pip3 install conan==1.64.1 setuptools==59.5.0 |
| 120 | + |
| 121 | +#Install Golang |
| 122 | +cd $wdir |
| 123 | +wget https://go.dev/dl/go${GO_VERSION}.linux-ppc64le.tar.gz |
| 124 | +rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-ppc64le.tar.gz |
| 125 | +rm -rf go${GO_VERSION}.linux-ppc64le.tar.gz |
| 126 | +export PATH=/usr/local/go/bin:$PATH |
| 127 | +go version |
| 128 | +export PATH=$PATH:$HOME/go/bin |
| 129 | + |
| 130 | +#Install docker |
| 131 | +#yum install iptables-nft -y |
| 132 | +#yum config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo |
| 133 | +#yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin |
| 134 | +#mkdir -p /etc/docker |
| 135 | +#touch /etc/docker/daemon.json |
| 136 | +#cat <<EOT > /etc/docker/daemon.json |
| 137 | +#{ |
| 138 | +#"ipv6": true, |
| 139 | +#"fixed-cidr-v6": "2001:db8:1::/64", |
| 140 | +#"mtu": 1450 |
| 141 | +#} |
| 142 | +#EOT |
| 143 | +#dockerd > /dev/null 2>&1 & |
| 144 | +#sleep 5 |
| 145 | +#docker run hello-world |
| 146 | + |
| 147 | +#Get milvus source and apply patch |
| 148 | +cd $wdir |
| 149 | +git clone -b ${PACKAGE_VERSION} ${PACKAGE_URL} |
| 150 | +cd ${PACKAGE_NAME} |
| 151 | +git apply ${SCRIPT_PATH}/${PACKAGE_NAME}-${SCRIPT_PACKAGE_VERSION}.patch |
| 152 | +if [ "$APPLYMCPU" -eq 1 ]; then |
| 153 | + sed -i "53d" ./internal/core/CMakeLists.txt |
| 154 | + sed -i '53i set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -mcpu=power10")' ./internal/core/CMakeLists.txt |
| 155 | +fi |
| 156 | + |
| 157 | +#Build |
| 158 | +pushd /usr/local/cmake |
| 159 | +create_cmake_conanfile |
| 160 | +conan export-pkg . cmake/${CMAKE_REQUIRED_VERSION}@ -s os="Linux" -s arch="ppc64le" |
| 161 | +conan profile update settings.compiler.libcxx=libstdc++11 default |
| 162 | +popd |
| 163 | +export VCPKG_FORCE_SYSTEM_BINARIES=1 |
| 164 | +mkdir -p $HOME/.cargo/bin/ |
| 165 | +ret=0 |
| 166 | +make -j$(nproc) || ret=$? |
| 167 | +if [ "$ret" -ne 0 ] |
| 168 | +then |
| 169 | + echo "FAIL: Build failed." |
| 170 | + exit 1 |
| 171 | +fi |
| 172 | +export MILVUS_BIN=$wdir/${PACKAGE_NAME}/bin/milvus |
| 173 | + |
| 174 | +#Cpp unit tests |
| 175 | +cd $wdir/${PACKAGE_NAME}/ |
| 176 | +make test-cpp -j$(nproc) || ret=$? |
| 177 | +if [ "$ret" -ne 0 ] |
| 178 | +then |
| 179 | + echo "Cpp Tests fail." |
| 180 | + exit 2 |
| 181 | +fi |
| 182 | + |
| 183 | +#Start Milvus dev stack |
| 184 | +#cd $wdir/${PACKAGE_NAME}/ |
| 185 | +#docker compose -f ./deployments/docker/dev/docker-compose.yml up -d |
| 186 | +#sleep 10 |
| 187 | + |
| 188 | +#Go unit tests |
| 189 | +#cd $wdir/${PACKAGE_NAME}/ |
| 190 | +#make test-go -j$(nproc) || ret=$? |
| 191 | +#if [ "$ret" -ne 0 ] |
| 192 | +#then |
| 193 | +# echo "Go Tests fail." |
| 194 | +# exit 2 |
| 195 | +#fi |
| 196 | + |
| 197 | +# Conclude |
| 198 | +set +ex |
| 199 | +echo "Complete: Build and Cpp Test successful! Milvus binary available at [$MILVUS_BIN]" |
| 200 | +echo "10 Azure related tests were disabled: https://github.com/milvus-io/milvus/pull/29021" |
| 201 | +echo "Golang tests were skipped" |
| 202 | + |
0 commit comments