Rate This Document
Findability
Accuracy
Completeness
Readability

Porting Binary Files from CentOS 7.6 to openEuler 20.03 LTS

When porting software from CentOS to openEuler in scenarios where source code is unavailable and the x2openEuler tool cannot be utilized, you may use a binary porting tool to modify the binary ELF file of the software. In this approach, you can replace dependencies from the CentOS environment with their alternatives in the openEuler environment, thereby enabling software porting. For more information about porting software to openEuler, visit the openEuler community.

This section describes how to port an application. The following operations are performed on openEuler.

  1. Install Ruby.
    yum install ruby -y
  2. Install patchelf-0.14.
    git clone https://github.com/NixOS/patchelf.git -b 0.14 
    cd patchelf
    ./bootstrap.sh 
    ./configure 
    make 
    make install
  3. Create directories for storing the ported binary files and dependencies.
    mkdir -p /opt/c7/usr/lib64 
    mkdir -p /opt/c7/usr/lib
    mkdir -p /opt/c7/usr/bin
  4. Copy the binary files and SO dependencies from CentOS. You can run the ldd command to view the SO dependencies.
    rsync -av <centos_ip>:/usr/lib64/* /opt/c7/usr/lib64
    rsync -av <centos_ip>:/usr/lib/* /opt/c7/usr/lib
    scp <centos_ip>:/usr/local/bin/qemu-img /opt/c7/usr/bin
  5. Upload the add-rpath.sh and expand-lib.rb scripts to the /opt/c7/usr directory and run the following commands.
    Obtain the scripts from https://www.hikunpeng.com/forum/thread-0248123322153999011-1-1.html.
    cd /opt/c7/usr
    chmod +x add-rpath.sh expand-lib.rb
    ./add-rpath.sh bin/* 
    ./add-rpath.sh lib64/libc-2.17.so 
    ./expand-lib.rb lib64/* lib64/*/*
  6. After the preceding steps are complete, run the ldd xx command to view the program dependency library.
    If any library is missing (indicated by the xx.so not found message), you need to use the patchelf utility to specify the runtime search path for shared libraries. For example, specify the search path for libaio.so.1 as /opt/c7/usr/lib64.
    patchelf --set-rpath /opt/c7/usr/lib64 ./lib64/libaio.so.1