Project: iSulad (Runtime / Container Runtime)
File: build_guide.md

Due to the complicated steps of building and installation form source, it is recommended that you install iSuald through the rpm package. For details, please refer to: . If you still want to build and install iSulad from source, please follow the steps below. You can automatically install isulad on openEuler directly by compiling dependencies (other rpm distributions can also refer to this method, but some package names are inconsistent). ```bash dnf builddep iSulad.spec ``` `tips` iSulad.spec directly uses the files in the isulad source code. Since isulad depends on capability.h, you need to use yum to install the libcap-devel library additionally. Then, you should build and install iSulad: ```sh $ git clone https://gitee.com/openeuler/iSulad.git $ cd iSulad $ mkdir build $ cd build $ sudo -E cmake .. $ sudo -E make $ sudo -E make install ``` `tips` The communication between isula and isulad uses grpc by default. If you want to use rest for communication, you can replace it with the following compilation options ```c cmake -DENABLE_GRPC=OFF ../ ``` We provided a script to auto install iSulad on centos7, you can just execute the script to install iSulad. ```sh $ git clone https://gitee.com/openeuler/iSulad.git $ cd iSulad/docs/build_docs/guide/script $ sudo ./installiSuladonCentos7.sh ``` We also provided a script to auto install iSulad on Ubuntu20.04, you can just execute the script to install iSulad. ```sh $ git clone https://gitee.com/openeuler/iSulad.git $ cd iSulad/docs/build_docs/guide/script $ sudo chmod +x ./installiSuladonUbuntu2004LTS.sh $ sudo ./installiSuladonUbuntu2004LTS.sh ``` `tips`: If you want to keep the source of all dependencies, you can comment `rm -rf $BUILD_DIR` in the script. After executing the automated installation command, if there are dependencies that do not exist in the package management or the versions do not meet the requirements, you can optionally build them from source. Note: grpc-1.22 can not support GCC 9+. Similarly, if you want to build and install iSulad from source step by step, you can follow the steps below to build and install basic dependencies, and then build and install specific versions of key dependencies. The default installation path is `/usr/local/lib/`, which needs to be added to `PKGCONFIGPATH` and `LDLIBRARYPATH`, so that the system can find the packages and lib libraries. If the installed path is `/usr/lib/`, you can ignore this step. ```bash $ export PKGCONFIGPATH=/usr/local/lib/pkgconfig:$PKGCONFIGPATH $ export LDLIBRARYPATH=/usr/local/lib:/usr/lib:$LDLIBRARYPATH $ sudo -E echo "/usr/local/lib" >> /etc/ld.so.conf ``` Note: If the build is interrupted, you must re-execute the above commands to set the paths of ldconfig and pkgconfig before building the source again. ```bash $ git clone https://gitee.com/src-openeuler/protobuf.git $ cd protobuf $ git checkout openEuler-20.03-LTS-tag $ tar -xzvf protobuf-all-3.9.0.tar.gz $ cd protobuf-3.9.0 $ sudo -E ./autogen.sh $ sudo -E ./configure $ sudo -E make -j $(nproc) $ sudo -E make install $ sudo -E ldconfig ``` ```bash $ git clone https://gitee.com/src-openeuler/c-ares.git $ cd c-ares $ git checkout openEuler-20.03-LTS-tag $ tar -xzvf c-ares-1.15.0.tar.gz $ cd c-ares-1.15.0 $ sudo -E autoreconf -if $ sudo -E

--enable-shared --disable-dependency-tracking $ sudo -E make -j $(nproc) $ sudo -E make install $ sudo -E ldconfig ``` ```bash $ git clone https://gitee.com/src-openeuler/grpc.git $ cd grpc $ git checkout openEuler-20.03-LTS-tag $ tar -xzvf grpc-1.22.0.tar.gz $ cd grpc-1.22.0 $ sudo -E make -j $(nproc) $ sudo -E make install $ sudo -E ldconfig ``` ```bash $ git clone https://gitee.com/src-openeuler/libevent.git $ cd libevent $ git checkout -b openEuler-20.03-LTS-tag openEuler-20.03-LTS-tag $ tar -xzvf libevent-2.1.11-stable.tar.gz $ cd libevent-2.1.11-stable && ./autogen.sh && ./configure $ sudo -E make -j $(nproc) $ sudo -E make install $ sudo -E ldconfig ``` ```bash $ git clone https://gitee.com/src-openeuler/libevhtp.git $ cd libevhtp && git checkout -b openEuler-20.03-LTS-tag openEuler-20.03-LTS-tag $ tar -xzvf libevhtp-1.2.16.tar.gz $ cd libevhtp-1.2.16 $ patch -p1 -F1 -s < ../0001-support-dynamic-threads.patch $ patch -p1 -F1 -s < ../0002-close-openssl.patch $ rm -rf build && mkdir build && cd build $ sudo -E cmake -D EVHTPBUILDSHARED=on -D EVHTPDISABLESSL=on ../ $ sudo -E make -j $(nproc) $ sudo -E make install $ sudo -E ldconfig ``` ```bash $ git clone https://gitee.com/src-openeuler/libwebsockets.git $ cd libwebsockets $ git checkout openEuler-20.03-LTS-tag $ tar -xzvf libwebsockets-2.4.2.tar.gz $ cd libwebsockets-2.4.2 $ patch -p1 -F1 -s < ../libwebsockets-fix-coredump.patch $ mkdir build $ cd build $ sudo -E cmake -DLWSWITHSSL=0 -DLWSMAXSMP=32 -DCMAKEBUILDTYPE=Debug ../ $ sudo -E make -j $(nproc) $ sudo -E make install $ sudo -E ldconfig ``` Finally, because iSulad depends on some specific versions of key dependencies, and each dependency is called through a functional interface, you must ensure that the versions of all key dependencies are consistent. The consistency of the version includes the following four aspects: Branch consistency: build and install the same branch of each dependency; Consistent releases: Since each isulad release has an adapted dependency release, you need to build and install the dependencies of the specified release; Specific OS: If you use a specific OS version of , you need to obtain the `src.rpm` package of each dependency through the package management tool to obtain the source to build and install; Src-openeuler: If the dependencies are obtained from the community, it is also necessary to keep the dependencies built with the same branch; ```bash $ git clone https://gitee.com/src-openeuler/lxc.git $ cd lxc $ ./apply-patches $ cd lxc-4.0.3 $ sudo -E ./autogen.sh $ sudo -E ./configure $ sudo -E make -j $ sudo -E make install ``` ```bash $ git clone https://gitee.com/openeuler/lcr.git $ cd lcr $ mkdir build $ cd build $ sudo -E cmake .. $ sudo -E make -j $ sudo -E make install ``` ```bash $ git clone https://gitee.com/openeuler/clibcni.git $ cd clibcni $ mkdir build $ cd build $ sudo -E cmake .. $ sudo -E make -j $ sudo -E make install ``` ```sh $ git clone https://gitee.com/openeuler/iSulad.git $ cd iSulad $ mkdir build $ cd build $ sudo -E cmake .. $ sudo -E make $ sudo -E make install ``` Tips The communication between isula and isulad uses grpc by default. If you want to use rest for communication, you can replace it with the following compilation options ```c cmake -DENABLE_GRPC=OFF ../ ```