|
| 1 | +#!/bin/bash -x |
| 2 | + |
| 3 | +# Copyright The containerd Authors. |
| 4 | + |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | + |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | + |
| 18 | +OS=${1} |
| 19 | +ARCH=`uname -m` |
| 20 | +BUILD_TYPE="Release" |
| 21 | +COMPILER="" |
| 22 | +PACKAGE_RELEASE="" |
| 23 | +CMAKE="cmake" |
| 24 | +CPACK="cpack" |
| 25 | + |
| 26 | +# Install Dependencies |
| 27 | +if [[ ${OS} =~ "ubuntu" ]]; then |
| 28 | + export DEBIAN_FRONTEND="noninteractive" |
| 29 | + export TZ="Etc/UTC" |
| 30 | + apt-get update -y |
| 31 | + apt-get install -y libgflags-dev libcurl4-openssl-dev libssl-dev libaio-dev libnl-3-dev libnl-genl-3-dev rpm wget make g++ git dpkg-dev sudo |
| 32 | + apt-get install -y uuid-dev libjson-c-dev libkmod-dev libsystemd-dev autoconf automake libtool libpci-dev nasm libzstd-dev libext2fs-dev zlib1g-dev |
| 33 | + |
| 34 | + DISTRO=${OS/:/1~} |
| 35 | + PACKAGE_RELEASE="-DPACKAGE_RELEASE=0${DISTRO}" |
| 36 | +elif [[ ${OS} =~ "centos" ]]; then |
| 37 | + if [[ ${OS} == "centos:7" ]]; then |
| 38 | + yum install -y centos-release-scl |
| 39 | + yum install -y devtoolset-7-gcc-c++ |
| 40 | + |
| 41 | + export PATH="/opt/rh/devtoolset-7/root/usr/bin:$PATH" |
| 42 | + PACKAGE_RELEASE="-DPACKAGE_RELEASE=1.el7" |
| 43 | + COMPILER="-DCMAKE_C_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/g++" |
| 44 | + elif [[ ${OS} == "centos:8" ]]; then |
| 45 | + rm -rf /etc/yum.repos.d/* && curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo |
| 46 | + yum install -y gcc gcc-c++ |
| 47 | + |
| 48 | + PACKAGE_RELEASE="-DPACKAGE_RELEASE=1.el8" |
| 49 | + fi |
| 50 | + |
| 51 | + yum install -y epel-release libaio-devel libcurl-devel openssl-devel libnl3-devel e2fsprogs-devel |
| 52 | + yum install -y rpm-build make git wget sudo |
| 53 | + yum install --skip-broken -y libzstd-static libzstd-devel |
| 54 | +fi |
| 55 | + |
| 56 | +if [[ ${ARCH} == "x86_64" ]]; then |
| 57 | + wget https://cmake.org/files/v3.15/cmake-3.15.0-Linux-x86_64.tar.gz |
| 58 | + tar -zxf cmake-3.15.0-Linux-x86_64.tar.gz -C /usr/local/ |
| 59 | + export PATH="/usr/local/cmake-3.15.0-Linux-x86_64/bin:$PATH" |
| 60 | +else |
| 61 | + wget https://cmake.org/files/v3.20/cmake-3.20.6-linux-aarch64.tar.gz |
| 62 | + tar -zxf cmake-3.20.6-linux-aarch64.tar.gz -C /usr/local/ |
| 63 | + export PATH="/usr/local/cmake-3.20.6-linux-aarch64/bin:$PATH" |
| 64 | +fi |
| 65 | + |
| 66 | +# Build |
| 67 | +mkdir build |
| 68 | +cd build |
| 69 | +${CMAKE} .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TESTING=0 -DENABLE_DSA=0 -DENABLE_ISAL=0 ${PACKAGE_RELEASE} ${COMPILER} |
| 70 | +make -j8 |
| 71 | +${CPACK} --verbose |
0 commit comments